/* Design tokens lifted from baldar-api/public/unknown-scans.html.
   Manual theme via html[data-theme] (set before first paint in layout.php);
   dark is the base, light overrides. */
:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8eaed;
  --muted: #9aa2b1;
  --accent: #4c8dff;
  --warn: #ffb020;
  --bad: #ff5c5c;
  --good: #35c78a;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 230px;
}
html[data-theme=light] {
  --bg: #f4f6fa; --panel: #fff; --panel-2: #f0f3f8; --line: #dde2ea;
  --text: #171a21; --muted: #5c6675;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 "Segoe UI", Arial, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---- app frame ---- */
.app { display: flex; min-height: 100vh; }
aside#sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--panel); border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 16px 14px; border-bottom: 1px solid var(--line); }
.brand-name { font-size: 17px; font-weight: 700; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
aside nav { flex: 1; overflow-y: auto; padding: 8px 0; }
aside nav a {
  display: block; padding: 10px 16px; color: var(--muted);
  text-decoration: none; font-size: 14px; border-right: 3px solid transparent;
}
aside nav a:hover { color: var(--text); background: var(--panel-2); }
aside nav a.active { color: var(--text); border-right-color: var(--accent); background: var(--panel-2); font-weight: 600; }
.side-footer {
  padding: 12px 16px; border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 13px; color: var(--muted);
}

.content { flex: 1; min-width: 0; }
.content > header {
  padding: 12px 20px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.content h1 { margin: 0; font-size: 18px; }
#menu-toggle { display: none; }
.filters { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-inline-start: auto; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, button {
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 7px;
  padding: 7px 10px; font: inherit; font-size: 14px;
}
button { cursor: pointer; border-color: var(--accent); }
button:hover:enabled { background: var(--accent); color: #fff; }
button.ghost { border-color: var(--line); }
button.danger { border-color: var(--bad); color: var(--bad); }
button.danger:hover:enabled { background: var(--bad); color: #fff; }
button:disabled { opacity: .45; cursor: not-allowed; }

main { padding: 20px; max-width: 1500px; margin: 0 auto; }

/* ---- caveats banner (spec: transparency next to every metric) ---- */
.caveats {
  margin: 14px 20px 0; padding: 10px 14px; font-size: 12.5px; line-height: 1.7;
  background: var(--panel); border: 1px solid var(--line);
  border-right: 3px solid var(--warn); border-radius: 10px; color: var(--muted);
}
.caveats b { color: var(--text); }

/* ---- client-side tabs (unknown-scans pattern) ---- */
.tabs { display: flex; gap: 4px; margin: 14px 0 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  border-radius: 0; padding: 10px 14px; color: var(--muted); font-size: 14px; cursor: pointer;
}
.tab:hover { background: none; color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab span { color: var(--muted); font-weight: 400; font-size: 12px; }

/* ---- cards ---- */
.cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card .k { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card .v { font-size: 26px; font-weight: 600; font-family: var(--mono); }
.card .n { color: var(--muted); font-size: 11px; margin-top: 4px; }
.v.bad { color: var(--bad); } .v.warn { color: var(--warn); } .v.good { color: var(--good); }

/* ---- sections / panels / tables ---- */
section { margin-top: 22px; }
h2 { font-size: 15px; margin: 0 0 4px; }
h2 .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-top: 8px; }
.panel-pad { padding: 14px; }
.scroll { overflow: auto; max-height: 460px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--panel-2); position: sticky; top: 0; font-weight: 600; font-size: 12px; color: var(--muted); z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { font-size: 10px; }
tbody tr:hover { background: var(--panel-2); }
tfoot td {
  background: var(--panel-2); font-weight: 700; border-top: 2px solid var(--line);
  position: sticky; bottom: 0;
}
tr.clickable { cursor: pointer; }
.bc { font-family: var(--mono); font-size: 12.5px; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 20px; font-size: 11px; border: 1px solid; }
.tag.ok   { color: var(--good); border-color: var(--good); }
.tag.warn { color: var(--warn); border-color: var(--warn); }
.tag.bad  { color: var(--bad); border-color: var(--bad); }
.tag.info { color: var(--accent); border-color: var(--accent); }
.tag.none { color: var(--muted); border-color: var(--line); }
.bar { height: 7px; background: var(--panel-2); border-radius: 4px; overflow: hidden; min-width: 70px; }
.bar > i { display: block; height: 100%; background: var(--accent); }
.bar.bad > i { background: var(--bad); }
.msg { padding: 14px; color: var(--muted); font-size: 13px; }
.msg.err { color: var(--bad); }
.gap-red { color: var(--bad); font-weight: 700; }

.split { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.chart-box { padding: 14px; height: 300px; position: relative; }
.lede {
  background: var(--panel); border: 1px solid var(--line);
  border-right: 3px solid var(--accent); border-radius: 10px;
  padding: 13px 15px; font-size: 13.5px; line-height: 1.7;
}

/* ---- forms / modals (admin screens) ---- */
.modal-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px; width: min(440px, 92vw); max-height: 88vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal .field { margin-bottom: 12px; }
.modal input, .modal select { width: 100%; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); margin: 0; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 18px; }
.notice { color: var(--warn); font-size: 13.5px; }

/* ---- login ---- */
body.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 30px; width: min(380px, 92vw); text-align: center;
}
.login-box form { margin-top: 20px; text-align: right; }
.login-box .brand-name { font-size: 22px; }
.login-box div { margin-bottom: 12px; }
.login-box input { width: 100%; }
.login-box button { width: 100%; margin-top: 6px; background: var(--accent); color: #fff; }

/* ---- mobile ---- */
@media (max-width: 900px) {
  .split { grid-template-columns: 1fr; }
  aside#sidebar {
    position: fixed; right: 0; top: 0; z-index: 40; height: 100vh;
    transform: translateX(100%); transition: transform .18s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,.4);
  }
  aside#sidebar.open { transform: none; }
  #menu-toggle { display: inline-block; }
  main { padding: 14px; }
  .content > header { padding: 10px 14px; }
  .caveats { margin: 12px 14px 0; }
}
