/* ekte web UI v2 — shared type, shape and base components.
 *
 * The "calm lab report" language (emerald and warm neutrals, system font
 * stacks (no web fonts), generous radii) as ONE stylesheet every v2 page links,
 * right after the colour tokens:
 *   <link rel="stylesheet" href="/static/tokens.css" />
 *   <link rel="stylesheet" href="/static/ekte.css" />
 *
 * Rules for pages:
 *   - colours only through the tokens in tokens.css, never a literal (every
 *     page must work light + dark; tokens.css holds both themes);
 *   - page-specific CSS lives in the page (or its own /static/<name>.css).
 *
 * Themes: tokens.css follows prefers-color-scheme unless the root carries
 * data-theme="light" / "dark"; theme.js sets it from the header's theme switch.
 */

/* tokens:begin
 * The design tokens besides colour (colours: tokens.css). This block is the
 * ONE place a font size, letter-spacing, radius, control height, duration or
 * easing is written as a number; every stylesheet, page and script under
 * ekte/web/static uses var(--…) for them. tests/test_web_design_tokens.py
 * fails on a literal anywhere else (issue 213).
 */
:root {
  /* type: system font stacks only. The app is local-only, so no web fonts
   * are fetched (works offline / behind firewalls, nothing leaves the
   * machine). Latin faces first, then CJK faces, then the generic family. */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --disp: var(--sans);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  /* type scale: chart ticks and meta, small, secondary, body, fields,
     titles, key figures, large figures; the page title; the report grade */
  --t-2xs: 11px;
  --t-xs: 12px;
  --t-sm: 13px;
  --t-base: 14px;
  --t-md: 15px;
  --t-lg: 17px;
  --t-xl: 22px;
  --t-2xl: 26px;
  --t-hero: clamp(28px, 5vw, 40px);
  --t-display: 84px;
  --t-display-sm: 64px;
  /* letter-spacing: uppercase labels open up, large type tightens */
  --track-label: 0.04em;
  --track-heading: -0.01em;
  --track-hero: -0.015em;
  --track-display: -0.035em;
  /* the uppercase label (form fields, table headers, key figures, card
     sections): font-size var(--label-size), font-weight var(--label-weight),
     letter-spacing var(--track-label), text-transform uppercase */
  --label-size: var(--t-2xs);
  --label-weight: 700;
  /* spacing (4 px steps) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  /* radius by role: chart keys, chips and code, controls, inner panels and
     nested cards, page cards, pills and bars. Nested corners: inner = outer
     minus the padding, rounded to a token. */
  --r-2xs: 3px;
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-pill: 999px;
  /* control heights: dense rows and inline edits, the default, the audit form */
  --h-sm: 32px;
  --h-md: 40px;
  --h-lg: 48px;
  /* motion: hover and colour, small moves (chevrons, switches), panels and
     chart parts entering, chart lines drawing; one heat-grid colour step and
     the stagger between meters (chartmotion.js reads these too); the endless loops (busy
     markers); none (reduced motion) */
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 360ms;
  --dur-slower: 600ms;
  --dur-step: 110ms;
  --dur-stagger: 90ms;
  --dur-blink: 1s;
  --dur-spin: 1.5s;
  --dur-wait: 1.6s;
  --dur-ripple: 2.4s;
  --dur-none: 0.001ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.3, 1.25);
  /* layout */
  --wrap: 760px;
}
/* tokens:end */

/* ---------- base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  background:
    radial-gradient(700px 460px at 50% -8%, color-mix(in srgb, var(--primary) 6%, var(--bg)) 0, transparent 60%),
    radial-gradient(760px 760px at 110% 114%, color-mix(in srgb, var(--primary) 10%, var(--bg)) 0, transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--primary); }
code, kbd { font-family: var(--mono); }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 16px; }
.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;
}
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
button { font: inherit; color: inherit; }

/* ---------- shared header (rendered by /static/nav.js) ---------- */
/* skip link (BITV 9.2.4.1): off-screen until it receives keyboard focus */
.skip-link {
  position: absolute; left: 16px; top: -100px; z-index: 1000;
  padding: 8px 14px; border-radius: var(--r-pill); background: var(--ink); color: var(--bg);
  font-size: var(--t-sm); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 8px; }
