/* ============================================================================
   Architect's Ascent — admin console
   The game's palette and fonts, at admin density. Light and dark follow the
   system unless the admin picks one in the menu.
   No inline styles anywhere: anything dynamic is set through the CSSOM.
   ========================================================================= */

:root {
  --font-display: 'Bricolage Grotesque', 'Inter', sans-serif;
  --font-body: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-code: 'JetBrains Mono', ui-monospace, monospace;

  --bg: #F3EEE3;
  --side-bg: #FFFDF7;
  --topbar-bg: #F7F2E8;
  --card: #FFFDF7;
  --card-2: #FAF6EC;
  --raise: #FFFFFF;
  --ink: #2A2620;
  --ink-soft: #4E463C;
  --muted: #6E6557;
  --faint: #938872;
  --line: #E3DAC8;
  --line-soft: #EDE6D7;
  --line-strong: #CFC4AD;
  --accent: #D97757;
  --accent-deep: #A04A2C;
  --accent-ink: #8E3F23;
  --accent-soft: #F6E3DA;
  --gold: #C2912E;
  --gold-soft: #FAF0D8;
  --gold-ink: #7E5B12;
  --good: #3D7349;
  --good-soft: #E2EFE2;
  --good-ink: #2C5636;
  --bad: #A8392F;
  --bad-soft: #F7E1DD;
  --bad-ink: #8A2C24;
  --on-strong: #FFFFFF;
  --focus: #1F5FBF;
  --d1: #B4532F; --d2: #7461A8; --d3: #3C7268; --d4: #4A6C92; --d5: #9A4E7A;

  --chart-accent: #C2603A;
  --chart-blue: #4A6C92;
  --chart-teal: #3C7268;
  --chart-violet: #7461A8;
  --chart-gold: #C2912E;
  --chart-good: #3D7349;
  --chart-bad: #A8392F;
  --chart-pink: #9A4E7A;
  --chart-muted: #C3B7A1;
  --grid-line: #E8E0CF;

  --shadow-sm: 0 1px 2px rgba(74, 60, 40, .06);
  --shadow: 0 1px 2px rgba(74, 60, 40, .06), 0 8px 20px -14px rgba(74, 60, 40, .3);
  --shadow-pop: 0 2px 6px rgba(74, 60, 40, .1), 0 20px 48px -18px rgba(74, 60, 40, .36);
  --r-lg: 14px;
  --r: 10px;
  --r-sm: 7px;
  --side-w: 236px;
  --topbar-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #201D19;
    --side-bg: #1A1815;
    --topbar-bg: #23201B;
    --card: #2B2722;
    --card-2: #332E27;
    --raise: #332E27;
    --ink: #F0EADD;
    --ink-soft: #D9D0C0;
    --muted: #B5A994;
    --faint: #94886F;
    --line: #433D33;
    --line-soft: #352F28;
    --line-strong: #57503F;
    --accent: #E08963;
    --accent-deep: #F0A07A;
    --accent-ink: #F0A07A;
    --accent-soft: #46342B;
    --gold: #D9AC4B;
    --gold-soft: #3D331D;
    --gold-ink: #E8C370;
    --good: #7CB888;
    --good-soft: #27331F;
    --good-ink: #9BD0A4;
    --bad: #EB8B7C;
    --bad-soft: #45302C;
    --bad-ink: #F3A89B;
    --on-strong: #1F1A14;
    --focus: #8DB8FF;
    --d1: #E08963; --d2: #A895D6; --d3: #6FB0A3; --d4: #85A7CC; --d5: #D188B1;
    --chart-accent: #E08963;
    --chart-blue: #85A7CC;
    --chart-teal: #6FB0A3;
    --chart-violet: #A895D6;
    --chart-gold: #D9AC4B;
    --chart-good: #7CB888;
    --chart-bad: #EB8B7C;
    --chart-pink: #D188B1;
    --chart-muted: #6E6554;
    --grid-line: #3A342C;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px -14px rgba(0, 0, 0, .7);
    --shadow-pop: 0 2px 6px rgba(0, 0, 0, .4), 0 20px 48px -18px rgba(0, 0, 0, .8);
  }
}

:root[data-theme="dark"] {
  --bg: #201D19;
  --side-bg: #1A1815;
  --topbar-bg: #23201B;
  --card: #2B2722;
  --card-2: #332E27;
  --raise: #332E27;
  --ink: #F0EADD;
  --ink-soft: #D9D0C0;
  --muted: #B5A994;
  --faint: #94886F;
  --line: #433D33;
  --line-soft: #352F28;
  --line-strong: #57503F;
  --accent: #E08963;
  --accent-deep: #F0A07A;
  --accent-ink: #F0A07A;
  --accent-soft: #46342B;
  --gold: #D9AC4B;
  --gold-soft: #3D331D;
  --gold-ink: #E8C370;
  --good: #7CB888;
  --good-soft: #27331F;
  --good-ink: #9BD0A4;
  --bad: #EB8B7C;
  --bad-soft: #45302C;
  --bad-ink: #F3A89B;
  --on-strong: #1F1A14;
  --focus: #8DB8FF;
  --d1: #E08963; --d2: #A895D6; --d3: #6FB0A3; --d4: #85A7CC; --d5: #D188B1;
  --chart-accent: #E08963;
  --chart-blue: #85A7CC;
  --chart-teal: #6FB0A3;
  --chart-violet: #A895D6;
  --chart-gold: #D9AC4B;
  --chart-good: #7CB888;
  --chart-bad: #EB8B7C;
  --chart-pink: #D188B1;
  --chart-muted: #6E6554;
  --grid-line: #3A342C;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 20px -14px rgba(0, 0, 0, .7);
  --shadow-pop: 0 2px 6px rgba(0, 0, 0, .4), 0 20px 48px -18px rgba(0, 0, 0, .8);
}

