:root {
  --ground: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --ink: #17181c;
  --ink-2: #464852;
  --ink-3: #686a74;
  --line: #e4e1ea;
  --line-2: #d3cfdc;
  --brand: #4b2a7b;
  --brand-hover: #3d2266;
  --brand-deep: #241438;
  --brand-soft: #efe9f8;
  --bar: #6d4aa8;
  --focus: #9b7bd4;
  --block-bg: #fdecea; --block-fg: #9b1c1c;
  --redact-bg: #fff1dc; --redact-fg: #874706;
  --warn-bg: #eceffe; --warn-fg: #353a96;
  --ok-bg: #e3f3ef; --ok-fg: #0d5a50;
  --muted-bg: #efeef2; --muted-fg: #55575f;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #131217; --surface: #1c1a22; --surface-2: #211f28; --ink: #f1eff5; --ink-2: #cbc8d3; --ink-3: #a19dab;
    --line: #322e3b; --line-2: #443f50; --brand: #a384db; --brand-hover: #b89be6; --brand-soft: #2b2240; --bar: #a88ae0;
    --block-bg: #3d1a1a; --block-fg: #f5b4b4; --redact-bg: #3a2a12; --redact-fg: #f3c88a; --warn-bg: #22254a; --warn-fg: #c3c7ff;
    --ok-bg: #123530; --ok-fg: #9fe0d2; --muted-bg: #2a2831; --muted-fg: #c4c1cc;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font: 14px/1.55 "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
p { margin: 0; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-hover); }
.btn.danger { color: var(--block-fg); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 600; font-size: 13px; }
.field .hint { font-size: 12px; color: var(--ink-3); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  min-height: 38px; padding: 7px 10px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
select { width: auto; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--brand); flex: none; }
.error-text { color: var(--block-fg); font-size: 13px; }