main[tabindex="-1"]:focus { outline: none; }
.znav { display: flex; align-items: center; gap: 12px; padding: 18px 0 6px; min-width: 0; }
.znav .logo {
  display: flex; align-items: center; gap: 9px; flex: 0 0 auto; text-decoration: none; color: var(--ink);
  font-family: var(--disp); font-weight: 700; font-size: var(--t-xl); letter-spacing: var(--track-heading);
}
.znav .logo .b {
  width: 30px; height: 30px; border-radius: var(--r-sm); display: grid; place-items: center;
  background: var(--primary); color: var(--on-primary); box-shadow: 0 8px 22px -10px var(--primary);
}
.znav .logo .b .zicon { width: 18px; height: 18px; }
.znav .logo b { color: var(--primary); }
.znav .links {
  display: flex; gap: 4px; margin-left: auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.znav .links::-webkit-scrollbar { display: none; }
.znav .links a {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; white-space: nowrap;
  font-size: var(--t-sm); font-weight: 600; color: var(--ink-muted); text-decoration: none;
  padding: 7px 11px; border-radius: var(--r-pill); transition: background var(--dur-fast), color var(--dur-fast);
}
.znav .links a:hover { background: var(--sunken); color: var(--ink); }
.znav .links a[aria-current="page"] { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.znav .links .zicon { width: 14px; height: 14px; }
.znav .tail { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
/* Six sections no longer fit beside the logo and language switch: the links
   always get their own row (scrollable on phones). nav.js renders them after
   .tail, so DOM, reading and Tab order follow the rows (BITV 9.1.3.2 / 9.2.4.3). */
.znav { flex-wrap: wrap; row-gap: 8px; }
.znav .tail { margin-left: auto; min-width: 0; flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end; row-gap: 6px; }
.znav .links { flex: 1 0 100%; margin-left: 0; }
@media (max-width: 720px) {
  .znav .links { margin: 0 -16px; padding: 0 16px; }
}
/* the display settings (theme, motion, language): in the row on wide
   screens; on phones (issue 231) behind one button, in a popover under it, so
   the header is two rows: logo + version + settings + accessibility, then
   the section links (nav.js) */
.znav .tail { position: relative; }
.zset-panel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.znav .zset {
  display: none; align-items: center; justify-content: center; flex: none; cursor: pointer;
  width: var(--h-sm); height: var(--h-sm); padding: 0; color: var(--ink-muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}
.znav .zset:hover, .znav .zset[aria-expanded="true"] { border-color: var(--ink-muted); color: var(--primary); }
@media (max-width: 600px) {
  .znav { flex-wrap: wrap; padding-top: 14px; }
  .znav .tail { flex-wrap: nowrap; }
  .znav .zset { display: inline-flex; }
  .zset-panel {
    position: absolute; z-index: 30; top: calc(100% + 6px); right: 0; flex-direction: column; align-items: stretch;
    width: max-content; max-width: calc(100vw - 32px); padding: var(--s-3); gap: var(--s-2);
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-pop);
  }
  .zset-panel:not(.open) { display: none; }
}
/* a row that scrolls sideways (nav.js EkteScroll.fade) fades at the edge
   (a mask: only its alpha counts, the colour is any opaque token)
   that hides more of it, so the hidden items show as such */
.scroll-x { --fl: 0px; --fr: 0px; }
.scroll-x.fl { --fl: 28px; }
.scroll-x.fr { --fr: 28px; }
.scroll-x.fl, .scroll-x.fr {
  -webkit-mask-image: linear-gradient(to right, transparent 0, var(--ink) var(--fl), var(--ink) calc(100% - var(--fr)), transparent 100%);
  mask-image: linear-gradient(to right, transparent 0, var(--ink) var(--fl), var(--ink) calc(100% - var(--fr)), transparent 100%);
}

/* ---------- pills / language switch ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); color: var(--ink-muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 6px 12px;
  text-decoration: none; white-space: nowrap;
}
.pill b { color: var(--primary); }
.lang-sel,
.theme-sel,
.motion-sel {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  font-family: var(--sans); font-size: var(--t-xs); font-weight: 600; color: var(--ink-muted);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-pill);
  min-height: var(--h-sm); padding: 4px 26px 4px 12px; transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 13px center, right 9px center;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
.lang-sel:hover,
.theme-sel:hover,
.motion-sel:hover { border-color: var(--ink-muted); }
.lang-sel:focus-visible,
.theme-sel:focus-visible,
.motion-sel:focus-visible { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
/* icon-only link to the accessibility report (nav.js), as tall as the switches;
   focus keeps the global teal outline (the current-page state already has a teal border) */
.znav .a11y {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--h-sm); height: var(--h-sm); color: var(--ink-muted); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); border-radius: 50%;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), color var(--dur-fast);
}
.znav .a11y .zicon { width: 16px; height: 16px; }
.znav .a11y:hover { border-color: var(--ink-muted); color: var(--primary); }
.znav .a11y[aria-current="page"] { color: var(--primary); border-color: var(--primary); }
/* the running version, a link to its changelog (nav.js), as tall as the switches */
.znav .ver {
  display: inline-flex; align-items: center; flex: none; white-space: nowrap;
  font-family: var(--mono); font-size: var(--t-xs); font-weight: 600; color: var(--ink-muted);
  text-decoration: none; padding: 6px 4px; border-radius: var(--r-pill);
}
.znav .ver:hover { color: var(--primary); text-decoration: underline; }

