/* ChamPay task control — styled to the champay.com identity.
 *
 * Palette taken from the live site: champagne gold #CCA251 / #F8E789,
 * ink #1C1C1C–#232323, deep green #203429, paper #F8F8F8.
 * Light is the default (the site is light); dark mirrors their dark sections.
 * Every text/background pair below was checked at 4.5:1 or better.
 */

/* The display face on champay.com is TT Livret Display, a licensed font we do
 * not ship, so a system Didone stands in. Drop the licensed woff2 at
 * web/static/fonts/champay-display.woff2 and the server emits the @font-face
 * for it automatically (see base.html) — until then nothing is requested. */

:root {
  color-scheme: light dark;

  --bg: #f2f1ee;
  --surface: #ffffff;
  --surface-2: #f7f6f3;
  --surface-3: #edebe5;
  --border: #e2dfd7;
  --border-strong: #cfcabd;

  --text: #1c1c1c;
  --text-muted: #5c5a55;
  --text-faint: #767268;

  /* Champagne gold is the brand accent. It is a *background* colour: gold
   * text on paper does not reach 4.5:1, so links use the deep green. */
  --gold: #cca251;
  --gold-hover: #b98f3f;
  --gold-light: #f8e789;
  --accent: #cca251;
  --accent-hover: #b98f3f;
  --accent-ink: #1c1c1c;
  --link: #203429;

  --ink: #1c1c1c;
  --ink-2: #232323;

  --danger: #a4231f;
  --danger-text: #8e1f1b;
  --danger-bg: #fbe9e7;
  --warn: #7a5200;
  --warn-text: #7a5200;
  --warn-bg: #fbf0da;
  --ok: #1b5137;
  --ok-text: #1b5137;
  --ok-bg: #e4f1e9;
  --info: #1f4e68;
  --info-text: #1f4e68;
  --info-bg: #e4f0f6;

  --nav-text: #cfccc4;
  --nav-active: #e8c57a;

  --radius: 10px;
  --radius-sm: 5px;
  --radius-pill: 100px;
  --shadow-1: 0 1px 2px rgb(28 28 28 / 0.06);
  --shadow-2: 0 12px 32px rgb(28 28 28 / 0.14);

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  --font: "Helvetica Neue", Helvetica, Arial, "Segoe UI", Roboto, sans-serif;
  --display: "Champay Display", Didot, "Bodoni 72", "Playfair Display",
             "Times New Roman", Times, serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171717;
    --surface: #232323;
    --surface-2: #2a2a29;
    --surface-3: #333331;
    --border: #3a3a37;
    --border-strong: #4d4c48;

    --text: #f2f0eb;
    --text-muted: #a8a49b;
    --text-faint: #9a968c;

    --link: #d9b674;
    --danger: #ff8a82;
    --danger-text: #ff8a82;
    --danger-bg: #3a1f1d;
    --warn: #edb65e;
    --warn-text: #edb65e;
    --warn-bg: #362a12;
    --ok: #79cfa0;
    --ok-text: #79cfa0;
    --ok-bg: #17301f;
    --info: #7fc4ea;
    --info-text: #7fc4ea;
    --info-bg: #12303d;

    --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
    --shadow-2: 0 12px 32px rgb(0 0 0 / 0.45);
  }
}

:root[data-theme="dark"] {
  --bg: #171717;
  --surface: #232323;
  --surface-2: #2a2a29;
  --surface-3: #333331;
  --border: #3a3a37;
  --border-strong: #4d4c48;
  --text: #f2f0eb;
  --text-muted: #a8a49b;
  --text-faint: #9a968c;
  --link: #d9b674;
  --danger: #ff8a82;
  --danger-text: #ff8a82;
  --danger-bg: #3a1f1d;
  --warn: #edb65e;
  --warn-text: #edb65e;
  --warn-bg: #362a12;
  --ok: #79cfa0;
  --ok-text: #79cfa0;
  --ok-bg: #17301f;
  --info: #7fc4ea;
  --info-text: #7fc4ea;
  --info-bg: #12303d;
  --shadow-1: 0 1px 2px rgb(0 0 0 / 0.4);
  --shadow-2: 0 12px 32px rgb(0 0 0 / 0.45);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
}

