/* BANANA UI. Light and dark themes via CSS custom properties. */
:root {
  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #f0f3f8; --border: #dfe4ec; --text: #18212f;
  --muted: #5d6b80; --accent: #2563eb; --accent-fg: #ffffff; --accent-soft: #dbe7ff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --bad: #b91c1c; --bad-soft: #fee2e2;
  --info: #0e7490; --info-soft: #cffafe; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --side: #0f172a; --side-text: #cbd5e1; --side-active: #1e293b; --chart-grid: #e5e9f0;
  --c1: #2563eb; --c2: #16a34a; --c3: #d97706; --c4: #9333ea; --c5: #dc2626; --c6: #0891b2; --c7: #ea580c; --c8: #65a30d;
  --radius: 10px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --border: #24314d; --text: #e2e8f0;
    --muted: #94a3b8; --accent: #60a5fa; --accent-fg: #0b1120; --accent-soft: #1e3a5f;
    --ok: #4ade80; --ok-soft: #12351f; --warn: #fbbf24; --warn-soft: #3b2a07; --bad: #f87171; --bad-soft: #3f1515;
    --info: #22d3ee; --info-soft: #0c3440; --shadow: 0 1px 2px rgba(0,0,0,.4); --side: #060b17;
    --side-text: #94a3b8; --side-active: #17223a; --chart-grid: #24314d;
    --c1: #60a5fa; --c2: #4ade80; --c3: #fbbf24; --c4: #c084fc; --c5: #f87171; --c6: #22d3ee; --c7: #fb923c; --c8: #a3e635; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #17223a; --border: #24314d; --text: #e2e8f0;
  --muted: #94a3b8; --accent: #60a5fa; --accent-fg: #0b1120; --accent-soft: #1e3a5f;
  --ok: #4ade80; --ok-soft: #12351f; --warn: #fbbf24; --warn-soft: #3b2a07; --bad: #f87171; --bad-soft: #3f1515;
  --info: #22d3ee; --info-soft: #0c3440; --shadow: 0 1px 2px rgba(0,0,0,.4); --side: #060b17;
  --side-text: #94a3b8; --side-active: #17223a; --chart-grid: #24314d;
  --c1: #60a5fa; --c2: #4ade80; --c3: #fbbf24; --c4: #c084fc; --c5: #f87171; --c6: #22d3ee; --c7: #fb923c; --c8: #a3e635; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 13px; }
h1.mono { font-size: 22px; }
.stat .value.mono { font-size: 18px; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-text); padding: 16px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 8px 16px; }
.brand-mark { width: 32px; height: 32px; border-radius: 7px; display: block; flex: none; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #64748b; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--side-text); }
.nav a:hover { background: var(--side-active); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.nav svg { width: 16px; height: 16px; flex: none; opacity: .85; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar form.search { flex: 1; max-width: 460px; }
.topbar .spacer { flex: 1; }
.content { padding: 24px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.flush > h2 { padding: 16px 18px 0; }
.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.stat .hint { color: var(--muted); font-size: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 0 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 500; }
.help { color: var(--muted); font-size: 12px; margin-top: 2px; }
.inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.inline .field { margin-bottom: 0; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; filter: none; }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; }

.badge { white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.ok, .badge.up, .badge.active { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.warning, .badge.notice, .badge.minor, .badge.reserved, .badge.dormant { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.down, .badge.critical, .badge.major, .badge.emerg, .badge.alert, .badge.crit, .badge.err, .badge.problem, .badge.error, .badge.offline, .badge.lowerLayerDown { background: var(--bad-soft); color: var(--bad); }
.badge.info, .badge.dhcp, .badge.trap, .badge.changed { background: var(--info-soft); color: var(--info); }
.badge.discovered { background: var(--accent-soft); color: var(--accent); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.bar.warn > span { background: var(--warn); } .bar.bad > span { background: var(--bad); }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); }
.flash.warn { background: var(--warn-soft); color: var(--warn); }
.flash.err { background: var(--bad-soft); color: var(--bad); }

.ipmap { display: grid; grid-template-columns: repeat(auto-fill, minmax(38px, 1fr)); gap: 3px; }
.ipmap a, .ipmap span { display: block; text-align: center; font-size: 11px; padding: 4px 0; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-family: var(--mono); }
.ipmap .active { background: var(--accent); color: var(--accent-fg); }
.ipmap .reserved { background: var(--warn-soft); color: var(--warn); }
.ipmap .dhcp { background: var(--info-soft); color: var(--info); }
.ipmap .pool { background: repeating-linear-gradient(45deg, var(--info-soft), var(--info-soft) 4px, transparent 4px, transparent 8px); color: var(--info); }
.ipmap .gateway { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.ipmap .offline { background: var(--bad-soft); color: var(--bad); }
.ipmap .discovered { background: var(--accent-soft); color: var(--accent); }
.ipmap .system { opacity: .4; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a.active { color: var(--accent); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Graphs (charts.js): plot, axes, crosshair, tooltip, legend */
.chart { --chart-h: 220px; position: relative; width: 100%; display: flex; flex-direction: column; min-width: 0; }
.chart .gc-plot { position: relative; height: var(--chart-h); min-height: 60px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.chart .gc-svg { position: absolute; inset: 0; display: block; overflow: visible; }
.chart .gc-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .gc-title { fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart .gc-hit { cursor: crosshair; }
.chart .gc-cross { stroke: var(--text); stroke-opacity: .35; stroke-dasharray: 3 3; pointer-events: none; }
.chart .gc-sel { fill: var(--accent); fill-opacity: .14; stroke: var(--accent); stroke-opacity: .5; pointer-events: none; }
.chart circle { pointer-events: none; }
.chart .gc-msg { position: absolute; inset: 0 0 20px 0; display: none; place-items: center; color: var(--muted); font-size: 13px; text-align: center; padding: 0 16px; pointer-events: none; }
.chart .gc-loading { position: absolute; left: 0; right: 0; top: 0; height: 2px; overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
.chart.is-loading .gc-loading { opacity: 1; }
.chart .gc-loading::after { content: ""; position: absolute; top: 0; bottom: 0; width: 30%; background: var(--accent); animation: gc-load 1s ease-in-out infinite; }
@keyframes gc-load { from { left: -30%; } to { left: 100%; } }
.gc-tip { position: absolute; z-index: 5; pointer-events: none; display: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,.18); min-width: 150px; max-width: 360px; }
.gc-tip-time { color: var(--muted); font-size: 11px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.gc-tip-row { display: flex; align-items: center; gap: 6px; line-height: 1.6; }
.gc-tip-row span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gc-tip-row b { font-variant-numeric: tabular-nums; font-weight: 600; padding-left: 10px; }
.gc-tip i, .gc-legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; flex: none; }
.gc-legend { font-size: 12px; color: var(--muted); }
.gc-legend-list { display: flex; flex-wrap: wrap; gap: 2px 6px; margin-top: 4px; }
.gc-key { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: inherit; font: inherit; padding: 2px 6px; border-radius: 5px; cursor: pointer; }
.gc-key:hover { background: var(--surface-2); color: var(--text); }
.gc-key b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.gc-key.off, .gc-legend tr.off { opacity: .4; }
.gc-legend-table { margin-top: 6px; max-height: 190px; overflow: auto; }
.gc-legend-table table { width: 100%; border-collapse: collapse; }
.gc-legend-table th { font-weight: 600; text-align: left; padding: 3px 8px; color: var(--muted); border-bottom: 1px solid var(--border); background: none; font-size: 11px; text-transform: none; letter-spacing: 0; }
.gc-legend-table td { padding: 3px 8px; border: 0; color: var(--text); font-variant-numeric: tabular-nums; }
.gc-legend-table th.num, .gc-legend-table td.num { text-align: right; white-space: nowrap; }
.gc-legend-table td:first-child { display: flex; align-items: center; gap: 8px; }
.gc-legend-table tbody tr { cursor: pointer; }
.gc-legend-table tbody tr:hover td { background: var(--surface-2); }
.chart-help { font-size: 12px; color: var(--muted); }
.health-graphs { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 18px; margin-top: 8px; }
.health-graph { font-size: 12px; min-width: 0; }
.health-graph .chart { --chart-h: 90px; }
/* Time picker */
.tp { position: relative; display: inline-flex; align-items: stretch; flex-wrap: nowrap; max-width: 100%; gap: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.tp-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; border-right: 1px solid var(--border); background: none; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; padding: 6px 10px; cursor: pointer; }
.tp-btn:first-child { border-radius: 8px 0 0 8px; }
.tp-btn:hover { background: var(--surface-2); }
.tp-shift { font-size: 18px; line-height: 1; padding: 4px 9px; color: var(--muted); }
.tp-caret { color: var(--muted); font-size: 11px; }
.tp-every { width: auto; min-width: 0; margin: 0; box-shadow: none; border: 0; background: none; color: var(--text); font: inherit; font-size: 12px; padding: 6px 8px; border-radius: 0 8px 8px 0; cursor: pointer; }
.tp-panel { display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.2); padding: 14px; gap: 18px; grid-template-columns: 230px 190px; }
.tp.open .tp-panel { display: grid; }
.tp-head { font-weight: 650; font-size: 13px; margin-bottom: 8px; }
.tp-abs label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.tp-abs input { display: block; width: 100%; margin-top: 3px; }
.tp-err { color: var(--bad); font-size: 12px; min-height: 16px; }
.tp-quick { display: flex; flex-direction: column; max-height: 380px; overflow: auto; border-left: 1px solid var(--border); padding-left: 14px; }
.tp-quick button { text-align: left; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.tp-quick button:hover { background: var(--surface-2); }
.tp-quick button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 600px) { .tp { flex-wrap: wrap; } .tp-panel { grid-template-columns: minmax(0, 1fr); left: 0; right: auto; width: min(92vw, 320px); } .tp-quick { border-left: 0; padding-left: 0; } }
.range-picker { display: flex; gap: 4px; }
.range-picker a { padding: 3px 10px; border-radius: 6px; border: 1px solid var(--border); color: var(--muted); font-size: 12px; font-weight: 600; }
.range-picker a.active { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }

pre.zone { background: var(--surface-2); padding: 14px; border-radius: 8px; overflow: auto; font-size: 12px; max-height: 420px; margin: 0; }
details summary { cursor: pointer; font-weight: 600; }
.muted { color: var(--muted); }
.right { text-align: right; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.empty-state { text-align: center; color: var(--muted); padding: 30px; }
.token-box { font-family: var(--mono); background: var(--warn-soft); color: var(--warn); padding: 10px; border-radius: 8px; word-break: break-all; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(1200px 600px at 10% -10%, var(--accent-soft), transparent), var(--bg); }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { color: var(--text); justify-content: center; padding-bottom: 8px; }
.login-card .brand-mark { width: 56px; height: 56px; border-radius: 12px; }
.login-card .brand { font-size: 22px; letter-spacing: .06em; }

.user-menu { display: flex; align-items: center; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.tenant-select select { width: auto; min-width: 160px; }

@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid.cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 10px 12px; }
  .brand { padding-bottom: 8px; }
  .nav { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 4px; }
  .nav a { flex: none; padding: 6px 10px; }
  .nav-group { display: none; }
  .topbar form.search { flex: 1 1 100%; max-width: none; order: 10; }
  .grid.cols-2, .grid.cols-4 { grid-template-columns: 1fr; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar { flex-wrap: wrap; }
}

.log-msg { font-family: var(--mono, ui-monospace, monospace); font-size: 12.5px; word-break: break-word; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.filters .field { margin-bottom: 0; }

/* ---- Device pages (0.3.0) ---- */
.tabs { overflow-x: auto; scrollbar-width: thin; }
.tabs a { white-space: nowrap; }
.tabs a .count { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.dev-head { display: flex; gap: 16px; align-items: center; background: var(--surface); border: 1px solid var(--border);
  border-left: 5px solid var(--muted); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin-bottom: 14px; }
.dev-head.up { border-left-color: var(--ok); } .dev-head.down { border-left-color: var(--bad); }
.dev-head .who { flex: 1; min-width: 0; }
.dev-head h1 { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dev-head .facts { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 4px; color: var(--muted); font-size: 13px; }
.dev-head .facts b { color: var(--text); font-weight: 600; }
.dev-head .side { display: flex; gap: 8px; align-items: center; }
.minis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.mini { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px 4px; box-shadow: var(--shadow); }
.mini .t { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.mini .t b { color: var(--text); font-weight: 600; }
.chart.mini-chart { --chart-h: 96px; }
.ov { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.box > .bh { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 9px 14px;
  background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 13px; }
.box > .bh a { font-weight: 500; font-size: 12px; }
.box > .bh .bh-title { display: flex; gap: 8px; align-items: center; }
.box > .bb { padding: 10px 14px; }
.box table th, .box table td { padding: 6px 14px; font-size: 13px; }
table.info { width: 100%; border-collapse: collapse; }
table.info th { width: 34%; color: var(--muted); font-weight: 500; text-align: left; background: none; text-transform: none; letter-spacing: 0; font-size: 13px; }
table.info td { word-break: break-word; }
.hrow { display: grid; grid-template-columns: minmax(110px, 38%) 1fr 64px; gap: 10px; align-items: center; padding: 5px 14px; font-size: 13px; border-bottom: 1px solid var(--border); }
.hrow:last-child { border-bottom: 0; }
.hrow .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hrow .val { text-align: right; font-variant-numeric: tabular-nums; }
.hrow .sub { display: block; color: var(--muted); font-size: 11px; }
.counts { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 14px; }
.counts span { padding: 3px 10px; border-radius: 99px; background: var(--surface-2); font-size: 12px; font-weight: 600; }
.counts .ok { background: var(--ok-soft); color: var(--ok); } .counts .bad { background: var(--bad-soft); color: var(--bad); }
.counts .off { color: var(--muted); }
.portgrid { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 14px 12px; }
.portgrid a { font-size: 11px; padding: 2px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-family: var(--mono); }
.portgrid a.up { background: var(--ok-soft); color: var(--ok); } .portgrid a.down { background: var(--bad-soft); color: var(--bad); }
.state { font-weight: 600; } .state.ok { color: var(--ok); } .state.warning { color: var(--warn); } .state.critical { color: var(--bad); } .state.unknown { color: var(--muted); }
td.indent { padding-left: calc(14px + var(--d, 0) * 18px) !important; }
.tree-node { color: var(--muted); }
.kind-tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.kind-tag.scalar, .kind-tag.column { background: var(--accent-soft); color: var(--accent); }
.kind-tag.notification { background: var(--warn-soft); color: var(--warn); }
.kind-tag.table, .kind-tag.row { background: var(--info-soft); color: var(--info); }
tr.st td:first-child { box-shadow: inset 4px 0 0 var(--muted); }
tr.st.up td:first-child { box-shadow: inset 4px 0 0 var(--ok); } tr.st.down td:first-child { box-shadow: inset 4px 0 0 var(--bad); }
.cell-bar { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.cell-bar .bar { flex: 1; min-width: 50px; }
.cell-bar small { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 1100px) { .ov { grid-template-columns: minmax(0, 1fr); } .minis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .minis { grid-template-columns: minmax(0, 1fr); } .dev-head { flex-direction: column; align-items: flex-start; } }
.devlist td { white-space: nowrap; vertical-align: middle; }
.devlist .clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.devlist .cell-bar { min-width: 0; gap: 6px; }
.devlist .cell-bar .bar { min-width: 40px; max-width: 54px; }
.devlist th, .devlist td { padding-left: 10px; padding-right: 10px; }
.devlist td:first-child { white-space: normal; min-width: 160px; }

/* ---------------------------------------------------------------- configuration backups */
.code-view { font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  overflow-x: auto; border-collapse: collapse; width: 100%; }
.code-view td { border: 0; padding: 0 10px; vertical-align: top; white-space: pre; }
.code-view td.ln { width: 1%; text-align: right; color: var(--muted); user-select: none; border-right: 1px solid var(--border); }
.code-view tr.ignored td:not(.ln) { color: var(--muted); font-style: italic; }
.code-view tr.add td { background: var(--ok-soft); }
.code-view tr.add td.sign, .code-view tr.add td:last-child { color: var(--ok); }
.code-view tr.del td { background: var(--bad-soft); }
.code-view tr.del td.sign, .code-view tr.del td:last-child { color: var(--bad); }
.code-view tr.hunk td { background: var(--surface-2); color: var(--info); padding: 3px 10px; }
.code-view td.sign { width: 1%; user-select: none; padding: 0 4px; }
.code-scroll { overflow-x: auto; max-width: 100%; }
.diff-pick { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }
.diff-pick .field { margin: 0; min-width: 180px; }
.change { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.change .plus { color: var(--ok); } .change .minus { color: var(--bad); }
textarea.config-paste { font-family: var(--mono); font-size: 12px; min-height: 160px; }

/* ---------- topology map ---------- */
.map-card { position: relative; overflow: hidden; }
.map-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.map-tools form { margin: 0; }
.map-search { max-width: 200px; }
.map-hint { font-size: 12px; }
.map-canvas { height: 70vh; min-height: 420px; cursor: grab; user-select: none; touch-action: none; }
.map-canvas.panning { cursor: grabbing; }
.map-canvas svg { width: 100%; height: 100%; display: block; }
.map-canvas .link { stroke: var(--muted); stroke-opacity: .55; }
.map-canvas .link.down { stroke: var(--bad); stroke-opacity: .9; stroke-dasharray: 6 4; }
.map-canvas .link.hl { stroke: var(--accent); stroke-opacity: 1; }
.map-canvas .port { font-size: 10px; fill: var(--muted); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.map-canvas .node { cursor: pointer; }
.map-canvas .node circle { stroke: var(--surface); stroke-width: 2.5px; }
.map-canvas .node.up circle { fill: var(--ok); }
.map-canvas .node.down circle { fill: var(--bad); }
.map-canvas .node.unknown circle { fill: var(--warn); }
.map-canvas .node.external circle { fill: var(--surface-2); stroke: var(--muted); stroke-dasharray: 3 2; }
.map-canvas .node.match circle { stroke: var(--accent); stroke-width: 4px; }
.map-canvas .node text { font-size: 12px; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; }
.map-canvas .node circle.badge-dot { fill: var(--bad); stroke: var(--surface); stroke-width: 2px; }
.map-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow); max-width: 320px; z-index: 5; }
.map-legend { display: inline-flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 12px; color: var(--muted); }
.map-legend .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: -4px; }
.map-legend .dot.up { background: var(--ok); } .map-legend .dot.down { background: var(--bad); }
.map-legend .dot.unknown { background: var(--warn); } .map-legend .dot.external { background: var(--surface-2); border: 1px dashed var(--muted); }
.map-legend .line { width: 18px; border-top: 2px dashed var(--bad); display: inline-block; margin-right: -4px; }

/* 0.22: sign-in separator, MFA QR code, recovery codes */
.login-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0 10px; }
.login-sep::before, .login-sep::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.qr-box { display: inline-block; background: #fff; padding: 6px; border-radius: 8px; line-height: 0; }
.qr-box svg { width: 200px; height: 200px; }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-family: var(--mono, monospace); font-size: 14px; margin: 10px 0; }

/* Dashboards (0.31.0) */
.dgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; grid-auto-flow: row dense; }
.dw { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; display: flex; flex-direction: column; }
.dw-w3 { grid-column: span 3; } .dw-w4 { grid-column: span 4; } .dw-w6 { grid-column: span 6; } .dw-w8 { grid-column: span 8; } .dw-w12 { grid-column: span 12; }
.dw-h1 { min-height: 110px; } .dw-h2 { height: 300px; } .dw-h3 { height: 440px; } .dw-h4 { height: 580px; }
.dw-title { margin: 0 0 10px; }
.dw.dw-stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.dw.dw-stat .value { font-size: 30px; font-weight: 700; margin-top: 4px; }
.dw .value.bad { color: var(--bad); }
.dw-big { font-size: 24px; font-weight: 700; margin-bottom: 8px; }
.dw-big .muted { font-size: 13px; font-weight: 500; }
.dw-scroll { overflow: auto; flex: 1; margin: 0 -16px -14px; }
.dw-scroll table td, .dw-scroll table th { padding: 7px 12px; }
.dw-empty { color: var(--muted); padding: 18px 0; text-align: center; flex: 1; display: grid; place-items: center; }
.dw-note { white-space: pre-wrap; word-break: break-word; overflow: auto; }
.dw-sub { font-size: 12px; margin-bottom: 6px; }
.dw .chart { flex: 1; min-height: 0; }
.dw .chart .gc-plot { flex: 1; height: auto; min-height: 90px; }
.dw .chart .gc-legend-table { max-height: 96px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-top: 8px; align-items: center; }
.legend .key { display: inline-block; width: 12px; height: 3px; border-radius: 2px; vertical-align: middle; }
.legend .key.k0 { background: var(--accent); } .legend .key.k1 { background: var(--ok); }
.stack { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.stack .s-up { background: var(--ok); } .stack .s-down { background: var(--bad); } .stack .s-unknown { background: var(--muted); }
.dash-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-tabs a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); font-weight: 600; font-size: 13px; background: var(--surface); }
.dash-tabs a.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.dash-tabs a:hover { text-decoration: none; color: var(--text); }
.editor-list { display: grid; gap: 8px; }
.ed-item { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.ed-item.dragging { opacity: .5; }
.ed-item .handle { cursor: grab; color: var(--muted); text-align: center; user-select: none; }
.ed-item .ed-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px 10px; }
.ed-item .ed-body .field { margin: 0; }
.ed-item .ed-kind { grid-column: 1 / -1; font-weight: 600; }
.ed-item .ed-tools { display: flex; gap: 4px; }
/* Assistant chat */
.chat-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 18px; align-items: start; }
.chat-list a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list a.active, .chat-list a:hover { background: var(--surface-2); text-decoration: none; }
.chat-thread { display: grid; gap: 14px; margin-bottom: 16px; }
.msg { max-width: 920px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); }
.msg.user { background: var(--accent-soft); border-color: transparent; justify-self: end; max-width: 720px; white-space: pre-wrap; }
.msg.error { border-color: var(--bad); color: var(--bad); }
.msg .md p { margin: 0 0 8px; } .msg .md p:last-child { margin-bottom: 0; } .msg .md ul, .msg .md ol { margin: 0 0 8px; padding-left: 20px; }
.msg .md pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow: auto; }
.msg .tools { font-size: 12px; color: var(--muted); margin-top: 8px; }
.msg .tools code { font-size: 12px; }
.msg .proposal { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.msg .proposal .dgrid { gap: 10px; }
.msg .proposal .dw { box-shadow: none; }
.typing { display: inline-flex; gap: 4px; } .typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
.chat-form textarea { min-height: 70px; resize: vertical; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggest button { font-size: 12px; }
@media (max-width: 1100px) { .dw-w3 { grid-column: span 6; } .dw-w4, .dw-w8 { grid-column: span 6; } }
@media (max-width: 860px) { .dgrid { grid-template-columns: minmax(0, 1fr); } .dgrid > * { grid-column: 1 / -1 !important; } .chat-layout { grid-template-columns: minmax(0, 1fr); } .dw-h2, .dw-h3, .dw-h4 { height: auto; max-height: 520px; } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; } }
/* Clive chat bubble (bottom right) */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.clive-face { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-weight: 700; font-size: 14px; flex: none; vertical-align: middle; }
h1 .clive-face { width: 34px; height: 34px; margin-right: 6px; }
.clive-fab { position: fixed; right: 22px; bottom: 22px; z-index: 900; width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; cursor: pointer; box-shadow: 0 6px 20px rgba(16, 24, 40, .25); transition: transform .15s; }
.clive-fab:hover { transform: scale(1.06); }
.clive-fab:focus-visible { outline: 3px solid var(--accent-soft); outline-offset: 2px; }
.clive-fab svg { width: 26px; height: 26px; }
.clive-fab .dot-new { position: absolute; top: 6px; right: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); border: 2px solid var(--accent); }
.clive-panel { position: fixed; right: 22px; bottom: 90px; z-index: 901; width: 400px; max-width: calc(100vw - 32px); height: min(620px, calc(100vh - 120px)); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 16px 48px rgba(16, 24, 40, .28); overflow: hidden; }
.clive-panel[hidden] { display: none; }
.clive-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.clive-who { flex: 1; display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.clive-who span { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn.sm { width: 28px; height: 28px; font-size: 14px; }
a.icon-btn:hover { text-decoration: none; }
.clive-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.clive-msg { padding: 8px 11px; border-radius: 12px; max-width: 88%; word-wrap: break-word; font-size: 13.5px; }
.clive-msg.me { align-self: flex-end; background: var(--accent-soft); white-space: pre-wrap; border-bottom-right-radius: 4px; }
.clive-msg.bot { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.clive-msg.err { color: var(--bad); }
.clive-msg p { margin: 0 0 6px; } .clive-msg p:last-child { margin: 0; } .clive-msg ul, .clive-msg ol { margin: 0 0 6px; padding-left: 18px; }
.clive-msg pre { background: var(--surface); padding: 8px; border-radius: 6px; overflow: auto; font-size: 12px; margin: 6px 0; }
.clive-msg .clive-card { margin-top: 8px; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.clive-msg .clive-card .btn { margin-top: 6px; }
.clive-msg .meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.clive-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); align-items: flex-end; }
.clive-form textarea { resize: none; min-height: 40px; max-height: 120px; }
@media (max-width: 600px) { .clive-panel { right: 8px; left: 8px; width: auto; max-width: none; bottom: 84px; height: calc(100vh - 110px); } .clive-fab { right: 14px; bottom: 14px; } }
@media (prefers-reduced-motion: reduce) { .clive-fab { transition: none; } }

/* Markdown in Clive's answers */
.md h3, .md h4, .md h5, .clive-msg h3, .clive-msg h4, .clive-msg h5 { margin: 10px 0 6px; line-height: 1.25; }
.md h3, .clive-msg h3 { font-size: 1.08em; } .md h4, .clive-msg h4 { font-size: 1em; } .md h5, .clive-msg h5 { font-size: .95em; color: var(--muted); }
.md > :first-child, .clive-msg .md > :first-child { margin-top: 0; }
.md-table { overflow-x: auto; margin: 6px 0 8px; max-width: 100%; }
.md-table table { border-collapse: collapse; font-size: .95em; min-width: 50%; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; vertical-align: top; }
.md-table th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.clive-msg .md-table th { background: var(--surface); }
.md-table tr:nth-child(even) td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.md code, .clive-msg code { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace); font-size: .92em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; }
.clive-msg code { background: var(--surface); }
.md pre code, .clive-msg pre code { background: none; padding: 0; }
.md blockquote, .clive-msg blockquote { margin: 6px 0; padding: 2px 10px; border-left: 3px solid var(--border); color: var(--muted); }
.md hr, .clive-msg hr { border: 0; border-top: 1px solid var(--border); margin: 10px 0; }
.md ul ul, .md ol ol, .md ul ol, .md ol ul, .clive-msg ul ul, .clive-msg ol ul, .clive-msg ul ol { margin: 2px 0; }
.md li.task, .clive-msg li.task { list-style: none; margin-left: -16px; }
.clive-msg .md-table { font-size: 12.5px; }
.clive-msg .md-table td { white-space: nowrap; }
.clive-msg.bot:has(.md-table) { max-width: 96%; }
.msg .pending-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.clive-steps { font-size: 11px; color: var(--muted); margin-top: 4px; }
.clive-steps summary { cursor: pointer; }
.clive-steps ul { margin: 4px 0 0; padding-left: 16px; }
.clive-working { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
