:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-soft: rgba(42, 120, 214, 0.10);
  --accent-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --warning-text: #8a5d00;
  --serious: #ec835a;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05);
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-soft: rgba(57, 135, 229, 0.16);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
    --series-6: #0ca30c;
    --series-7: #9085e9;
    --series-8: #e66767;
    --good-text: #0ca30c;
    --warning-text: #fab219;
    --shadow: none;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #242422;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-soft: rgba(57, 135, 229, 0.16);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #0ca30c;
  --series-7: #9085e9;
  --series-8: #e66767;
  --good-text: #0ca30c;
  --warning-text: #fab219;
  --shadow: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1 { font-size: 17px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.error-text { color: var(--critical); }

button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: 0.5; cursor: default; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.ghost { background: transparent; border-color: transparent; }
button.danger { color: var(--critical); }
.small-btn { padding: 4px 10px; font-size: 12px; white-space: nowrap; }
.icon-btn { padding: 4px 9px; font-size: 15px; line-height: 1.2; background: transparent; }
.icon-btn.spinning { animation: spin 0.8s linear infinite; }
.link-btn { border: none; background: none; padding: 0; color: var(--accent); font-size: 13px; }
.link-btn:hover:not(:disabled) { background: none; text-decoration: underline; }

input[type="text"], input[type="password"], select {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 0;
}

.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: 11px; text-align: center; font-weight: 600; }

/* ---------- header ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; padding: 10px 24px 6px; flex-wrap: wrap; }
.brand, .controls { display: flex; gap: 8px; align-items: center; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; border-radius: 999px; padding: 2px 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.badge.demo { background: var(--warning); color: #0b0b0b; border-color: transparent; }
.badge.live { background: var(--good); color: #fff; border-color: transparent; }

.status-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; border-radius: 999px; padding: 3px 10px; background: transparent; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.st-fresh .dot, .st-new .dot { background: var(--good); }
.st-stale .dot { background: var(--warning); }

.tabs { display: flex; gap: 2px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs [role=tab] {
  border: none; background: none; border-radius: 0; padding: 8px 12px 10px; color: var(--ink-2); white-space: nowrap;
  border-bottom: 2px solid transparent; font-weight: 500;
}
.tabs [role=tab]:hover { background: none; color: var(--ink); }
.tabs [role=tab][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { background: var(--accent); color: var(--accent-ink); margin-left: 2px; }

.data-notes { background: var(--surface); border-bottom: 1px solid var(--border); }
.data-notes-inner { max-width: 1180px; margin: 0 auto; padding: 10px 24px; font-size: 13px; }
.data-notes ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-2); }
#error-banner { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.banner { margin-top: 12px; border: 1px solid var(--border); border-left: 4px solid var(--critical); background: var(--surface); border-radius: 8px; padding: 10px 14px; }

/* ---------- layout ---------- */
main { max-width: 1180px; margin: 0 auto; padding: 20px 24px 96px; }
.tab-panel { display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); margin: 0; min-width: 0; }
.card > h2, .card-head { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card > p.muted { margin: -6px 0 12px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.toolbar-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.list-title { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin: 14px 0 6px; font-weight: 600; }

/* ---------- brief ---------- */
.brief { padding: 18px 20px; border-left: 4px solid var(--accent); }
.brief-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.brief-label { font-size: 12px; font-weight: 600; color: var(--accent); letter-spacing: 0.02em; }
.brief-status { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.brief-status .link-btn { font-size: 12px; }
.brief-reason { margin-top: 6px; }
.brief-headline { font-size: 20px; line-height: 1.3; margin: 8px 0 6px; letter-spacing: -0.01em; }
.brief-summary { color: var(--ink-2); max-width: 78ch; }
.brief-summary.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.brief-recs { display: flex; flex-direction: column; gap: 6px; }
#all-recs { margin-top: 8px; }
.analyze-box { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--grid); }
.analyze-box details.focus summary { font-size: 12px; color: var(--ink-2); cursor: pointer; }
.analyze-row { display: flex; gap: 8px; margin-top: 6px; }
.analyze-row input { flex: 1; min-width: 200px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--ink-2); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 600; margin: 2px 0; letter-spacing: -0.01em; }
.kpi .delta { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.delta.better, .trend.better { color: var(--good-text); }
.delta.worse, .trend.worse { color: var(--critical); }
@media (max-width: 980px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi .value { font-size: 20px; } }

/* ---------- chart ---------- */
.chart-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }
.chart-card { padding: 14px 16px 8px; }
.chart-box { position: relative; height: 280px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface-2); }
.segmented button { border: none; background: transparent; padding: 4px 12px; font-size: 13px; border-radius: 6px; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 500; }