/* --------------------------------------------------------------- baseline */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: .9375rem;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: none; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; }
ul, ol { list-style: none; }
svg { display: block; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 10px; top: -60px; z-index: 60;
  background: var(--card); color: var(--ink); border: 1px solid var(--line-strong);
  padding: 9px 14px; border-radius: var(--r); font-weight: 600; box-shadow: var(--shadow);
}
.skip-link:focus { top: 10px; text-decoration: none; }

.mono { font-family: var(--font-code); font-size: .8em; letter-spacing: -.01em; }
.mono.lc { overflow-wrap: anywhere; }
.nowrap { white-space: nowrap; }
.wrap-any { overflow-wrap: anywhere; }
.sep { color: var(--faint); margin: 0 .3em; }
.muted-cell { color: var(--faint); }
.num-good { color: var(--good-ink); font-weight: 600; }
.num-bad { color: var(--bad-ink); font-weight: 600; }
.num-plain { font-weight: 600; }

.booting { display: grid; place-items: center; min-height: 60vh; }
.boot-note { color: var(--muted); }

/* ------------------------------------------------------------ sign-in gate */

.gate { display: grid; place-items: center; min-height: 100vh; padding: 24px 16px; }
.gate-card {
  width: min(460px, 100%); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 28px; box-shadow: var(--shadow);
}
.gate-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.gate-name { font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem; }
.gate-kicker { color: var(--muted); font-size: .8125rem; }
.gate-title { font-family: var(--font-display); font-size: 1.375rem; font-weight: 700; margin-bottom: 10px; }
.gate-text { color: var(--ink-soft); margin-bottom: 18px; }
.gate-note, .gate-error {
  display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r);
  margin-bottom: 16px; font-size: .875rem;
}
.gate-note { background: var(--accent-soft); color: var(--accent-ink); }
.gate-error { background: var(--bad-soft); color: var(--bad-ink); }
.gate-note svg, .gate-error svg { flex: none; margin-top: 1px; }
.gate-actions { margin-bottom: 16px; }
.gate-actions .btn { width: 100%; }
.gate-fine {
  display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: .8125rem;
  border-top: 1px solid var(--line-soft); padding-top: 14px;
}
.gate-fine svg { flex: none; margin-top: 1px; }

/* ------------------------------------------------------------------ shell */

.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  background: var(--side-bg); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px; padding: 14px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 10px; }
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: .9375rem; letter-spacing: -.01em; }
.brand-kicker { font-size: .6875rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.side-head .side-close { display: none; }

.env {
  display: flex; align-items: center; gap: 7px; font-size: .75rem; font-weight: 600;
  padding: 6px 10px; border-radius: 999px; margin: 0 2px 10px; border: 1px solid transparent;
}
.env-dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; flex: none; }
.env-prod { background: var(--accent-soft); color: var(--accent-ink); border-color: var(--accent); }
.env-staging { background: color-mix(in srgb, var(--d4) 14%, transparent); color: var(--d4); border-color: color-mix(in srgb, var(--d4) 40%, transparent); }
.env-mock {
  margin-left: auto; font-size: .625rem; text-transform: uppercase; letter-spacing: .08em;
  background: var(--gold-soft); color: var(--gold-ink); padding: 1px 6px; border-radius: 999px;
}

.nav { flex: 1; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r);
  color: var(--ink-soft); font-weight: 500; font-size: .875rem;
}
.nav-link:hover { background: var(--card-2); color: var(--ink); text-decoration: none; }
.nav-link svg { flex: none; color: var(--faint); }
.nav-link.is-active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-link.is-active svg { color: var(--accent-ink); }

.side-foot { border-top: 1px solid var(--line-soft); padding-top: 10px; }
.side-link { display: flex; align-items: center; gap: 6px; font-size: .8125rem; color: var(--muted); padding: 6px 10px; }
.side-link:hover { color: var(--ink); text-decoration: none; }

