:root {
  color-scheme: light;
  --page:           #f9f9f7;
  --surface-1:      #fcfcfb;
  --text-primary:   #0b0b0b;
  --text-secondary: #52514e;
  --text-muted:     #898781;
  --grid:           #e1e0d9;
  --baseline:       #c3c2b7;
  --border:         rgba(11,11,11,0.10);
  --series-1:       #2a78d6;
  --status-good:    #0ca30c;
  --status-critical:#d03b3b;
  --status-warning: #fab219;
  --good-text:      #006300;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page:           #0d0d0d;
    --surface-1:      #1a1a19;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --baseline:       #383835;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;
    --good-text:      #0ca30c;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 1080px; margin: 0 auto; padding: 0 20px 40px; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
h3 { font-size: 14px; margin: 24px 0 8px; color: var(--text-secondary); }
.sub { color: var(--text-muted); font-size: 12.5px; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  max-width: 1080px; margin: 0 auto; padding: 18px 20px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 26px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.scan-meta { text-align: right; font-size: 13px; color: var(--text-secondary); }

.btn {
  font: inherit; font-size: 13.5px; padding: 7px 14px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1);
  color: var(--text-primary); cursor: pointer;
}
.btn:hover { border-color: var(--baseline); }
.btn.primary { background: var(--series-1); border-color: transparent; color: #fff; }
.btn.primary:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 3px 10px; font-size: 12.5px; }

.banner {
  max-width: 1040px; margin: 0 auto 12px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-1); font-size: 13.5px;
}
.banner.error { border-left: 4px solid var(--status-critical); }
.banner.notif { border-left: 4px solid var(--status-warning); display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.banner.notif.reconnect { border-left-color: var(--status-good); }
.banner.notif-more {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 6px 14px;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.tile {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
}
.tile-label { font-size: 12px; color: var(--text-muted); }
.tile-value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile-value small { font-size: 14px; font-weight: 500; color: var(--text-secondary); }

.card {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; margin-bottom: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th {
  text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px;
  padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
td.num, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; color: var(--text-secondary); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.status.online .dot { background: var(--status-good); }
.status.online { color: var(--good-text); }
.status.offline .dot { background: var(--status-critical); }
.status.offline { color: var(--status-critical); }

.dev-name { cursor: pointer; font-weight: 500; }
.dev-name:hover { text-decoration: underline dotted; }
.router-tag {
  font-size: 10.5px; font-weight: 600; color: var(--text-muted);
  border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; margin-left: 6px;
  vertical-align: 1px;
}

/* device row: name cell with chevron + type/os/vendor sub-line */
.dev-row { cursor: pointer; }
.dev-row:hover td { background: color-mix(in srgb, var(--text-primary) 3%, transparent); }
.dev-row.is-off { opacity: .72; }
.name-cell { display: flex; align-items: baseline; gap: 8px; }
.chev { color: var(--text-muted); font-size: 11px; transition: transform .12s; flex: none; }
.dev-row.open .chev { transform: rotate(90deg); }
.dev-id { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dev-sub { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.unit { color: var(--text-muted); font-size: 11px; margin-left: 1px; }

/* health pill */
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.health .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.health.ok { color: var(--good-text); } .health.ok .dot { background: var(--status-good); }
.health.warn { color: var(--status-warning); } .health.warn .dot { background: var(--status-warning); }
.health.bad { color: var(--status-critical); } .health.bad .dot { background: var(--status-critical); }

/* expanded detail panel */
.detail-row > td { background: color-mix(in srgb, var(--text-primary) 4%, transparent); padding: 4px 10px 12px 28px; }
dl.detail { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 22px; margin: 6px 0 0; }
dl.detail > div { display: flex; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--grid); }
dl.detail dt { color: var(--text-muted); font-size: 12px; min-width: 84px; flex: none; }
dl.detail dd { margin: 0; font-size: 12.5px; color: var(--text-secondary); white-space: normal; }
.pill { font-size: 10.5px; color: var(--text-muted); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; }
.ports { display: flex; flex-wrap: wrap; gap: 5px; }
.port {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px;
  font-variant-numeric: tabular-nums; background: var(--page);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
}
.port .svc { color: var(--text-muted); font-size: 10.5px; }
/* name line: label + tags + info button */
.dev-line { display: flex; align-items: center; gap: 6px; }
.unnamed-tag {
  font-size: 10px; font-weight: 600; letter-spacing: .03em; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: 5px; padding: 0 4px;
}
.info-btn {
  flex: none; width: 16px; height: 16px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--border); background: transparent; color: var(--text-muted);
  font: 600 10.5px/1 ui-serif, Georgia, serif; padding: 0; opacity: .65;
}
.info-btn:hover { opacity: 1; color: var(--series-1); border-color: var(--series-1); }
.name-hint { margin: -2px 0 8px; }
.name-input {
  font: inherit; font-size: 13.5px; font-weight: 500; width: 190px;
  padding: 1px 6px; border-radius: 6px; color: var(--text-primary);
  border: 1px solid var(--series-1); background: var(--page);
}

/* identity popover (ⓘ) */
.info-pop {
  position: fixed; z-index: 20; width: min(340px, calc(100vw - 16px));
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.22);
}
.idcard-head { font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.info-pop dl.detail { grid-template-columns: 1fr; gap: 0; }
.info-pop dl.detail dt { min-width: 92px; }
.info-pop dl.detail > div:last-child { border-bottom: none; }
.mac-big { font-size: 13px; color: var(--text-primary); letter-spacing: .02em; }

.watch-btn { background: none; border: none; cursor: pointer; font-size: 17px; opacity: .35; padding: 2px 6px; }
.watch-btn.on { opacity: 1; }
.forget-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 13px; }
.forget-btn:hover { color: var(--status-critical); }

/* probes */
.probes { display: flex; flex-direction: column; gap: 2px; }
.probe {
  display: flex; align-items: center; gap: 8px; padding: 5px 0;
  border-bottom: 1px solid var(--grid); font-size: 13.5px;
}
.probe:last-child { border-bottom: none; }
.probe-name { font-weight: 500; }
.probe .forget-btn { margin-left: auto; }
.probe.stale .probe-name { color: var(--status-critical); }
.install-box { margin-top: 10px; border-top: 1px solid var(--grid); padding-top: 10px; }
.install-box pre {
  margin: 6px 0; padding: 10px 12px; border-radius: 8px; overflow-x: auto;
  background: var(--page); border: 1px solid var(--border);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px;
  color: var(--text-primary); user-select: all;
}
.install-box code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
}

.filters { display: flex; gap: 10px; align-items: center; }
select {
  font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  max-width: 220px;
}
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button {
  font: inherit; font-size: 12.5px; padding: 5px 12px; border: none; cursor: pointer;
  background: transparent; color: var(--text-secondary);
}
.seg button.on { background: var(--series-1); color: #fff; }

.chart-sub { margin: -4px 0 6px; }
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .bar { fill: var(--series-1); }
.chart .bar-hit { fill: transparent; }
.chart .bar-hit:hover + .bar, .chart .hot .bar { opacity: .8; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; }
.chart text { fill: var(--text-muted); font-size: 11px; font-family: inherit; font-variant-numeric: tabular-nums; }
.chart .empty-msg { fill: var(--text-secondary); font-size: 13px; }

.tooltip {
  position: fixed; z-index: 10; pointer-events: none;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.tooltip .t-val { font-weight: 600; }

/* interval picker in the topbar */
.interval-label { display: inline-flex; align-items: center; gap: 6px; }

/* per-device online/offline timeline */
.timeline-legend { display: flex; align-items: center; gap: 6px; margin: 0 0 8px; }
.timeline-legend .lg { width: 14px; height: 6px; border-radius: 3px; display: inline-block; margin-left: 10px; }
.timeline-legend .lg:first-child { margin-left: 0; }
.timeline-legend .lg.on { background: var(--status-good); }
.timeline-legend .lg.off { background: var(--status-critical); }
.timeline-legend .lg.unknown { background: var(--grid); }
#timeline .lane-name { fill: var(--text-secondary); font-size: 12px; }
#timeline .lane-tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
#timeline .lane-track { fill: var(--grid); }
#timeline .lane-on { fill: var(--status-good); opacity: .55; }
#timeline .lane-off { fill: var(--status-critical); cursor: pointer; }
#timeline .lane-off:hover { opacity: .8; }

.ongoing { color: var(--status-critical); font-weight: 500; }
footer { text-align: center; padding: 8px 0 24px; }