/* ---------- Claude insight bars ---------- */
.insight:empty { display: none; }
.insight { border: 1px solid var(--border); border-left: 4px solid var(--accent); background: var(--surface); border-radius: var(--radius); }
.insight.tone-good { border-left-color: var(--good); }
.insight.tone-attention { border-left-color: var(--serious); }
.insight.stale { opacity: 0.8; }
.insight-head { display: flex; width: 100%; gap: 10px; align-items: flex-start; text-align: left; border: none; background: none; padding: 12px 16px; border-radius: var(--radius); }
.insight-head:hover:not(:disabled) { background: var(--surface-2); }
.insight-icon { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; background: var(--accent-soft); color: var(--accent); margin-top: 1px; }
.tone-good .insight-icon { background: rgba(12, 163, 12, 0.12); color: var(--good-text); }
.tone-attention .insight-icon { background: rgba(236, 131, 90, 0.16); color: var(--critical); }
.insight-text { flex: 1; min-width: 0; }
.insight-tag { display: block; font-size: 11px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.insight-summary { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink); }
.insight.open .insight-summary { -webkit-line-clamp: unset; display: block; }
.insight-more { flex: none; font-size: 12px; color: var(--accent); white-space: nowrap; margin-top: 2px; }
.chev { display: inline-block; margin-left: 4px; transition: transform 0.15s; }
.insight.open .chev { transform: rotate(180deg); }
.insight-body { padding: 0 16px 14px 48px; }
.insight-body .list-title:first-child { margin-top: 0; }
.insight-list { display: flex; flex-direction: column; gap: 6px; }
.insight-item { display: grid; grid-template-columns: 116px 1fr; gap: 10px; align-items: baseline; color: var(--ink-2); font-size: 13px; }
.insight-item strong { color: var(--ink); font-weight: 600; }
.kind, .verb { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--border); white-space: nowrap; justify-self: start; }
.kind-top_performer, .kind-rising, .kind-quality { border-color: var(--good); color: var(--good-text); }
.kind-fatigue, .kind-underperformer, .kind-risk { border-color: var(--critical); color: var(--critical); }
.kind-budget_limited, .kind-opportunity { border-color: var(--accent); color: var(--accent); }
.kind-learning, .kind-trend, .kind-info { color: var(--ink-2); }
.verb { background: var(--ink); color: var(--surface); border-color: transparent; }
.verb-remove, .verb-cut, .verb-replace { background: var(--critical); color: #fff; }
.verb-scale, .verb-add { background: var(--good); color: #fff; }
.verb-iterate, .verb-test { background: var(--accent); color: #fff; }
.verb-keep, .verb-watch, .verb-adjust { background: var(--surface-2); color: var(--ink-2); border-color: var(--border); }
.rec-link { font-weight: 600; color: var(--accent); text-decoration: none; white-space: nowrap; }
@media (max-width: 600px) {
  .insight-body { padding-left: 16px; }
  .insight-item { grid-template-columns: 1fr; gap: 2px; }
  .insight-more { display: none; }
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tr:last-child td { border-bottom: none; }
.campaign { white-space: nowrap; }
.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 6px; }
.cell-sub { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.cell-sub .campaign { color: var(--muted); }
.meter { display: inline-flex; align-items: center; gap: 6px; }
.meter-bar { width: 44px; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; background: var(--series-1); border-radius: 3px; }
.meter-bar span.full { background: var(--serious); }

.label-chip { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; border-radius: 999px; padding: 1px 9px; border: 1px solid var(--border); white-space: nowrap; color: var(--ink-2); }
.label-chip.BEST { border-color: var(--good); color: var(--good-text); }
.label-chip.LOW { border-color: var(--critical); color: var(--critical); }
.label-chip.LEARNING, .label-chip.PENDING, .label-chip.UNKNOWN { color: var(--muted); border-style: dashed; }
.fatigue-chip { display: inline-block; font-size: 12px; font-weight: 600; color: var(--critical); border: 1px solid var(--critical); border-radius: 999px; padding: 0 8px; white-space: nowrap; }
.trend { white-space: nowrap; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chip-btn { border-radius: 999px; padding: 3px 11px; font-size: 12px; }
.chip-btn[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: transparent; }
.chip-btn[aria-pressed="true"]:hover:not(:disabled) { background: var(--ink); }
.chip-btn[aria-pressed="true"] .count { background: rgba(255, 255, 255, 0.2); color: inherit; }
.chip-btn.warn:not([aria-pressed="true"]) { color: var(--critical); }

details.more { border-top: 1px solid var(--grid); margin-top: 12px; padding-top: 10px; }
details.more:first-child { border-top: none; margin-top: 0; padding-top: 0; }
details.more > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: 6px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: "▸"; color: var(--muted); transition: transform 0.15s; }
details.more[open] > summary::before { transform: rotate(90deg); }
details.more > div, details.more > p { margin-top: 8px; }
details.more ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.coverage-row { padding: 6px 0; border-top: 1px solid var(--grid); font-size: 13px; }
.coverage-row:first-child { border-top: none; }
.coverage-items { display: flex; flex-wrap: wrap; gap: 2px 14px; color: var(--ink-2); }
.coverage-items .low-fill { color: var(--warning-text); }

/* ---------- recommendations & proposals ---------- */
.actions-layout { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .actions-layout { grid-template-columns: minmax(0, 1fr); } }
.rec { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; transition: outline-color 0.3s; }
.rec.compact { display: flex; gap: 10px; align-items: center; padding: 8px 12px; margin: 0; }
.rec-top { display: flex; gap: 10px; align-items: flex-start; }
.rec-main { flex: 1; min-width: 0; }
.rec-title { font-weight: 600; }
.prio { flex: none; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; min-width: 22px; }
.change { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; margin: 8px 0 4px; font-size: 13px; }
.change .from { color: var(--muted); }
.change .arrow { color: var(--muted); }
.change .to { font-weight: 600; }
.expected { font-size: 13px; color: var(--ink-2); }
details.why { margin-top: 6px; font-size: 13px; color: var(--ink-2); }
details.why summary { cursor: pointer; color: var(--accent); font-size: 12px; }
details.why p { margin-top: 4px; }
.rec.flash { outline: 2px solid var(--accent); }

.proposal { border-top: 1px solid var(--grid); padding: 10px 0; }
.proposal:first-child { border-top: none; padding-top: 0; }
.proposal .row { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.status { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--border); text-transform: capitalize; white-space: nowrap; }
.status.pending { border-color: var(--warning); color: var(--warning-text); }
.status.approved { border-color: var(--accent); color: var(--accent); }
.status.applied { border-color: var(--good); color: var(--good-text); }
.status.rejected { color: var(--muted); }
.actions { display: flex; gap: 6px; margin-top: 6px; }

.brief-item { padding: 8px 0; border-top: 1px solid var(--grid); }
.brief-item:first-child { border-top: none; }
.brief-item p { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.finding { display: grid; grid-template-columns: 20px 1fr; gap: 6px; padding: 8px 0; border-top: 1px solid var(--grid); }
.finding:first-child { border-top: none; }
.finding .icon { font-weight: 700; text-align: center; }
.finding.good .icon { color: var(--good-text); }
.finding.warning .icon { color: var(--warning-text); }
.finding.critical .icon { color: var(--critical); }
.finding.info .icon { color: var(--accent); }
.finding p { font-size: 13px; color: var(--ink-2); margin-top: 2px; }

/* ---------- ask drawer ---------- */
.fab { position: fixed; right: 24px; bottom: 24px; z-index: 20; border-radius: 999px; padding: 10px 18px; background: var(--ink); color: var(--surface); border-color: transparent; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18); font-weight: 600; }
.fab:hover:not(:disabled) { background: var(--ink); filter: brightness(1.15); }
.drawer {
  position: fixed; right: 16px; bottom: 16px; z-index: 30; width: min(420px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 32px));
  display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 16px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
}
.drawer-head { display: flex; align-items: center; gap: 10px; }
.drawer-head h2 { flex: 1; }
.drawer-foot { display: flex; justify-content: space-between; gap: 8px; }
.chat { display: flex; flex-direction: column; gap: 8px; overflow: auto; min-height: 60px; flex: 1; }
.msg { padding: 8px 10px; border-radius: 10px; font-size: 13px; }
.msg.user { background: var(--surface-2); align-self: flex-end; max-width: 85%; }
.msg.assistant { border: 1px solid var(--border); }
.msg p { margin: 0 0 6px; }
.msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 0 0 6px; padding-left: 18px; }
.ask-row { display: flex; gap: 8px; }
.ask-row input { flex: 1; }
@media (max-width: 600px) {
  .drawer { right: 0; left: 0; bottom: 0; width: 100%; max-height: 85vh; border-radius: 14px 14px 0 0; }
  .fab { right: 16px; bottom: 16px; }
}

.spinner { display: inline-block; width: 12px; height: 12px; border: 2px solid var(--grid); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); max-width: 440px; width: calc(100% - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, 0.35); }
dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 14px 0 0; }
dialog input { width: 100%; margin-top: 4px; }