.main-col { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  min-height: var(--topbar-h); padding: 8px 20px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--line);
}
.topbar-title { min-width: 0; flex: 1; }
.page-title { font-family: var(--font-display); font-size: 1.1875rem; font-weight: 700; letter-spacing: -.015em; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar .menu-btn { display: none; }

.fresh {
  display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; font-weight: 600;
  padding: 5px 9px; border-radius: 999px; white-space: nowrap;
}
.fresh.tone-good { background: var(--card-2); color: var(--muted); }
.fresh.tone-warn { background: var(--gold-soft); color: var(--gold-ink); }
.fresh.tone-bad { background: var(--bad-soft); color: var(--bad-ink); }
.fresh svg { flex: none; }
.fresh-sub { font-weight: 400; opacity: .8; }

.main { padding: 20px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.side-backdrop { display: none; }

/* -------------------------------------------------------------- who menu */

.who { position: relative; }
.who-btn {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px 5px 5px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card);
}
.who-btn:hover { border-color: var(--line-strong); }
.avatar {
  width: 26px; height: 26px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent-deep); color: #fff; font-weight: 700; font-size: .75rem; flex: none;
}
.who-text { display: flex; flex-direction: column; line-height: 1.15; max-width: 160px; }
.who-email { font-size: .75rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: .6875rem; color: var(--muted); }
.who-btn svg { color: var(--faint); flex: none; }

.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: 262px;
  background: var(--raise); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); padding: 12px;
}
.menu-who { padding: 2px 2px 8px; }
.menu-email { font-size: .8125rem; font-weight: 600; overflow-wrap: anywhere; }
.menu-role { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.menu-env { font-size: .6875rem; color: var(--muted); }
.menu-sep { height: 1px; background: var(--line-soft); margin: 8px -12px; }
.menu-row { display: flex; flex-direction: column; gap: 7px; padding: 4px 2px; }
.menu-label { font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; margin: 0 -2px;
  border-radius: var(--r); font-size: .875rem; font-weight: 500; text-align: left;
}
.menu-item:hover { background: var(--card-2); }
.menu-item svg { color: var(--faint); }

/* -------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-weight: 600; font-size: .875rem; padding: 8px 14px; border-radius: var(--r);
  border: 1px solid transparent; white-space: nowrap;
}
.btn-sm { padding: 6px 11px; font-size: .8125rem; }
.btn-ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--card-2); }
.btn-primary { background: var(--accent-deep); color: #fff; }
.btn-primary:hover { filter: brightness(1.07); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn svg { flex: none; }
[data-theme="dark"] .btn-primary, [data-theme="dark"] .btn-danger { color: #241a14; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .btn-danger { color: #241a14; }
}

.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-sm);
  color: var(--muted); border: 1px solid transparent;
}
.icon-btn:hover { background: var(--card-2); color: var(--ink); }
.icon-btn.tiny { width: 22px; height: 22px; }
.icon-btn:disabled { opacity: .45; cursor: not-allowed; }

.segmented { display: inline-flex; background: var(--card-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.seg {
  padding: 5px 11px; border-radius: 999px; font-size: .8125rem; font-weight: 600; color: var(--muted);
  white-space: nowrap;
}
.seg:hover { color: var(--ink); }
.seg.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

.input {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 8px 11px; font-size: .875rem; color: var(--ink);
}
.input:hover { border-color: var(--line-strong); }
.input::placeholder { color: var(--faint); }
textarea.input { resize: vertical; min-height: 72px; line-height: 1.5; }
select.input { padding-right: 28px; }
.input.narrow { max-width: 120px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label, .field > .field-label { font-size: .8125rem; font-weight: 600; display: flex; gap: 7px; align-items: baseline; }
.req { font-size: .6875rem; font-weight: 500; color: var(--accent-ink); text-transform: uppercase; letter-spacing: .06em; }
.field-hint { font-size: .75rem; color: var(--muted); }
.field-error { font-size: .75rem; color: var(--bad-ink); font-weight: 600; }
.field-counter { text-align: right; }
.counter { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > * { flex: 1 1 200px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 4px; }

.switch { display: block; }
.switch-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-label { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .875rem; font-weight: 500; }
.switch-track {
  width: 40px; height: 23px; border-radius: 999px; background: var(--line-strong);
  padding: 2px; display: block; flex: none;
}
.switch-knob { width: 19px; height: 19px; border-radius: 999px; background: #fff; display: block; box-shadow: var(--shadow-sm); }
.switch-input:checked + .switch-label .switch-track { background: var(--good); }
.switch-input:checked + .switch-label .switch-knob { transform: translateX(17px); }
.switch-input:focus-visible + .switch-label .switch-track { outline: 3px solid var(--focus); outline-offset: 2px; }
.switch-input:disabled + .switch-label { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------------------------ cards */

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px; min-width: 0; box-shadow: var(--shadow-sm);
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head-text { min-width: 0; }
.card-title { font-size: .9375rem; font-weight: 600; letter-spacing: -.005em; }
.card-sub { font-size: .8125rem; color: var(--muted); margin-top: 2px; }
.card-actions { display: flex; gap: 8px; align-items: center; flex: none; flex-wrap: wrap; }
.card-note { font-size: .8125rem; color: var(--muted); margin-bottom: 10px; }

.grid { display: grid; gap: 14px; min-width: 0; }
.grid > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); }
.grid.tight { gap: 12px; }
.grid.kpis { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; }