/* ---------- hero ---------- */
.hero { padding: 24px 0 4px; }
.hero h1 {
  font-family: var(--disp); font-weight: 700; font-size: var(--t-hero);
  line-height: 1.12; letter-spacing: var(--track-hero); margin: 0; overflow-wrap: anywhere;
}
/* Negative tracking was tuned for Latin display faces; CJK glyphs are
 * full-width and look cramped with it, so Chinese headings use none. */
:lang(zh) .hero h1, :lang(zh) .znav .logo { letter-spacing: 0; }
.hero h1 .u { background: linear-gradient(transparent 62%, var(--highlight) 0); padding: 0 4px; color: inherit; }
.hero p { color: var(--ink-muted); font-size: var(--t-md); line-height: 1.6; margin: 12px 0 0; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-card); }
/* one card padding (--pad, issue 230): every page-level card, the filter
   panel and the page notice inset their content by it, so text in the
   column starts at two x positions only: the hero's and the cards' */
:root { --pad: var(--s-5); }
@media (max-width: 520px) { :root { --pad: 18px; } }
.card-pad { padding: var(--pad); }
/* the page's main block: a card whose first child is the tab switch
   (.tabs[role=tablist]); the selected tab's panel opens inside it */

/* ---------- the page template (issue 230) ----------
   every page's <main> is one column, in this order:
     .hero  →  page notice (.znote#note …)  →  .toolbar (the filters and the
     page's own actions, e.g. Export, API key storage)  →  the content
     (a .tab-card, or the page's cards)
   with one gap between the blocks (--s-5); no block sets a margin of its
   own (an empty live region or a visually hidden one takes no gap) */
main#main { display: flow-root; }
main#main > * { margin-top: 0; margin-bottom: 0; }
main#main > :not(:empty):not(.sr-only) ~ :not(:empty):not(.sr-only) { margin-top: var(--s-5); }
.toolbar { display: flex; flex-direction: column; gap: var(--s-3); min-width: 0; }
.toolbar[hidden] { display: none; }
/* a toolbar's own actions: one row, right-aligned (left on phones) */
.tool-row { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: var(--s-2) var(--s-3); min-width: 0; }
.tool-row:not(:has(> :not([hidden]))) { display: none; }
@media (max-width: 600px) { .tool-row { justify-content: flex-start; } }
.section-title { font-family: var(--disp); font-weight: 600; font-size: var(--t-lg); margin: 28px 0 12px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.section-title .count { font-family: var(--sans); font-size: var(--t-xs); font-weight: 600; color: var(--ink-muted); white-space: nowrap; }

/* ---------- form fields ---------- */
.grp { margin-bottom: 14px; min-width: 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 560px) { .two, .three { grid-template-columns: 1fr; } }
.lab-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 0 0 7px; flex-wrap: wrap; }
.lab {
  display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap; margin: 0 0 7px;
  font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: var(--track-label); color: var(--ink-muted); text-transform: uppercase;
}
.lab-row .lab { margin: 0; }
/* a technical key shown next to a human label — never uppercased */
.key {
  font-family: var(--mono); font-size: var(--t-2xs); font-weight: 500; letter-spacing: 0; text-transform: none;
  color: var(--ink-muted); background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 0 5px;
}
/* "optional" suffix on a label */
.opt { font-size: var(--t-xs); font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--ink-muted); }
.aside { font-size: var(--t-xs); color: var(--ink-muted); }
.in {
  width: 100%; min-width: 0; border: 1.5px solid var(--border); background: var(--surface); color: var(--ink);
  border-radius: var(--r-sm); font-family: var(--sans); font-weight: 500; font-size: var(--t-md);
  min-height: var(--field-h, var(--h-md)); padding: 6px 14px;
  outline: none; transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}