@media (max-width: 600px) {
  .topbar-row { padding: 10px 16px 4px; }
  .tabs { padding: 0 8px; }
  main { padding: 16px 16px 96px; }
  .data-notes-inner, #error-banner { padding-left: 16px; padding-right: 16px; }
  .status-chip .status-text { display: none; }
  .brief-headline { font-size: 18px; }
  .chart-box { height: 220px; }
  .rec.compact { flex-wrap: wrap; }
}

/* ---------- accounts: user menu, role gating ---------- */
:root:not([data-role="viewer"]) .viewer-only { display: none !important; }
:root[data-role="viewer"] .member-only { display: none !important; }
:root:not([data-role]) .member-only { display: none !important; }
.user-slot { display: flex; }
.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 4px; border-radius: 999px; background: transparent; font-size: 13px; max-width: 180px; }
.user-btn .user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 700; }
.user-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; min-width: 220px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}
.user-menu .menu[hidden] { display: none !important; }
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px 8px; }
.user-menu .menu [role=menuitem] { display: block; width: 100%; text-align: left; border: none; background: none; border-radius: 6px; padding: 7px 10px; color: var(--ink); text-decoration: none; font-size: 13px; }
.user-menu .menu [role=menuitem]:hover { background: var(--surface-2); }
.user-menu hr { border: none; border-top: 1px solid var(--grid); margin: 4px 0; width: 100%; }
.role-chip { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap; text-transform: capitalize; }
.role-chip.role-admin { border-color: var(--accent); color: var(--accent); }
.role-chip.role-member { border-color: var(--good); color: var(--good-text); }
.form-error { color: var(--critical); font-size: 13px; margin: 8px 0 0; }
button.block { display: block; width: 100%; margin-top: 12px; }
@media (max-width: 600px) { .user-btn .user-name { display: none; } .user-btn { padding: 3px; } }