.page-lede { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lede-text { color: var(--muted); font-size: .875rem; }
.foot-note { font-size: .75rem; color: var(--muted); margin-top: 10px; }

/* -------------------------------------------------------------------- KPI */

.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 13px; display: flex; flex-direction: column; gap: 4px; min-width: 0; overflow: hidden;
}
.kpi-label { font-size: .75rem; color: var(--muted); font-weight: 600; line-height: 1.3; }
.kpi-value {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.kpi-note { font-size: .6875rem; color: var(--faint); line-height: 1.35; }
.kpi-foot { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; margin-top: auto; min-height: 22px; }
.kpi-missing { font-size: .8125rem; color: var(--faint); font-style: italic; margin-top: 6px; }
.kpi-void { border-style: dashed; }
.kpi-flat { font-size: .6875rem; color: var(--faint); }

.delta {
  display: inline-flex; align-items: center; gap: 3px; font-size: .75rem; font-weight: 700;
  padding: 2px 6px; border-radius: 999px; font-variant-numeric: tabular-nums;
  white-space: nowrap; flex: none;
}
.kpi-foot > .spark, .kpi-foot > .spark-empty { flex: 0 1 auto; min-width: 0; max-width: 100%; height: auto; }
.delta.tone-good { background: var(--good-soft); color: var(--good-ink); }
.delta.tone-bad { background: var(--bad-soft); color: var(--bad-ink); }
.delta.tone-flat { background: var(--card-2); color: var(--muted); font-weight: 600; }
.delta svg { flex: none; }

/* ------------------------------------------------------- badges and pills */

.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--ink-soft);
  border: 1px solid var(--line); white-space: nowrap;
}
.badge svg { flex: none; }
.badge.tone-good { background: var(--good-soft); color: var(--good-ink); border-color: transparent; }
.badge.tone-bad { background: var(--bad-soft); color: var(--bad-ink); border-color: transparent; }
.badge.tone-warn { background: var(--gold-soft); color: var(--gold-ink); border-color: transparent; }
.badge.tone-role { background: var(--card-2); color: var(--ink-soft); }
.badge.tone-role-super { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; font-size: .75rem; font-weight: 600;
  padding: 2px 8px; border-radius: 999px; white-space: nowrap;
}
.pill-mark { font-size: .625rem; line-height: 1; }
.pill.tone-good { background: var(--good-soft); color: var(--good-ink); }
.pill.tone-warn { background: var(--gold-soft); color: var(--gold-ink); }
.pill.tone-bad { background: var(--bad-soft); color: var(--bad-ink); }
.pill.tone-neutral { background: var(--card-2); color: var(--muted); }

/* ----------------------------------------------------------------- tables */

.table-wrap { min-width: 0; }
.scroll { overflow-x: auto; max-width: 100%; border-radius: var(--r-sm); }
.scroll:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.table { width: 100%; font-size: .8125rem; }
.table.wide { min-width: 740px; }
.table caption.cap { text-align: left; font-size: .8125rem; color: var(--muted); padding-bottom: 8px; }
.table th, .table td { text-align: left; padding: 8px 10px; vertical-align: top; }
.table thead th {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; border-bottom: 1px solid var(--line); white-space: nowrap; padding-bottom: 7px;
}
.table tbody tr { border-bottom: 1px solid var(--line-soft); }
.table tbody tr:last-child { border-bottom: none; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--card-2); }
.table tbody tr.selected { background: var(--accent-soft); }
.table td, .table tbody th { font-variant-numeric: tabular-nums; }
.table .align-right { text-align: right; }
.table .align-center { text-align: center; }
.table .empty-cell { color: var(--muted); padding: 22px 10px; text-align: center; }
.mono-cell { font-family: var(--font-code); font-size: .75rem; }
.col-player { min-width: 190px; }
.col-question { min-width: 300px; max-width: 460px; }
.col-ts { min-width: 170px; }
.col-reason { min-width: 180px; max-width: 280px; }
.col-id, .col-req { white-space: nowrap; }