/* control heights (issue 213): three sizes, --h-sm / --h-md / --h-lg. A field
   or button takes --field-h / --btn-h from its context (default --h-md), as a
   minimum: larger text (zoom, text-spacing overrides) still fits. */
.in::placeholder { color: var(--ink-muted); font-weight: 400; font-style: italic; opacity: 1; }
.in:hover { border-color: var(--ink-muted); }
.in:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint); background: var(--surface); }
.in.mono, textarea.in { font-family: var(--mono); font-size: var(--t-sm); }
select.in {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: right 19px center, right 14px center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  text-overflow: ellipsis;
}
.hint { font-size: var(--t-xs); color: var(--ink-muted); margin-top: 6px; line-height: 1.45; }

/* Selection has three looks, one per level (issue 225): a primary tab is a
   raised surface pill, a secondary tab an underline, and a choice inside a
   panel (segmented control, radio segment, chip) a primary-tint wash with a
   primary border and text. A solid primary fill is kept for the one main
   action of a view (.btn.primary, .cta). */
/* segmented control: <div class="seg" role="group"><button aria-pressed="true">… */
.seg { display: flex; gap: 7px; flex-wrap: wrap; }
.seg button {
  flex: 1 1 0; min-width: 64px; cursor: pointer; font-family: var(--sans); font-weight: 600; font-size: var(--t-sm);
  color: var(--ink-muted); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-sm);
  min-height: var(--h-md); padding: 6px 8px; transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.seg button:hover:not(:disabled) { border-color: var(--line); color: var(--ink); }
.seg button[aria-pressed="true"] { color: var(--primary); background: var(--primary-tint); border-color: var(--primary); }
.seg button:disabled { opacity: 0.45; cursor: not-allowed; }

/* native radios dressed as a segmented control (the audit's endpoint type,
   the monitors' key storage): <div class="seg radio"><span><input type=radio>
   <label>…</label></span>…; one column per option, stacked on phones so a
   long label (e.g. "Riordinamento") does not push a 320 px page sideways */
.seg.radio { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(min-content, 1fr); }
@media (max-width: 480px) { .seg.radio { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); } }
.seg.radio > span { position: relative; display: grid; }
.seg.radio label {
  display: flex; align-items: center; justify-content: center; text-align: center; cursor: pointer; font-family: var(--sans); font-weight: 600; font-size: var(--t-sm);
  color: var(--ink-muted); background: var(--surface); border: 1.5px solid transparent; border-radius: var(--r-sm);
  min-height: var(--h-md); padding: 6px 8px; transition: background var(--dur-fast), color var(--dur-fast);
}
/* a small one (a toolbar setting, e.g. the monitors' key storage) */
.seg.sm button, .seg.radio.sm label { min-height: var(--h-sm); padding: 3px 12px; }
/* the radio itself covers its option: it draws the boundary (3:1, like the
   text fields) and carries the focus ring */
.seg.radio input {
  appearance: none; position: absolute; inset: 0; z-index: 1; margin: 0; cursor: pointer;
  border: 1.5px solid var(--border); border-radius: var(--r-sm); background: transparent; transition: border-color var(--dur-fast);
}
.seg.radio input:hover { border-color: var(--ink-muted); }
.seg.radio input:hover + label { color: var(--ink); }
.seg.radio input:checked { border-color: var(--primary); }
.seg.radio input:checked + label { color: var(--primary); background: var(--primary-tint); }
.seg.radio input:disabled { cursor: not-allowed; }
.seg.radio input:disabled + label { opacity: 0.6; }

/* multi-select chips: <div class="chips" role="group"><button aria-pressed="true">… (each toggles) */
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chips button {
  cursor: pointer; font-family: var(--sans); font-weight: 600; font-size: var(--t-sm);
  color: var(--ink-muted); background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-pill);
  min-height: var(--h-sm); padding: 4px 12px; transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.chips button:hover:not(:disabled) { border-color: var(--line); color: var(--ink); }
.chips button[aria-pressed="true"] { color: var(--primary); background: var(--primary-tint); border-color: var(--primary); }
.chips button[aria-pressed="true"]::before { content: "✓ "; }
.chips button:disabled { opacity: 0.45; cursor: not-allowed; }