/* Display type mirrors the site's uppercase Didone headlines. */
h1, h2 {
  font-family: var(--display);
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.15;
  margin: 0 0 var(--space-3);
}
h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.1rem); text-transform: uppercase; }
h2 { font-size: 1.2rem; }
h3, h4 {
  font-family: var(--font);
  font-size: 0.95rem; font-weight: 700;
  letter-spacing: 0.02em; line-height: 1.3;
  margin: 0 0 var(--space-3);
}
p { margin: 0 0 var(--space-3); }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.visually-hidden {
  position: absolute; 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: -999px; top: 0; z-index: 100;
  background: var(--gold); color: var(--ink);
  padding: var(--space-2) var(--space-4); border-radius: 0 0 var(--radius) 0;
  font-weight: 600;
}
.skip-link:focus { left: 0; }

/* ---------------------------------------------------------------- layout */

/* The bar is always ink with the white logo — the same contrast the brand
 * uses on champay.com, and it frames the app in both themes. */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--ink);
  border-bottom: 1px solid #000;
  flex-wrap: nowrap;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 45%, var(--gold) 100%);
}

.brand { display: inline-flex; align-items: center; gap: var(--space-2); }
.brand:hover { text-decoration: none; }
.brand img { height: 22px; width: auto; display: block; }
.brand .suffix {
  color: var(--nav-text); font-size: 0.72rem; font-weight: 600;
  letter-spacing: 0.16em; text-transform: uppercase;
  padding-left: var(--space-3); margin-left: var(--space-1);
  border-left: 1px solid #444;
}

/* Never wrap the bar: if it gets cramped the nav scrolls sideways instead of
 * folding into a second row and shuffling the logo into the middle. */
.nav {
  display: flex; gap: var(--space-1); flex-wrap: nowrap; flex: 1;
  overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-3);
  border-radius: var(--radius-sm); white-space: nowrap;
  color: var(--nav-text); font-weight: 500; font-size: 0.9rem;
  letter-spacing: 0.02em;
}
.nav a:hover { background: #2e2e2c; color: #fff; text-decoration: none; }
.nav a[aria-current="page"] {
  color: var(--nav-active);
  box-shadow: inset 0 -2px 0 var(--gold);
  background: #2a2a28;
}

.topbar-right { display: flex; align-items: center; gap: var(--space-2); }

.user-chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-3); min-height: 40px;
  border: 1px solid #45443f; border-radius: var(--radius-pill);
  color: #f2f0eb; font-size: 0.85rem;
}
.user-chip small { color: var(--nav-text); }

.topbar .btn-ghost { color: var(--nav-text); }
.topbar .btn-ghost:hover { background: #2e2e2c; color: #fff; }

main { padding: var(--space-5) var(--space-4) var(--space-6); max-width: 1420px; margin: 0 auto; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-5);
}
.page-head p { color: var(--text-muted); margin: 0; max-width: 68ch; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.split { display: grid; gap: var(--space-4); grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); }
@media (max-width: 980px) { .split { grid-template-columns: 1fr; } }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.card > header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.card > header h2, .card > header h3 {
  margin: 0; font-family: var(--font); font-size: 0.85rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted);
  display: inline-flex; align-items: center; gap: var(--space-2);
}
.card-body { padding: var(--space-4); }
.card-body.tight { padding: var(--space-2) var(--space-4) var(--space-3); }

.stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--gold);
}
.stat .value {
  font-family: var(--display); font-size: 2.1rem; font-weight: 500;
  font-variant-numeric: tabular-nums; line-height: 1.05;
}
.stat .label {
  color: var(--text-muted); font-size: 0.78rem;
  letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600;
}
.stat.alert { border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: var(--danger-bg); }
.stat.alert::before { background: var(--danger); }
.stat.alert .value { color: var(--danger-text); }
.stat.warn { border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: var(--warn-bg); }
.stat.warn::before { background: var(--warn); }
.stat.warn .value { color: var(--warn-text); }
.stat.good::before { background: var(--ok); }
.stat.good .value { color: var(--ok-text); }

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

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
  text-align: left; padding: var(--space-2) var(--space-3);
  color: var(--text-muted); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
  background: var(--surface-2);
  position: sticky; top: 0;
}
tbody td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.nowrap { white-space: nowrap; }

tr.is-overdue { background: color-mix(in srgb, var(--danger) 7%, transparent); }
tr.is-overdue:hover { background: color-mix(in srgb, var(--danger) 12%, transparent); }
tr.is-soon { background: color-mix(in srgb, var(--warn) 9%, transparent); }
tr.is-closed td { color: var(--text-faint); }
tr.is-closed .task-title { text-decoration: line-through; }

.task-code {
  font-family: var(--mono); font-size: 0.75rem; letter-spacing: 0.06em;
  color: var(--text-faint); white-space: nowrap; text-transform: uppercase;
}
.task-title { font-weight: 600; }
.task-title a { color: var(--text); }
.meta { color: var(--text-muted); font-size: 0.82rem; }