.row-open { display: flex; flex-direction: column; gap: 1px; text-align: left; border-radius: var(--r-sm); padding: 1px 2px; }
.row-name { font-weight: 600; font-size: .8125rem; }
.row-email { font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.row-open:hover .row-name { color: var(--accent-ink); }

.pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding-top: 12px; }
.pager-text { font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- states */

.state {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 30px 18px; border-radius: var(--r); background: var(--card-2); border: 1px dashed var(--line-strong);
}
.state.inline { padding: 20px 16px; }
.state-mark { color: var(--faint); }
.state-mark.bad { color: var(--bad); }
.state-title { font-weight: 600; font-size: .9375rem; }
.state-detail { font-size: .8125rem; color: var(--muted); max-width: 52ch; }
.state-actions { margin-top: 6px; }
.state.failed { background: var(--bad-soft); border-color: transparent; }
.state.failed .state-detail { color: var(--bad-ink); }
.state.unavailable { background: var(--card-2); }

.reqid { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: .6875rem; color: var(--muted); }
.reqid-label { text-transform: uppercase; letter-spacing: .07em; font-weight: 700; }

.skel-wrap { display: flex; flex-direction: column; gap: 10px; }
.skel { background: var(--card-2); border-radius: var(--r-sm); border: 1px solid var(--line-soft); }
.skel-card { height: 96px; }
.skel-chart { height: 230px; }
.skel-block { height: 150px; }
.skel-row { height: 38px; }
.skel-line { height: 13px; border: none; }
.skel-line.short { width: 42%; }
.skel-line.big { height: 26px; width: 62%; }
.skel-kpi { gap: 8px; }
@media (prefers-reduced-motion: no-preference) {
  .skel { animation: pulse 1.5s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
}

.notice {
  display: flex; gap: 11px; align-items: flex-start; padding: 13px 15px; border-radius: var(--r);
  background: var(--card-2); border: 1px solid var(--line);
}
.notice > svg { flex: none; color: var(--faint); margin-top: 1px; }
.notice.tone-warn { background: var(--gold-soft); border-color: transparent; }
.notice.tone-warn > svg { color: var(--gold-ink); }
.notice-title { font-weight: 600; font-size: .875rem; }
.notice-text { font-size: .8125rem; color: var(--ink-soft); margin-top: 3px; max-width: 86ch; }
.notice-fine { font-size: .75rem; color: var(--muted); margin-top: 5px; }

/* ----------------------------------------------------------------- charts */

.chart-box { position: relative; width: 100%; min-width: 0; }
.chart { width: 100%; }
.chart-nodata { font-size: .8125rem; color: var(--muted); padding: 18px 0; text-align: center; }

.gridline { stroke: var(--grid-line); stroke-width: 1; }
.axis-line { stroke: var(--line-strong); stroke-width: 1; }
.axis-text { font-family: var(--font-body); font-size: 10.5px; fill: var(--muted); }
.axis-text.strong { font-weight: 600; fill: var(--ink-soft); font-size: 11.5px; }
.axis-text.faint { fill: var(--faint); font-size: 10px; }
.axis-alt { fill: var(--faint); }
.target-line { stroke: var(--ink-soft); stroke-width: 1.3; stroke-dasharray: 3 3; opacity: .7; }
.target-text { fill: var(--ink-soft); font-weight: 600; font-size: 10px; }
.track { fill: var(--card-2); stroke: var(--line-soft); }
.band-text { font-family: var(--font-body); font-size: 11px; font-weight: 700; fill: #fff; }
[data-theme="dark"] .band-text { fill: #1F1A14; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .band-text { fill: #1F1A14; } }

.hm { fill: var(--line-soft); stroke: var(--line); stroke-width: .5; }
.hm-0 { fill: var(--line-soft); }
.hm-1 { fill: color-mix(in srgb, var(--chart-accent) 28%, var(--card)); }
.hm-2 { fill: color-mix(in srgb, var(--chart-accent) 52%, var(--card)); }
.hm-3 { fill: color-mix(in srgb, var(--chart-accent) 76%, var(--card)); }
.hm-4 { fill: var(--chart-accent); }
.hm-future { fill: none; stroke: var(--line-soft); stroke-width: .5; stroke-dasharray: 2 2; }

.chart-tip {
  position: absolute; z-index: 10; pointer-events: none;
  background: var(--raise); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  box-shadow: var(--shadow-pop); padding: 7px 10px; font-size: .75rem; max-width: 230px;
}
.tip-head { font-weight: 700; margin-bottom: 2px; }
.tip-row { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; color: var(--ink-soft); }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-swatch.shape-line { height: 3px; border-radius: 2px; width: 14px; }
.legend-value { font-weight: 700; font-variant-numeric: tabular-nums; }

.spark { opacity: .95; }
.spark-empty { display: block; width: 96px; height: 30px; }

.data-details { margin-top: 12px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.data-details > summary {
  display: flex; align-items: center; gap: 5px; cursor: pointer; font-size: .75rem;
  color: var(--muted); font-weight: 600; width: fit-content; padding: 3px 4px; border-radius: var(--r-sm);
  list-style: none;
}
.data-details > summary::-webkit-details-marker { display: none; }
.data-details > summary:hover { color: var(--ink); }
.data-details[open] > summary svg { transform: rotate(90deg); }
.data-details .table { font-size: .75rem; }

/* --------------------------------------------------------------- health */

.health-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.health-item { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--card-2); }
.health-item.is-warn { border-color: var(--gold); }
.health-item.is-down { border-color: var(--bad); }
.health-label { font-weight: 600; font-size: .875rem; margin-top: 7px; }
.health-detail { font-size: .75rem; color: var(--muted); margin-top: 2px; }

.health-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.health-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; background: var(--card-2); }
.health-card.is-warn { border-color: var(--gold); }
.health-card.is-down { border-color: var(--bad); }
.health-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.health-card-name { font-weight: 600; font-size: .875rem; }
.health-card-detail { font-size: .75rem; color: var(--muted); margin-top: 6px; }

/* ------------------------------------------------------------- breakdown */

.breakdown { display: flex; flex-direction: column; gap: 2px; }
.breakdown-row {
  display: grid; grid-template-columns: minmax(80px, 1.3fr) minmax(50px, 2fr) auto 52px;
  gap: 10px; align-items: center; padding: 6px 2px; border-bottom: 1px solid var(--line-soft);
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label { font-size: .8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.breakdown-n { font-size: .8125rem; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.breakdown-pct { font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.mini-bar { display: block; height: 8px; border-radius: 999px; background: var(--card-2); overflow: hidden; }
.mini-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--chart-accent); }
.mini-bar-fill.tone-good { background: var(--chart-good); }
.mini-bar-fill.tone-bad { background: var(--chart-bad); }

/* ---------------------------------------------------------------- toasts */

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 13px;
  background: var(--raise); border: 1px solid var(--line-strong); border-left: 3px solid var(--muted);
  border-radius: var(--r); box-shadow: var(--shadow-pop);
}
.toast.tone-good { border-left-color: var(--good); }
.toast.tone-bad { border-left-color: var(--bad); }
.toast.tone-warn { border-left-color: var(--gold); }
.toast-mark { flex: none; color: var(--muted); margin-top: 1px; }
.toast.tone-good .toast-mark { color: var(--good-ink); }
.toast.tone-bad .toast-mark { color: var(--bad-ink); }
.toast.tone-warn .toast-mark { color: var(--gold-ink); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: .8125rem; }
.toast-text { font-size: .8125rem; color: var(--ink-soft); overflow-wrap: anywhere; }
.toast .icon-btn { flex: none; }

/* -------------------------------------------------------- dialog / drawer */

dialog { border: none; padding: 0; color: var(--ink); background: var(--card); max-width: none; max-height: none; }
dialog::backdrop { background: rgba(32, 26, 18, .45); }
[data-theme="dark"] dialog::backdrop { background: rgba(0, 0, 0, .6); }

.modal {
  width: min(520px, calc(100vw - 28px)); border-radius: var(--r-lg); border: 1px solid var(--line);
  box-shadow: var(--shadow-pop); margin: auto; max-height: calc(100vh - 40px); display: flex; flex-direction: column;
}
.modal.wide { width: min(760px, calc(100vw - 28px)); }
.modal.danger { border-top: 3px solid var(--bad); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 0; }
.modal-title { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 700; }
.modal-desc { padding: 8px 16px 0; font-size: .875rem; color: var(--ink-soft); }
.modal-body { padding: 14px 16px; overflow-y: auto; }
.modal-body:empty { padding: 0; }
.modal-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 16px; border-top: 1px solid var(--line-soft); background: var(--card-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg); flex-wrap: wrap;
}
.modal-foot-right { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.dialog-form { display: flex; flex-direction: column; gap: 12px; }
.dialog-target { display: flex; flex-direction: column; gap: 5px; background: var(--card-2); border-radius: var(--r); padding: 10px 12px; }
.dialog-target > div { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.dialog-target dt { font-size: .75rem; color: var(--muted); font-weight: 600; }
.dialog-target dd { font-size: .8125rem; overflow-wrap: anywhere; text-align: right; }
.dialog-hint { display: flex; gap: 7px; align-items: center; font-size: .8125rem; color: var(--gold-ink); }
.dialog-hint svg { flex: none; }
.dialog-error {
  display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap;
  background: var(--bad-soft); color: var(--bad-ink); border-radius: var(--r); padding: 10px 12px; font-size: .8125rem;
}
.dialog-error > svg { flex: none; margin-top: 1px; }

.drawer {
  margin: 0 0 0 auto; width: min(620px, 100vw); height: 100vh; max-height: 100vh;
  border-left: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: var(--shadow-pop);
}
.drawer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line); position: sticky; top: 0;
  background: var(--card); z-index: 2;
}
.drawer-head-text { min-width: 0; }
.drawer-title { font-family: var(--font-display); font-size: 1.125rem; font-weight: 700; overflow-wrap: anywhere; }
.drawer-sub { font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.drawer-body { padding: 14px 18px 28px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.drawer-chips { display: flex; gap: 7px; flex-wrap: wrap; }
.drawer-card { background: var(--card-2); }
.drawer-card .card-title { font-size: .875rem; }

/* ---------------------------------------------------------- facts / stats */

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 18px; }
.fact { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fact dt { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.fact dd { font-size: .8125rem; overflow-wrap: anywhere; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(118px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 10px; min-width: 0; }
.stat-label { font-size: .6875rem; color: var(--muted); font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-note { font-size: .625rem; color: var(--faint); line-height: 1.3; }
.sub-head { font-size: .8125rem; font-weight: 600; margin: 16px 0 6px; }

.score-cell { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.score-value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- actions */

.action-grid { display: flex; flex-direction: column; gap: 8px; }
.action-row {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r); background: var(--card);
}
.action-row.is-danger { border-color: var(--bad); background: var(--bad-soft); }
.action-text { min-width: 0; }
.action-name { font-weight: 600; font-size: .8125rem; }
.action-what { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.action-row.is-danger .action-what { color: var(--bad-ink); }
.action-row .btn { flex: none; }

/* -------------------------------------------------------------- timeline */

.timeline { display: flex; flex-direction: column; gap: 2px; }
.timeline-item { display: flex; gap: 11px; padding: 2px 0 10px; position: relative; }
.timeline-item:not(:last-child)::before {
  content: ''; position: absolute; left: 4px; top: 16px; bottom: 0; width: 1px; background: var(--line);
}
.timeline-dot { width: 9px; height: 9px; border-radius: 999px; margin-top: 5px; flex: none; background: var(--muted); }
.timeline-dot.is-ok { background: var(--good); }
.timeline-dot.is-bad { background: var(--bad); }
.timeline-body { min-width: 0; }
.timeline-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timeline-action { font-weight: 600; font-size: .8125rem; }
.timeline-meta { font-size: .75rem; color: var(--muted); }
.timeline-reason { font-size: .8125rem; color: var(--ink-soft); margin-top: 3px; overflow-wrap: anywhere; }

/* ------------------------------------------------------------ users page */

.list-head { display: flex; flex-direction: column; gap: 10px; }
.search-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1 1 260px; min-width: 0; }
.search-wrap .input { padding-left: 32px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }

/* --------------------------------------------------------- learning page */

.filter-bar { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.filter-bar .field { flex: 0 1 auto; }
.filter-seg { display: flex; flex-direction: column; gap: 5px; }
.month-pick { display: flex; gap: 6px; align-items: flex-end; }
.month-pick .btn { padding: 8px 9px; }
.month-pick .btn:first-child svg { transform: rotate(90deg); }
.month-pick .btn:last-child svg { transform: rotate(-90deg); }

.dom-chip {
  display: inline-block; font-size: .6875rem; font-weight: 700; padding: 2px 7px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
}
.dom-chip[data-d="D1"] { color: var(--d1); border-color: var(--d1); }
.dom-chip[data-d="D2"] { color: var(--d2); border-color: var(--d2); }
.dom-chip[data-d="D3"] { color: var(--d3); border-color: var(--d3); }
.dom-chip[data-d="D4"] { color: var(--d4); border-color: var(--d4); }
.dom-chip[data-d="D5"] { color: var(--d5); border-color: var(--d5); }

.ts-cell { display: flex; flex-direction: column; gap: 1px; }
.ts-id { font-family: var(--font-code); font-size: .6875rem; color: var(--muted); }
.ts-name { font-size: .75rem; }

.q-open { display: flex; gap: 7px; align-items: flex-start; text-align: left; line-height: 1.45; padding: 1px 2px; border-radius: var(--r-sm); }
.q-caret { flex: none; margin-top: 3px; color: var(--faint); }
.q-open[aria-expanded="true"] .q-caret { transform: rotate(90deg); }
.q-open:hover { color: var(--accent-ink); }
tr.is-open { background: var(--card-2); }
.detail-row > td { background: var(--card-2); padding: 0 10px 14px; }
.q-detail { display: flex; flex-direction: column; gap: 10px; max-width: 80ch; }
.q-full { font-size: .8125rem; line-height: 1.6; }
.q-options { display: flex; flex-direction: column; gap: 5px; }
.q-option {
  display: flex; gap: 7px; align-items: flex-start; font-size: .8125rem; padding: 6px 9px;
  border-radius: var(--r-sm); background: var(--card); border: 1px solid var(--line);
}
.q-option svg { flex: none; margin-top: 2px; color: var(--good-ink); }
.q-option.is-correct { background: var(--good-soft); border-color: var(--good); font-weight: 500; }
.q-bullet { width: 14px; height: 14px; border-radius: 999px; border: 1px solid var(--line-strong); flex: none; margin-top: 2px; }
.q-explain { background: var(--card); border-left: 3px solid var(--accent); border-radius: var(--r-sm); padding: 9px 12px; font-size: .8125rem; line-height: 1.6; }
.q-explain-head { font-size: .6875rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
.q-meta { font-size: .75rem; color: var(--muted); display: flex; gap: 2px; flex-wrap: wrap; align-items: baseline; }
.q-task-name { display: block; width: 100%; margin-top: 2px; font-style: italic; }

.band-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 12px; }
.band-item { min-width: 0; }
.band-head { display: flex; align-items: center; gap: 7px; }
.band-name { font-size: .8125rem; font-weight: 600; }
.band-count { font-size: .8125rem; font-weight: 700; margin-left: auto; font-variant-numeric: tabular-nums; }
.band-what { font-size: .75rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }

/* ------------------------------------------------------- operations page */

.mini-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.mini-metric { border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; background: var(--card-2); min-width: 0; }
.mini-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.mini-name { font-size: .8125rem; font-weight: 600; }
.mini-now { text-align: right; }
.mini-value { font-family: var(--font-display); font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; display: block; }
.mini-label { font-size: .625rem; color: var(--faint); }
.mini-foot { font-size: .6875rem; color: var(--muted); font-variant-numeric: tabular-nums; }

.meter-block { display: flex; flex-direction: column; gap: 8px; }
.meter-top { display: flex; align-items: baseline; gap: 8px; }
.meter-value { font-family: var(--font-display); font-size: 1.375rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.meter-label { font-size: .8125rem; color: var(--muted); }
.meter { display: block; height: 10px; border-radius: 999px; background: var(--card-2); border: 1px solid var(--line); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--good); }
.meter-fill.tone-warn { background: var(--gold); }
.meter-fill.tone-bad { background: var(--bad); }
.meter-note { font-size: .75rem; color: var(--muted); }
.meter-warn { display: flex; gap: 6px; align-items: center; font-size: .8125rem; color: var(--gold-ink); font-weight: 600; }

.error-list { display: flex; flex-direction: column; gap: 2px; }
.error-row { display: flex; gap: 11px; align-items: center; padding: 9px 2px; border-bottom: 1px solid var(--line-soft); }
.error-row:last-child { border-bottom: none; }
.error-mark { color: var(--gold-ink); flex: none; }
.error-body { flex: 1; min-width: 0; }
.error-cat { font-size: .8125rem; font-weight: 500; }
.error-meta { font-size: .75rem; color: var(--muted); }

/* ----------------------------------------------------------- banner page */

.banner-form { display: flex; flex-direction: column; gap: 14px; }
.preview-frame { background: var(--card-2); border: 1px dashed var(--line-strong); border-radius: var(--r); padding: 14px; }
.preview-label { font-size: .6875rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 10px; }
.preview-empty { font-size: .8125rem; color: var(--muted); font-style: italic; }
.game-banner {
  display: flex; gap: 10px; align-items: center; padding: 11px 15px; border-radius: var(--r);
  background: var(--accent-soft); color: var(--accent-ink); border: 1px solid var(--accent); flex-wrap: wrap;
}
.game-banner > svg { flex: none; }
.game-banner.tone-success { background: var(--good-soft); color: var(--good-ink); border-color: var(--good); }
.game-banner.tone-warning { background: var(--gold-soft); color: var(--gold-ink); border-color: var(--gold); }
.game-banner-text { font-size: .875rem; font-weight: 500; flex: 1; min-width: 180px; }
.game-banner-link { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; font-size: .8125rem; text-decoration: underline; }

/* ------------------------------------------------------------ audit page */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); }
.tab {
  padding: 8px 14px; font-size: .875rem; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); text-decoration: none; }
.tab.is-active { color: var(--accent-ink); border-bottom-color: var(--accent); }

.when-cell { display: flex; flex-direction: column; gap: 0; }
.when-day { font-size: .8125rem; white-space: nowrap; }
.when-time { font-size: .6875rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.actor-cell { display: flex; flex-direction: column; gap: 0; }
.actor-email { font-size: .8125rem; overflow-wrap: anywhere; }
.actor-role { font-size: .6875rem; color: var(--muted); }
.target-cell { display: flex; flex-direction: column; gap: 1px; }
.target-sub { font-family: var(--font-code); font-size: .625rem; color: var(--faint); }
.reqid-cell { display: inline-flex; align-items: center; gap: 4px; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .grid.two { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 272px; height: 100%; z-index: 60;
    transform: translateX(-100%); box-shadow: var(--shadow-pop);
  }
  .menu-open .sidebar { transform: translateX(0); }
  .side-head .side-close { display: inline-grid; }
  .topbar .menu-btn { display: inline-grid; }
  .side-backdrop {
    display: block; position: fixed; inset: 0; z-index: 50; background: rgba(32, 26, 18, .4);
    opacity: 0; pointer-events: none; border: none; border-radius: 0;
  }
  .menu-open .side-backdrop { opacity: 1; pointer-events: auto; }
  @media (prefers-reduced-motion: no-preference) {
    .sidebar { transition: transform .22s ease; }
    .side-backdrop { transition: opacity .22s ease; }
  }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 8px 14px; }
  .topbar-title { flex: 1 1 auto; order: 1; }
  .menu-btn { order: 0; }
  .who { order: 2; margin-left: auto; }
  .topbar-right { order: 3; flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; }
  .who { position: static; }
  .menu-panel { right: 14px; top: calc(var(--topbar-h) - 4px); }
  .main { padding: 14px; }
  .who-text { display: none; }
  .who-btn { padding: 4px; }
  .drawer { width: 100vw; border-left: none; }
  .modal-foot-right { width: 100%; }
  .modal-foot-right .btn { flex: 1; }
}

@media (max-width: 640px) {
  body { font-size: 1rem; }
  .page-title { font-size: 1.0625rem; }
  .grid.kpis { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .kpi-value { font-size: 1.3125rem; }
  .card { padding: 13px; border-radius: var(--r); }
  .stack { gap: 13px; }
  .segmented { font-size: .75rem; }
  .seg { padding: 5px 9px; }
  .breakdown-row { grid-template-columns: minmax(70px, 1.1fr) minmax(40px, 1.4fr) auto 46px; gap: 7px; }
  .drawer-body { padding: 12px 14px 24px; }
  .drawer-head { padding: 13px 14px 10px; }
  .facts { grid-template-columns: 1fr 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; }
  .action-row { flex-direction: column; align-items: stretch; }
  .action-row .btn { width: 100%; }
  .toasts { right: 10px; left: 10px; bottom: 10px; width: auto; }
  .health-strip, .health-grid { grid-template-columns: 1fr; }
  .mini-grid { grid-template-columns: 1fr; }
  .filter-bar { gap: 10px; }
  .filter-bar .field, .filter-seg { flex: 1 1 100%; }
  .month-pick { flex: 1 1 100%; }
  .q-detail { max-width: none; }
}

@media (prefers-reduced-motion: no-preference) {
  .nav-link, .btn, .icon-btn, .seg, .switch-knob, .switch-track, .q-caret, .data-details summary svg {
    transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .15s ease, opacity .15s ease;
  }
  .btn-ghost:hover, .btn-primary:hover, .btn-danger:hover { transform: translateY(-1px); }
  .is-spinning svg { animation: spin .9s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
}

@media print {
  .sidebar, .topbar, .toasts { display: none; }
}