/* ---------- sign-in page ---------- */
.auth-page { min-height: 100vh; }
.auth-main { max-width: 400px; margin: 0 auto; padding: 12vh 16px 48px; }
.auth-brand { text-align: center; margin-bottom: 16px; }
.auth-brand h1 { font-size: 22px; }
.auth-card { padding: 22px 22px 18px; }
.auth-card h2 { margin-bottom: 4px; font-size: 17px; }
.auth-card > p.muted { margin: 0 0 6px; }
.auth-card label { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; }
.auth-card input { width: 100%; padding: 9px 12px; }
#auth-loading { text-align: center; }

/* ---------- admin page ---------- */
.admin-main { display: flex; flex-direction: column; gap: 16px; }
.create-form { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2fr) auto; gap: 10px; align-items: end; }
.create-form label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.create-form input, .create-form select { width: 100%; }
@media (max-width: 760px) { .create-form { grid-template-columns: minmax(0, 1fr); } }
.secret-box { margin-top: 12px; border: 1px solid var(--border); border-left: 4px solid var(--warning); border-radius: 8px; padding: 10px 14px; background: var(--surface-2); }
.secret-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.secret-row code { font: 600 15px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; user-select: all; word-break: break-all; }
.users-table td { vertical-align: middle; }
.users-table td.nowrap { white-space: nowrap; }
.users-table select { padding: 3px 8px; font-size: 13px; }
.user-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.state-chip { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--border); white-space: nowrap; }
.state-chip.on { border-color: var(--good); color: var(--good-text); }
.state-chip.off { color: var(--muted); border-style: dashed; }
.state-chip.warn { border-color: var(--warning); color: var(--warning-text); }
tr.is-disabled td:first-child strong { color: var(--muted); }
.you { font-size: 11px; color: var(--muted); margin-left: 4px; }
@media (max-width: 760px) {
  .users-table thead { display: none; }
  .users-table, .users-table tbody, .users-table tr, .users-table td { display: block; width: 100%; }
  .users-table tr { border-bottom: 1px solid var(--grid); padding: 10px 0; }
  .users-table td { border: none; padding: 3px 0; }
  .users-table td.num { text-align: left; }
  .users-table td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 90px; color: var(--muted); font-size: 12px; }
  .user-actions { justify-content: flex-start; margin-top: 4px; }
}
.brand-link { color: inherit; text-decoration: none; }
.card > p.form-help { margin: 8px 0 0; }
.controls a.small { color: var(--accent); text-decoration: none; white-space: nowrap; }

/* ---------- Sign in with Google ---------- */
.google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 14px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; }
.google-btn:hover { background: var(--surface-2); }
.google-btn:focus-visible { outline: 2px solid var(--accent, #2a6df4); outline-offset: 2px; }
.or-divider { display: flex; align-items: center; gap: 10px; margin: 16px 0 2px; color: var(--muted); font-size: 12px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
#google-error { margin-top: 12px; }
.create-form.with-email { grid-template-columns: minmax(0, 1.4fr) minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1.6fr) auto; }
.create-form .check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); margin: 0; white-space: nowrap; }
.create-form .check input { width: auto; }
@media (max-width: 900px) { .create-form.with-email { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
@media (max-width: 560px) { .create-form.with-email { grid-template-columns: minmax(0, 1fr); } }
.signin-chips { display: flex; gap: 4px; flex-wrap: nowrap; }
.email-cell { display: flex; gap: 6px; align-items: center; min-width: 0; }
.email-cell .email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent, #2a6df4); font-size: 12px; cursor: pointer; text-decoration: underline; }
.menu-note { padding: 6px 12px; }
