/* dotLumen Fleet Management — "Signal" design system (from the Claude Design mock, variant B). */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* JS toggles visibility via the hidden attribute; it must beat any
   display: set by component classes (e.g. .map-empty's display:grid). */
[hidden] { display: none !important; }

:root {
  --bg:#f5f6f8; --surface:#ffffff; --surface-2:#f0f2f5; --surface-3:#e9ecf0;
  --border:#e4e7ec; --border-strong:#cdd3db;
  --text:#161b22; --text-2:#5a626d; --text-3:#8a929d;
  --ok:#1f9d55; --ok-weak:#e6f5ec;
  --warn:#c07c12; --warn-weak:#fbf1dc;
  --crit:#d5392f; --crit-weak:#fbe6e4;
  --net-eth:#2e8b57; --net-wlan:#2f6df6; --net-lte:#8a5cf6;
  --info:#2f6df6;
  --accent:#0c8f82; --accent-weak:#d6f1ed; --on-accent:#ffffff;
  --sans:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,"Helvetica Neue",sans-serif;
  --mono:ui-monospace,SFMono-Regular,"SF Mono",Menlo,Consolas,"Liberation Mono",monospace;
  --r1:4px; --r2:6px; --r3:10px; --r4:16px;
  --shadow:0 1px 2px rgba(16,22,34,.05),0 1px 3px rgba(16,22,34,.04);
  --shadow-lg:0 4px 16px rgba(16,22,34,.08);
}
[data-theme="dark"] {
  --bg:#0d1117; --surface:#161b22; --surface-2:#1b222b; --surface-3:#232c37;
  --border:#242c37; --border-strong:#39434f;
  --text:#e7ecf2; --text-2:#98a2af; --text-3:#6a7482;
  --ok:#3fc57d; --ok-weak:#123123;
  --warn:#e0a53a; --warn-weak:#33280f;
  --crit:#f0675c; --crit-weak:#3a1c1a;
  --net-eth:#4bbd7f; --net-wlan:#5b8dff; --net-lte:#a98bff;
  --info:#5b8dff;
  --accent:#2dd4bf; --accent-weak:#0f2e2a; --on-accent:#05201d;
  --shadow:0 1px 2px rgba(0,0,0,.4); --shadow-lg:0 8px 28px rgba(0,0,0,.5);
}

body {
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-weak); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
input, button, select, textarea { font-family: inherit; color: inherit; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.scroll-x::-webkit-scrollbar { height: 10px; width: 10px; }
.scroll-x::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 8px; }
.mono { font-family: var(--mono); }
.spacer { flex: 1; }

@keyframes lf-pulse { 0%,100% { opacity:.35; } 50% { opacity:1; } }
@keyframes lf-fade { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  border-radius: var(--r2); font-size: 12.5px; padding: 7px 12px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.icon { width: 34px; height: 32px; padding: 0; display: grid; place-items: center; font-size: 14px; }
.btn.ghost { background: var(--surface); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.accent { background: var(--accent); color: var(--on-accent); border: 0; font-weight: 600; font-size: 14px; padding: 11px 12px; }
.btn.accent:hover { filter: brightness(1.08); background: var(--accent); }
.btn.block { width: 100%; }
.btn.toggle { padding: 8px 12px; }
.btn.toggle.active { border-color: var(--accent); background: var(--accent-weak); color: var(--accent); font-weight: 600; }
.select {
  padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--r2);
  background: var(--surface); font-size: 12.5px; color: var(--text-2); cursor: pointer;
}
.select.sm { padding: 6px 9px; font-size: 12px; }

/* ---- Top bar ------------------------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 600;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo-mark {
  width: 24px; height: 24px; border-radius: 6px; background: var(--accent);
  display: inline-grid; place-items: center; color: var(--on-accent);
  font-weight: 700; font-size: 15px;
}
.logo-mark.lg { width: 26px; height: 26px; border-radius: 7px; font-size: 16px; }
.brand-name { font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.crumbs { display: flex; align-items: center; gap: 8px; margin-left: 4px; font-size: 13px; color: var(--text-3); }
.crumb-host { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }

.page { max-width: 1380px; margin: 0 auto; padding: 22px 20px 60px; }

/* ---- Toast -------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 900;
  background: var(--text); color: var(--bg); font-size: 12.5px; font-family: var(--mono);
  padding: 9px 16px; border-radius: var(--r2); box-shadow: var(--shadow-lg);
  animation: lf-fade .2s ease both;
}

/* ---- Login -------------------------------------------------------------- */
.login-wrap { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 24px; }
.login-box { width: 352px; max-width: 100%; animation: lf-fade .3s ease both; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 26px; }
.login-brand-name { font-size: 18px; font-weight: 650; letter-spacing: -.01em; }
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3);
  padding: 24px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 550; }