/* ----------------------------------------------------------------- chips */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 10px; border-radius: var(--radius-pill);
  font-size: 0.73rem; font-weight: 600; white-space: nowrap;
  letter-spacing: 0.04em; border: 1px solid transparent; line-height: 1.75;
}
.chip::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}
.chip.plain::before { display: none; }

.chip-new         { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }
.chip-in_progress { background: var(--info-bg); color: var(--info-text); border-color: color-mix(in srgb, var(--info) 35%, transparent); }
.chip-blocked     { background: var(--danger-bg); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.chip-review      { background: var(--warn-bg); color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.chip-done        { background: var(--ok-bg); color: var(--ok-text); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.chip-cancelled   { background: var(--surface-3); color: var(--text-faint); border-color: var(--border); }

.chip-urgent { background: var(--danger-bg); color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.chip-high   { background: var(--warn-bg); color: var(--warn-text); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.chip-normal { background: var(--surface-3); color: var(--text-muted); border-color: var(--border); }
.chip-low    { background: var(--surface-3); color: var(--text-faint); border-color: var(--border); }

.chip-dept { background: transparent; color: var(--text-muted); border-color: var(--border-strong); }
.chip-escalated { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger); }

.due { font-variant-numeric: tabular-nums; white-space: nowrap; }
.due .rel { display: block; font-size: 0.78rem; color: var(--text-muted); }
.due.overdue .rel { color: var(--danger-text); font-weight: 700; }
.due.soon .rel { color: var(--warn-text); font-weight: 700; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4);
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.88rem; font-weight: 600; letter-spacing: 0.02em;
  cursor: pointer; text-decoration: none;
  transition: background 160ms ease-out, border-color 160ms ease-out, transform 120ms ease-out;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* The one gold thing on a screen: the primary action. */
.btn-primary {
  background: var(--gold); border-color: var(--gold); color: var(--accent-ink);
  border-radius: var(--radius-pill); padding: 0 var(--space-5);
}
.btn-primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn-danger { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { min-height: 32px; padding: 0 var(--space-3); font-size: 0.8rem; }
.btn-primary.btn-sm { padding: 0 var(--space-4); }

.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
  .btn:active { transform: none; }
}

/* ----------------------------------------------------------------- forms */

.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.field > label, .field > .label {
  font-size: 0.78rem; font-weight: 700; color: var(--text);
  letter-spacing: 0.06em; text-transform: uppercase;
}
.field .hint { font-size: 0.8rem; color: var(--text-muted); text-transform: none; letter-spacing: 0; font-weight: 400; }
.field .error { font-size: 0.8rem; color: var(--danger-text); }

input[type="text"], input[type="email"], input[type="number"],
input[type="search"], input[type="datetime-local"], select, textarea {
  width: 100%; min-height: 40px;
  padding: var(--space-2) var(--space-3);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  font: inherit; font-size: 0.9rem;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
select { cursor: pointer; }
input::placeholder, textarea::placeholder { color: var(--text-faint); }

fieldset { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--space-3); margin: 0 0 var(--space-4); }
legend {
  font-size: 0.74rem; font-weight: 700; color: var(--text-muted);
  letter-spacing: 0.08em; text-transform: uppercase; padding: 0 var(--space-2);
}

.checks { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.check {
  display: inline-flex; align-items: center; gap: var(--space-2);
  min-height: 36px; padding: 0 var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface-2); font-size: 0.85rem; cursor: pointer;
}
.check input { accent-color: var(--gold-hover); width: 16px; height: 16px; }
.check:has(input:checked) {
  border-color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, transparent);
}

.inline-form { display: flex; gap: var(--space-2); align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* --------------------------------------------------------------- filters */

.filters {
  display: grid; gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  align-items: end;
  padding: var(--space-4); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: var(--space-4);
}
.filters .field { margin-bottom: 0; }
.filters .wide { grid-column: span 2; }
@media (max-width: 640px) { .filters .wide { grid-column: span 1; } }

.scope-tabs { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.scope-tabs a {
  min-height: 36px; display: inline-flex; align-items: center; padding: 0 var(--space-4);
  border-radius: var(--radius-pill); border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted); font-size: 0.83rem; font-weight: 600; letter-spacing: 0.03em;
}
.scope-tabs a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.scope-tabs a[aria-current="true"] {
  background: var(--ink); border-color: var(--ink); color: #fff;
}

/* ----------------------------------------------------------------- board */

.board { display: grid; gap: var(--space-3); grid-template-columns: repeat(5, minmax(230px, 1fr)); overflow-x: auto; }

.board-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); min-width: 0; }
.board-col > header {
  padding: var(--space-3); border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.board-col > header h2 {
  font-family: var(--font); font-size: 0.76rem; font-weight: 700;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); margin: 0;
}
.board-col > header .count { color: var(--text-faint); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.board-list { padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-2); }

.board-card {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: var(--space-3);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.board-card.is-overdue { border-left-color: var(--danger); }
.board-card.is-soon { border-left-color: var(--warn); }
.board-card .title { font-size: 0.88rem; font-weight: 600; line-height: 1.4; }
.board-card .title a { color: var(--text); }

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

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 var(--space-4) var(--space-5);
  border-left: 1px solid var(--border); margin-left: 6px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline li.escalated::before { background: var(--danger); border-color: var(--danger); }
.timeline .when { color: var(--text-faint); font-size: 0.78rem; }

.comment {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: var(--space-3); margin-bottom: var(--space-3);
}
.comment .who { font-weight: 700; font-size: 0.85rem; }
.comment .when { color: var(--text-faint); font-size: 0.78rem; font-weight: 400; }
.comment .body { white-space: pre-wrap; margin-top: var(--space-2); }

/* --------------------------------------------------------------- banners */

.banner {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface);
  margin-bottom: var(--space-3); font-size: 0.9rem;
}
.banner.info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 35%, transparent); color: var(--info-text); }
.banner.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn-text); }
.banner.danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, transparent); color: var(--danger-text); }
.banner .icon { flex: none; margin-top: 2px; }
.banner code { background: color-mix(in srgb, currentColor 12%, transparent); padding: 1px 5px; border-radius: 3px; }

