/* biso dashboard — every colour is a token, defined once per theme */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #05080f; --surface: #0d1422; --surface-2: #121c2f; --border: #1e2b44; --grid: #1a2539;
  --text: #e8edf6; --text-2: #b4bfd2; --muted: #8592a8;
  --brand: #205fc7; --hl: #3d8bfd;
  --s1: #3d8bfd; --s2: #d95926; --neg: #e66767;                 /* validated chart colours (dark) */
  --good: #0ca30c; --warn: #fab219; --crit: #d03b3b;
  --good-bg: rgba(12,163,12,.16); --warn-bg: rgba(250,178,25,.16); --crit-bg: rgba(208,59,59,.18); --run-bg: rgba(61,139,253,.16);
  --shadow: 0 8px 24px rgba(0,0,0,.35); --glow: rgba(32,95,199,.28);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f9; --surface: #ffffff; --surface-2: #f5f7fc; --border: #d8e0ed; --grid: #e6ebf3;
  --text: #0b1220; --text-2: #34415a; --muted: #5d6a80;
  --brand: #205fc7; --hl: #205fc7;
  --s1: #205fc7; --s2: #eb6834; --neg: #e34948;                 /* validated chart colours (light) */
  --good-bg: rgba(12,163,12,.12); --warn-bg: rgba(250,178,25,.2); --crit-bg: rgba(208,59,59,.12); --run-bg: rgba(32,95,199,.1);
  --shadow: 0 6px 18px rgba(16,32,64,.10); --glow: rgba(32,95,199,.14);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
       font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--hl); outline-offset: 2px; border-radius: 4px; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--muted); } .small { font-size: 12px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 24px;
          background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); }
.wordmark { font-weight: 700; font-size: 22px; letter-spacing: -0.5px; } .wordmark.big { font-size: 34px; } .hl { color: var(--hl); }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { padding: 8px 14px; border-radius: 8px; color: var(--text-2); text-decoration: none; font-weight: 500; }
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: inset 0 -2px 0 var(--hl); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.user { color: var(--muted); padding: 0 4px; }
.ghost { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; color: var(--text-2); }
.ghost:hover { background: var(--surface-2); color: var(--text); }
.primary { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 8px 16px; font-weight: 600; cursor: pointer; }
.primary:hover { filter: brightness(1.1); } .primary:disabled { opacity: .6; cursor: default; }
.link-btn { background: none; border: 0; color: var(--hl); cursor: pointer; padding: 2px 6px; font-size: 13px; }

/* layout */
.main { max-width: 1440px; margin: 0 auto; padding: 16px 24px 48px; }
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin: 4px 0 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; }
.lbl { font-size: 12px; color: var(--muted); }
select, input[type="date"], input[type="text"], input[type="password"], .search {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; min-width: 150px; }
.section { margin: 28px 0 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 12px; }
.section-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.status-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px; padding: 12px 16px; background: var(--surface);
                border: 1px solid var(--border); border-radius: 12px; }
.stat { white-space: nowrap; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-height: 96px; }
.tile-label { color: var(--text-2); font-size: 13px; }
.tile-value { font-size: clamp(20px, 2.1vw, 28px); font-weight: 650; letter-spacing: -0.5px; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-value:empty { display: none; }
.tile-sub { margin-top: 6px; font-size: 12px; color: var(--text-2); }
.delta-arrow { margin-right: 3px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 12px; margin-top: 12px; }
.section > .grid2:first-of-type { margin-top: 0; } .tiles + .grid2, .tiles + .card { margin-top: 12px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 8px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-body { min-width: 0; }

/* status pills: always icon + word, never colour alone */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--text); }
.pill-icon { font-weight: 800; }
.pill-ok { background: var(--good-bg); } .pill-ok .pill-icon { color: var(--good); }
.pill-warn { background: var(--warn-bg); } .pill-warn .pill-icon { color: var(--warn); }
.pill-crit { background: var(--crit-bg); } .pill-crit .pill-icon { color: var(--crit); }
.pill-run { background: var(--run-bg); } .pill-run .pill-icon { color: var(--hl); }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; margin-bottom: 12px;
          background: var(--crit-bg); border: 1px solid var(--crit); border-radius: 10px; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; overflow: visible; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .zero { stroke: var(--muted); stroke-width: 1; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-dot { stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart .hit { fill: transparent; cursor: crosshair; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
       padding: 8px 10px; box-shadow: var(--shadow); font-size: 12px; min-width: 160px; }
.tip-title { color: var(--muted); margin-bottom: 4px; }
.tip-row { display: flex; align-items: center; gap: 8px; } .tip-row b { margin-left: auto; padding-left: 12px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 6px; color: var(--text-2); font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.hbars { display: flex; flex-direction: column; gap: 6px; }
.hbar { display: grid; grid-template-columns: minmax(70px, 160px) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.hbar-track { height: 14px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hbar-value { min-width: 70px; text-align: right; }
.empty { color: var(--muted); padding: 24px 4px; text-align: center; }

/* tables */
.table-wrap { overflow: auto; max-height: 520px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--text-2); white-space: nowrap; padding: 0; z-index: 1; }
.th-btn { background: none; border: 0; padding: 9px 10px; width: 100%; text-align: inherit; cursor: pointer; font-weight: 600; color: inherit; }
.table td { padding: 7px 10px; border-top: 1px solid var(--border); white-space: nowrap; }
.table tr:hover td { background: var(--surface-2); }
.num, .table th.num { text-align: right; }
.search { width: 100%; max-width: 360px; margin-bottom: 8px; }
.lookup { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; } .lookup .search { margin: 0; flex: 1; max-width: 480px; }

/* loading */
.skeleton { min-height: 96px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%);
            background-size: 200% 100%; animation: shimmer 1.4s infinite; }
.skeleton.tall { min-height: 260px; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
         background: radial-gradient(ellipse at 50% 25%, var(--glow), transparent 60%), var(--bg); }
.login-box { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 32px 28px;
             box-shadow: var(--shadow); text-align: center; }
.login-logo { display: block; margin: 0 auto 10px; border-radius: 16px; }
.login-form { display: flex; flex-direction: column; gap: 12px; margin-top: 20px; text-align: left; }
.login-form label { display: flex; flex-direction: column; gap: 4px; }
.login-form input { width: 100%; }
.wide { width: 100%; padding: 10px; margin-top: 4px; }
.login-error { min-height: 1.2em; margin: 0; color: var(--crit); font-weight: 600; }
.login-foot { display: flex; justify-content: center; gap: 8px; margin-top: 18px; }

/* access page */
.stack > h3 { margin: 16px 0 6px; font-size: 13px; font-weight: 600; color: var(--text-2); } .stack > h3:first-child { margin-top: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ghost.danger { color: var(--crit); border-color: var(--crit); }
.qr { display: block; width: 200px; height: 200px; padding: 8px; margin: 8px 0; background: #fff; border-radius: 8px; }   /* QR codes need a white quiet zone in both themes */
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; user-select: all; word-break: break-all; }
.filters + .login-error { margin-top: -8px; }

/* phones */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 8px 16px; gap: 8px; }
  .tabs { order: 3; flex-basis: 100%; overflow-x: auto; }
  .user { display: none; }
  .main { padding: 12px 16px 40px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { min-height: 84px; padding: 12px; }
  .tile-value { font-size: 21px; }
  .filters { gap: 8px; }
  .filters label { flex: 1 1 140px; min-width: 0; }
  .filters select, .filters input { width: 100%; min-width: 0; }
  .card { padding: 12px; }
}
