/* Tensai — design system ("Swiss precision"), shared by the staff portal and the client portal.
 *
 * Typographic and flat, after the Minimalism & Swiss Style guidance for enterprise tools: IBM Plex
 * Sans and Mono, a strict spacing scale, thin rules instead of floating shadowed cards, small
 * radii, ink text with one accent (Tensai blue), green kept for "issued / valid", a solid
 * navy sidebar as the brand anchor. Pages use the full width of the window; components adapt to
 * the space they are given (container queries), not to the window.
 *
 * One stylesheet, no external assets (the Content-Security-Policy forbids them; the fonts are
 * served from /static/fonts). Every colour is a token defined once with light-dark(), so light
 * and dark come from the same line. The <html> element carries the person's preferences:
 *   data-theme   system | light | dark
 *   data-accent  tensai | teal | violet | amber | graphite
 *   data-density comfortable | compact
 *   data-text    normal | large
 *   data-motion  system | reduce
 *   data-sidebar expanded | collapsed
 * Contrast of every text/background pair is checked by scripts/tools/contrast.py
 * (WCAG 2.2: 4.5:1 for text, 3:1 for control borders, marks and large text).
 */

/* ── fonts (SIL Open Font Licence: /static/fonts/OFL.txt) ───────────── */
@font-face {
  font-family: "IBM Plex Sans"; font-style: normal; font-weight: 100 700; font-display: swap;
  src: url(/static/fonts/ibm-plex-sans-latin.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(/static/fonts/ibm-plex-mono-400-latin.woff2) format("woff2");
}
@font-face {
  font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(/static/fonts/ibm-plex-mono-500-latin.woff2) format("woff2");
}

/* ── tokens ─────────────────────────────────────────────────────────── */
:root {
  color-scheme: light dark;

  /* neutrals. Light: soft navy-tinted greys, nothing pure white, easy on the eyes for a
     working day. Dark: deep Smart Solution navy. */
  --canvas:        light-dark(#e3e7ed, #0a1220);
  --surface:       light-dark(#f1f3f6, #101b2e);
  --surface-2:     light-dark(#ebeef2, #142139);
  --surface-3:     light-dark(#e0e5eb, #1a2a45);
  --surface-sunk:  light-dark(#e7eaef, #0d1626);
  --line:          light-dark(#cdd4dd, #213250);
  --line-strong:   light-dark(#b4becb, #2d4164);
  --control-line:  light-dark(#737f94, #6b7d9b);
  --text:          light-dark(#12203a, #e5eaf2);
  --text-2:        light-dark(#28364f, #c2cbd9);
  --muted:         light-dark(#475569, #97a4b9);
  --faint:         light-dark(#535f73, #8693a9);
  --on-solid:      #ffffff;

  /* status tones: text on its soft background, a solid fill, and a border */
  --ok-text:       light-dark(#0d6640, #5fd3a0);
  --ok-soft:       light-dark(#d9eee3, #0d2a22);
  --ok-solid:      light-dark(#178048, #3ec487);
  --ok-line:       light-dark(#9fd0b7, #1d4d3c);
  --warn-text:     light-dark(#824200, #f3b862);
  --warn-soft:     light-dark(#f4e6cf, #2c1f0e);
  --warn-solid:    light-dark(#b35c00, #f0a640);
  --warn-line:     light-dark(#e3c28e, #5a3e17);
  --bad-text:      light-dark(#a8201a, #f8897d);
  --bad-soft:      light-dark(#f4dedb, #331718);
  --bad-solid:     light-dark(#c4321f, #f07b6e);
  --bad-line:      light-dark(#e6aba3, #5e2624);
  --bad-ink:       light-dark(#ffffff, #1a0705);
  --info-text:     light-dark(#0f50b0, #85b4ff);
  --info-soft:     light-dark(#dbe5f3, #12223f);
  --info-line:     light-dark(#acc4e8, #263d68);
  --neutral-text:  light-dark(#36435a, #c3cad8);
  --neutral-soft:  light-dark(#dde2e9, #1f2c43);

  /* accent: Smart Solution blue (see [data-accent] below for the others) */
  --accent:        light-dark(#005dae, #2a6cb8);
  --accent-hover:  light-dark(#004c8e, #245fa3);
  --accent-ink:    #ffffff;
  --accent-text:   light-dark(#00529b, #80b6ee);
  --accent-soft:   light-dark(#d7e3f1, #12274a);
  --accent-soft-2: light-dark(#c3d5ea, #19335c);
  --accent-on-soft:light-dark(#003e75, #bbd5f5);

  /* the brand: Smart Solution navy and gold; Tensai blue and green (the product's logo) */
  --brand-navy:    #1c3355;
  --brand-gold:    #bf8a2f;
  --gold-text:     light-dark(#7a5311, #e2b865);
  --brand-green:   #3bba92;
  --tensai-blue:   #3354a3;

  /* the navigation: Smart Solution navy in both themes, gold marks the current page */
  --nav-bg:        light-dark(#1c3355, #0f1b30);
  --nav-bg-2:      light-dark(#284572, #1b2d4c);
  --nav-line:      light-dark(#2b456e, #1e2f4d);
  --nav-text:      #ffffff;
  --nav-text-2:    #c9d3e4;
  --nav-muted:     #9aa9c2;
  --nav-accent:    #e2b259;

  /* chart series */
  --chart-1: var(--accent);
  --chart-2: light-dark(#1b8f64, #3bba92);
  --chart-3: light-dark(#94661a, #e2b259);
  --chart-4: light-dark(#c4321f, #f07b6e);
  --chart-grid: var(--line);

  /* elevation is reserved for things that float (menus, dialogs, toasts) */
  --shadow-xs: none;
  --shadow-sm: light-dark(0 1px 2px rgba(12, 18, 32, .06), 0 1px 2px rgba(0, 0, 0, .4));
  --shadow-md: light-dark(0 4px 14px rgba(12, 18, 32, .08), 0 4px 14px rgba(0, 0, 0, .5));
  --shadow-lg: light-dark(0 16px 40px rgba(12, 18, 32, .16), 0 16px 40px rgba(0, 0, 0, .6));
  --ring: color-mix(in srgb, var(--accent) 45%, transparent);

  --font: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-display: var(--font);
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;

  --r-sm: 3px;
  --r-md: 4px;
  --r-lg: 6px;
  --r-xl: 8px;

  /* density (an 8px rhythm) */
  --fs: 14px;
  --ctl-h: 36px;
  --row-pad: 11px;
  --card-pad: 20px;
  --gap: 20px;
  --gutter: clamp(16px, 1.6vw + 6px, 40px);
  --sidebar-w: 248px;
  --topbar-h: 56px;
  --ease: 140ms cubic-bezier(.2, .7, .3, 1);
}

:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

:root[data-accent="teal"] {
  --accent: light-dark(#0f7a5c, #13836a); --accent-hover: light-dark(#0b634a, #0f7560);
  --accent-text: light-dark(#0c6e52, #62d7b1);
  --accent-soft: light-dark(#e1f4ed, #10291f); --accent-soft-2: light-dark(#c9eadd, #173a2d);
  --accent-on-soft: light-dark(#0a5640, #94e4c8);
}
:root[data-accent="violet"] {
  --accent: light-dark(#5a45c0, #6a55cc); --accent-hover: light-dark(#4836a3, #5c47c0);
  --accent-text: light-dark(#5240b5, #b9abf7);
  --accent-soft: light-dark(#efebfb, #221c3f); --accent-soft-2: light-dark(#e0d9f8, #2e2556);
  --accent-on-soft: light-dark(#3e2f93, #d2c9fa);
}
:root[data-accent="amber"] {
  --accent: light-dark(#87601a, #8f661c); --accent-hover: light-dark(#6f4e14, #7c5818);
  --accent-text: light-dark(#79540f, #e2b865);
  --accent-soft: light-dark(#efe4cf, #2b2313); --accent-soft-2: light-dark(#e6d4b1, #3b2f16);
  --accent-on-soft: light-dark(#5a3d08, #f0d49b);
}
:root[data-accent="graphite"] {
  --accent: light-dark(#363f4e, #646f82); --accent-hover: light-dark(#252c38, #586274);
  --accent-text: light-dark(#363f4e, #d4dae2);
  --accent-soft: light-dark(#eceef2, #232a35); --accent-soft-2: light-dark(#dde1e7, #2d3542);
  --accent-on-soft: light-dark(#1f2733, #e2e6ec);
}

:root[data-density="compact"] {
  --fs: 13.5px; --ctl-h: 32px; --row-pad: 7px; --card-pad: 16px; --gap: 16px; --topbar-h: 52px;
}
:root[data-text="large"] { --fs: 15.5px; }
:root[data-density="compact"][data-text="large"] { --fs: 15px; }
@media (min-width: 2200px) { :root[data-text="normal"]:not([data-density="compact"]) { --fs: 15px; } }
/* Motion: "system" follows the computer's setting, "reduce" always turns it off. */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after,
:root[data-motion="reduce"] dialog::backdrop { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  :root[data-motion="system"] *, :root[data-motion="system"] *::before, :root[data-motion="system"] *::after { animation: none !important; transition: none !important; }
}
:root[data-sidebar="collapsed"] { --sidebar-w: 68px; }

/* ── base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
html { font-size: var(--fs); }
body {
  font: 400 1rem/1.5 var(--font);
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "kern";
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); text-wrap: balance; }
h1 { font: 600 1.72rem/1.2 var(--font); letter-spacing: -.018em; }
h2 { font-size: 1rem; font-weight: 600; letter-spacing: -.003em; }
h3 { font-size: .74rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
p { margin: 0 0 .75em; text-wrap: pretty; }
p:last-child { margin-bottom: 0; }
code, kbd, .mono { font-family: var(--mono); font-size: .92em; }
hr { border: 0; border-top: 1px solid var(--line); margin: var(--gap) 0; }
img { max-width: 100%; }
svg.i { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
svg.i-sm { width: 14px; height: 14px; }
svg.i-lg { width: 21px; height: 21px; }
svg.i-xl { width: 26px; height: 26px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }
::selection { background: var(--accent-soft-2); }

/* ── environment ribbon ─────────────────────────────────────────────── */
.env {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  font: 600 .7rem/1 var(--mono); letter-spacing: .06em; text-transform: uppercase;
  background: var(--warn-soft); color: var(--warn-text); border: 1px solid var(--warn-line);
  white-space: nowrap;
}
.env::before { content: ""; width: 6px; height: 6px; background: var(--warn-solid); }
.env-staging { background: var(--info-soft); color: var(--info-text); border-color: var(--info-line); }
.env-staging::before { background: var(--info-text); }

/* ── app shell ──────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns var(--ease); }

/* Its own layer, over the page and the top bar, so the portal switcher's menu opens over them. */
.sidebar {
  position: sticky; top: 0; z-index: 35; height: 100vh; overflow: hidden auto;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--nav-bg); color: var(--nav-text-2);
  padding: 0 10px 12px;
  scrollbar-width: thin; scrollbar-color: var(--nav-line) transparent;
}
.sb-brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; height: var(--topbar-h); margin: 0 -10px 10px; padding-inline: 18px;
  border-bottom: 1px solid var(--nav-line); color: var(--nav-text); }
.sb-brand:hover { text-decoration: none; }
/* The portal switcher: the brand opens a directory of the portals, numbered like an index. */
.pswitch { margin: 0 -10px 10px; }
.pswitch > .sb-brand { margin: 0; list-style: none; cursor: pointer; }
.pswitch > .sb-brand::-webkit-details-marker { display: none; }
.pswitch > .sb-brand:hover { background: rgba(255, 255, 255, .05); }
.pswitch > .sb-brand:focus-visible { outline: 2px solid var(--nav-accent); outline-offset: -2px; }
.ps-caret { margin-left: auto; color: var(--nav-muted); display: grid; transition: transform var(--ease); }
.pswitch[open] .ps-caret { transform: rotate(180deg); color: var(--nav-accent); }
[data-sidebar="collapsed"] .ps-caret { display: none; }
.ps-panel { width: 360px; max-width: calc(100vw - 24px); padding: 0; overflow: hidden; }
.ps-panel > .ps-head { display: flex; justify-content: space-between; padding: 11px 14px 9px; border-bottom: 1px solid var(--line);
  font: 500 .66rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ps-list { list-style: none; margin: 0; padding: 0; }
.ps-list li + li { border-top: 1px solid var(--line); }
.ps-item { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: start; gap: 0 10px;
  padding: 12px 14px; color: var(--text); }
a.ps-item:hover { background: var(--surface-3); text-decoration: none; }
a.ps-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.ps-item.is-here { background: var(--surface-2); }
.ps-item.is-here::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--gold-text); }
.ps-num { font: 500 .78rem/1.2rem var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.ps-text { display: grid; gap: 3px; min-width: 0; }
.ps-name { font-weight: 600; line-height: 1.2rem; }
.ps-note { font-size: .8rem; color: var(--muted); line-height: 1.35; }
/* The host is on its own line: a long one (issuer-admin.uat.…) is cut short, never overlaps. */
.ps-host { margin-top: 2px; font: .7rem/1.3 var(--mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-go { align-self: center; display: grid; color: var(--muted); transition: transform var(--ease), color var(--ease); }
a.ps-item:hover .ps-go, a.ps-item:focus-visible .ps-go { color: var(--accent-text); transform: translateX(2px); }
.ps-here { font: 500 .64rem/1.2rem var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--gold-text); }
.ps-foot { margin: 0; padding: 10px 14px 12px; border-top: 1px solid var(--line); font-size: .76rem; color: var(--muted); line-height: 1.4; }
.ps-box { border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; margin: 4px 0 16px; }
.ps-box-head { padding: 9px 14px 8px; border-bottom: 1px solid var(--line); font: 500 .7rem/1 var(--mono); letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); }
.sb-logo { width: 30px; height: 30px; flex: none; border-radius: var(--r-md); display: grid; place-items: center; background: #ffffff; color: var(--brand-navy); }
.sb-logo svg { width: 18px; height: 18px; }
.sb-mark { width: 34px; height: 34px; flex: none; display: block; }
.sb-name { display: grid; gap: 5px; font: 600 .98rem/1.15 var(--font); letter-spacing: .01em; }
.sb-name small { display: block; font: 500 .68rem/1 var(--font); color: var(--nav-muted); letter-spacing: .12em; text-transform: uppercase; }
/* The Tensai logo: Tensai blue and green; white and green on navy. */
.wordmark { display: block; height: 15px; width: auto; }
.tw-a { fill: var(--tw-a, var(--tensai-blue)); }
.tw-b { fill: var(--tw-b, var(--brand-green)); }
.sidebar, .auth-side, .cp-top { --tw-a: #ffffff; }
.sb-section { margin: 16px 10px 6px; font: 600 .68rem/1 var(--font); text-transform: uppercase; letter-spacing: .1em; color: var(--nav-muted); }
.sidebar nav > div { display: grid; gap: 4px; align-content: start; }
.sb-link {
  position: relative; display: flex; align-items: center; gap: 11px;
  height: 36px; padding: 0 10px; border-radius: var(--r-md);
  color: var(--nav-text-2); font-weight: 450; white-space: nowrap;
  transition: background var(--ease), color var(--ease);
}
.sb-link:hover { background: rgba(255, 255, 255, .07); color: var(--nav-text); text-decoration: none; }
.sb-link.is-active { background: var(--nav-bg-2); color: var(--nav-text); font-weight: 550; }
.sb-link.is-active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; background: var(--nav-accent); }
.sb-link .i { opacity: .85; }
.sb-link.is-active .i { opacity: 1; color: var(--nav-accent); }
.sb-count { margin-left: auto; min-width: 22px; padding: 0 6px; height: 19px; border-radius: var(--r-sm); display: inline-grid; place-items: center;
  font: 500 .72rem/1 var(--mono); background: rgba(255, 255, 255, .1); color: var(--nav-text); }
.sb-link.is-active .sb-count { background: rgba(255, 255, 255, .16); }
.sb-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--nav-line); display: grid; gap: 4px; }
.sb-toggle { background: none; border: 0; font: inherit; cursor: pointer; width: 100%; }
[data-sidebar="collapsed"] .sb-name, [data-sidebar="collapsed"] .sb-section, [data-sidebar="collapsed"] .sb-label,
[data-sidebar="collapsed"] .sb-count { display: none; }
[data-sidebar="collapsed"] .sb-link { justify-content: center; padding: 0; }
[data-sidebar="collapsed"] .sb-brand { justify-content: center; padding-inline: 0; }
[data-sidebar="collapsed"] .sb-toggle .i { transform: rotate(180deg); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 var(--gutter);
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.tb-search {
  display: flex; align-items: center; gap: 10px; flex: 0 1 460px; height: 34px; padding: 0 6px 0 11px;
  border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--faint);
  font: inherit; cursor: pointer; text-align: left;
  transition: border-color var(--ease), background var(--ease);
}
.tb-search:hover { border-color: var(--control-line); background: var(--surface); }
.tb-search .tb-search-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-search .kbd { flex: none; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.kbd {
  display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 5px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--muted); font: 500 .7rem/1 var(--mono);
}
/* Full width: pages use the whole window; text keeps a readable measure (see .measure). */
.content { width: 100%; padding: 28px var(--gutter) 72px; container: page / inline-size; }
.content-narrow { max-width: none; }

/* ── page head ──────────────────────────────────────────────────────── */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px 24px; margin-bottom: 24px; flex-wrap: wrap;
  padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.ph-main { min-width: 0; flex: 1 1 420px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: .84rem; color: var(--muted); margin-bottom: 10px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.crumbs .i { width: 13px; height: 13px; opacity: .55; }
.ph-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ph-desc { color: var(--muted); margin-top: 6px; max-width: 80ch; }
.ph-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-head:has(.crumbs) .ph-actions { margin-top: 28px; }

/* ── layout helpers ─────────────────────────────────────────────────── */
.stack { display: grid; gap: var(--gap); align-content: start; }
.stack-sm { display: grid; gap: 10px; align-content: start; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: var(--gap); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.auto-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); }
/* A main column and an aside that grows with the window. */
.split { grid-template-columns: minmax(0, 1fr) clamp(320px, 23vw, 460px); align-items: start; }
.split:not(:has(> :nth-child(2))) { grid-template-columns: minmax(0, 1fr); }
.split-wide { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: start; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 20px); }
@media (max-height: 900px) { .sticky-side { position: static; } }
.measure { max-width: 76ch; }
.form-narrow { max-width: 620px; }
.pair-wide { display: grid; gap: var(--gap); align-content: start; }
@container page (min-width: 1700px) {
  .pair-wide { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .pair-wide > .span-all { grid-column: 1 / -1; }
}

/* ── cards: thin rules, no shadow ───────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px var(--card-pad); border-bottom: 1px solid var(--line); min-height: 52px; }
.card-head.plain { border-bottom: 0; padding-bottom: 4px; }
.card-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.card-title > .i { display: none; } /* titles are typographic; no decorative icons */
.card-title h2 { font-size: .98rem; }
.card-sub { color: var(--muted); font-size: .86rem; margin-top: 2px; max-width: 90ch; }
.card-body { padding: var(--card-pad); }
.card-body.flush { padding: 0; }
.card-foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 11px var(--card-pad); border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card-foot.between { justify-content: space-between; }
a.card { display: block; color: inherit; transition: border-color var(--ease); }
a.card:hover { text-decoration: none; border-color: var(--control-line); }
.card-danger { border-color: var(--bad-line); }
.card-danger .card-head { border-bottom-color: var(--bad-line); }

/* ── buttons ────────────────────────────────────────────────────────── */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-line: var(--line-strong); --btn-hover: var(--surface-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--ctl-h); padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--btn-fg);
  font: 500 .93rem/1 var(--font); white-space: nowrap; cursor: pointer; user-select: none;
  transition: background var(--ease), border-color var(--ease), color var(--ease);
}
.btn:hover { background: var(--btn-hover); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn[disabled], .btn.is-disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-line: var(--accent); --btn-hover: var(--accent-hover); }
.btn-primary:hover { border-color: var(--accent-hover); }
.btn-ghost { --btn-bg: transparent; --btn-line: transparent; --btn-hover: var(--surface-3); color: var(--text-2); }
.btn-danger { --btn-bg: var(--bad-solid); --btn-fg: var(--bad-ink); --btn-line: var(--bad-solid); --btn-hover: color-mix(in srgb, var(--bad-solid) 88%, #000); }
.btn-danger-soft { --btn-bg: var(--surface); --btn-fg: var(--bad-text); --btn-line: var(--bad-line); --btn-hover: var(--bad-soft); }
.btn-sm { height: calc(var(--ctl-h) - 6px); padding: 0 10px; font-size: .86rem; gap: 6px; border-radius: var(--r-sm); }
.btn-lg { height: calc(var(--ctl-h) + 8px); padding: 0 20px; font-size: 1rem; }
.btn-icon { width: var(--ctl-h); padding: 0; }
.btn-icon.btn-sm { width: calc(var(--ctl-h) - 6px); }
.btn-block { width: 100%; }
.btn .i { width: 16px; height: 16px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.btn-group .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group .btn + .btn { margin-left: -1px; }
.linkbtn { font: inherit; color: var(--accent-text); background: none; border: 0; padding: 0; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.iconbtn {
  position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md);
  background: transparent; border: 1px solid transparent; color: var(--text-2); cursor: pointer; transition: background var(--ease);
}
.iconbtn:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.iconbtn.tb-menu { display: none; }
.dot-badge { position: absolute; top: 3px; right: 1px; box-sizing: border-box; min-width: 17px; height: 17px; padding: 0 4px; border-radius: var(--r-sm);
  background: var(--bad-solid); color: var(--bad-ink); font: 600 .64rem/17px var(--mono); text-align: center; }
@media (pointer: coarse) { .btn-sm { height: 40px; } }

/* ── badges ─────────────────────────────────────────────────────────── */
.badge {
  --b-fg: var(--neutral-text); --b-bg: var(--neutral-soft);
  display: inline-flex; align-items: center; gap: 6px; height: 21px; padding: 0 7px; border-radius: var(--r-sm);
  font: 500 .76rem/1 var(--font); white-space: nowrap; color: var(--b-fg); background: var(--b-bg);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 1px; background: currentColor; }
.badge.lg { height: 24px; padding: 0 9px; font-size: .82rem; }
.tone-info    { --b-fg: var(--info-text); --b-bg: var(--info-soft); }
.tone-ok      { --b-fg: var(--ok-text);   --b-bg: var(--ok-soft); }
.tone-warn    { --b-fg: var(--warn-text); --b-bg: var(--warn-soft); }
.tone-bad     { --b-fg: var(--bad-text);  --b-bg: var(--bad-soft); }
.tone-accent  { --b-fg: var(--accent-on-soft); --b-bg: var(--accent-soft); }
.tone-neutral { --b-fg: var(--neutral-text); --b-bg: var(--neutral-soft); }
/* A short code (QA, TEST, REQUIRED): mono, outlined. */
.tag { display: inline-flex; align-items: center; height: 19px; padding: 0 6px; border-radius: var(--r-sm); font: 500 .68rem/1 var(--mono);
  letter-spacing: .05em; text-transform: uppercase; background: transparent; color: var(--text-2); border: 1px solid var(--line-strong); }
.tag-test { color: var(--warn-text); border-color: var(--warn-line); background: var(--warn-soft); }
/* A label in words (a permission, a category). */
.chip { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: var(--r-sm);
  background: var(--surface-3); color: var(--text-2); font: 450 .8rem/1 var(--font); white-space: nowrap; }

/* ── alerts ─────────────────────────────────────────────────────────── */
.alert {
  --a-fg: var(--info-text); --a-bg: var(--info-soft); --a-line: var(--info-line);
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; border-radius: var(--r-md);
  background: var(--a-bg); color: var(--text); border: 1px solid var(--a-line); border-left-width: 3px; margin-bottom: var(--gap);
}
.alert > .i { color: var(--a-fg); margin-top: 2px; }
.alert-title { font-weight: 600; color: var(--a-fg); }
.alert .alert-body { flex: 1; min-width: 0; max-width: 100ch; }
.alert p { margin: 2px 0 0; color: var(--text-2); }
.alert.tone-ok   { --a-fg: var(--ok-text);   --a-bg: var(--ok-soft);   --a-line: var(--ok-line); }
.alert.tone-warn { --a-fg: var(--warn-text); --a-bg: var(--warn-soft); --a-line: var(--warn-line); }
.alert.tone-bad  { --a-fg: var(--bad-text);  --a-bg: var(--bad-soft);  --a-line: var(--bad-line); }
.alert.compact { padding: 9px 12px; margin-bottom: 0; }

/* ── toasts ─────────────────────────────────────────────────────────── */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: grid; gap: 10px; width: min(400px, calc(100vw - 40px)); }
.toast {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line-strong); border-left: 3px solid var(--ok-solid); box-shadow: var(--shadow-lg); color: var(--text);
  animation: toast-in 200ms cubic-bezier(.2, .8, .3, 1);
}
.toast > .i { color: var(--ok-text); margin-top: 1px; }
.toast.tone-bad { border-left-color: var(--bad-solid); }
.toast.tone-bad > .i { color: var(--bad-text); }
.toast.tone-info { border-left-color: var(--info-text); }
.toast.tone-info > .i { color: var(--info-text); }
.toast .t-body { flex: 1; }
.toast .t-close { margin: -4px -4px 0 0; }
.toast.is-leaving { opacity: 0; transform: translateY(6px); transition: opacity 200ms, transform 200ms; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── forms ──────────────────────────────────────────────────────────── */
/* A form section: its title and explanation on the left, its fields on the right, capped so
   fields keep sensible widths on a wide window. */
.fsec { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 16px 32px; padding: 24px var(--card-pad); border-bottom: 1px solid var(--line); }
.fsec:last-of-type { border-bottom: 0; }
.fsec > :last-child { max-width: 1040px; min-width: 0; }
.fsec-intro h2 { margin-bottom: 6px; }
.fsec-intro p { color: var(--muted); font-size: .9rem; max-width: 46ch; }
.fields { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px 16px; align-content: start; }
.fields > .field { grid-column: span 2; }
.fields > .w-1 { grid-column: span 1; }
.fields > .w-3 { grid-column: span 3; }
.fields > .w-4 { grid-column: span 4; }
.fields > .w-full { grid-column: 1 / -1; }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.label { font-size: .86rem; font-weight: 550; color: var(--text); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--bad-text); }
.label .opt { color: var(--faint); font-weight: 400; font-size: .8rem; }
.help { color: var(--muted); font-size: .85rem; max-width: 80ch; }
.err { display: flex; gap: 6px; align-items: center; color: var(--bad-text); font-size: .85rem; font-weight: 500; }
.err .i { width: 14px; height: 14px; }
.input, .select, .textarea {
  width: 100%; height: var(--ctl-h); padding: 0 11px; border-radius: var(--r-md);
  border: 1px solid var(--control-line); background: var(--surface); color: var(--text);
  font: 400 .95rem/1.4 var(--font); transition: border-color var(--ease), box-shadow var(--ease);
}
.textarea { height: auto; min-height: 96px; padding: 9px 11px; resize: vertical; }
.select { appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--ring); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input[readonly] { background: var(--surface-sunk); color: var(--muted); }
.input-mono { font-family: var(--mono); font-size: .9rem; }
.has-err .input, .has-err .select, .has-err .textarea { border-color: var(--bad-solid); background: color-mix(in srgb, var(--bad-soft) 55%, var(--surface)); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .i { position: absolute; left: 11px; color: var(--faint); pointer-events: none; }
.input-wrap > .i ~ .input { padding-left: 35px; }
.input-wrap > .suffix { position: absolute; right: 11px; color: var(--muted); font-size: .86rem; pointer-events: none; }
.input-wrap > .input.has-suffix { padding-right: 56px; }
input[type=file].input { padding: 5px; height: auto; }
input[type=file]::file-selector-button {
  font: 500 .86rem var(--font); margin-right: 10px; cursor: pointer; height: 28px; padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
}
.check { display: inline-flex; align-items: center; gap: 9px; font-weight: 450; cursor: pointer; }
.check input, .cb { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 450; }
.switch input { appearance: none; margin: 0; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong);
  border: 1px solid var(--control-line); position: relative; cursor: pointer; transition: background var(--ease); flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform var(--ease); }
.switch input:checked { background: var(--accent); border-color: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: var(--accent-ink); }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
.switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--line); flex-wrap: wrap; justify-self: start; }
.seg label { display: inline-flex; align-items: center; gap: 7px; height: calc(var(--ctl-h) - 6px); padding: 0 12px; border-radius: var(--r-sm);
  font-weight: 500; font-size: .9rem; color: var(--muted); cursor: pointer; transition: background var(--ease), color var(--ease); }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--text); color: var(--canvas); font-weight: 550; }
.seg label:has(input:checked) .i { color: inherit; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--accent); }

.choices { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)); }
.choices.cols { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.choice {
  position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
}
.choice:hover { border-color: var(--control-line); }
.choice input { margin: 3px 0 0; accent-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.choice:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.choice .c-title { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.choice .c-title > .i { color: var(--muted); }
.choice .c-desc { color: var(--muted); font-size: .88rem; margin-top: 3px; }
.swatch { width: 18px; height: 18px; border-radius: var(--r-sm); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); flex: none; }
.sw-tensai { background: #005dae; } .sw-teal { background: #0f7a5c; } .sw-violet { background: #5a45c0; }
.sw-amber { background: #bf8a2f; } .sw-graphite { background: #363f4e; }

/* "Everything" ticked: the choices give way to what it means. */
.grant-pick:has([name=grants_all]:checked) .choices:not(.grant-off), .grant-pick:has([name=grants_all]:checked) .grant-pick-note { display: none; }
/* Permissions the organisation lacks: shown greyed, with the way to turn them on for it. */
.choice.is-off { cursor: default; }
.choice.is-off a { pointer-events: auto; }
.grant-pick:not(:has([name=grants_all]:checked)) .grant-all-note { display: none; }
.grant-all-note .chip { margin: 2px 0; }
/* The offer form asks for a person only when the offer is sent to one. */
.delivery-pick:has([name=delivery][value=handover]:checked) .send-to:not(.has-err) { display: none; }
.delivery-pick .send-to { max-width: 640px; }
.input-wrap > .pw-toggle { position: absolute; right: 6px; padding: 4px 8px; font-size: .84rem; font-weight: 500; border-radius: var(--r-sm); }
.input-wrap > .input.has-toggle { padding-right: 64px; }

.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px var(--card-pad); border-top: 1px solid var(--line);
  background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); position: sticky; bottom: 0; z-index: 5; }
.form-actions .grow { margin-right: auto; color: var(--muted); font-size: .88rem; }
/* A save bar floating at the foot of the window, for long forms (settings, preferences). */
.form-actions.float { position: sticky; bottom: 12px; border: 1px solid var(--line-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-md); background: var(--surface); }

/* ── tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th, .table td { padding: var(--row-pad) 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--line); }
.table th:first-child, .table td:first-child { padding-left: var(--card-pad); }
.table th:last-child, .table td:last-child { padding-right: var(--card-pad); }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); color: var(--muted);
  font: 600 .7rem/1.2 var(--font); text-transform: uppercase; letter-spacing: .07em; white-space: nowrap; padding-top: 10px; padding-bottom: 10px; }
.table thead th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table thead th a.is-sorted { color: var(--text); }
.table tbody tr { transition: background var(--ease); }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.table tbody tr.is-selected { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-check { width: 44px; padding-right: 0; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table td.wrap { white-space: normal; }
/* A row with a .row-link opens from anywhere on it: the link's box stretches over the row
   (so middle-click, Ctrl+click and the keyboard work as for any link), while the row's other
   controls sit above it and keep their own clicks. */
.table tbody tr:has(.row-link) { position: relative; cursor: pointer; }
.table .row-link::after { content: ""; position: absolute; inset: 0; }
.table .row-link:focus-visible { outline: none; }
.table tbody tr:has(.row-link:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.table tbody tr:has(.row-link) :is(a:not(.row-link), button, input, select, textarea, label, summary, details) { position: relative; z-index: 1; }
.table tbody tr:has(.row-link) details[open] { z-index: 5; } /* an open menu stays over the rows below */
.cell-main { font-weight: 550; color: var(--text); }
a.cell-main:hover { color: var(--accent-text); }
.cell-sub { color: var(--muted); font-size: .84rem; margin-top: 1px; }
.cell-person { display: flex; align-items: center; gap: 12px; min-width: 0; }
.dim { color: var(--muted); }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px var(--card-pad); border-top: 1px solid var(--line); color: var(--muted); font-size: .86rem; flex-wrap: wrap; }
.pager { display: flex; align-items: center; gap: 6px; }
/* On a narrow page, tables marked .responsive turn each row into a small block. */
@container page (max-width: 640px) {
  .table.responsive thead { display: none; }
  .table.responsive tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px var(--card-pad); border-bottom: 1px solid var(--line); }
  .table.responsive tbody tr:last-child { border-bottom: 0; }
  .table.responsive td { display: block; padding: 0 !important; border: 0; grid-column: 1; }
  .table.responsive td.col-actions, .table.responsive td.col-end { grid-column: 2; grid-row: 1 / span 3; align-self: center; }
  .table.responsive td.col-check { display: none; }
  .table.responsive td[data-label]::before { content: attr(data-label) " · "; color: var(--muted); font-size: .84rem; }
  .table.responsive td.num { text-align: left; }
  .table.responsive td:empty { display: none; }
}

.toolbar { display: flex; align-items: center; gap: 10px; padding: 12px var(--card-pad); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar .grow { flex: 1 1 320px; max-width: 560px; }
.toolbar .select { width: auto; min-width: 150px; max-width: 280px; }
.toolbar .end { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 0; padding: 0 var(--card-pad); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 8px; padding: 13px 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.is-active { color: var(--text); font-weight: 600; }
.tab.is-active::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.tab .count { min-width: 20px; height: 18px; padding: 0 5px; border-radius: var(--r-sm); display: inline-grid; place-items: center; font: 500 .72rem/1 var(--mono);
  background: var(--neutral-soft); color: var(--neutral-text); }
.tab.is-active .count { background: var(--accent-soft); color: var(--accent-on-soft); }

.bulkbar {
  position: sticky; bottom: 18px; z-index: 20; margin: 14px auto 0; width: fit-content; max-width: 100%;
  display: flex; align-items: center; gap: 12px; padding: 7px 7px 7px 16px; border-radius: var(--r-lg);
  background: var(--text); color: var(--canvas); box-shadow: var(--shadow-lg);
}
.bulkbar[hidden] { display: none; }
.bulkbar .btn { --btn-bg: transparent; --btn-fg: var(--canvas); --btn-line: color-mix(in srgb, var(--canvas) 30%, transparent); --btn-hover: color-mix(in srgb, var(--canvas) 14%, transparent); }
.bulkbar .btn-primary { --btn-bg: var(--canvas); --btn-fg: var(--text); --btn-line: var(--canvas); --btn-hover: color-mix(in srgb, var(--canvas) 86%, var(--text)); }
.bulkbar strong { font-weight: 600; }

/* ── empty states: words first, a quiet mark ────────────────────────── */
.empty { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 44px 24px; color: var(--muted); }
.empty-icon { color: var(--faint); margin-bottom: 4px; }
.empty-icon .i { width: 26px; height: 26px; stroke-width: 1.4; }
.empty strong { color: var(--text); font-size: 1rem; font-weight: 600; }
.empty p { max-width: 52ch; }
.empty .row { justify-content: center; margin-top: 10px; }
.empty.sm { padding: 24px 16px; }

/* ── description lists ──────────────────────────────────────────────── */
.dl { display: grid; grid-template-columns: minmax(120px, min(34%, 220px)) minmax(0, 1fr); column-gap: 16px; margin: 0; }
.dl > dt, .dl > dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); }
.dl > dt { color: var(--muted); font-size: .88rem; }
.dl > dd { font-weight: 450; overflow-wrap: break-word; color: var(--text); min-width: 0; }
.dl > :nth-last-child(-n+2) { border-bottom: 0; }
.dl.tight > dt, .dl.tight > dd { padding: 6px 0; }
.dl .none { color: var(--faint); font-weight: 400; }
/* Label above value, in as many columns as fit (facts of a person, a phone). */
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 0 24px; margin: 0; }
.facts > div { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.facts dt { color: var(--muted); font-size: .8rem; margin-bottom: 2px; }
.facts dd { margin: 0; font-weight: 450; overflow-wrap: break-word; }
.kv { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); font-size: .84rem; }
.kv b { color: var(--text-2); font-weight: 550; }

/* ── stats: a strip of figures ──────────────────────────────────────── */
.stat { padding: 16px var(--card-pad) 18px; display: grid; gap: 4px; position: relative; overflow: hidden; align-content: start; }
.stat-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat-label { color: var(--muted); font: 600 .7rem/1.2 var(--font); text-transform: uppercase; letter-spacing: .08em; }
.stat-icon { display: none; } /* figures carry the meaning */
.stat-value { font: 600 2.1rem/1.05 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--text); margin-top: 6px; }
.stat-foot { color: var(--muted); font-size: .84rem; display: flex; align-items: center; gap: 6px; }
.stat-spark { display: block; width: 100%; height: 32px; margin-top: 6px; }
/* One card holding several figures, divided by rules. */
.statbar { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.statbar > .stat { border-left: 1px solid var(--line); }
.statbar > .stat:first-child { border-left: 0; }

/* ── charts (server-rendered SVG; colours from tokens) ──────────────── */
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: var(--chart-grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font: 400 11px var(--font); }
.chart .bar-1 { fill: var(--chart-1); }
.chart .bar-2 { fill: var(--chart-2); }
.chart .bar-1, .chart .bar-2 { transition: opacity var(--ease); }
.chart .day:hover .bar-1, .chart .day:hover .bar-2 { opacity: .8; }
.chart .day .hit { fill: transparent; }
.chart .day:hover .hit { fill: var(--surface-3); }
.chart .spark-line { fill: none; stroke: var(--chart-1); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.chart .spark-area { fill: color-mix(in srgb, var(--chart-1) 10%, transparent); }
.chart-box { max-height: 300px; }
.chart .grid-line, .chart .spark-line { vector-effect: non-scaling-stroke; }
/* Bar chart: a stretched plot of fixed height, with HTML labels that keep their size. */
.bars { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 220px auto; column-gap: 12px; padding-top: 8px; }
.bars-y { display: flex; flex-direction: column; justify-content: space-between; color: var(--muted); font: 400 .74rem/1 var(--mono); }
.bars-y span { height: 0; display: flex; align-items: center; justify-content: flex-end; }
.bars-plot { grid-column: 2; width: 100%; height: 100%; display: block; overflow: visible; }
.bars-x { grid-column: 2; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); padding-top: 8px; color: var(--muted); font-size: .76rem; text-align: center; white-space: nowrap; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .85rem; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 1px; display: inline-block; }
.legend .l-1 { background: var(--chart-1); } .legend .l-2 { background: var(--chart-2); }
.legend .l-3 { background: var(--chart-3); } .legend .l-4 { background: var(--chart-4); } .legend .l-5 { background: var(--line-strong); }
.funnel { display: grid; gap: 12px; }
.funnel-row { display: grid; grid-template-columns: 120px 1fr 48px; gap: 12px; align-items: center; font-size: .9rem; }
.funnel-row .f-label { color: var(--muted); }
.funnel-row .f-val { text-align: right; font: 500 .9rem var(--mono); }
.meter { width: 100%; height: 6px; border: 0; border-radius: 1px; background: var(--surface-3); overflow: hidden; appearance: none; display: block; }
.meter::-webkit-progress-bar { background: var(--surface-3); border-radius: 1px; }
.meter::-webkit-progress-value { background: var(--accent); border-radius: 1px; }
.meter::-moz-progress-bar { background: var(--accent); border-radius: 1px; }
.meter.tone-ok::-webkit-progress-value { background: var(--chart-2); } .meter.tone-ok::-moz-progress-bar { background: var(--chart-2); }
.meter.tone-warn::-webkit-progress-value { background: var(--chart-3); } .meter.tone-warn::-moz-progress-bar { background: var(--chart-3); }
.meter.tone-bad::-webkit-progress-value { background: var(--chart-4); } .meter.tone-bad::-moz-progress-bar { background: var(--chart-4); }
.meter.sm { height: 4px; }

/* ── lists ──────────────────────────────────────────────────────────── */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px var(--card-pad); border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list a.li-link { display: flex; align-items: center; gap: 12px; color: inherit; margin: -11px calc(-1 * var(--card-pad)); padding: 11px var(--card-pad); flex: 1; min-width: 0; }
.list a.li-link:hover { background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); text-decoration: none; }
/* A status mark: a small icon in the tone's colour, no tinted tile. */
.li-icon { width: 26px; height: 26px; display: grid; place-items: center; flex: none; color: var(--muted); border-radius: var(--r-sm); border: 1px solid var(--line); }
.li-icon .i { width: 15px; height: 15px; }
.li-icon.tone-ok { color: var(--ok-text); border-color: var(--ok-line); }
.li-icon.tone-warn { color: var(--warn-text); border-color: var(--warn-line); }
.li-icon.tone-bad { color: var(--bad-text); border-color: var(--bad-line); }
.li-icon.tone-info { color: var(--info-text); border-color: var(--info-line); }
.li-icon.tone-accent { color: var(--accent-text); border-color: var(--accent-soft-2); }
.li-title { font-weight: 550; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-sub { color: var(--muted); font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li-end { flex: none; text-align: right; color: var(--muted); font-size: .85rem; }

/* ── timeline: a rule with markers ──────────────────────────────────── */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: 12px; padding-bottom: 16px; }
.tl li:last-child { padding-bottom: 0; }
.tl li::after { content: ""; position: absolute; left: 8px; top: 16px; bottom: -2px; width: 1px; background: var(--line-strong); }
.tl li:last-child::after { display: none; }
.tl-dot { width: 9px; height: 9px; margin: 6px 0 0 4px; background: var(--line-strong); border-radius: 1px; color: transparent; overflow: hidden; }
.tl-dot .i { display: none; }
.tl-dot.tone-ok { background: var(--ok-solid); }
.tl-dot.tone-warn { background: var(--warn-solid); }
.tl-dot.tone-bad { background: var(--bad-solid); }
.tl-dot.tone-info { background: var(--info-text); }
.tl-dot.tone-accent { background: var(--accent); }
.tl-title { font-weight: 500; }
.tl-meta { color: var(--muted); font-size: .84rem; }

/* ── avatars ────────────────────────────────────────────────────────── */
.avatar { width: 32px; height: 32px; border-radius: var(--r-md); flex: none; display: grid; place-items: center; overflow: hidden;
  background: var(--surface-3); color: var(--text-2); font: 600 .8rem/1 var(--font); object-fit: cover; }
.avatar.sm { width: 26px; height: 26px; font-size: .7rem; }
.avatar.lg { width: 44px; height: 44px; font-size: 1rem; }
.avatar.sq { border-radius: var(--r-md); }
img.avatar { background: var(--surface-3); }

/* ── dropdown menus (details/summary; JS closes on outside click) ───── */
.dd { position: relative; }
.dd > summary { list-style: none; cursor: pointer; }
.dd > summary::-webkit-details-marker { display: none; }
.dd-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 230px; max-width: min(380px, calc(100vw - 24px));
  padding: 5px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-lg);
  animation: dd-in 120ms ease-out;
}
.dd-panel.left { left: 0; right: auto; }
.dd-panel.is-floating { position: fixed; right: auto; }
.dd-panel.wide { width: 380px; }
@keyframes dd-in { from { opacity: 0; transform: translateY(-3px); } }
.dd-head { padding: 10px 10px 8px; }
.dd-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); border: 0; background: none;
  color: var(--text); font: 450 .93rem var(--font); text-align: left; cursor: pointer; }
.dd-item:hover { background: var(--surface-3); text-decoration: none; }
.dd-item .i { color: var(--muted); }
.dd-item.danger, .dd-item.danger .i { color: var(--bad-text); }
.dd-item .end { margin-left: auto; }
/* The theme button and its ticks show the theme in force: they follow <html data-theme>, also
   when a page changes it without reloading (a choice here, or one made in another portal). */
.th-ico { display: none; }
:root[data-theme="light"] .th-light, :root[data-theme="dark"] .th-dark,
:root:not([data-theme="light"]):not([data-theme="dark"]) .th-system { display: contents; }
.th-tick { visibility: hidden; }
:root[data-theme="light"] [data-set-theme="light"] .th-tick, :root[data-theme="dark"] [data-set-theme="dark"] .th-tick,
:root:not([data-theme="light"]):not([data-theme="dark"]) [data-set-theme="system"] .th-tick { visibility: visible; }
.dd-sep { height: 1px; background: var(--line); margin: 5px 4px; }
.dd-label { padding: 8px 10px 4px; font: 600 .68rem/1 var(--font); text-transform: uppercase; letter-spacing: .09em; color: var(--faint); }
.dd form { margin: 0; }
.dd-checks { display: grid; gap: 2px; padding: 4px; }
.dd-checks label { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer; font-weight: 450; }
.dd-checks label:hover { background: var(--surface-3); }

/* ── notifications ──────────────────────────────────────────────────── */
.notes { list-style: none; margin: 0; padding: 0; }
.note { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; padding: 12px var(--card-pad); border-bottom: 1px solid var(--line); position: relative; }
.note:last-child { border-bottom: 0; }
.note.is-unread { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.note.is-unread::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.note-title { font-weight: 550; color: var(--text); }
.note-title a { color: inherit; }
.note-body { color: var(--muted); font-size: .88rem; margin-top: 2px; max-width: 100ch; }
.note-time { color: var(--faint); font-size: .8rem; white-space: nowrap; }
.dd-notes { max-height: 420px; overflow: auto; margin: 0 -5px; }
.dd-notes .note { padding: 10px 16px; grid-template-columns: 26px 1fr; }

/* ── dialogs ────────────────────────────────────────────────────────── */
dialog.modal {
  width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-xl);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(9, 12, 22, .55); }
dialog.modal[open] { animation: modal-in 160ms cubic-bezier(.2, .8, .3, 1); }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px); } }
.modal-head { display: flex; gap: 14px; align-items: flex-start; padding: 22px 22px 6px; }
.modal-icon { width: 36px; height: 36px; border-radius: var(--r-md); flex: none; display: grid; place-items: center; border: 1px solid var(--bad-line); color: var(--bad-text); }
.modal-icon.tone-info { border-color: var(--info-line); color: var(--info-text); }
.modal-body { padding: 4px 22px 18px 72px; color: var(--muted); }
.modal-body .field { margin-top: 14px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 22px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }

/* ── command palette ────────────────────────────────────────────────── */
dialog.palette { width: min(680px, calc(100vw - 32px)); margin-top: 12vh; padding: 0; border: 1px solid var(--line-strong);
  border-radius: var(--r-xl); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog.palette::backdrop { background: rgba(9, 12, 22, .5); }
.pal-search { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.pal-search .i { color: var(--faint); }
.pal-search input { flex: 1; height: 54px; border: 0; outline: 0; background: transparent; color: var(--text); font: 400 1.05rem var(--font); }
.pal-search input::placeholder { color: var(--faint); }
.pal-results { max-height: min(440px, 55vh); overflow: auto; padding: 6px; }
.pal-group { padding: 10px 12px 4px; font: 600 .68rem/1 var(--font); text-transform: uppercase; letter-spacing: .09em; color: var(--faint); }
.pal-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-md); color: var(--text); cursor: pointer; }
.pal-item:hover, .pal-item.is-active { background: var(--accent-soft); color: var(--accent-on-soft); text-decoration: none; }
button.pal-item { width: 100%; border: 0; background: none; font: inherit; text-align: left; }
.pal-item .i { color: var(--muted); }
.pal-item.is-active .i { color: var(--accent-text); }
.pal-item .p-sub { margin-left: auto; color: var(--faint); font-size: .84rem; }
.pal-empty { padding: 28px; text-align: center; color: var(--muted); }
.pal-foot { display: flex; gap: 16px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: .8rem; background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.pal-foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ── licence card preview (matches the Tensai Wallet card) ──────────── */
.licence-card {
  position: relative; aspect-ratio: 1.586; width: 100%; max-width: 420px; border-radius: 12px; overflow: hidden; padding: 18px 20px;
  color: #fff; background: linear-gradient(135deg, #2f4f9e, #13234d);
  display: grid; grid-template-rows: auto 1fr auto; isolation: isolate; border: 1px solid #13234d;
}
.licence-card::before { content: ""; position: absolute; inset: 0; z-index: -1; opacity: .08;
  background: repeating-radial-gradient(circle at 110% 120%, #fff 0 1px, transparent 1px 9px); }
.lc-top { display: flex; align-items: center; justify-content: space-between; }
.lc-brand { font: 700 .96rem/1 var(--font); letter-spacing: .16em; }
.lc-kind { font: 500 .6rem/1 var(--mono); letter-spacing: .12em; opacity: .9; margin-top: 6px; }
.lc-chip { background: var(--brand-green); color: #06261c; font: 600 .64rem/1 var(--mono); letter-spacing: .08em; padding: 5px 8px; border-radius: var(--r-sm); }
.lc-mid { display: flex; align-items: center; gap: 14px; min-height: 0; }
.lc-photo { width: 64px; aspect-ratio: .8; border-radius: var(--r-md); object-fit: cover; border: 1px solid rgba(255, 255, 255, .45); background: rgba(255, 255, 255, .15); flex: none; }
.lc-name { font: 600 1.18rem/1.15 var(--font); letter-spacing: -.005em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lc-num { font: 500 .8rem var(--mono); letter-spacing: .05em; opacity: .85; margin-top: 3px; }
.lc-bottom { display: flex; justify-content: space-between; gap: 10px; }
.lc-field small { display: block; font: 500 .56rem/1.2 var(--mono); letter-spacing: .1em; opacity: .85; }
.lc-field span { font-size: .8rem; font-weight: 500; }
.lc-field.end { text-align: right; }

/* ── offer reveal ───────────────────────────────────────────────────── */
.steps { display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 36px 1fr; gap: 16px; padding: 22px var(--card-pad); border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step-num { width: 28px; height: 28px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 600 .9rem var(--mono); }
.step-num.done { background: var(--ok-soft); color: var(--ok-text); }
.step h2 { margin-bottom: 4px; }
.step .help { margin-bottom: 14px; }
.qr-frame { background: #fff; padding: 12px; border-radius: var(--r-md); border: 1px solid var(--line); width: fit-content; }
.qr-frame img { display: block; width: 220px; height: 220px; image-rendering: pixelated; }
.qr-frame.sm img { width: 120px; height: 120px; }
.copy-field { display: flex; gap: 8px; }
.copy-field .input { font-family: var(--mono); font-size: .86rem; }
.pin { display: inline-flex; gap: 8px; }
.pin span { width: 44px; height: 54px; display: grid; place-items: center; border-radius: var(--r-md); background: var(--surface-3);
  font: 500 1.65rem var(--mono); color: var(--text); }
.pin.sm span { width: 30px; height: 38px; font-size: 1.1rem; }
.reveal-grid { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: start; }
.sim-code { font-size: 1.9rem; font-weight: 600; letter-spacing: .12em; margin: 0; }
.live { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); flex-wrap: wrap; }
.live > .meter { flex: 0 0 200px; width: 200px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); position: relative; flex: none; }
.pulse::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 2px solid var(--accent); opacity: 0; animation: pulse 1.6s ease-out infinite; }
.pulse.tone-ok { background: var(--ok-solid); } .pulse.tone-ok::after { display: none; }
.pulse.tone-bad { background: var(--bad-solid); } .pulse.tone-bad::after { display: none; }
@keyframes pulse { 0% { opacity: .7; transform: scale(.6); } 100% { opacity: 0; transform: scale(1.6); } }

/* ── photos ─────────────────────────────────────────────────────────── */
.photo { width: 132px; aspect-ratio: .8; border-radius: var(--r-md); object-fit: cover; background: var(--surface-3); border: 1px solid var(--line); display: grid; place-items: center; color: var(--faint); }
.photo.sm { width: 84px; }
.sig { max-width: 220px; max-height: 70px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px; }
.uploader { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }

/* ── automations ────────────────────────────────────────────────────── */
.job { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px var(--card-pad); border-bottom: 1px solid var(--line); }
.job:last-child { border-bottom: 0; }
.job-name { font-weight: 550; color: var(--text); }
.job-name:hover { color: var(--accent-text); }
.job-meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); font-size: .84rem; margin-top: 3px; }
.job-meta span { display: inline-flex; align-items: center; gap: 5px; }
.job-meta .i { width: 13px; height: 13px; }

/* ── settings ───────────────────────────────────────────────────────── */
/* A setting's label and help next to its control, kept close on a wide window. */
.setting-row { display: grid; grid-template-columns: minmax(0, 560px) minmax(240px, 420px); justify-content: space-between; gap: 12px 32px;
  padding: 16px var(--card-pad); border-bottom: 1px solid var(--line); align-items: start; }
.setting-row:last-child { border-bottom: 0; }
.setting-row .s-label { font-weight: 550; }
.setting-row > .seg, .setting-row > .switch, .setting-row > div > .seg { justify-self: start; }
.interval { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: 8px; }
.select.w-auto, .input.w-auto { width: auto; min-width: 180px; }
.setting-row .s-help { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.setting-row .s-meta { color: var(--faint); font-size: .8rem; margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
/* Settings and preferences: groups as cards in columns on a wide page. */
.settings-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, 640px), 1fr)); align-items: start; }
.settings-grid > .span-all { grid-column: 1 / -1; }
.settings-grid .setting-row { grid-template-columns: minmax(0, 1fr) minmax(200px, 300px); }
.side-nav { display: grid; gap: 4px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: var(--r-md); color: var(--text-2); font-weight: 450; }
.side-nav a:hover { background: var(--surface-3); text-decoration: none; }
.side-nav a.is-active { background: var(--accent-soft); color: var(--accent-on-soft); font-weight: 550; }

/* widget editor */
.widget-row { display: flex; align-items: center; gap: 12px; padding: 10px var(--card-pad); border-bottom: 1px solid var(--line); }
.widget-row:last-child { border-bottom: 0; }
.widget-row .grow { flex: 1; }

/* ── sign-in ────────────────────────────────────────────────────────── */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(480px, 1fr); background: var(--canvas); }
.auth-side {
  position: relative; overflow: hidden; padding: clamp(32px, 4vw, 80px); color: #fff; display: flex; flex-direction: column; justify-content: space-between;
  background-color: var(--brand-navy);
  background-image: linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 56px 56px;
}
.auth-side::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, #005dae 0 72%, var(--brand-gold) 72% 100%); }
.auth-side > * { position: relative; }
.auth-brand { display: flex; align-items: center; gap: 12px; font: 600 1.1rem/1 var(--font); letter-spacing: .02em; }
.auth-logo { display: block; width: clamp(150px, 11vw, 210px); height: auto; }
.auth-product { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; color: rgba(255, 255, 255, .8); font: 500 .78rem/1 var(--font); letter-spacing: .14em; text-transform: uppercase; }
.auth-product .wordmark { height: 20px; }
.auth-brand .sb-logo { background: #fff; color: var(--brand-navy); }
.auth-pitch h2 { color: #fff; font: 600 clamp(2rem, 1.2rem + 1.7vw, 3.4rem)/1.08 var(--font); letter-spacing: -.025em; max-width: 15ch; }
.auth-pitch p { color: rgba(255, 255, 255, .8); font-size: 1.05rem; max-width: 44ch; margin-top: 18px; }
.auth-points { display: grid; gap: 0; margin-top: 32px; max-width: 46ch; border-top: 1px solid rgba(255, 255, 255, .16); }
.auth-points div { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, .16); color: rgba(255, 255, 255, .9); }
.auth-points .i { color: var(--nav-accent); }
.auth-foot-note { color: rgba(255, 255, 255, .66); font: 400 .8rem var(--mono); letter-spacing: .03em; }
.auth-main { display: grid; align-content: start; justify-items: center; padding: max(40px, 14vh) 24px 40px; }
.auth-card { width: 100%; max-width: clamp(400px, 26vw, 480px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: clamp(28px, 2.2vw, 40px); }
.auth-card.wide { max-width: clamp(480px, 32vw, 600px); }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 8px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .env { margin-bottom: 20px; }
.code-input { font: 500 1.35rem/1 var(--mono) !important; letter-spacing: .4em; text-align: center; height: 48px !important; max-width: 16ch; }
.auth-card .code-input { max-width: none; }
.secret { font-family: var(--mono); font-size: .9rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; word-break: normal; overflow-wrap: normal; letter-spacing: .04em; }
.enrol { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: center; margin: 6px 0 22px; }
.enrol .qr-frame img { width: 168px; height: 168px; }
.numbered { margin: 0 0 18px; padding-left: 22px; color: var(--muted); }
.numbered li { margin-bottom: 6px; }
.numbered strong { color: var(--text); }

/* ── dashboard grid ─────────────────────────────────────────────────── */
.dash { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); grid-auto-flow: row dense; align-items: stretch; }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-6 { grid-column: span 6; } .span-4 { grid-column: span 4; }
.lc-pair { display: grid; grid-template-columns: minmax(240px, 360px) minmax(0, 1fr); gap: 28px; align-items: center; }
.btn.is-copied { --btn-line: var(--ok-line); color: var(--ok-text); }

/* A button that steps through match the device, light and dark (theme.js). */
.theme-cycle .i { display: none; }
.theme-cycle[data-current="system"] .t-system, .theme-cycle[data-current="light"] .t-light, .theme-cycle[data-current="dark"] .t-dark,
.theme-cycle:not([data-current]) .t-system { display: block; }

/* ── utilities ──────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .86rem; }
.tiny { font-size: .8rem; }
.strong { font-weight: 600; }
.tone-bad-text { color: var(--bad-text); }
.email-reports-off { margin: 0 var(--card-pad) 14px; }
.email-delivery { min-width: 150px; max-width: 280px; }
.login-forgot { margin: -6px 0 14px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plain-list li { display: flex; gap: 8px; align-items: flex-start; }
.plain-list li.row-between { justify-content: space-between; }
.plain-list .i { margin-top: 2px; flex: 0 0 auto; }
.tpl-list { padding: 4px var(--card-pad) 8px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); column-gap: 28px; }
.tpl-item { padding: 14px 0; border-bottom: 1px solid var(--line); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 28px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 20px; }
.inline { display: inline; }
.hidden, [hidden] { display: none !important; }
.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; }
.ok-text { color: var(--ok-text); } .warn-text { color: var(--warn-text); } .bad-text { color: var(--bad-text); } .accent-text { color: var(--accent-text); }
.divider { height: 1px; background: var(--line); margin: var(--gap) 0; }
.skip-link { position: absolute; left: 12px; top: -40px; z-index: 100; padding: 8px 12px; border-radius: var(--r-sm); background: var(--accent); color: var(--accent-ink); }
.skip-link:focus { top: 12px; }
/* Device-specific copy and controls: a phone or tablet, or a computer with a mouse. */
@media (hover: hover) and (pointer: fine) { .only-touch { display: none !important; } }
@media not ((hover: hover) and (pointer: fine)) { .only-mouse { display: none !important; } }

/* ── components that adapt to the page's width (container queries) ──── */
@container page (max-width: 1500px) {
  .lc-pair { grid-template-columns: minmax(220px, 300px) minmax(0, 1fr); gap: 22px; }
}
@container page (max-width: 1180px) {
  .split, .split-wide { grid-template-columns: minmax(0, 1fr); }
  .sticky-side { position: static; }
  .span-8, .span-6 { grid-column: span 12; }
  .span-4 { grid-column: span 6; }
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@container page (max-width: 900px) {
  .fsec { grid-template-columns: 1fr; gap: 14px; }
  .lc-pair { grid-template-columns: 1fr; }
  .setting-row, .settings-grid .setting-row { grid-template-columns: 1fr; }
  .span-4 { grid-column: span 12; }
  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields > .field, .fields > .w-1, .fields > .w-3, .fields > .w-4 { grid-column: span 1; }
  .fields > .w-full { grid-column: 1 / -1; }
  .reveal-grid, .uploader { grid-template-columns: 1fr; }
}
@container page (max-width: 560px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fields { grid-template-columns: 1fr; }
  .dl { grid-template-columns: minmax(96px, 38%) minmax(0, 1fr); }
  .page-head { padding-bottom: 16px; }
  .ph-actions { width: 100%; }
  .ph-actions .btn-primary { order: -1; }
  .form-actions .grow { flex-basis: 100%; }
  .statbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .statbar > .stat:nth-child(odd) { border-left: 0; }
  .statbar > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}

/* ── the window (shell only) ────────────────────────────────────────── */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 70; left: 0; top: 0; width: 272px; transform: translateX(-100%); transition: transform var(--ease); box-shadow: var(--shadow-lg); }
  .app.is-nav-open .sidebar { transform: none; }
  [data-sidebar="collapsed"] .sidebar .sb-name, [data-sidebar="collapsed"] .sidebar .sb-section,
  [data-sidebar="collapsed"] .sidebar .sb-label, [data-sidebar="collapsed"] .sidebar .sb-count { display: revert; }
  [data-sidebar="collapsed"] .sidebar .sb-link { justify-content: flex-start; padding: 0 10px; }
  .sb-toggle { display: none !important; }
  .iconbtn.tb-menu { display: inline-grid; }
  .tb-search .tb-search-text, .tb-search .kbd { display: none; }
  .tb-search { flex: 0 0 auto; width: 36px; padding: 0; justify-content: center; }
  /* Sign-in: the brand panel becomes a band above the form. */
  .auth { grid-template-columns: 1fr; }
  .auth-side { padding: 22px 20px 26px; gap: 14px; justify-content: flex-start; }
  .auth-logo { width: 120px; }
  .auth-product { margin-bottom: 10px; }
  .auth-pitch h2 { font-size: 1.45rem; max-width: none; }
  .auth-pitch p, .auth-foot-note { display: none; }
  .auth-points { margin-top: 10px; font-size: .88rem; }
  .auth-points div:not(:last-child) { display: none; }
  .auth-main { padding: 24px 16px 40px; }
  .auth-card { max-width: 520px; padding: 24px 20px; }
  .enrol { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .modal-body { padding-left: 22px; }
}
@media print {
  .sidebar, .topbar, .bulkbar, .toasts, .ph-actions { display: none !important; }
  .app { display: block; }
  body { background: #fff; }
}

/* ── licence requests ──────────────────────────────────────────────────────── */
.sb-count.is-alert { background: var(--gold-text); color: #10151f; }
.sb-link.is-active .sb-count.is-alert { background: var(--gold-text); }
.clamp-1 { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.req-person { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 18px; align-items: start; padding: 16px var(--card-pad) 4px; }
.req-steps { list-style: none; margin: 0; padding: 0; }
.req-steps li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; padding: 12px var(--card-pad); border-top: 1px solid var(--line); font-size: .88rem; color: var(--text-2); }
.req-steps li:first-child { border-top: 0; }
.req-steps .n { font: 500 .76rem/1.35rem var(--mono); color: var(--accent-text); }
@media (max-width: 600px) {
  .req-person { grid-template-columns: 1fr; }
}
