/* Pangrazio Monitor portal. Dark-first operations UI; light theme follows the OS. */
:root {
  --bg: #0b1012; --panel: #121a1d; --panel-2: #172126; --line: #22313a; --line-2: #2e4250;
  --ink: #e4ecee; --ink-2: #b8c6ca; --muted: #7d9298;
  --accent: #3fc1b3; --accent-ink: #062320; --accent-soft: rgba(63, 193, 179, .14);
  --ok: #4fca82; --ok-soft: rgba(79, 202, 130, .14);
  --rec: #ff6b5f; --rec-soft: rgba(255, 107, 95, .15);
  --speech: #f2b84b; --speech-soft: rgba(242, 184, 75, .15);
  --bad: #ff5f6d; --bad-soft: rgba(255, 95, 109, .15);
  --warn: #f2a23c; --warn-soft: rgba(242, 162, 60, .15);
  --idle: #5f7680;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, Consolas, monospace;
  --r: 10px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f2f5f6; --panel: #ffffff; --panel-2: #f6f9fa; --line: #dbe3e6; --line-2: #c5d2d6;
    --ink: #13201f; --ink-2: #33474b; --muted: #637a80;
    --accent: #0b7d73; --accent-ink: #ffffff; --accent-soft: rgba(11, 125, 115, .10);
    --ok: #1f8a4c; --ok-soft: rgba(31, 138, 76, .10); --rec: #d23a2f; --rec-soft: rgba(210, 58, 47, .10);
    --speech: #b57600; --speech-soft: rgba(181, 118, 0, .10); --bad: #c4283a; --bad-soft: rgba(196, 40, 58, .10);
    --warn: #b26a00; --warn-soft: rgba(178, 106, 0, .10); --idle: #8aa0a6;
    color-scheme: light;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
form.inline { display: inline; margin: 0; }

/* shell */
.shell { display: grid; grid-template-columns: 268px 1fr; height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-weight: 700; letter-spacing: .01em; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(from 200deg, var(--accent), #2a7fd4, var(--accent)); box-shadow: 0 0 0 3px var(--accent-soft); }
.nav { display: flex; flex-direction: column; padding: 0 10px 8px; gap: 2px; }
.nav a, .tree a { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); }
.nav a:hover, .tree a:hover { background: var(--panel-2); color: var(--ink); }
.nav a.on, .tree a.on { background: var(--accent-soft); color: var(--ink); }
.nav .count { margin-left: auto; font-size: 11px; padding: 0 7px; border-radius: 9px; background: var(--bad-soft); color: var(--bad); font-weight: 600; }
.side-search { padding: 4px 14px 8px; }
.side-search input { width: 100%; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; outline: none; }
.side-search input:focus { border-color: var(--accent); }
.tree { overflow-y: auto; padding: 0 10px 12px; flex: 1; }
.tree .site { margin-top: 10px; }
.tree .site > a { font-weight: 600; color: var(--ink); }
.tree .rooms a { padding-left: 26px; font-size: 13px; }
.tree .rooms a .lvl { margin-left: auto; width: 44px; }
.side-foot { padding: 10px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(6px); }
.crumbs { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.crumbs a { color: var(--muted); font-weight: 500; }
.crumbs .sep { color: var(--line-2); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 2s infinite; }
.live.stale .pulse { background: var(--warn); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 60%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.view { overflow-y: auto; padding: 22px; flex: 1; display: flex; flex-direction: column; gap: 18px; }
.menu-btn { display: none; }

/* controls */
button.ghost, .seg button, .icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 11px; cursor: pointer; color: var(--ink-2); }
button.ghost:hover, .seg button:hover, .icon-btn:hover { border-color: var(--line-2); color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 7px 13px; cursor: pointer; font-weight: 600; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-soft); color: var(--ink); }
input.search { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-width: 200px; outline: none; }
input.search:focus { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin: 0; font-size: 15px; }
.card-b { padding: 14px 16px; }
.card-h .right { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
h1.title { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.subtitle { color: var(--muted); margin-top: 3px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi .l { color: var(--muted); font-size: 12.5px; }
.kpi.bad .v { color: var(--bad); } .kpi.ok .v { color: var(--ok); } .kpi.rec .v { color: var(--rec); }

/* chips and dots */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line); }
.chip.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.chip.bad { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.chip.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip.rec { background: var(--rec-soft); color: var(--rec); border-color: transparent; }
.chip.speech { background: var(--speech-soft); color: var(--speech); border-color: transparent; }
.chip.idle { color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--idle); flex: none; }
.dot.ok { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.warn { background: var(--warn); }
.dot.rec { background: var(--rec); box-shadow: 0 0 0 3px var(--rec-soft); } .dot.speech { background: var(--speech); }
.facts { display: flex; flex-wrap: wrap; gap: 8px; }

/* level meter */
.lvl { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; border: 1px solid var(--line); }
.lvl > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #6fd8a0 70%, var(--speech)); border-radius: 3px; transition: width .6s ease; }

/* room tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tile { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; cursor: pointer; transition: border-color .15s, transform .15s; color: var(--ink); }
.tile:hover { border-color: var(--accent); transform: translateY(-1px); }
.tile .t-top { display: flex; align-items: center; gap: 8px; }
.tile .t-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile .t-top .chip { margin-left: auto; }
.tile .t-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.tile canvas { width: 100%; height: 38px; display: block; }

/* tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--panel-2); }
.tbl tr.sel td { background: var(--accent-soft); }
.tbl td.sum { color: var(--ink-2); max-width: 520px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.problems { list-style: none; margin: 0; padding: 0; }
.problems li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-bottom: 1px solid var(--line); }
.problems li:last-child { border-bottom: 0; }

/* chart */
.chart { position: relative; }
.chart canvas { width: 100%; height: 220px; display: block; }
.chart .tip { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 9px; font-size: 12px; white-space: nowrap; display: none; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); align-items: center; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--accent); }
.legend .lr::before { background: var(--rec-soft); border: 1px solid var(--rec); }

/* tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 11px 12px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--panel); border-left: 1px solid var(--line-2); transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column; z-index: 20; box-shadow: -18px 0 40px rgba(0,0,0,.3); }
.drawer.open { transform: none; }
.drawer .d-h { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer .d-h h3 { margin: 0; font-size: 16px; }
.drawer .d-b { overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.drawer audio { width: 100%; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.transcript { white-space: pre-wrap; font-size: 13.5px; line-height: 1.6; background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; max-height: 48vh; overflow-y: auto; }
.transcript mark { background: var(--speech-soft); color: var(--ink); border-radius: 3px; padding: 0 2px; }
.summary-box { background: var(--panel-2); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 6px; color: var(--ink-2); }

.empty { color: var(--muted); padding: 24px; text-align: center; }
.err-box { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 10px 12px; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 26px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login .brand { padding: 0 0 6px; font-size: 18px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.login input { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; outline: none; }
.login input:focus { border-color: var(--accent); }
.login button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: 10px; font-weight: 700; cursor: pointer; margin-top: 4px; }
.login .err { color: var(--bad); margin: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 18px 0 40px rgba(0,0,0,.35); }
  .menu-btn { display: inline-block; }
  .view { padding: 14px; }
  .tbl td.sum { max-width: 220px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