/* switch: <label class="switch"><input type="checkbox" role="switch"><span></span> text</label>
   The input itself is the visible track (so the focused element is the one on
   screen, with its own focus ring); the span is only the knob drawn over it. */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--t-base); color: var(--ink-muted); }
.switch input {
  -webkit-appearance: none; appearance: none; margin: 0; cursor: pointer;
  position: relative; width: 38px; height: 22px; flex: 0 0 38px; border-radius: var(--r-pill);
  background: var(--sunken); border: 1px solid var(--border); transition: background var(--dur-fast);
}
.switch span {
  position: absolute; left: 3px; top: 50%; margin-top: -8px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 3px var(--shadow); transition: transform var(--dur-fast); pointer-events: none;
}
/* off: an --ink-muted knob on the --sunken track (a --surface knob all but
   vanished there in dark mode); on: a --surface knob on the --primary track */
.switch input:not(:checked) + span { background: var(--ink-muted); box-shadow: none; }
.switch input:checked { background: var(--primary); border-color: var(--primary); }
.switch input:checked + span { transform: translateX(16px); }
.switch input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled { cursor: not-allowed; opacity: 0.5; }
.switch input:disabled + span { opacity: 0.5; }
/* forced colours drop backgrounds: draw the knob and the "on" track in system colours */
@media (forced-colors: active) {
  .switch span, .switch input:not(:checked) + span { forced-color-adjust: none; background: CanvasText; box-shadow: none; }
  .switch input:checked { forced-color-adjust: none; background: Highlight; border-color: Highlight; }
  .switch input:checked + span { background: HighlightText; }
}

/* the Disclosure (issue 227): always a button and a region,
   <button class="disclosure" aria-expanded aria-controls="…"> + <div id="…"
   class="disclosure-body" hidden>. The chevron sits on the right of a
   standalone block, on the left (.lead) in a list of rows or groups.
   Optional frame .disclosure-box: solid with --r-md corners; dashed only
   for an "add" affordance (.disclosure-box.add). Pages without a handler of
   their own mark the button data-disclosure: disclosure.js toggles it. */
.disclosure-box { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.disclosure-box.add { border: 1.5px dashed var(--line); }
.disclosure-box:has(> .disclosure[aria-expanded="true"]) { background: var(--sunken); }
.disclosure {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left;
  background: none; border: 0; cursor: pointer; font-family: var(--sans); font-weight: 700; font-size: var(--t-base);
  color: var(--ink-muted); padding: 13px 14px;
}
.disclosure[aria-expanded="true"] { color: var(--primary); }
.disclosure .cv { display: inline-flex; flex: none; transition: transform var(--dur-base); }
.disclosure[aria-expanded="true"] .cv { transform: rotate(180deg); }
/* in a list: the chevron leads, pointing right when shut, down when open */
.disclosure.lead { justify-content: flex-start; }
.disclosure.lead .cv { order: -1; transform: rotate(-90deg); }
.disclosure.lead[aria-expanded="true"] .cv { transform: none; }
.disclosure-body { padding: 2px 14px 14px; }
.disclosure-body[hidden] { display: none; }

/* ---------- buttons ---------- */
.cta {
  width: 100%; border: 0; border-radius: var(--r-sm); min-height: var(--h-lg); padding: 8px 16px; cursor: pointer;
  font-family: var(--disp); font-weight: 600; font-size: var(--t-lg); color: var(--on-primary); background: var(--primary);
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: background var(--dur-fast);
}
.cta:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--primary-strong); }
/* aria-disabled: busy but still focusable (focus must not fall to <body>) */
.cta:disabled, .cta[aria-disabled="true"] { opacity: 0.55; cursor: wait; }
.cta .zicon { width: 1em; height: 1em; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; cursor: pointer; text-decoration: none;
  border-radius: var(--r-sm); min-height: var(--btn-h, var(--h-md)); padding: 6px 16px; font-family: var(--disp); font-weight: 600; font-size: var(--t-base);
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  transition: border-color var(--dur-fast), background var(--dur-fast);
}
.btn:hover:not(:disabled):not([aria-disabled="true"]) { border-color: var(--line); }
.btn.pri { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.pri:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--danger-tint); border-color: var(--danger); }
/* a group of actions (issue 230): each button as wide as its label, the
   row right-aligned (left on phones), the one primary action last; a
   destructive action is a plain .btn.danger beside it, never a wide block.
   Only the page's single submit (the audit's Start audit, .cta) is full width. */
.actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s-2) var(--s-3); margin-top: var(--s-4); min-width: 0; }
.actions > .btn { flex: none; max-width: 100%; white-space: normal; text-align: center; }
.actions > .hint, .actions > .ask { margin: 0 auto 0 0; }
@media (max-width: 600px) { .actions { justify-content: flex-start; } .actions > .hint, .actions > .ask { flex-basis: 100%; } }
.btn.sm { min-height: var(--h-sm); padding: 4px 11px; font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn .zicon { width: 1em; height: 1em; }
.linkbtn {
  background: none; border: 0; padding: 0; cursor: pointer; font-family: var(--sans); font-weight: 700;
  font-size: var(--t-sm); color: var(--primary);
}
.linkbtn:hover { text-decoration: underline; }

/* ---------- status badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; border-radius: var(--r-pill);
  font-family: var(--sans); font-weight: 700; font-size: var(--t-xs); padding: 3px 10px;
}
.badge .zicon { width: 1em; height: 1em; }
.badge.good { color: var(--success); background: var(--success-tint); }
.badge.warn { color: var(--warning); background: var(--warning-tint); }
.badge.bad { color: var(--danger); background: var(--danger-tint); }
.badge.sky { color: var(--info); background: var(--info-tint); }
.badge.fair { color: var(--fair); background: var(--fair-tint); }
.badge.grey { color: var(--ink-muted); background: var(--sunken); }
/* who decides a step (accessibility report): solid = the whole, light = the part */
.badge.machine { color: var(--on-primary); background: var(--machine); }
.badge.machine-soft { color: var(--info); background: var(--machine-tint); }
.badge.human { color: var(--on-primary); background: var(--human); }
.badge.human-soft { color: var(--human); background: var(--human-tint); }

/* ---------- messages ---------- */
.reassure { text-align: center; font-size: var(--t-sm); color: var(--ink-muted); margin-top: 13px; line-height: 1.5; }
.reassure b { color: var(--ink-muted); }
/* The Callout (issue 226): the one box for a message that needs attention or
   action. Page size (.znote): the page notice (notice.js show), one per page,
   right under the hero; icon, text and buttons share one vertical centre line.
   Inline size (.znote.inline): inside a card or form (notice.js callout).
   The tone (info, success, warning, critical, neutral) sets tint, border and
   icon colour; the text stays --ink for contrast. Anything else is a Note
   (.note below): one muted line with an icon, no box. */
.znote {
  display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap;
  margin: 18px 0 0; padding: 12px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--sunken);
}
.znote[hidden] { display: none; }
/* the page notice (a block of <main>): its icon starts where card content does */
main#main > .znote { padding-left: var(--pad); padding-right: var(--pad); }
.znote .ico { display: inline-flex; }
.znote .ico .zicon { width: 18px; height: 18px; }
.znote .txt { flex: 1 1 260px; min-width: 0; font-size: var(--t-base); line-height: 1.45; color: var(--ink); overflow-wrap: anywhere; }
.znote .txt b { font-weight: 700; }
.znote .meta { color: var(--ink-muted); }
.znote .txt ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-muted); }
.znote .txt code { font-size: var(--t-xs); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xs); padding: 0 5px; }
.znote .act { display: flex; gap: 6px; flex-wrap: wrap; }
.znote.info { background: var(--info-tint); border-color: var(--info); }
.znote.info .ico { color: var(--info); }
.znote.success { background: var(--success-tint); border-color: var(--success); }
.znote.success .ico { color: var(--success); }
.znote.warning { background: var(--warning-tint); border-color: var(--warning); }
.znote.warning .ico { color: var(--warning); }
.znote.critical { background: var(--danger-tint); border-color: var(--danger); }
.znote.critical .ico { color: var(--danger); }
.znote.neutral .ico { color: var(--ink-muted); }
.znote.inline { margin: 14px 0 0; padding: 10px 14px; align-items: flex-start; gap: 8px 10px; }
.znote.inline .ico { margin-top: 2px; }
.znote.inline .ico .zicon { width: 16px; height: 16px; }
.znote.inline .txt { flex-basis: 200px; }
.znote.inline .txt a { font-weight: 700; }
/* the Note: an inline hint, one muted line with an info icon, no box */
.note { display: flex; gap: 8px; align-items: flex-start; margin: 0; font-size: var(--t-sm); line-height: 1.5; color: var(--ink-muted); }
.note > .zicon, .note > .pico { width: 14px; height: 14px; flex: none; margin-top: 3px; }
.note > span { min-width: 0; overflow-wrap: anywhere; }
.note ul { margin: 4px 0 0; padding-left: 18px; }
/* the EmptyState (issue 227): an icon, one sentence and an optional action,
   centred; no box (a dashed border is for "add" only). Built by
   EkteNotice.empty(text, { icon, action }) or written as
   <div class="empty"><span class="ico">…</span><p>…</p></div>. */
.empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; padding: 32px 20px; color: var(--ink-muted); font-size: var(--t-base); line-height: 1.5; }
.empty > p { margin: 0; max-width: 46ch; }
.empty .ico { display: inline-flex; color: var(--ink-muted); }
.empty .ico .zicon, .empty > .zicon { width: 28px; height: 28px; }
.empty a { font-weight: 700; }
.empty[hidden] { display: none; }

/* the Table (issue 227): every data table is <table class="tbl"> (add
   .dense for wide analysis tables): a label-style header, 10/12 px cells
   (7/8 dense), hairlines between rows, numbers right-aligned in tabular
   figures (.n), a sub-value muted under its number (.sub). A wide table
   scrolls inside its own wrapper, never the page. */
.tbl { width: 100%; border-collapse: collapse; font-size: var(--t-sm); color: var(--ink); --tbl-y: 10px; --tbl-x: 12px; }
.tbl.dense { --tbl-y: 7px; --tbl-x: 8px; font-size: var(--t-xs); }
.tbl caption { text-align: left; caption-side: top; font-size: var(--t-xs); color: var(--ink-muted); padding: 6px var(--tbl-x); }
.tbl th, .tbl td { padding: var(--tbl-y) var(--tbl-x); text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.tbl thead th {
  border-top: 0; vertical-align: bottom; color: var(--ink-muted);
  font-size: var(--label-size); font-weight: var(--label-weight); letter-spacing: var(--track-label); text-transform: uppercase;
}
.tbl tbody th { font-weight: 600; }
.tbl .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl .sub { display: block; font-size: var(--t-2xs); color: var(--ink-muted); font-weight: 400; }
.foot { text-align: center; color: var(--ink-muted); font-size: var(--t-xs); padding: 16px 0 32px; line-height: 1.6; }
.foot code { font-size: var(--t-xs); }
/* the shared disclaimer footer (nav.js): all local, black box */
.zdisc { text-align: center; color: var(--ink-muted); font-size: var(--t-xs); line-height: 1.6; padding: 16px 0 32px; }
.zdisc p { margin: 0 0 4px; }
/* a page without a footer keeps the same space below its last card as one with
   (the footer's one-line .foot: 12px margins, 16px + 32px padding, ~19px text) */
.wrap > main:last-child { padding-bottom: 24px; }

/* inline canonical SVG icons (icons.js) inherit currentColor */
.pico { display: inline-flex; vertical-align: -0.12em; }
.pico .zicon { width: 1em; height: 1em; }

/* ---------- tabs (driven by /static/tabs.js), issue 225 ----------
 * Two levels, each with one look; no page styles [role=tab] itself
 * (tests/test_web_tabs.py):
 *   primary   <div class="tabs" role="tablist">: a sunken rail; the selected
 *             tab is a raised surface pill with ink text (like the current
 *             page in the header), never a solid fill
 *   secondary <div class="tabs sub" role="tablist">: text tabs on a hairline
 *             inside a panel; the selected one is underlined in primary
 * Width: a rail of up to four tabs shares its width equally; five or more
 * take their label's width (fixed padding) and wrap. Secondary tabs are
 * always as wide as their label.
 * Slots, used alike on every bar: an icon first (every tab of a primary bar
 * has one), a count last: <span class="tab-count"> (a neutral pill; .live,
 * info tint, for work under way, e.g. running audits). A tab with nothing
 * in it (e.g. "Running" while nothing runs) stays selectable and its panel
 * says so (an empty state), on every page. */
.tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 20px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-md); }
.tabs [role="tab"] {
  flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--disp); font-weight: 600; font-size: var(--t-md); color: var(--ink-muted); cursor: pointer;
  background: transparent; border: 0; border-radius: var(--r-sm); min-height: var(--h-md); padding: 8px 14px; text-align: center;
  transition: background var(--dur-fast), color var(--dur-fast), box-shadow var(--dur-fast);
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); background: var(--surface); box-shadow: 0 0 0 1px var(--line), var(--shadow-pop); }
.tabs [role="tab"][aria-selected="true"] .zicon { color: var(--primary); }
/* five or more tabs: each as wide as its label, in one row that scrolls
   sideways where it does not fit (phones), with fading edges (nav.js) */
