/* thummer admin console. Served under a strict CSP: no inline styles anywhere. */

/* Theme: every color is a light-dark() pair; color-scheme picks the half. "System" follows the OS;
   theme.js sets data-theme="light"/"dark" on <html> for an explicit choice (before first paint). */
:root {
  color-scheme: light dark;
  --page: light-dark(#f9f9f7, #0d0d0d);
  --surface: light-dark(#fcfcfb, #1a1a19);
  --surface-2: light-dark(#f3f2ef, #232321);
  --ink: light-dark(#0b0b0b, #ffffff);
  --ink-2: light-dark(#52514e, #c3c2b7);
  --muted: light-dark(#6f6d68, #9d9b93);
  --axis: #898781;
  --grid: light-dark(#e1e0d9, #2c2c2a);
  --baseline: light-dark(#c3c2b7, #383835);
  --border: light-dark(rgba(11, 11, 11, 0.12), rgba(255, 255, 255, 0.12));
  --accent: light-dark(#2a78d6, #3987e5);
  --accent-ink: #ffffff;
  --accent-wash: light-dark(rgba(42, 120, 214, 0.10), rgba(57, 135, 229, 0.16));
  --danger: light-dark(#c23434, #e66767);
  --danger-wash: light-dark(rgba(208, 59, 59, 0.10), rgba(230, 103, 103, 0.14));
  --good: #0ca30c;
  --good-ink: light-dark(#006300, #0ca30c);
  --warn-ink: light-dark(#8a5a00, #fab219);
  --warn-wash: light-dark(rgba(250, 178, 25, 0.18), rgba(250, 178, 25, 0.14));
  --series-1: light-dark(#2a78d6, #3987e5); /* accepted / committed */
  --series-2: light-dark(#eb6834, #d95926); /* rejected */
  --series-3: light-dark(#1baf7a, #199e70); /* duplicate */
  --hover-band: light-dark(rgba(11, 11, 11, 0.05), rgba(255, 255, 255, 0.06));
  --shadow: 0 1px 2px light-dark(rgba(0, 0, 0, 0.06), rgba(0, 0, 0, 0.4)), 0 4px 16px light-dark(rgba(0, 0, 0, 0.06), transparent);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root { --topbar-h: 56px; --sidebar-w: 220px; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 15px; font-weight: 650; margin: 0; }
h3 { font-size: 13px; font-weight: 600; margin: 0; color: var(--ink-2); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  height: var(--topbar-h); padding: 0 24px 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { width: 28px; height: 28px; flex: none; }

/* Two logo artworks: a black outline for light backgrounds, a softer grey one for dark. Show the
   one for the theme in effect: data-theme when the user picked one, otherwise the OS setting. */
.logo-for-dark { display: none; }
:root[data-theme="dark"] .logo-for-light { display: none; }
:root[data-theme="dark"] .logo-for-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-for-light { display: none; }
  :root:not([data-theme="light"]) .logo-for-dark { display: block; }
}
.brand-sub { font-weight: 500; color: var(--muted); font-size: 13px; }
.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0; border: none; border-radius: 8px;
  background: transparent; color: var(--ink-2);
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
:root[data-sidebar="closed"] .toggle-fill { opacity: 0; }

/* ---- menu column (left) and status line (bottom left) ---- */
.shell { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--topbar-h); flex: none;
  width: var(--sidebar-w); height: calc(100vh - var(--topbar-h));
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 10px 72px; /* the bottom leaves room for the status line */
  overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
}
:root[data-sidebar="closed"] .sidebar { display: none; }
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 550;
}
.sidebar a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.sidebar a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.sidebar a[aria-current="page"] { background: var(--accent-wash); color: var(--accent); }
.sidebar-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 25; background: rgb(0 0 0 / 0.35); }
.statusbar {
  position: fixed; left: 0; bottom: 0; z-index: 30;
  width: var(--sidebar-w);
  display: grid; gap: 1px; padding: 8px 14px;
  font-size: 11.5px; line-height: 1.35; color: var(--muted);
  background: var(--surface); border-top: 1px solid var(--border); border-right: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
#app-version { color: var(--ink-2); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Menu hidden: the status line becomes a small tab in the corner. */
:root[data-sidebar="closed"] .statusbar { width: auto; border-top-right-radius: 8px; }
main { flex: 1; min-width: 0; }
.topbar .spacer { flex: 1; }
/* Account menu: one button in the top bar opening who / theme / change password / log out. */
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px 4px 4px; border-radius: 999px;
  background: transparent; border-color: var(--border); color: var(--ink-2); font-size: 13px; font-weight: 550;
}
.user-btn:hover:not(:disabled), .user-btn[aria-expanded="true"] { background: var(--surface-2); }
.user-btn .email { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-btn .chev { flex: none; transition: transform 0.15s; }
.user-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.avatar {
  display: grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-wash); color: var(--accent); font-weight: 700; font-size: 12.5px;
}
.user-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20;
  width: min(280px, calc(100vw - 32px));
  padding: 6px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); box-shadow: var(--shadow), 0 8px 28px rgb(0 0 0 / 0.14);
}
.user-pop[hidden] { display: none; }
.user-head { padding: 8px 10px; display: grid; gap: 4px; justify-items: start; }
.user-email { font-weight: 600; overflow-wrap: anywhere; }
.menu-sep { height: 1px; background: var(--border); margin: 6px 0; }
.menu-label { padding: 4px 10px; font-size: 12px; color: var(--muted); }
.theme-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; margin: 2px 8px 6px; padding: 2px; border-radius: 8px; background: var(--surface-2); }
.theme-seg button { border: none; background: transparent; padding: 5px 0; font-size: 12.5px; border-radius: 6px; color: var(--ink-2); }
.theme-seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 0.12); }
.menu-item {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border: none; border-radius: 6px;
  background: transparent; color: var(--ink); font-size: 13.5px; font-weight: 500;
}
.menu-item:hover, .menu-item:focus-visible, .theme-seg button:focus-visible { background: var(--surface-2); text-decoration: none; }
.menu-item:focus-visible, .theme-seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---- layout ---- */
main { max-width: 1240px; margin: 0 auto; padding: 24px 24px 72px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 18px; }
.grid-2 { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2.wide-right { grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  min-width: 0;
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.is-refreshing { opacity: 0.55; transition: opacity 0.2s; }

/* ---- stat tiles ---- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
@media (min-width: 1000px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.tile .label { color: var(--ink-2); font-size: 12.5px; }
.tile .value { font-size: 26px; font-weight: 650; margin-top: 4px; letter-spacing: -0.01em; }
.tile .detail { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---- buttons & forms ---- */
button, .btn {
  font: inherit; font-weight: 550; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 6px 12px;
  border-radius: 7px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap;
}
button:hover:not(:disabled) { background: var(--surface-2); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover:not(:disabled) { background: var(--accent); filter: brightness(1.08); }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger:hover:not(:disabled) { background: var(--danger-wash); }
button.danger.solid { background: var(--danger); color: #fff; }
button.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
button.ghost:hover:not(:disabled) { background: var(--surface-2); }
button.small { min-height: 28px; padding: 3px 9px; font-size: 12.5px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; padding: 2px; background: var(--surface); }
.segmented button { border: 0; min-height: 28px; padding: 3px 12px; border-radius: 6px; background: transparent; color: var(--ink-2); }
.segmented button[aria-pressed="true"] { background: var(--accent-wash); color: var(--accent); }

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="url"], input[type="number"], select {
  font: inherit; font-size: 14px; color: var(--ink);
  width: 100%; min-height: 36px; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface);
}
select.inline { width: auto; min-height: 30px; padding: 3px 8px; font-size: 13px; }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 0; }
.field { min-width: 0; }
/* Password field with a Show/Hide toggle inside its right edge. */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 62px; }
button.reveal {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  min-height: 28px; padding: 2px 10px; font-size: 12px;
  border-color: transparent; background: transparent; color: var(--accent);
}
button.reveal:hover:not(:disabled) { background: var(--accent-wash); }
button.reveal:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); align-items: start; margin-bottom: 12px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; }
input.search { width: 260px; max-width: 100%; }
.truncate.narrow { max-width: 190px; }

/* ---- auth screens ---- */
.auth-wrap { min-height: calc(100vh - 48px); display: grid; place-items: center; padding: 24px 0; }
.auth-card { width: min(400px, 100%); }
.auth-logo { width: 64px; height: 64px; margin-bottom: 12px; }
.auth-logo.logo-for-light { display: block; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 18px; }
.auth-card .field + .field { margin-top: 12px; }
.auth-card .form-actions { justify-content: stretch; }
.auth-card .form-actions button { flex: 1; min-height: 38px; }
.auth-theme { display: flex; justify-content: center; margin-top: 14px; }
.notice {
  border: 1px solid var(--border); border-left: 3px solid var(--accent);
  background: var(--accent-wash); border-radius: 8px; padding: 10px 12px; margin-bottom: 16px;
  font-size: 13px; color: var(--ink);
}

/* ---- tables ---- */
/* position: relative keeps absolutely positioned children (e.g. .sr-only headers) inside the scroll box. */
.table-wrap { position: relative; overflow-x: auto; margin: 0 -18px; padding: 0 18px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: middle; }
th { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
th.num, td.num { text-align: right; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td .cell-main { font-weight: 550; }
td .cell-sub { color: var(--muted); font-size: 12px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.empty { padding: 26px 10px; text-align: center; color: var(--muted); }
.truncate { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- badges (status: icon + label, never color alone) ---- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--border); color: var(--ink-2); white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--axis); }
.badge.good { color: var(--good-ink); }
.badge.good .dot { background: var(--good); }
.badge.off .dot { background: transparent; border: 1.5px solid var(--axis); }
.badge.admin { color: var(--accent); border-color: var(--accent); }
.badge.warn { color: var(--warn-ink); }

/* ---- charts ---- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.chart .grid line { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.chart .baseline { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
.chart .tick { fill: var(--axis); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .s1 { fill: var(--series-1); }
.chart .s2 { fill: var(--series-2); }
.chart .s3 { fill: var(--series-3); }
.chart .band { fill: transparent; }
.chart .band.active { fill: var(--hover-band); }
.chart .empty-msg { fill: var(--muted); font-size: 13px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--ink-2); margin-bottom: 8px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 10px; height: 10px; border-radius: 2px; }
.swatch.s1, .line-key.s1 { background: var(--series-1); }
.swatch.s2, .line-key.s2 { background: var(--series-2); }
.swatch.s3, .line-key.s3 { background: var(--series-3); }
.tooltip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 8px 10px; font-size: 12.5px; min-width: 150px;
}
.tooltip .tt-title { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; }
.tooltip .tt-row strong { font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }
.tooltip .tt-row span.lbl { color: var(--ink-2); }
.line-key { width: 12px; height: 3px; border-radius: 2px; flex: none; }
details.data-table { margin-top: 10px; }
details.data-table summary { cursor: pointer; color: var(--ink-2); font-size: 12.5px; }
details.data-table .table-wrap { max-height: 260px; overflow-y: auto; margin-top: 8px; }

/* ---- detail page ---- */
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; margin-bottom: 10px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 18px; }
.kv .k { font-size: 12px; color: var(--muted); }
.kv .v { font-weight: 550; margin-top: 2px; overflow-wrap: anywhere; }
.controls-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--grid); }
.controls-row .grow { flex: 1; }
.rating { display: inline-flex; align-items: baseline; gap: 4px; }
.rating strong { font-size: 14px; }

/* ---- dialog ---- */
dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 0;
  background: var(--surface); color: var(--ink);
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
dialog form { padding: 20px; }
dialog h2 { font-size: 17px; margin-bottom: 8px; }
dialog p { margin: 0 0 12px; color: var(--ink-2); }
dialog .form-actions { margin-top: 18px; }

/* ---- toast ---- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-left: 4px solid var(--good);
  border-radius: 8px; padding: 10px 14px; box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  font-size: 13.5px;
}
.toast.error { border-left-color: var(--danger); }

/* ---- states ---- */
.loading { padding: 40px 0; text-align: center; color: var(--muted); }
.banner-error {
  border: 1px solid var(--danger); background: var(--danger-wash); color: var(--ink);
  border-radius: 8px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}

/* ---- responsive ---- */
@media (max-width: 900px) {
  .grid-2, .grid-2.wide-right { grid-template-columns: minmax(0, 1fr); }
}
/* ---- logs ---- */
.log-filters { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-start; }
.field-inline { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-inline.grow { flex: 1 1 220px; }
.field-inline .label { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0; }
.field-inline input.search { width: 100%; }
.segmented.wrap { flex-wrap: wrap; }
.segmented button:disabled { opacity: 0.55; }
.lvl {
  display: inline-block; padding: 2px 7px; border-radius: 5px; white-space: nowrap;
  font-size: 11px; font-weight: 700; letter-spacing: 0.03em; color: var(--ink-2); background: var(--hover-band);
}
.lvl-error { color: var(--danger); background: var(--danger-wash); }
.lvl-warning { color: var(--warn-ink); background: var(--warn-wash); }
.lvl-info { color: var(--accent); background: var(--accent-wash); }
.lvl-debug { color: var(--muted); background: var(--hover-band); }
td.nowrap { white-space: nowrap; }
table.logs td { vertical-align: top; }
table.logs td.msg { min-width: 200px; overflow-wrap: anywhere; }
table.logs td.user, table.logs td.user button.linkish { white-space: nowrap; overflow-wrap: normal; }
button.linkish {
  border: 0; background: transparent; padding: 0; min-height: 0; border-radius: 3px;
  font: inherit; font-weight: 500; color: var(--accent); text-align: left; white-space: normal; overflow-wrap: anywhere;
}
button.linkish:hover:not(:disabled) { background: transparent; text-decoration: underline; }
button.linkish:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ev-attrs summary { cursor: pointer; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.ev-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 10px; margin: 6px 0 0; }
.ev-kv dt, .ev-kv dd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.ev-kv dt { color: var(--muted); }
.ev-kv dd { margin: 0; overflow-wrap: anywhere; max-width: 360px; }
.ev-attrs[open] .ev-kv { min-width: 240px; }  /* widen the column when opened, so values don't break mid-word */
tr.is-new td { animation: ev-new 1.8s ease-out; }
@keyframes ev-new { from { background: var(--accent-wash); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { tr.is-new td { animation: none; } }

@media (max-width: 640px) {
  main { padding: 16px 16px 72px; }
  .topbar { padding: 0 12px 0 8px; gap: 8px; }
  .user-btn .email { max-width: 120px; }
  .brand-sub { display: none; }
  .card { padding: 14px; }
  .table-wrap { margin: 0 -14px; padding: 0 14px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile .value { font-size: 22px; }
  input.search { width: 100%; }
  .toolbar { width: 100%; }
}

@media (forced-colors: active) {
  .chart .s1, .chart .s2, .chart .s3 { fill: CanvasText; }
  .badge .dot { forced-color-adjust: none; }
}

/* Consumers: copyable IDs and the one-time API key panel. */
.id-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
button.copy { padding: 2px 8px; font-size: 12px; }
.card-head .grow { flex: 1; }
.created { border-color: var(--accent); }
.cred-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px 28px; align-items: start; }
.cred { display: grid; gap: 8px; min-width: 0; align-content: start; }
.cred .k { font-size: 12px; color: var(--muted); }
.cred .v { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.cred code.big { font-size: 16px; font-weight: 600; letter-spacing: 0.04em; }
.cred code.break { overflow-wrap: anywhere; min-width: 0; }
.cred code.masked { color: var(--muted); letter-spacing: 0.08em; }
.qr-wrap { display: flex; }
/* Drawn at a whole number of pixels per module (qrSvg); never rescale it, or scanners struggle. */
svg.qr { flex: none; box-sizing: content-box; border-radius: 6px; border: 1px solid var(--border); }
.cred-dialog { width: min(640px, calc(100vw - 32px)); }
.cred-body { padding: 20px; }
.cred-body > p { margin-top: -4px; }
.warn-text { color: var(--warn-ink); }

/* Narrow screens: the menu column is a drawer over the page, and the status line spans the bottom. */
@media (max-width: 760px) {
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); z-index: 26; box-shadow: 0 8px 28px rgb(0 0 0 / 0.2); }
  .statusbar, :root[data-sidebar="closed"] .statusbar {
    width: 100%; grid-auto-flow: column; justify-content: space-between; gap: 12px;
    border-right: none; border-top-right-radius: 0; padding: 6px 16px;
  }
}

/* Reset password dialog: the typed-password field sits under its radio button. */
.field.indent { margin-left: 26px; }

/* Credentials dialog: consumer ID and public key stacked in one column. */
.stack-tight { display: grid; gap: 18px; align-content: start; min-width: 0; }
.cred code.small { font-size: 11.5px; }
#pk-input { flex: 1; min-width: 0; }

/* ---- email settings ---- */
.label-like { font-size: 12.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.em-other { margin-top: -2px; }
.field-err { margin-top: 4px; }
.field-err:empty { display: none; }
.banner-ok {
  border: 1px solid var(--good); background: var(--accent-wash); color: var(--ink);
  border-radius: 8px; padding: 12px 14px;
}

