:root {
  --bg: #f4f6f9; --panel: #ffffff; --ink: #18212f; --muted: #667085; --line: #e3e7ee;
  --brand: #1f4e8c; --brand-ink: #ffffff; --side: #14243b; --side-ink: #c9d4e3; --side-active: #22385a;
  --ok: #1a8a5a; --warn: #c27c0e; --bad: #c8372d; --bar: #3a6fb5;
  --radius: 12px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1520; --panel: #172030; --ink: #e6ebf2; --muted: #93a0b4; --line: #26324a;
          --side: #0b111b; --side-ink: #aeb9cb; --side-active: #1b2a42; --bar: #5b8fd6; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); }
button, input { font: inherit; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.error { color: var(--bad); margin: 0; } .warn-text { color: var(--warn); font-weight: 600; }

/* login */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; box-shadow: var(--shadow); }
.login-card form { display: grid; gap: 14px; margin-top: 22px; }
.login-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); }
.login-card input:focus { outline: 2px solid var(--brand); outline-offset: 0; }
.btn-primary { padding: 11px; border: 0; border-radius: 8px; background: var(--brand); color: var(--brand-ink); font-weight: 600; cursor: pointer; }
.btn-primary:disabled { opacity: .6; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: .2px; }
.brand-lg { font-size: 20px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px; gap: 18px; }
.sidebar .brand { color: #fff; padding: 0 8px; }
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 10px; padding: 9px 10px; border: 0; border-radius: 8px; background: none; color: inherit; text-align: left; text-decoration: none; cursor: pointer; font-size: 14px; }
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; stroke-linecap: round; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #6aa1ea; }
.nav-item .sub, .nav-item .ext { font-size: 11px; opacity: .6; }
.me { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 8px 0; border-top: 1px solid rgba(255,255,255,.08); }
.me-name { color: #fff; font-size: 14px; }
.btn-ghost { padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; background: transparent; color: inherit; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.sidebar .btn-ghost { border-color: rgba(255,255,255,.15); }
.content { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--panel); }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.frames { flex: 1; position: relative; min-height: 0; }
.frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; display: none; }
.frames iframe.active { display: block; }
[hidden] { display: none !important; }

/* summary */
.summary { padding: 20px 24px 32px; overflow: auto; flex: 1; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile-label { font-size: 13px; color: var(--muted); }
.tile-value { font-size: 26px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 12px; color: var(--muted); }
.tile.good .tile-value { color: var(--ok); font-size: 20px; } .tile.bad .tile-value { color: var(--bad); font-size: 20px; }
.tile.warn { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.span2 { grid-column: span 2; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 13.5px; }
.list li { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.bar { width: 100%; max-width: 44px; background: var(--bar); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bar-val { font-size: 12px; font-variant-numeric: tabular-nums; }
.bar-lbl { font-size: 11.5px; color: var(--muted); }
.meter { margin-bottom: 12px; }
.meter-head { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; }
.meter-track { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.meter-fill { height: 100%; background: var(--ok); } .meter-fill.warn { background: var(--warn); } .meter-fill.bad { background: var(--bad); }

@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 8px 12px; gap: 10px; overflow-x: auto; }
  .sidebar .brand span:last-child, .me > div { display: none; }
  #nav { flex-direction: row; }
  .nav-item { grid-template-columns: 18px auto; white-space: nowrap; }
  .nav-item .sub, .nav-item .ext { display: none; }
  .me { border: 0; padding: 0; }
  .topbar, .summary { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 600; font-size: 12.5px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line); }
.badge.live { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, var(--line)); }
.badge.shadow { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, var(--line)); }
.badge.off { color: var(--muted); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 4px 9px; font-size: 12px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--line); color: inherit; font-weight: 600; }
.counters { display: flex; flex-wrap: wrap; gap: 6px; }
.counters span { font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--line); font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
