/* Operator dashboard.
   One stylesheet, no framework, no build step. Tokens first so light and dark
   are one set of decisions rather than two. */
:root {
  color-scheme: light dark;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --sidebar: #10141c;
  --sidebar-text: #98a2b3;
  --sidebar-active: #ffffff;
  --border: #e1e5ea;
  --text: #131820;
  --muted: #5b6472;
  --accent: #1a56db;
  --accent-soft: #eaf0fe;
  --on-accent: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --ok: #067647;
  --ok-bg: #ecfdf3;
  --warn: #b54708;
  --warn-bg: #fffaeb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.08);
  --side-w: 232px;
  --side-w-collapsed: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c0f14; --surface: #151a22; --surface-2: #1b212b; --sidebar: #0a0d12;
    --sidebar-text: #8b96a8; --border: #262d39; --text: #e6eaf1; --muted: #97a2b4;
    --accent: #5b86ff; --accent-soft: #16203a; --danger: #f97066; --danger-bg: #2a1615;
    --ok: #47cd89; --ok-bg: #0e2419; --warn: #f79009; --warn-bg: #2a1f0f;
    --shadow: 0 1px 2px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.layout.collapsed { grid-template-columns: var(--side-w-collapsed) 1fr; }
main { padding: 28px 32px 64px; min-width: 0; }
main.centred { display: grid; place-items: center; min-height: 100vh; padding: 24px; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh; overflow: hidden;
}
.side-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 14px; border-bottom: 1px solid rgba(255,255,255,.07);
}
.logo {
  width: 30px; height: 30px; flex: none; border-radius: 8px;
  background: var(--accent); color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 12px; letter-spacing: .02em;
}
.wordmark { color: #fff; font-weight: 640; letter-spacing: -.01em; white-space: nowrap; }
.collapse {
  margin-left: auto; width: 26px; height: 26px; flex: none; cursor: pointer;
  border-radius: 6px; border: 1px solid rgba(255,255,255,.12);
  background: transparent; color: var(--sidebar-text); line-height: 1;
}
.collapse:hover { background: rgba(255,255,255,.08); color: #fff; }

.sidebar nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px;
  border-radius: 7px; color: var(--sidebar-text); text-decoration: none;
  font-weight: 500; white-space: nowrap;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.on { background: var(--accent); color: var(--sidebar-active); }
.ico { width: 18px; flex: none; text-align: center; opacity: .9; }
.divider { height: 1px; background: rgba(255,255,255,.08); margin: 10px 4px; }

.side-foot { padding: 12px 10px 14px; border-top: 1px solid rgba(255,255,255,.07); }
.me {
  display: flex; align-items: center; gap: 10px; padding: 8px 9px; margin-bottom: 8px;
  border-radius: 7px; text-decoration: none; color: var(--sidebar-text);
}
.me:hover, .me.on { background: rgba(255,255,255,.07); color: #fff; }
.avatar {
  width: 28px; height: 28px; flex: none; border-radius: 50%;
  background: rgba(255,255,255,.13); display: grid; place-items: center;
  font-weight: 640; font-size: 12px; color: #fff;
}
.me .lbl { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.me strong { font-size: 13px; font-weight: 580; color: #fff; }
.me em { font-style: normal; font-size: 11.5px; opacity: .75; text-transform: capitalize; }

/* Collapsed: icons only. Labels are hidden rather than removed so the
   accessible name still reads correctly. */
.layout.collapsed .wordmark,
.layout.collapsed .lbl { display: none; }
.layout.collapsed .sidebar nav a,
.layout.collapsed .me { justify-content: center; padding-left: 0; padding-right: 0; }
.layout.collapsed .side-head { justify-content: center; padding-left: 8px; padding-right: 8px; }
.layout.collapsed .collapse { margin-left: 0; }
.layout.collapsed .collapse span { display: inline-block; transform: rotate(180deg); }
.layout.collapsed .side-foot form { display: none; }

@media (max-width: 820px) {
  .layout, .layout.collapsed { grid-template-columns: var(--side-w-collapsed) 1fr; }
  .wordmark, .lbl { display: none; }
  .sidebar nav a, .me { justify-content: center; }
  .side-foot form { display: none; }
  main { padding: 20px 16px 48px; }
}

/* ---------- Typography ---------- */
h1 { font-size: 23px; margin: 0 0 4px; letter-spacing: -.022em; font-weight: 640; }
h2 { font-size: 15px; margin: 30px 0 12px; letter-spacing: -.01em; font-weight: 620; }
.sub { color: var(--muted); margin: 0 0 22px; max-width: 68ch; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------- Cards & panels ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow);
}
.card .n { font-size: 27px; font-weight: 640; letter-spacing: -.025em; }
.card .l { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
  margin-bottom: 18px;
}
.panel .hd {
  padding: 13px 17px; border-bottom: 1px solid var(--border); font-weight: 600;
  display: flex; align-items: center; gap: 10px;
}
.panel .hd .muted { font-weight: 400; }
.panel .bd { padding: 17px; }
.panel .bd > p:first-child { margin-top: 0; }

/* ---------- Tables ---------- */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 17px; border-bottom: 1px solid var(--border); }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .045em; color: var(--muted); font-weight: 620; }
tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.act { text-align: right; white-space: nowrap; }

/* ---------- Bits ---------- */
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 560; }
.tag.ok { background: var(--ok-bg); color: var(--ok); }
.tag.bad { background: var(--danger-bg); color: var(--danger); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.tag.mute { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

label { display: block; font-weight: 550; margin-bottom: 5px; font-size: 13px; }
input, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--surface-2); color: var(--text); font: inherit;
}
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 9px; }
.check label { margin: 0; font-weight: 500; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 15px; }
.field { margin-bottom: 15px; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }

button {
  padding: 9px 15px; border-radius: 7px; border: 1px solid transparent;
  background: var(--accent); color: var(--on-accent); font: inherit;
  font-weight: 560; cursor: pointer;
}
button:hover { filter: brightness(1.07); }
button.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
button.ghost:hover { background: var(--surface-2); filter: none; color: var(--text); }
button.danger { background: transparent; color: var(--danger); border-color: var(--border); }
button.danger:hover { background: var(--danger-bg); filter: none; }
button.sm { padding: 5px 11px; font-size: 12.5px; }
button.block { width: 100%; }
form.inline { display: inline; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 4px; }

.note { padding: 12px 15px; border-radius: var(--radius); margin-bottom: 18px; border: 1px solid; }
.note.err { background: var(--danger-bg); color: var(--danger); border-color: currentColor; }
.note.ok { background: var(--ok-bg); color: var(--ok); border-color: currentColor; }
.note.warn { background: var(--warn-bg); color: var(--warn); border-color: currentColor; }
.note strong { display: block; margin-bottom: 3px; }

.secret {
  display: block; padding: 13px 15px; margin: 10px 0;
  background: var(--surface); border: 1px dashed var(--border);
  border-radius: 7px; font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 15px; word-break: break-all; user-select: all; color: var(--text);
}
.codes {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px; margin: 12px 0;
}
.codes code {
  padding: 9px 11px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; text-align: center; user-select: all; font-size: 13.5px;
}
.empty { padding: 30px 17px; text-align: center; color: var(--muted); }

/* ---------- Sign-in ---------- */
.auth { width: 100%; max-width: 390px; }
.auth .panel .bd { padding: 26px; }
.auth h1 { font-size: 19px; margin-bottom: 18px; }
.brandline { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.brandline .logo { width: 34px; height: 34px; font-size: 13px; }
.brandline b { font-size: 15px; letter-spacing: -.01em; }

/* Inline role selector: select plus its own submit button, because an inline
   onchange handler would be blocked by script-src 'self' and fail silently. */
.rolebar { display: flex; gap: 6px; align-items: center; }
.rolebar select { width: auto; min-width: 92px; padding: 5px 8px; font-size: 12.5px; }