.field input { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r2); background: var(--surface); font-size: 14px; }
.login-error {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px;
  color: var(--crit); background: var(--crit-weak); border: 1px solid var(--crit);
  border-radius: var(--r2); padding: 8px 10px;
}
.login-foot { display: flex; justify-content: flex-end; margin-top: 16px; }

/* ---- Dashboard ---------------------------------------------------------- */
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 680; letter-spacing: -.015em; }
.page-sub { font-size: 13px; color: var(--text-3); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3); padding: 15px 17px; box-shadow: var(--shadow); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 600; margin-bottom: 9px; }
.stat-value { font-size: 27px; font-weight: 680; font-family: var(--mono); line-height: 1; color: var(--text-2); }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.info { color: var(--info); }
.stat-value.dim { color: var(--text-3); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.search-wrap { position: relative; flex: 1; min-width: 220px; max-width: 360px; }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 14px; }
.search-wrap input {
  width: 100%; padding: 9px 12px 9px 32px; border: 1px solid var(--border);
  border-radius: var(--r2); background: var(--surface); font-size: 13px;
}
.muted-count { font-size: 12.5px; color: var(--text-3); }

.table-card { border: 1px solid var(--border); border-radius: var(--r3); background: var(--surface); overflow: hidden; box-shadow: var(--shadow); }
.scroll-x { overflow-x: auto; }
.fleet-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 940px; }
.fleet-table thead tr { text-align: left; color: var(--text-3); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
.fleet-table th { padding: 12px 16px; font-weight: 600; }
.fleet-table td { padding: 13px 16px; }
.fleet-table tbody tr { border-top: 1px solid var(--border); cursor: pointer; }
.fleet-table tbody tr:hover { background: var(--surface-2); }
.nowrap { white-space: nowrap; }

.status-cell { display: inline-flex; align-items: center; gap: 9px; white-space: nowrap; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.online { background: var(--ok); animation: lf-pulse 2.4s ease-in-out infinite; }
.last-seen { font-size: 12.5px; color: var(--text-2); }

.dev-host { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.dev-sub { font-size: 12px; color: var(--text-3); }

.batt-ring { display: inline-block; }
.batt-ring svg { width: 28px; height: 28px; display: block; }
.batt-ring .ring-bg { fill: none; stroke: var(--surface-3); stroke-width: 3.5; }
.batt-ring .ring-fg { fill: none; stroke: var(--ok); stroke-width: 3.5; stroke-linecap: round; }
.batt-ring text { font: 700 10px var(--mono); fill: var(--text); text-anchor: middle; dominant-baseline: central; }
.batt-warn .ring-fg { stroke: var(--warn); }
.batt-crit .ring-fg { stroke: var(--crit); }
.batt-none { font-family: var(--mono); font-size: 12.5px; color: var(--text-3); }

.net-badge {
  font-family: var(--mono); font-size: 10.5px; font-weight: 700;
  border-radius: 5px; padding: 4px 9px; text-transform: uppercase; letter-spacing: .04em;
}
.net-badge.eth { color: var(--net-eth); background: color-mix(in srgb, var(--net-eth) 15%, transparent); }
.net-badge.wlan { color: var(--net-wlan); background: color-mix(in srgb, var(--net-wlan) 15%, transparent); }
.net-badge.lte { color: var(--net-lte); background: color-mix(in srgb, var(--net-lte) 15%, transparent); }
.net-badge.none { color: var(--text-3); background: var(--surface-2); }

.build-cell { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.build-cell.outdated { color: var(--warn); }

.task-chip {
  display: inline-flex; align-items: center; font-size: 11px; font-family: var(--mono);
  border-radius: 999px; padding: 3px 11px; white-space: nowrap;
}
.task-chip.pending { color: var(--warn); background: var(--warn-weak); }
.task-chip.started { color: var(--info); background: var(--accent-weak); }
.task-chip.completed { color: var(--ok); background: var(--ok-weak); }
.task-chip.failed { color: var(--crit); background: var(--crit-weak); }
.task-chip.cancelled { color: var(--text-3); background: var(--surface-2); }

.ssh-copy { font-family: var(--mono); font-size: 12px; color: var(--ok); background: var(--ok-weak); border: 0; border-radius: 5px; padding: 5px 9px; cursor: pointer; }
.ssh-kill { font-size: 11.5px; color: var(--text-3); background: transparent; border: 1px solid var(--border); border-radius: 5px; padding: 5px 8px; cursor: pointer; }
.ssh-kill:hover { color: var(--crit); border-color: var(--crit); }
.ssh-request { font-size: 12px; color: var(--accent); background: var(--accent-weak); border: 0; border-radius: 5px; padding: 5px 12px; cursor: pointer; font-weight: 600; }
.ssh-request:hover { filter: brightness(.97); }
.ssh-request[disabled] { opacity: .55; cursor: default; }
.ssh-group { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.empty {
  border: 1px dashed var(--border-strong); border-radius: var(--r3);
  padding: 56px 24px; text-align: center; color: var(--text-3); background: var(--surface);
}
.empty-ico { font-size: 28px; margin-bottom: 10px; opacity: .5; }
.empty-title { font-size: 15px; color: var(--text-2); font-weight: 550; }
.empty-hint { font-size: 13px; margin-top: 4px; }

/* ---- Device details ------------------------------------------------------ */
.detail { animation: lf-fade .25s ease both; }
.back-link { display: inline-block; color: var(--text-2); font-size: 12.5px; margin-bottom: 12px; }
.back-link:hover { color: var(--accent); text-decoration: none; }

.detail-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; margin-bottom: 20px; }
.detail-title { flex: 1; min-width: 260px; }
.detail-host-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-host-row h1 { margin: 0; font-size: 22px; font-weight: 680; font-family: var(--mono); letter-spacing: -.01em; }
.detail-status { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.detail-status .dot { width: 8px; height: 8px; }
.detail-name-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.detail-name { font-size: 14px; font-weight: 550; }
.detail-actions { display: flex; gap: 8px; align-items: center; }
.ssh-copy.lg { font-size: 12.5px; padding: 8px 12px; border: 1px solid var(--ok); border-radius: var(--r2); }
.ssh-kill.lg { font-size: 12.5px; padding: 8px 12px; border-radius: var(--r2); color: var(--text-2); background: var(--surface); }
.ssh-request.lg { font-size: 12.5px; padding: 8px 14px; border-radius: var(--r2); background: var(--accent); color: var(--on-accent); }
.ssh-request.lg:hover { filter: brightness(1.08); }

.detail-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.detail-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 980px) { .detail-grid { grid-template-columns: 1fr; } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r3); padding: 18px; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.card-title { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); font-weight: 650; }
.card-title.mb { margin-bottom: 12px; display: block; }

.seg-group { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r2); overflow: hidden; }
.seg { padding: 6px 13px; border: 0; border-left: 1px solid var(--border); cursor: pointer; font-size: 12px; background: var(--surface); color: var(--text-2); transition: background .12s; }
.seg:first-child { border-left: 0; }
.seg.active { background: var(--accent-weak); color: var(--accent); font-weight: 650; }

.batt-now { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.batt-now-value { font-size: 26px; font-weight: 680; font-family: var(--mono); color: var(--text-2); }
.batt-now-value.warn { color: var(--warn); } .batt-now-value.crit { color: var(--crit); }
.batt-now-label { font-size: 12px; color: var(--text-3); }
.spark { width: 100%; height: 96px; display: block; }
.spark-grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.spark-area { fill: var(--accent-weak); stroke: none; opacity: .5; }
.spark-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-scale { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text-3); font-family: var(--mono); margin-top: 2px; }
.conn-block { margin-top: 16px; }
.conn-title { font-size: 11px; color: var(--text-3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.conn-strip { width: 100%; height: 16px; display: block; border-radius: 3px; overflow: hidden; }
.conn-strip rect.eth { fill: var(--net-eth); }
.conn-strip rect.wlan { fill: var(--net-wlan); }
.conn-strip rect.lte { fill: var(--net-lte); }
.conn-strip rect.offline { fill: var(--surface-3); }
.conn-legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-3); margin-top: 7px; flex-wrap: wrap; }
.conn-legend > span { display: inline-flex; align-items: center; gap: 5px; }
.swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.swatch.net-eth { background: var(--net-eth); }
.swatch.net-wlan { background: var(--net-wlan); }
.swatch.net-lte { background: var(--net-lte); }
.swatch.net-offline { background: var(--surface-3); }

#fleet-map { width: 100%; height: 560px; border-radius: var(--r2); border: 1px solid var(--border); }
.leaflet-container { background: var(--surface-2); font-family: var(--sans); border-radius: var(--r2); }
.map-caption { font-size: 11px; color: var(--text-3); margin-top: 8px; font-family: var(--mono); }
.map-empty { height: 200px; border: 1px dashed var(--border-strong); border-radius: var(--r2); display: grid; place-items: center; text-align: center; color: var(--text-3); }
.map-empty-ico { font-size: 24px; opacity: .4; margin-bottom: 6px; }
.map-empty-title { font-size: 13px; color: var(--text-2); }
.map-empty-hint { font-size: 12px; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 520px; }
.mini-table thead tr { text-align: left; color: var(--text-3); font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; }
.mini-table th { padding: 6px 10px; font-weight: 600; }
.mini-table td { padding: 6px 10px; }
.mini-table tbody tr { border-top: 1px solid var(--border); }
.mini-table tbody tr.day-break { border-top: 2px solid var(--border-strong); }
.ck-time { font-family: var(--mono); color: var(--text-2); white-space: nowrap; }
.ck-net { font-family: var(--mono); font-size: 10px; font-weight: 700; }
.ck-net.eth { color: var(--net-eth); } .ck-net.wlan { color: var(--net-wlan); } .ck-net.lte { color: var(--net-lte); } .ck-net.none { color: var(--text-3); }
.ck-ip { font-family: var(--mono); color: var(--text-2); }
.ck-batt { font-family: var(--mono); color: var(--text-2); }
.ck-batt.warn { color: var(--warn); } .ck-batt.crit { color: var(--crit); }
.ck-state { color: var(--text-2); }
.ck-rsync { color: var(--text-3); font-family: var(--mono); font-size: 11px; }
.load-more { margin-top: 12px; width: 100%; padding: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r2); color: var(--text-2); font-size: 12.5px; cursor: pointer; }
.load-more:hover { background: var(--surface-3); }

.id-list { display: flex; flex-direction: column; }
.id-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 8px; border-radius: var(--r1); cursor: pointer; }
.id-row:hover { background: var(--surface-2); }
.id-label { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.id-value { font-family: var(--mono); font-size: 12px; color: var(--text); text-align: right; word-break: break-all; }

.mini-label { font-size: 11px; color: var(--text-3); display: block; margin-bottom: 5px; margin-top: 14px; }
.mini-label:first-of-type { margin-top: 0; }
.input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--r2); background: var(--surface); font-size: 13px; }
.input.mono { font-size: 12.5px; }
.textarea { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: var(--r2); background: var(--surface); font-size: 12.5px; resize: vertical; line-height: 1.5; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.tag-list:empty { margin-bottom: 0; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-family: var(--mono);
  color: var(--accent); background: var(--accent-weak); border-radius: 4px; padding: 3px 5px 3px 9px;
}
.tag-chip.view { padding: 2px 8px; }
.tag-chip button { background: transparent; border: 0; color: var(--accent); cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px; opacity: .7; }

.task-list { display: flex; flex-direction: column; gap: 2px; }
.task-row { display: flex; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.task-row .dot { width: 7px; height: 7px; margin-top: 5px; animation: none; }
.task-row .dot.pending { background: var(--warn); }
.task-row .dot.started { background: var(--info); }
.task-row .dot.completed { background: var(--ok); }
.task-row .dot.failed { background: var(--crit); }
.task-row .dot.cancelled { background: var(--text-3); }
.task-body { flex: 1; min-width: 0; }
.task-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.task-name { font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.task-status { font-size: 10.5px; font-family: var(--mono); border-radius: 4px; padding: 1px 6px; text-transform: uppercase; letter-spacing: .03em; }
.task-status.pending { color: var(--warn); background: var(--warn-weak); }
.task-status.started { color: var(--info); background: var(--accent-weak); }
.task-status.completed { color: var(--ok); background: var(--ok-weak); }
.task-status.failed { color: var(--crit); background: var(--crit-weak); }
.task-status.cancelled { color: var(--text-3); background: var(--surface-2); }
.task-meta { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.task-msg { font-size: 11.5px; color: var(--text-2); font-family: var(--mono); margin-top: 3px; background: var(--surface-2); border-radius: 4px; padding: 4px 7px; word-break: break-word; }
.task-empty { font-size: 12.5px; color: var(--text-3); padding: 4px 0; }