.empty { padding: var(--space-6) var(--space-4); text-align: center; color: var(--text-muted); }
.empty p { margin: 0; }

/* ----------------------------------------------------------------- login */

.login-shell {
  min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5);
  background:
    radial-gradient(120% 80% at 50% -10%, color-mix(in srgb, var(--gold) 26%, transparent) 0%, transparent 60%),
    var(--bg);
}
.login-card {
  width: min(440px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-6); box-shadow: var(--shadow-2); text-align: center;
  position: relative; overflow: hidden;
}
.login-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--gold) 0%, var(--gold-light) 50%, var(--gold) 100%);
}
.login-logo { display: block; height: 34px; width: auto; margin: 0 auto var(--space-5); }
/* The wordmark comes in ink and white — show whichever the theme needs. */
.on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .on-dark { display: block; }
  :root:not([data-theme="light"]) .on-light { display: none; }
}
:root[data-theme="dark"] .on-dark { display: block; }
:root[data-theme="dark"] .on-light { display: none; }
:root[data-theme="light"] .on-dark { display: none; }
:root[data-theme="light"] .on-light { display: block; }
.login-card h1 { font-size: 1.15rem; letter-spacing: 0.14em; margin-bottom: var(--space-2); }
.login-card p { color: var(--text-muted); }
.login-widget { margin: var(--space-5) 0; min-height: 48px; display: flex; justify-content: center; }

/* ------------------------------------------------------------------ misc */

.bar {
  height: 8px; border-radius: var(--radius-pill); background: var(--surface-3);
  overflow: hidden; min-width: 80px;
}
.bar > span { display: block; height: 100%; background: var(--gold); }
.bar > span.danger { background: var(--danger); }
.bar > span.ok { background: var(--ok); }

.kv { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: var(--space-2) var(--space-4); font-size: 0.9rem; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none;
        stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 15px; height: 15px; }

details.disclose > summary {
  cursor: pointer; min-height: 40px; display: flex; align-items: center;
  gap: var(--space-2); font-weight: 600; font-size: 0.88rem;
}
details.disclose[open] > summary { margin-bottom: var(--space-3); }

code, .mono { font-family: var(--mono); font-size: 0.85em; }
.mono-box {
  font-family: var(--mono); font-size: 0.85rem; background: var(--surface-3);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3); overflow-x: auto;
}

.desc { white-space: pre-wrap; line-height: 1.7; }

@media (max-width: 900px) {
  /* Two rows on narrow screens: identity + account, then the nav. */
  .topbar { flex-wrap: wrap; }
  .brand { order: 1; }
  .topbar-right { order: 2; margin-left: auto; }
  .nav { order: 3; flex-basis: 100%; }
  .brand .suffix { display: none; }
}

@media (max-width: 720px) {
  main { padding: var(--space-4) var(--space-3) var(--space-6); }
  .topbar { padding: var(--space-2) var(--space-3); }
  .nav a { padding: 0 var(--space-2); font-size: 0.84rem; }
  .user-chip small { display: none; }
}
