:root {
  --bg: #f6f5f1; --surface: #ffffff; --text: #1c1d1f; --muted: #62656b; --line: #e2e0d9;
  --accent: #1f5f8b; --accent-text: #ffffff; --ok: #1d6b45; --ok-bg: #e5f2ea; --err: #9b2c2c; --err-bg: #f8e6e4;
  --radius: 10px; --gap: 16px;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131417; --surface: #1c1e22; --text: #e8e6e1; --muted: #9a9ca1; --line: #2e3136;
    --accent: #6fb0dc; --accent-text: #0d1b26; --ok: #7fd1a3; --ok-bg: #16281e; --err: #f0a39b; --err-bg: #2e1716;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 12px 16px;
         background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1; }
.brand { font-weight: 700; font-size: 17px; text-decoration: none; color: var(--text); letter-spacing: .02em; }
nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--muted); }
nav a:hover { background: var(--bg); color: var(--text); }
nav a[aria-current="page"] { background: var(--bg); color: var(--text); font-weight: 600; }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent);
         color: var(--accent-text); font-size: 12px; text-align: center; }
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }
h1 { font-size: 24px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 24px 0 10px; }
.card h2 { margin-top: 0; display: flex; justify-content: space-between; gap: 8px; }
.more { font-size: 13px; font-weight: 400; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--gap); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); margin-bottom: var(--gap); }
.stats a { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
           text-decoration: none; color: var(--text); }
.stats b { display: block; font-size: 26px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 13px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.card table { background: transparent; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td { font-variant-numeric: tabular-nums; }
.kv th { width: 30%; text-transform: none; letter-spacing: 0; font-size: 14px; }
.empty, .hint { color: var(--muted); }
.hint { font-size: 14px; }
.notice { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: var(--radius); }
.flash { padding: 10px 14px; border-radius: var(--radius); }
.flash.ok { background: var(--ok-bg); color: var(--ok); }
.flash.error { background: var(--err-bg); color: var(--err); }
form.stack { display: grid; gap: 12px; max-width: 560px; margin: 12px 0; }
form.narrow { max-width: 360px; }
form.inline { display: flex; flex-wrap: wrap; gap: 6px; align-items: end; margin: 0; }
form.inline label span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
label { display: grid; gap: 4px; position: relative; }
label span { font-size: 13px; color: var(--muted); }
input, select, textarea { font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line);
                          border-radius: 8px; padding: 7px 9px; min-width: 0; }
input[type="number"] { width: 6em; }
form.stack input[type="number"] { width: auto; }
input[type="checkbox"] { justify-self: start; width: 18px; height: 18px; }
button { font: inherit; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--accent);
         color: var(--accent-text); cursor: pointer; justify-self: start; }
button:disabled { opacity: .6; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.logout button { background: transparent; color: var(--muted); border: 1px solid var(--line); padding: 6px 10px; }
details { margin: 16px 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; }
summary { cursor: pointer; font-weight: 600; }
.row { display: flex; gap: 8px; margin-top: 12px; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .04em; border: 1px solid var(--line); }
.pill.lvl-ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.lvl-critical { background: var(--err-bg); color: var(--err); border-color: transparent; }
.pill.lvl-warning { background: #fdf3dc; color: #7a5300; border-color: transparent; }
@media (prefers-color-scheme: dark) { .pill.lvl-warning { background: #2e2512; color: #f0c674; } }
.alerts { margin: 8px 0 0; padding-left: 18px; }
.alerts .lvl-critical { color: var(--err); font-weight: 600; }
.alerts .lvl-info { color: var(--muted); }
.row form + form button { background: transparent; color: var(--text); border: 1px solid var(--line); }  /* Reject is secondary */
.approval { margin-bottom: var(--gap); }
.note { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 10px 0; }
.note h3 { margin: 0 0 6px; font-size: 15px; }
.note small { color: var(--muted); font-weight: 400; }
.note p { margin: 0; white-space: pre-wrap; }
#chat-log { display: grid; gap: 10px; margin: 12px 0; max-width: 760px; }
.msg { padding: 10px 14px; border-radius: var(--radius); white-space: pre-wrap; border: 1px solid var(--line); background: var(--surface); }
.msg.user { justify-self: end; background: var(--accent); color: var(--accent-text); border-color: transparent; max-width: 85%; }
.msg.pending { color: var(--muted); }
.msg.error { background: var(--err-bg); color: var(--err); }
.msg.note { font-size: 13px; color: var(--muted); }
@media (max-width: 640px) {
  header { position: static; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  td { border: 0; padding: 3px 10px; }
  td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12px; }
  td[data-label]:empty { display: none; }
}
.report { white-space: pre-wrap; font: 13px/1.5 ui-monospace, Consolas, monospace; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 8px 0; overflow-wrap: anywhere; }