/* auth screens */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.auth-card .head { background: var(--brand-deep); color: #fff; padding: 18px 24px; display: flex; gap: 10px; align-items: center; font-weight: 650; font-size: 16px; }
.auth-card form { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 20px; }
.auth-card .sub { color: var(--ink-3); margin-top: -8px; }
.qr { display: flex; justify-content: center; padding: 8px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.qr img { width: 180px; height: 180px; image-rendering: pixelated; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 13px; word-break: break-all; }

/* shell */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--brand-deep); color: #e9e2f5; display: flex; flex-direction: column; padding: 18px 12px; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; color: #fff; }
.org { font-size: 12px; color: #bfb2d6; padding: 0 10px 14px; margin-top: -10px; }
.side a { color: #ddd3ee; text-decoration: none; padding: 8px 10px; border-radius: 8px; font-weight: 500; }
.side a:hover { background: rgba(255,255,255,.08); }
.side a[aria-current=page] { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.side .spacer { flex: 1; }
.side .me { font-size: 12px; color: #bfb2d6; padding: 8px 10px; border-top: 1px solid rgba(255,255,255,.12); display: flex; flex-direction: column; gap: 8px; }
.side .me button { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px; padding: 6px 10px; cursor: pointer; }
main { padding: 28px 36px 64px; max-width: 1240px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }
.page-head p { color: var(--ink-3); margin-top: 4px; max-width: 70ch; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 18px 20px; }
.card h2 { font-size: 16px; }
.card .card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card .card-head p { color: var(--ink-3); font-size: 13px; }
.card .card-body { padding: 18px 20px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tile { padding: 16px 18px; }
.tile .v { font-size: 30px; font-weight: 650; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--ink-3); font-size: 13px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(0, 180px) minmax(0, 1fr) 48px; gap: 12px; align-items: center; font-size: 13px; }
.bar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { height: 10px; background: var(--line); border-radius: 4px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--bar); border-radius: 0 4px 4px 0; }
.bar .n { text-align: right; font-variant-numeric: tabular-nums; }
.trend { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: 8px; }
.trend .col { flex: 1; background: var(--bar); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.trend-axis { display: flex; justify-content: space-between; color: var(--ink-3); font-size: 12px; margin-top: 6px; }
.empty { color: var(--ink-3); font-size: 13px; padding: 6px 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td.num, .num { font-variant-numeric: tabular-nums; }
td .sub { color: var(--ink-3); font-size: 12px; }
tr.dim td { opacity: .5; }
.table-wrap { overflow-x: auto; }

.tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.tag.block, .tag.stopped, .tag.blocked, .tag.blocked_tool, .tag.revoked { background: var(--block-bg); color: var(--block-fg); }
.tag.redact, .tag.redacted { background: var(--redact-bg); color: var(--redact-fg); }
.tag.warn, .tag.sent_anyway { background: var(--warn-bg); color: var(--warn-fg); }
.tag.approved, .tag.ok, .tag.active { background: var(--ok-bg); color: var(--ok-fg); }
.tag.off, .tag.muted { background: var(--muted-bg); color: var(--muted-fg); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--muted-bg); color: var(--muted-fg); }

.packs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pack { padding: 14px 16px; display: flex; gap: 12px; cursor: pointer; }
.pack.on { border-color: var(--brand); background: var(--brand-soft); }
.pack b { display: block; }
.pack .d { font-size: 12px; color: var(--ink-3); margin: 2px 0 6px; }

.savebar { position: sticky; bottom: 0; background: var(--surface); border: 1px solid var(--brand); border-radius: var(--radius); padding: 12px 16px; display: flex; gap: 12px; align-items: center; box-shadow: 0 -6px 24px rgba(0,0,0,.08); }
.savebar input { max-width: 380px; }
.secret-box { background: var(--surface-2); border: 1px dashed var(--brand); border-radius: 8px; padding: 12px 14px; }
pre.code { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; margin: 0; font: 12.5px/1.5 ui-monospace, Consolas, monospace; white-space: pre; }
.notice { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 10px 14px; font-size: 13px; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 14px; color: var(--ink-3); font-size: 13px; }

.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: var(--ground); padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.25); max-width: 380px; z-index: 50; }
.toast.err { background: var(--block-fg); color: #fff; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(20, 16, 28, .5); }
dialog form { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
dialog h2 { font-size: 18px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 1000px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .grid-3, .packs { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .side .spacer, .org { display: none; }
  main { padding: 20px 16px 48px; }
}
.auth-card .card-body { padding: 22px 24px; }
.auth > .stack { width: min(420px, 100%); }
[hidden] { display: none !important; }
main > * + * { margin-top: 20px; }  main > .page-head + * { margin-top: 0; }
td.mono { white-space: nowrap; }

.radios { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pack.radio input { accent-color: var(--brand); width: 18px; height: 18px; margin-top: 2px; flex: none; }
.swapcard { border-color: var(--brand); }
.swapcard .card-head { background: var(--brand-soft); }
.sub { color: var(--ink-3); font-size: 13px; }
@media (max-width: 1000px) { .radios { grid-template-columns: minmax(0, 1fr); } }

/* 1.2: grouped menu, health strip, coach and admin pages */
.side { overflow-y: auto; }
.nav-links { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #a596c2; padding: 14px 10px 4px; }
.side a { padding: 6px 10px; }
.banner { background: var(--redact-bg); color: var(--redact-fg); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.banner a { color: inherit; font-weight: 600; }
.health { display: flex; flex-wrap: wrap; }
.health-item { flex: 1 1 200px; display: flex; flex-direction: column; gap: 2px; padding: 12px 18px; text-decoration: none; color: var(--ink); border-right: 1px solid var(--line); }
.health-item:last-child { border-right: 0; }
.health-item:hover { background: var(--surface-2); }
.health-item .tag { align-self: flex-start; }
.tile .sub { margin-top: 4px; font-size: 12px; }
.trend .col.none { background: var(--line); }
.tag.protected, .tag.auto_protected { background: var(--ok-bg); color: var(--ok-fg); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 46ch; font-size: 13px; color: var(--ink-2); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.checks-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; max-height: 220px; overflow-y: auto; padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.seatbar { height: 12px; background: var(--line); border-radius: 6px; overflow: hidden; margin-top: 6px; }
.seatbar .fill { height: 100%; background: var(--bar); }
.seatbar .fill.over { background: var(--block-fg); }
ul.ticks { margin: 0; padding-left: 18px; color: var(--ink-2); }
ul.ticks li { margin: 2px 0; }
.sso-block .or { text-align: center; color: var(--ink-3); font-size: 12px; }
.w-status { width: 90px; } .w-name { width: 240px; }
dialog { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog form { max-height: calc(100vh - 40px); overflow-y: auto; }
@media (max-width: 760px) { .nav-links { flex-direction: row; flex-wrap: wrap; } .nav-group { width: 100%; padding-top: 6px; } .checks-grid { grid-template-columns: minmax(0, 1fr); } }
.field label.check, .checks-grid label, .stack-sm label.check { font-weight: 400; font-size: 14px; }
.stack-sm label.check b, .field label.check b { font-weight: 600; }
td .sub { max-width: 40ch; }