.tabs:has(> [role="tab"]:nth-of-type(5)) { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.tabs:has(> [role="tab"]:nth-of-type(5))::-webkit-scrollbar { display: none; }
.tabs:has(> [role="tab"]:nth-of-type(5)) > [role="tab"] { flex: 1 0 auto; white-space: nowrap; }
/* a tab tabs.js skips (aria-disabled) */
.tabs [role="tab"][aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; }
.tabs [role="tab"][aria-disabled="true"]:hover { color: var(--ink-muted); }
.tabs [role="tab"] .zicon { width: 15px; height: 15px; flex: none; }
/* secondary tabs: text on a hairline, the selected one underlined */
.tabs.sub { gap: 18px; padding: 0; margin: 0 0 18px; background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; flex-wrap: wrap; }
.tabs.sub [role="tab"] {
  flex: 0 0 auto; font-family: var(--sans); font-size: var(--t-base); border-radius: 0; padding: 8px 2px;
  margin-bottom: -1px; border-bottom: 2px solid transparent; box-shadow: none;
}
.tabs.sub [role="tab"][aria-selected="true"] { color: var(--ink); background: transparent; box-shadow: none; border-bottom-color: var(--primary); }
/* the count slot */
.tab-count {
  min-width: 1.6em; padding: 1px 7px; border-radius: var(--r-pill); font-family: var(--sans); font-size: var(--t-xs); font-weight: 700;
  font-variant-numeric: tabular-nums; line-height: 1.5; color: var(--ink-muted); background: color-mix(in srgb, var(--ink-muted) 16%, transparent);
}
.tab-count.live { color: var(--info); background: var(--info-tint); }
.tab-count:empty, .tab-count[hidden] { display: none; }
/* forced colours (Windows high contrast) drop backgrounds and shadows: give the
   primary tabs a system-coloured border so their shape stays visible and mark
   the selected one with the system highlight colours; secondary tabs keep
   their underline in Highlight */
@media (forced-colors: active) {
  .tabs [role="tab"] { border: 1px solid ButtonText; padding: 7px 13px; }
  .tabs [role="tab"][aria-selected="true"] { forced-color-adjust: none; background: Highlight; color: HighlightText; border-color: Highlight; }
  .tabs.sub [role="tab"] { border: 0; border-bottom: 2px solid transparent; padding: 8px 2px; }
  .tabs.sub [role="tab"][aria-selected="true"] { forced-color-adjust: auto; background: Canvas; color: CanvasText; border-bottom-color: Highlight; }
}
/* phones: the tabs stay side by side; a long label (e.g. ES "Auditoría de
   embeddings") wraps onto a second line between words, not mid-word */
@media (max-width: 480px) {
  .tabs { gap: 4px; padding: 4px; }
  .tabs [role="tab"] { gap: 6px; padding: 8px 6px; font-size: var(--t-base); line-height: 1.25; text-wrap: balance; overflow-wrap: break-word; }
  .tabs.sub { gap: 14px; padding: 0; }
  .tabs.sub [role="tab"] { padding: 8px 2px; }
}
[role="tabpanel"][hidden] { display: none; }
[role="tabpanel"] { animation: z-rise var(--dur-slow) var(--ease-out); }
[role="tabpanel"]:focus-visible { outline-offset: 6px; border-radius: var(--r-xs); }

/* ---------- motion ---------- */
.view { display: none; }
.view.show { display: block; animation: z-rise var(--dur-slow) var(--ease-out); }
@keyframes z-rise { from { opacity: 0; transform: translateY(10px); } }
/* the header's motion switch (theme.js: data-motion="off") stops the same as
   prefers-reduced-motion: every animation and transition, spinners included */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: var(--dur-none) !important;
    animation-iteration-count: 1 !important;
    transition-duration: var(--dur-none) !important;
    scroll-behavior: auto !important;
  }
}
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation-duration: var(--dur-none) !important;
  animation-iteration-count: 1 !important;
  transition-duration: var(--dur-none) !important;
  scroll-behavior: auto !important;
}
