/* Afrapportering: one stylesheet, no build step, no external assets.
   Works from 360 px phones to 1600 px desktops. Every colour comes from a token below.

   Reusable components (use these for new pages before adding new ones):
   - Auth layout ......... .auth > .auth-brand + .card.auth-card (centred card, brand above; pages/login.html)
   - Data table .......... .table-wrap > table.table (th scope="col"; .num for amounts)
   - Segmented control ... .segmented > label.segment > input[type=radio] + span (also the report's .rating)
   - Tabs ................ nav.tabs > a.tab[aria-current="page"] (links, so they work without JavaScript)
   - Dropdown menu ....... details.menu > summary.menu-trigger + .menu-panel > .menu-item (a or button),
                           .menu-head, .menu-sep; app.js closes it on outside click and Escape
   - Badge / chip ........ .chip.chip-{ok|warn|bad|info|muted|ai|demo}; .badge-demo, .ai-badge for inline tags
   - Stat tile ........... .tiles > .tile > .tile-label + .tile-value
   - Empty state ......... .empty-state (inside .card): .empty-icon, h2, p, .actions.center
   - Copyable value box .. .copybox > pre.copybox-value#id + button.copy[data-copy=id] (app.js copies)
   - Inline notice ....... .alert.alert-{error|warning|info|ok}; .missing for a list of what is left
   - Definition list ..... dl.facts > div > dt + dd (.facts-inline puts value right of label)
   - Card ................ .card (.card-head, .card-warning, .card-danger, .card-ok, .narrow)
   - Page head ........... .page-head > div (h1 + p.muted) + .actions
*/

:root {
  /* Brand: Europæisk Ungdom's white mark with the EU flag's blue and yellow as accents. */
  --eu-blue: #003399;
  --eu-blue-hover: #00267a;
  --eu-yellow: #ffcc00;
  --navy-950: #091733;
  --navy-900: #0f2347;
  --navy-800: #172f5c;
  --navy-700: #213d72;

  /* Neutrals */
  --white: #ffffff;
  --gray-25: #fafbfd;
  --gray-50: #f4f6fa;
  --gray-100: #edf0f5;
  --gray-200: #e1e6ee;
  --gray-300: #cdd5e0;
  --gray-500: #848ea0;   /* control borders: at least 3:1 on white */

  /* Text */
  --text: #172033;
  --text-strong: #0f2347;
  --text-muted: #556070;  /* 6.4:1 on white, 5.8:1 on the page background */
  --text-subtle: #626c7d;
  --text-on-dark: #ffffff;
  --text-on-dark-muted: #c2cde2;

  /* Surfaces and lines */
  --bg: var(--gray-50);
  --surface: var(--white);
  --surface-sunken: var(--gray-25);
  --surface-hover: #f6f8fc;
  --line: var(--gray-200);
  --line-strong: var(--gray-300);
  --control-border: var(--gray-500);

  /* Interaction */
  --primary: var(--eu-blue);
  --primary-hover: var(--eu-blue-hover);
  --link: #1546ad;
  --link-hover: var(--navy-900);
  --focus: #2563d9;
  --focus-on-dark: var(--eu-yellow);
  --selected-soft: #edf2fd;

  /* State colours: text, soft background, line, solid mark */
  --ok: #12683a;
  --ok-soft: #e7f5ec;
  --ok-line: #a6d8b9;
  --ok-solid: #1d8a4e;
  --warn: #855000;
  --warn-soft: #fff4d8;
  --warn-line: #efd28b;
  --warn-solid: #d99a00;
  --bad: #b42318;
  --bad-hover: #8f1c13;
  --bad-soft: #fdecea;
  --bad-line: #f2b8b2;
  --info: #1d4fb8;
  --info-soft: #ebf1fd;
  --info-line: #c3d5f7;
  --info-solid: #2f66d4;
  --ai: #5a2fb5;
  --ai-soft: #f4effe;
  --ai-line: #d8cbf6;
  --ai-solid: #7a4fd0;
  --demo: #6a4c00;
  --demo-soft: #fff8dc;
  --demo-line: #ecd27a;
  --track: var(--gray-200);

  /* Type */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --text-xs: .75rem;
  --text-sm: .8125rem;
  --text-md: .9375rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --leading: 1.55;
  --leading-tight: 1.25;

  /* Space (4 px steps) */
  --space-1: .25rem;
  --space-2: .5rem;
  --space-3: .75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --gutter: var(--space-6);
  --container: 1200px;
  --control-h: 2.5rem;

  /* Shape and depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-full: 999px;
  --shadow-xs: 0 1px 2px rgba(15, 35, 71, .05);
  --shadow-sm: 0 1px 2px rgba(15, 35, 71, .04), 0 2px 8px rgba(15, 35, 71, .05);
  --shadow-lg: 0 12px 32px rgba(15, 35, 71, .16), 0 2px 6px rgba(15, 35, 71, .08);
  --ring: 0 0 0 3px rgba(37, 99, 217, .28);
  --ring-bad: 0 0 0 3px rgba(180, 35, 24, .22);
  --scrim-dark: rgba(255, 255, 255, .1);
  --scrim-dark-strong: rgba(255, 255, 255, .16);
  --line-on-dark: rgba(255, 255, 255, .28);

  /* Motion */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --fast: 120ms;
  --slow: 300ms;

  color-scheme: light;
  font-family: var(--font-sans);
  font-size: 100%;
  line-height: var(--leading);
  color: var(--text);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); font-size: var(--text-md); }
a { color: var(--link); text-underline-offset: .18em; text-decoration-thickness: 1px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }
h1, h2, h3 { line-height: var(--leading-tight); margin: 0 0 var(--space-2); color: var(--text-strong); letter-spacing: -.01em; }
h1 { font-size: var(--text-2xl); font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: var(--text-lg); font-weight: 650; }
h3 { font-size: var(--text-md); font-weight: 650; }
p { margin: 0 0 var(--space-3); }
ul, ol { padding-left: 1.25rem; }
img, svg { max-width: 100%; }
code, pre, .hash { font-family: var(--font-mono); font-size: .86em; }
code { background: var(--gray-100); border-radius: 4px; padding: .05em .3em; overflow-wrap: anywhere; }
.hash, .break { overflow-wrap: anywhere; }
.muted { color: var(--text-muted); }
.small { font-size: var(--text-sm); }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.icon { width: 1em; height: 1em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.125em; }
.wrap { width: 100%; max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); }
.main { flex: 1; padding-top: var(--space-8); padding-bottom: var(--space-12); position: relative; min-width: 0; }
.skip-link { position: absolute; left: -999px; top: var(--space-2); background: var(--surface); color: var(--link); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 50; }
.skip-link:focus { left: var(--space-2); }
html:not(.js) .js-only { display: none; }
html.js .no-js-label { display: none; }
.footer { color: var(--text-muted); font-size: var(--text-xs); padding-top: var(--space-5); padding-bottom: var(--space-6); }

/* Top bar ---------------------------------------------------------------- */
.topbar { background: var(--navy-900); color: var(--text-on-dark); position: relative; z-index: 30; }
.topbar :focus-visible { outline-color: var(--focus-on-dark); }
.topbar-inner { max-width: var(--container); margin: 0 auto; padding: 0 var(--gutter); min-height: 3.75rem; display: flex; align-items: center; gap: var(--space-2) var(--space-6); }
.brand { display: flex; align-items: center; gap: var(--space-3); color: var(--text-on-dark); text-decoration: none; padding: var(--space-2) 0; flex: none; }
.brand:hover { color: var(--text-on-dark); }
.brand-mark { display: block; width: 32px; height: 34px; flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-org { font-size: var(--text-base); font-weight: 400; letter-spacing: -.01em; white-space: nowrap; }
.brand-org strong { font-weight: 700; }
.brand-branch { color: var(--eu-yellow); font-weight: 650; }
.brand-app { font-size: var(--text-xs); color: var(--text-on-dark-muted); }
.mainnav { display: flex; align-items: stretch; gap: var(--space-1); flex: 1; align-self: stretch; min-width: 0; }
.mainnav a { position: relative; display: inline-flex; align-items: center; color: var(--text-on-dark-muted); text-decoration: none; padding: 0 var(--space-3); font-size: var(--text-md); font-weight: 550; white-space: nowrap; transition: color var(--fast) var(--ease); }
.mainnav a:hover { color: var(--text-on-dark); }
.mainnav a::after { content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: 0; height: 3px; border-radius: 3px 3px 0 0; background: transparent; transition: background-color var(--fast) var(--ease); }
.mainnav a[aria-current] { color: var(--text-on-dark); }
.mainnav a[aria-current]::after { background: var(--eu-yellow); }
.mainnav a:focus-visible { outline-offset: -4px; }
.topbar-tools { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; flex: none; }
.env-chip { font-size: var(--text-xs); border: 1px solid var(--line-on-dark); color: var(--text-on-dark-muted); padding: .1rem .55rem; border-radius: var(--radius-full); white-space: nowrap; }

/* Dropdown menu (details-based, works without JavaScript) */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-trigger { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-h); padding: var(--space-1) var(--space-2) var(--space-1) var(--space-1); border-radius: var(--radius-full); cursor: pointer; user-select: none; transition: background-color var(--fast) var(--ease); }
.topbar .menu-trigger { color: var(--text-on-dark); }
.topbar .menu-trigger:hover, .topbar .menu[open] > .menu-trigger { background: var(--scrim-dark); }
.menu-caret { width: .85rem; height: .85rem; transition: transform var(--fast) var(--ease); }
.menu[open] .menu-caret { transform: rotate(180deg); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--eu-yellow); color: var(--navy-900); font-size: var(--text-xs); font-weight: 700; letter-spacing: .02em; flex: none; }
.user-name { font-size: var(--text-md); font-weight: 550; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel { position: absolute; right: 0; top: calc(100% + var(--space-2)); min-width: 15rem; max-width: min(20rem, calc(100vw - 2 * var(--space-4))); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: var(--space-2); z-index: 40; }
.menu-head { display: flex; flex-direction: column; padding: var(--space-2) var(--space-3) var(--space-3); border-bottom: 1px solid var(--line); margin-bottom: var(--space-2); }
.menu-title { font-weight: 650; color: var(--text-strong); overflow-wrap: anywhere; }
.menu-caption { font-size: var(--text-sm); color: var(--text-muted); }
.menu-sep { border: 0; border-top: 1px solid var(--line); margin: var(--space-2) 0; }
.menu-panel form { margin: 0; }
.menu-item { display: flex; align-items: center; gap: var(--space-2); width: 100%; min-height: var(--control-h); padding: var(--space-2) var(--space-3); border: 0; border-radius: var(--radius-sm); background: none; color: var(--text); font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.menu-item:hover { background: var(--surface-hover); color: var(--text-strong); }
.menu-item[aria-current] { background: var(--selected-soft); color: var(--primary); font-weight: 600; }
.menu-env { display: none; margin: 0; padding: var(--space-1) var(--space-3) var(--space-2); font-size: var(--text-sm); color: var(--text-muted); }

/* Banners, toasts, notices ------------------------------------------------ */
.banner { padding: var(--space-3) 0; font-size: var(--text-sm); }
.banner-warning { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--warn-line); }
.banner-warning a { color: var(--warn); font-weight: 600; }
.banner-demo { display: flex; gap: var(--space-3); align-items: flex-start; background: var(--demo-soft); color: var(--demo); border: 1px solid var(--demo-line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-5); font-size: var(--text-sm); }
.banner-demo .icon { margin-top: .2em; }
.toast { position: fixed; right: var(--space-6); bottom: var(--space-6); display: flex; gap: var(--space-2); align-items: center; background: var(--navy-900); color: var(--text-on-dark); padding: var(--space-3) var(--space-5); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 60; max-width: 28rem; font-weight: 500; transition: opacity var(--slow) var(--ease), transform var(--slow) var(--ease); }
.toast::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: var(--eu-yellow); flex: none; }
.toast.hide { opacity: 0; transform: translateY(8px); pointer-events: none; }
.alert { border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-4); border: 1px solid; border-left-width: 4px; font-size: var(--text-md); }
.alert-error { background: var(--bad-soft); border-color: var(--bad-line); border-left-color: var(--bad); color: var(--bad); }
.alert-warning { background: var(--warn-soft); border-color: var(--warn-line); border-left-color: var(--warn-solid); color: var(--warn); }
.alert-info { background: var(--info-soft); border-color: var(--info-line); border-left-color: var(--info); color: var(--info); }
.alert-ok { background: var(--ok-soft); border-color: var(--ok-line); border-left-color: var(--ok); color: var(--ok); }
.alert a { color: inherit; font-weight: 600; }
.alert:focus { outline: none; box-shadow: var(--ring); }
.alert:focus-visible { outline: none; }
.alert details { margin-top: var(--space-2); }
.missing { background: var(--warn-soft); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); color: var(--warn); }
.missing h3 { font-size: var(--text-sm); color: var(--warn); margin-bottom: var(--space-1); }
.missing ul { margin: 0; padding-left: 1.1rem; font-size: var(--text-sm); }
.missing li + li { margin-top: .15rem; }

/* Page layout ------------------------------------------------------------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-6); }
.page-head h1 { margin-bottom: var(--space-1); }
.page-head p { margin: 0; max-width: 46rem; }
.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.actions.center { justify-content: center; }
.actions form { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-6); margin-bottom: var(--space-5); box-shadow: var(--shadow-xs); min-width: 0; }
.card > h2:first-child { margin-bottom: var(--space-3); }
.card > details:only-child { margin: 0; }
.card.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-3); }
.card-head h2 { margin: 0; }
.card-head .muted { font-size: var(--text-sm); }
.card-warning { border-color: var(--warn-line); background: var(--warn-soft); }
.card-warning h2 { color: var(--warn); }
.card-danger { border-color: var(--bad-line); }
.card-danger h2 { color: var(--bad); }
.card-ok { border-color: var(--ok-line); background: var(--ok-soft); }
.card-ok h2 { color: var(--ok); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-5); align-items: start; }
.grid-2.wide-left { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
.grid-2 > .card, .side > .card { margin-bottom: 0; }
.side { display: grid; gap: var(--space-5); position: sticky; top: var(--space-4); }
.back { display: inline-flex; align-items: center; gap: var(--space-1); margin-bottom: var(--space-4); text-decoration: none; font-size: var(--text-sm); font-weight: 550; color: var(--text-muted); min-height: 2rem; }
.back:hover { color: var(--link); }
.empty, .empty-state { text-align: center; padding: var(--space-12) var(--space-6); }
.empty-state p { max-width: 34rem; margin-left: auto; margin-right: auto; }
.empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: 50%; background: var(--selected-soft); color: var(--primary); margin-bottom: var(--space-4); }
.empty-icon .icon { width: 1.4rem; height: 1.4rem; }

/* Buttons ----------------------------------------------------------------- */
.button { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-h); border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-strong); padding: var(--space-2) var(--space-4); border-radius: var(--radius-sm); font: inherit; font-size: var(--text-md); font-weight: 600; text-decoration: none; cursor: pointer; line-height: var(--leading-tight); box-shadow: var(--shadow-xs); transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.button:hover { background: var(--surface-hover); border-color: var(--control-border); color: var(--text-strong); }
.button.primary { background: var(--primary); border-color: var(--primary); color: var(--white); }
.button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--white); }
.button.danger { background: var(--bad); border-color: var(--bad); color: var(--white); }
.button.danger:hover { background: var(--bad-hover); border-color: var(--bad-hover); }
.button.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--link); }
.button.ghost:hover { background: var(--surface-hover); }
.button.wide { width: 100%; }
.button .icon { width: 1rem; height: 1rem; }
.link-button { display: inline; background: none; border: 0; padding: 0; color: var(--link); font: inherit; font-weight: 550; cursor: pointer; text-decoration: underline; text-underline-offset: .18em; text-decoration-thickness: 1px; }
.link-button:hover { color: var(--link-hover); }
.link-button.danger { color: var(--bad); }
.htmx-request .button[type="submit"], .button.htmx-request { opacity: .6; cursor: progress; }

/* Forms ------------------------------------------------------------------- */
.field { margin-bottom: var(--space-4); min-width: 0; }
.field label, .label { display: block; font-weight: 600; font-size: var(--text-sm); margin-bottom: var(--space-1); color: var(--text-strong); }
.req { color: var(--bad); }
input[type="text"], input[type="email"], input[type="url"], input[type="date"], input[type="password"],
input[type="search"], input[type="number"], input:not([type]), select, textarea {
  display: block; width: 100%; min-height: var(--control-h); font: inherit; font-size: var(--text-md); color: var(--text); background: var(--surface);
  border: 1px solid var(--control-border); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); opacity: 1; }
textarea { resize: vertical; line-height: var(--leading); }
select { cursor: pointer; }
input:hover, select:hover, textarea:hover { border-color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: var(--ring); }
input[type="file"] { font: inherit; font-size: var(--text-sm); max-width: 100%; color: var(--text-muted); }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; color: var(--text-strong); background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); margin-right: var(--space-3); cursor: pointer; min-height: var(--control-h); }
input[type="file"]::file-selector-button:hover { background: var(--surface-hover); }
.help { color: var(--text-muted); font-size: var(--text-sm); margin: var(--space-1) 0 0; display: block; font-weight: 400; line-height: 1.45; }
.field > label + .help { margin: -.1rem 0 var(--space-2); }
.card > p.help, fieldset > p.help { margin-bottom: var(--space-3); }
.input-suffix { display: flex; align-items: center; gap: var(--space-2); }
.row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-4); }
.row.three { grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr); }
.check { display: flex; gap: var(--space-3); align-items: flex-start; margin-bottom: var(--space-2); }
.check input { margin: .2rem 0 0; width: 1.125rem; height: 1.125rem; flex: none; accent-color: var(--primary); cursor: pointer; }
.check label { font-weight: 500; font-size: var(--text-md); color: var(--text); cursor: pointer; }
.check .help { margin-top: .1rem; }
.checkfield { display: flex; align-items: flex-end; padding-bottom: var(--space-1); }
fieldset { border: 0; padding: 0; margin: 0 0 var(--space-5); min-width: 0; }
legend { font-weight: 650; color: var(--text-strong); margin-bottom: var(--space-3); font-size: var(--text-base); padding: 0; }
form fieldset + fieldset { border-top: 1px solid var(--line); padding-top: var(--space-5); }
form fieldset + fieldset > legend { float: left; width: 100%; }
form fieldset + fieldset > legend + * { clear: both; }
.radios legend { font-size: var(--text-sm); margin-bottom: var(--space-2); }
.form-actions { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; margin-top: var(--space-2); }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; background: var(--surface); border-top: 1px solid var(--line); margin: var(--space-2) calc(-1 * var(--space-6)) calc(-1 * var(--space-6)); padding: var(--space-4) var(--space-6); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.subhead { margin-top: var(--space-6); padding-top: var(--space-5); border-top: 1px solid var(--line); }

/* Disclosure (details/summary) with a chevron instead of the browser triangle */
details > summary { cursor: pointer; color: var(--link); font-weight: 600; padding: var(--space-1) 0; list-style: none; display: flex; align-items: center; gap: var(--space-2); min-height: 2.25rem; border-radius: var(--radius-sm); }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; flex: none; width: .45rem; height: .45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); margin: 0 .2rem 0 .1rem; transition: transform var(--fast) var(--ease); }
details[open] > summary::before { transform: rotate(45deg); }
details > summary:hover { color: var(--link-hover); }
.menu > summary::before { content: none; }
details.more, details.edit { margin: var(--space-2) 0 var(--space-4); }
details.add { border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-2) var(--space-4); background: var(--surface-sunken); margin: var(--space-4) 0 0; }
details.add + details.add { margin-top: var(--space-3); }
details.add[open] { padding-bottom: var(--space-4); background: var(--surface); border-color: var(--line-strong); }
details.add > summary { min-height: 2.5rem; }
details.add[open] > summary, details.edit[open] > summary { margin-bottom: var(--space-3); }

/* Segmented control (and the report's 1–5 rating) */
.segmented, .rating { display: inline-flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--control-border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; max-width: 100%; }
.segment, .rating-option { position: relative; display: flex; }
.segment + .segment, .rating-option + .rating-option { border-left: 1px solid var(--line-strong); }
.segment input, .rating-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.segment span, .rating-option span { display: inline-flex; min-width: 2.75rem; min-height: var(--control-h); align-items: center; justify-content: center; background: var(--surface); font-weight: 600; color: var(--text); cursor: pointer; padding: 0 var(--space-3); transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease); }
.segment span:hover, .rating-option span:hover { background: var(--surface-hover); }
.segment input:checked + span, .rating-option input:checked + span { background: var(--primary); color: var(--white); }
.segment input:focus-visible + span, .rating-option input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: -4px; border-radius: 4px; }
.rating-none span { font-weight: 500; color: var(--text-muted); }

/* Tabs (links styled as tabs) */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); margin-bottom: var(--space-5); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; min-height: 2.75rem; padding: 0 var(--space-4); color: var(--text-muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--text-strong); }
.tab[aria-current] { color: var(--primary); border-bottom-color: var(--primary); }

/* Chips, badges, dots, tiles ---------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: .3rem; font-size: var(--text-xs); font-weight: 600; line-height: 1.4; padding: .12rem .55rem; border-radius: var(--radius-full); white-space: nowrap; vertical-align: middle; border: 1px solid transparent; }
.chip-ok { background: var(--ok-soft); color: var(--ok); border-color: var(--ok-line); }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-line); }
.chip-bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.chip-info { background: var(--info-soft); color: var(--info); border-color: var(--info-line); }
.chip-muted { background: var(--gray-100); color: var(--text-muted); border-color: var(--line); }
.chip-ai { background: var(--ai-soft); color: var(--ai); border-color: var(--ai-line); }
.chip-demo { background: var(--demo-soft); color: var(--demo); border-color: var(--demo-line); }
.badge-demo, .ai-badge { display: inline-block; font-size: var(--text-xs); font-weight: 650; line-height: 1.4; border-radius: 4px; padding: 0 .35rem; vertical-align: .1em; letter-spacing: .01em; border: 1px solid; }
.badge-demo { background: var(--demo-soft); color: var(--demo); border-color: var(--demo-line); }
.ai-badge { background: var(--ai-soft); color: var(--ai); border-color: var(--ai-line); }
.dots { display: inline-flex; gap: 3px; }
.dot { width: 1.25rem; height: .3125rem; border-radius: var(--radius-full); background: var(--track); }
.dot-done { background: var(--ok-solid); }
.dot-current { background: var(--info-solid); }
.dot-attention { background: var(--warn-solid); }
.dot-skipped { background: var(--gray-100); }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); }
.tile-label { display: block; font-size: var(--text-sm); color: var(--text-muted); }
.tile-value { font-size: var(--text-xl); font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; }

/* Definition lists */
dl.facts, dl.preview, dl.compare { margin: 0; }
dl.facts > div, dl.preview > div { padding: var(--space-2) 0; border-top: 1px solid var(--line); }
dl.facts > div:first-child, dl.preview > div:first-child { border-top: 0; padding-top: 0; }
dl.facts dt, dl.preview dt { font-size: var(--text-sm); font-weight: 600; color: var(--text-muted); }
dl.facts dd, dl.preview dd { margin: .1rem 0 0; overflow-wrap: anywhere; }
dl.facts dd, .cofinancing-facts dd { font-variant-numeric: tabular-nums; }
dl.facts-inline > div, .ws-rail dl.cofinancing-facts > div { display: flex; justify-content: space-between; gap: var(--space-3); align-items: baseline; }
dl.facts-inline dd, .ws-rail dl.cofinancing-facts dd { text-align: right; margin: 0; }
.ws-rail .cofinancing-facts dd { white-space: nowrap; }
dl.compare { margin-top: var(--space-2); font-size: var(--text-sm); }
dl.compare dt { font-weight: 700; display: inline; }
dl.compare dt::after { content: ": "; }
dl.compare dd { display: inline; margin: 0; }

/* Data table */
.table-wrap { overflow-x: auto; position: relative; margin: var(--space-2) 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; border-collapse: collapse; margin: var(--space-2) 0 var(--space-3); font-size: var(--text-md); }
.table-wrap > .table { margin: 0; }
.table th, .table td { text-align: left; padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { font-size: var(--text-xs); color: var(--text-muted); font-weight: 650; background: var(--surface-sunken); border-bottom-color: var(--line-strong); white-space: nowrap; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-sunken); }
.table.small { font-size: var(--text-sm); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Copyable value box */
.copybox { display: flex; gap: var(--space-2); align-items: flex-start; background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-2) var(--space-2) var(--space-2) var(--space-3); }
.copybox-value, .copybox pre { flex: 1; min-width: 0; margin: 0; padding: var(--space-1) 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: var(--text-sm); color: var(--text); background: none; }
.copy { flex: none; display: inline-flex; align-items: center; justify-content: center; font: inherit; font-size: var(--text-sm); font-weight: 600; color: var(--text-strong); border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-sm); min-height: 2rem; padding: .15rem .7rem; cursor: pointer; white-space: nowrap; transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease); }
.copy:hover { background: var(--surface-hover); border-color: var(--control-border); }

/* Overview ---------------------------------------------------------------- */
.pipeline { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: var(--space-2); margin-bottom: var(--space-5); }
.stage { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow-xs); min-height: 4.5rem; transition: border-color var(--fast) var(--ease), background-color var(--fast) var(--ease); overflow: hidden; }
.stage::before { content: ""; position: absolute; left: 0; top: var(--space-3); bottom: var(--space-3); width: 3px; border-radius: 0 3px 3px 0; background: var(--stage-tone, var(--gray-300)); }
.stage:hover { border-color: var(--line-strong); background: var(--surface-hover); color: var(--text); }
.stage.active { border-color: var(--primary); background: var(--selected-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.stage-count { font-size: var(--text-xl); font-weight: 700; color: var(--text-strong); font-variant-numeric: tabular-nums; line-height: 1.15; }
.stage-label { font-size: var(--text-sm); color: var(--text-muted); line-height: var(--leading-tight); }
.stage.empty { box-shadow: none; background: var(--surface-sunken); text-align: left; padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4); }
.stage.empty .stage-count { color: var(--text-subtle); font-weight: 600; }
.stage.empty::before { opacity: .45; }
.stage-verify, .stage-awaiting_outcome { --stage-tone: var(--warn-solid); }
.stage-report, .stage-finance { --stage-tone: var(--info-solid); }
.stage-ready { --stage-tone: var(--primary); }
.stage-submitted { --stage-tone: var(--ok-solid); }
.stage-closed { --stage-tone: var(--gray-500); }
.stage-verify:not(.empty) .stage-count, .stage-awaiting_outcome:not(.empty) .stage-count { color: var(--warn); }
.stage-submitted:not(.empty) .stage-count { color: var(--ok); }
.filters { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); box-shadow: var(--shadow-xs); }
.filters .field { margin: 0; }
.filters .grow { flex: 1; min-width: 12rem; }
.filters label { font-size: var(--text-xs); color: var(--text-muted); }
/* Activity list: a table-like list with sortable columns (sorting is a script enhancement). */
.activity-table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-xs); }
.activity-head, .activity-link { display: grid; grid-template-columns: minmax(0, 2.3fr) minmax(8.5rem, 1fr) minmax(10rem, 1.1fr) minmax(0, 2fr) 1rem; gap: var(--space-4); align-items: center; padding: var(--space-4) var(--space-5); }
.activity-head { font-size: var(--text-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); border-bottom: 1px solid var(--line); background: var(--surface-sunken); padding-top: var(--space-2); padding-bottom: var(--space-2); }
.sort { background: none; border: 0; padding: var(--space-1) 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; display: inline-flex; align-items: center; gap: .3rem; }
.sort:hover { color: var(--text-strong); }
.sort[aria-pressed="true"] { color: var(--text-strong); }
.sort[aria-pressed="true"]::after { content: "▾"; font-size: .9em; }
.sort[aria-pressed="true"][data-dir="asc"]::after { content: "▴"; }
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-row + .activity-row { border-top: 1px solid var(--line); }
.activity-link { text-decoration: none; color: var(--text); box-shadow: inset 3px 0 0 transparent; transition: background-color var(--fast) var(--ease); }
.activity-link:hover { background: var(--surface-hover); color: var(--text); }
.activity-link:focus-visible { outline-offset: -3px; border-radius: 0; }
.activity-link.needs-attention { box-shadow: inset 3px 0 0 var(--warn-solid); }
.attention-mark { font-weight: 650; color: var(--warn); }
.activity-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.activity-title { font-weight: 650; color: var(--text-strong); overflow-wrap: anywhere; }
.activity-meta { font-size: var(--text-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.activity-date { font-size: var(--text-sm); font-variant-numeric: tabular-nums; color: var(--text); }
.activity-progress { display: flex; flex-direction: column; gap: .35rem; align-items: flex-start; }
.stage-name { font-size: var(--text-sm); color: var(--text-muted); font-weight: 550; }
.activity-next { font-size: var(--text-sm); color: var(--text); overflow-wrap: anywhere; }
.row-chevron { width: 1rem; height: 1rem; color: var(--text-subtle); justify-self: end; }
.activity-link:hover .row-chevron { color: var(--link); }
.demo-link { margin-top: var(--space-4); text-align: right; font-size: var(--text-sm); }

/* Workspace --------------------------------------------------------------- */
.ws-head { margin-bottom: var(--space-5); }
.ws-head h1 { overflow-wrap: anywhere; }
.ws-meta { color: var(--text-muted); margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.ws-meta > span { min-width: 0; overflow-wrap: anywhere; }
.ws-sep { color: var(--line-strong); }
.steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, .75fr); gap: 0; margin-bottom: var(--space-6); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-1); box-shadow: var(--shadow-xs); }
.step { position: relative; display: flex; gap: var(--space-3); align-items: center; border-radius: var(--radius); padding: var(--space-2) var(--space-3); text-decoration: none; color: var(--text); min-width: 0; min-height: 3.25rem; transition: background-color var(--fast) var(--ease); }
.step + .step::before { content: ""; position: absolute; left: 0; top: 25%; bottom: 25%; width: 1px; background: var(--line); }
.step:hover { background: var(--surface-hover); color: var(--text); }
.step[aria-current] { background: var(--selected-soft); }
.step[aria-current]::after { content: ""; position: absolute; left: var(--space-3); right: var(--space-3); bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
.step[aria-current] + .step::before, .step + .step[aria-current]::before { background: transparent; }
.step-num { flex: none; width: 1.75rem; height: 1.75rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--text-sm); background: var(--surface); color: var(--text-muted); border: 1.5px solid var(--line-strong); }
.step-done .step-num { background: var(--ok-solid); border-color: var(--ok-solid); color: var(--white); }
.step-current .step-num { background: var(--primary); border-color: var(--primary); color: var(--white); }
.step-attention .step-num { background: var(--warn-solid); border-color: var(--warn-solid); color: var(--navy-900); }
.step-history .step-num { background: var(--gray-100); border-color: var(--gray-100); }
.step-num .icon { width: .9rem; height: .9rem; stroke-width: 3; }
.step-text { display: flex; flex-direction: column; min-width: 0; }
.step-label { font-weight: 650; font-size: var(--text-md); color: var(--text-strong); line-height: 1.25; }
.step-note { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Workspace: content on the left; the next step and a sticky rail on the right.
   In the markup the next step comes first, so on a phone it sits above the long form. */
.ws-layout { display: grid; grid-template-columns: minmax(0, 1fr) 21.5rem; grid-template-rows: auto 1fr; grid-template-areas: "main next" "main rail"; gap: var(--space-4) var(--space-6); align-items: start; }
.ws-main { grid-area: main; min-width: 0; }
.ws-main > .card:last-child { margin-bottom: 0; }
.next-action { grid-area: next; }
.ws-rail { grid-area: rail; position: sticky; top: var(--space-4); display: grid; gap: var(--space-4); max-height: calc(100vh - 2 * var(--space-4)); overflow-y: auto; overscroll-behavior: contain; padding: 2px 2px var(--space-1); margin: -2px; min-width: 0; }
.ws-rail > .card { margin-bottom: 0; padding: var(--space-5); }
.ws-rail h2 { font-size: var(--text-base); }
.rail-title { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; margin-bottom: var(--space-2); }
.next-action { background: var(--navy-900); color: var(--text-on-dark); border-radius: var(--radius-lg); padding: var(--space-5); box-shadow: var(--shadow-sm); }
.next-action .rail-title { color: var(--eu-yellow); }
.next-action p { margin-bottom: var(--space-4); font-size: var(--text-base); font-weight: 500; }
.next-action p:last-child { margin-bottom: 0; }
.next-action :focus-visible { outline-color: var(--focus-on-dark); }
.next-action .button.primary { background: var(--white); border-color: var(--white); color: var(--navy-900); }
.next-action .button.primary:hover { background: var(--info-soft); border-color: var(--info-soft); }
.next-action.here { background: var(--info-soft); color: var(--text-strong); border: 1px solid var(--info-line); box-shadow: none; }
.next-action.here .rail-title { color: var(--info); }
.next-action.here :focus-visible { outline-color: var(--focus); }
.rail-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; gap: var(--space-2); }
.rail-tiles .tile { padding: var(--space-3); }
.rail-tiles .tile-value { font-size: var(--text-lg); }
.ws-rail .cofinancing-facts { grid-template-columns: minmax(0, 1fr); gap: 0; }
.ws-rail dl.preview dd { font-size: var(--text-sm); }
details.evidence { border-top: 1px solid var(--line); padding: var(--space-2) 0; }
details.evidence > summary { font-size: var(--text-sm); }
.item { border-top: 1px solid var(--line); padding: var(--space-4) 0 var(--space-1); }
.item:first-of-type { border-top: 0; padding-top: var(--space-1); }
.item-head { display: flex; justify-content: space-between; gap: var(--space-4); align-items: flex-start; flex-wrap: wrap; }
.item-head h3 { margin-bottom: .1rem; }
.remove { margin: var(--space-1) 0 var(--space-2); }

/* Finance ----------------------------------------------------------------- */
/* Receipts ledger: one row per receipt, edited in place below its row. */
.ledger-head, .ledger-row, .ledger-total { display: grid; grid-template-columns: minmax(0, 2.4fr) minmax(7rem, 1fr) repeat(3, minmax(5.5rem, .8fr)) minmax(6.5rem, auto); gap: var(--space-3); align-items: start; }
.ledger-head { font-size: var(--text-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); padding: var(--space-2) 0; border-bottom: 1px solid var(--line-strong); }
.ledger-item { border-top: 0; border-bottom: 1px solid var(--line); padding: var(--space-3) 0 var(--space-1); }
.ledger-item:first-of-type { padding-top: var(--space-3); }
.ledger-row .num, .ledger-date { padding-top: .1rem; font-size: var(--text-md); }
.ledger-main h3 { margin-bottom: .1rem; overflow-wrap: anywhere; }
.ledger-main p { margin: 0; overflow-wrap: anywhere; }
.ledger-status { text-align: right; }
.ledger-item details.edit { margin: var(--space-1) 0 var(--space-2); }
.ledger-item details.edit[open] { background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-2) var(--space-4) var(--space-4); margin-top: var(--space-2); }
.ledger-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
.ledger-total { font-weight: 700; color: var(--text-strong); padding: var(--space-3) 0 var(--space-4); border-top: 1px solid var(--line-strong); margin-top: -1px; }
.alloc { background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3); margin-bottom: var(--space-4); }
details.edit[open] .alloc { background: var(--surface); }
.alloc-head, .alloc-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-2); }
.alloc-head { font-size: var(--text-xs); font-weight: 650; color: var(--text-muted); margin-bottom: var(--space-1); }
.alloc-row .field { margin-bottom: var(--space-2); }
.alloc-row .sr-mobile { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
.alloc-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2) var(--space-4); flex-wrap: wrap; font-size: var(--text-sm); }
.alloc-sum { font-variant-numeric: tabular-nums; }
.alloc-sum.good { color: var(--ok); font-weight: 600; }
.alloc-sum.warn { color: var(--warn); font-weight: 600; }
.alloc-sum.bad { color: var(--bad); font-weight: 600; }
.alloc .help { margin-top: var(--space-2); }
.cofinancing-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--space-2) var(--space-4); }
.cofinancing-shortfall { color: var(--warn); font-weight: 600; margin-top: var(--space-3); }
.work-entry { border-top: 1px solid var(--line); padding: var(--space-1) 0; }
.work-entry:last-of-type { border-bottom: 1px solid var(--line); margin-bottom: var(--space-3); }
.work-entry[open] { padding-bottom: var(--space-3); }
.work-entry > summary { font-size: var(--text-md); }

/* Submission -------------------------------------------------------------- */
.howto { padding-left: 1.2rem; }
.howto li { margin-bottom: var(--space-1); }
.checklist { list-style: none; padding: 0; margin: var(--space-3) 0 0; }
.checklist li { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.checklist li::before { content: ""; flex: none; width: 1.125rem; height: 1.125rem; border-radius: 50%; border: 1.5px solid var(--control-border); background: var(--surface); }
.checklist li.done::before { border-color: var(--ok-solid); background: var(--ok-solid); box-shadow: inset 0 0 0 3px var(--surface); }
.formfields { list-style: none; padding: 0; margin: var(--space-3) 0 0; }
.formfields li { border-top: 1px solid var(--line); padding: var(--space-3) 0; scroll-margin-top: var(--space-4); }
.ff-head { display: flex; align-items: center; gap: var(--space-2) var(--space-3); scroll-margin-top: var(--space-4); }
.ff-section { font-size: var(--text-xs); color: var(--text-muted); min-width: 6.5rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.ff-label { font-weight: 600; flex: 1; min-width: 0; }
.ff-value { background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); margin: var(--space-2) 0 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; font-size: var(--text-md); }
.ff-copied .ff-value { background: var(--ok-soft); border-color: var(--ok-line); }
.ff-copied .copy { border-color: var(--ok-line); color: var(--ok); background: var(--ok-soft); }
.formfields li.ff-next { box-shadow: inset 3px 0 0 var(--primary); padding-left: var(--space-3); padding-right: var(--space-3); background: var(--selected-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.fill-state { margin-bottom: var(--space-2); }
.fill-note { margin-bottom: var(--space-1); font-weight: 600; }
.fill-differences, .fill-blocked { padding-left: 1.1rem; margin: 0 0 var(--space-3); }
.fill-differences li, .fill-blocked li { margin-bottom: var(--space-1); overflow-wrap: anywhere; }
.fill-card form { margin-top: var(--space-2); }
.fill-card .sent-by-hand { margin-top: var(--space-3); }
.copy-card { background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin: var(--space-3) 0; }
.copy-card .copy-count { font-size: var(--text-lg); font-weight: 700; color: var(--text-strong); margin-bottom: var(--space-2); font-variant-numeric: tabular-nums; }
.copy-card .copy-count.good { color: var(--ok); }
.copy-card p:last-child { margin-bottom: 0; }
.copy-meter { display: block; width: 100%; height: .5rem; margin-bottom: var(--space-3); accent-color: var(--ok-solid); }
.attempt + .attempt { border-top: 1px solid var(--line); padding-top: var(--space-4); margin-top: var(--space-4); }
.timeline { list-style: none; padding: 0; margin: var(--space-2) 0 var(--space-3); }
.timeline li { position: relative; padding: var(--space-2) 0 var(--space-2) var(--space-6); overflow-wrap: anywhere; }
.timeline li::before { content: ""; position: absolute; left: .3rem; top: 1rem; width: .5rem; height: .5rem; border-radius: 50%; background: var(--gray-300); box-shadow: 0 0 0 3px var(--surface); z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: calc(.55rem - 1px); top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline li:first-child::after { top: 1rem; }
.timeline li:last-child::after { bottom: calc(100% - 1rem); }
.timeline li:only-child::after { display: none; }
.timeline .area-report::before { background: var(--info-solid); }
.timeline .area-finance::before { background: var(--ai-solid); }
.timeline .area-submission::before { background: var(--ok-solid); }
.timeline .area-source::before { background: var(--warn-solid); }
.tl-time { color: var(--text-muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; margin-right: var(--space-1); }
.form-check { color: var(--text-muted); }

/* Backup commands */
pre.code { background: var(--surface-sunken); color: var(--text); padding: var(--space-2) var(--space-3); border-radius: var(--radius-sm); overflow-x: auto; margin: 0; }
.command-steps { padding-left: 0; margin: var(--space-4) 0; list-style: none; counter-reset: step; }
.command-steps li { position: relative; padding-left: 2.25rem; margin-bottom: var(--space-4); counter-increment: step; }
.command-steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--selected-soft); color: var(--primary); font-size: var(--text-xs); font-weight: 700; display: flex; align-items: center; justify-content: center; }
.command-label { display: block; font-weight: 600; margin-bottom: var(--space-2); color: var(--text-strong); }
.command { display: flex; gap: var(--space-2); align-items: flex-start; }
.command pre.code { flex: 1; min-width: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.command.copybox pre.code { padding: var(--space-1) 0; background: none; }

/* AI suggestions ---------------------------------------------------------- */
.ai-section { border-color: var(--ai-line); background: var(--ai-soft); }
.ai-section > h2 { color: var(--ai); }
.ai-card { background: var(--surface); border: 1px solid var(--ai-line); border-radius: var(--radius); padding: var(--space-4); }
.ai-card + .ai-card { margin-top: var(--space-3); }
.ai-card .item-head { margin-bottom: var(--space-2); }
.ai-warning { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); border-radius: var(--radius-sm); padding: var(--space-2) var(--space-3); font-size: var(--text-sm); margin: var(--space-2) 0; }
.ai-warning p, .ai-warning ul { margin: 0; }
.ai-banner { background: var(--ai-soft); border: 1px solid var(--ai-line); border-left: 4px solid var(--ai-solid); color: var(--ai); border-radius: var(--radius); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.ai-banner:focus { outline: none; box-shadow: var(--ring); }
.ai-banner a { color: inherit; }
.quote { display: block; color: var(--text-muted); font-style: italic; font-size: var(--text-sm); }
.ai-notes { margin-bottom: var(--space-4); }
.activity-title .ai-badge { margin-left: .2rem; }

/* Auth layout: centred card with the brand above it ----------------------- */
.auth { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: calc(100vh - 12rem); padding: var(--space-6) 0; }
.auth-brand { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-6); color: var(--text-strong); text-decoration: none; }
.auth-brand .brand-mark-box { display: inline-flex; align-items: center; justify-content: center; width: 3rem; height: 3rem; border-radius: var(--radius); background: var(--navy-900); flex: none; }
.auth-brand .brand-mark { width: 30px; height: 32px; }
.auth-brand .brand-org { color: var(--text-strong); font-size: var(--text-lg); }
.auth-brand .brand-branch { color: var(--primary); }
.auth-brand .brand-app { color: var(--text-muted); font-size: var(--text-sm); }
.auth-card { width: 100%; max-width: 26rem; padding: var(--space-8); box-shadow: var(--shadow-sm); }
.auth-card h1 { font-size: var(--text-xl); }
.auth-card .button.wide { margin-top: var(--space-2); }
.auth-page .footer { text-align: center; border-top: 0; }
/* Kept for older markup */
.login { display: grid; place-items: center; min-height: 60vh; }
.login-card { width: 100%; max-width: 420px; }

/* Responsive -------------------------------------------------------------- */
@media (max-width: 1100px) {
  /* Top bar: brand and tools on the first row, the main menu as a full-width row below. */
  .topbar-inner { flex-wrap: wrap; column-gap: var(--space-3); min-height: 0; padding-top: var(--space-1); }
  .brand { flex: 1 1 auto; min-width: 0; }
  .topbar-tools { order: 2; }
  .mainnav { order: 3; flex: 1 1 100%; margin: 0 calc(-1 * var(--space-3)); overflow-x: auto; scrollbar-width: none; border-top: 1px solid var(--line-on-dark); }
  .mainnav a { min-height: 2.75rem; }
  .pipeline { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .activity-head, .activity-link { grid-template-columns: minmax(0, 2fr) minmax(8rem, 1fr) minmax(9.5rem, 1fr) minmax(0, 1.6fr) 1rem; }
}
@media (max-width: 1000px) {
  .grid-2, .grid-2.wide-left { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; }
  .ws-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: none; grid-template-areas: "next" "main" "rail"; }
  .ws-rail { position: static; max-height: none; overflow: visible; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); align-items: start; padding: 0; margin: 0; }
  .next-action { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); padding: var(--space-4) var(--space-5); }
  .next-action .rail-title { flex-basis: 100%; margin: 0; }
  .next-action p { flex: 1 1 16rem; margin: 0; }
  .next-action .button.wide { width: auto; flex: none; }
  .steps { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .step-note { display: none; }
  .activity-head { display: none; }
  .activity-link { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "main main" "progress date" "next next"; gap: var(--space-2) var(--space-4); }
  .activity-main { grid-area: main; }
  .activity-date { grid-area: date; color: var(--text-muted); }
  .activity-progress { grid-area: progress; flex-direction: row; align-items: center; gap: var(--space-3); }
  .activity-next { grid-area: next; color: var(--text-muted); }
  .row-chevron { display: none; }
}
@media (max-width: 860px) {
  .step { flex-direction: column; justify-content: center; padding: var(--space-2) var(--space-1); gap: var(--space-1); text-align: center; min-height: 3.75rem; }
  .step + .step::before { top: 30%; bottom: 30%; }
  .step-text { width: 100%; }
  .step-label { font-size: var(--text-sm); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .step[aria-current]::after { left: var(--space-2); right: var(--space-2); }
}
@media (max-width: 760px) {
  .ledger-head { display: none; }
  .ledger-row, .ledger-total { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-1) var(--space-3); }
  .ledger-main { grid-column: 1 / -1; }
  .ledger-row .num { text-align: left; }
  .ledger-status { text-align: left; }
  .ledger-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; clip-path: none; color: var(--text-muted); font-size: var(--text-sm); }
  .ledger-total span:empty { display: none; }
  .mainnav { justify-content: space-between; gap: 0; }
  .mainnav a { padding: 0 var(--space-2); font-size: var(--text-sm); }
  .mainnav a::after { left: var(--space-2); right: var(--space-2); }
  .env-chip { display: none; }
  .menu-env { display: block; }
  .topbar .user-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
  .menu-trigger { padding-right: var(--space-1); }
}
@media (max-width: 640px) {
  :root { --gutter: var(--space-4); --control-h: 2.75rem; }
  body { font-size: var(--text-base); }
  h1 { font-size: 1.5rem; }
  .main { padding-top: var(--space-5); }
  .card { padding: var(--space-4); border-radius: var(--radius); }
  .sticky-actions { margin: var(--space-2) calc(-1 * var(--space-4)) calc(-1 * var(--space-4)); padding: var(--space-3) var(--space-4); border-radius: 0 0 var(--radius) var(--radius); }
  input[type="text"], input[type="email"], input[type="url"], input[type="date"], input[type="password"],
  input[type="search"], input[type="number"], input:not([type]), select, textarea { font-size: var(--text-base); }
  .page-head { margin-bottom: var(--space-5); }
  .page-head .actions { width: 100%; }
  .page-head .actions .button { flex: 1 1 auto; }
  .pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .stage, .stage.empty { flex-direction: row; align-items: center; gap: var(--space-3); min-height: 3rem; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4); }
  .stage::before { top: var(--space-2); bottom: var(--space-2); }
  .stage-count { font-size: var(--text-lg); min-width: 1.5rem; }
  .filters { padding: var(--space-3); }
  .filters .grow { flex-basis: 100%; }
  .filters .field:not(.grow) { flex: 1; }
  .activity-link { padding: var(--space-4); grid-template-columns: minmax(0, 1fr); grid-template-areas: "main" "date" "progress" "next"; }
  .activity-date { margin-top: calc(-1 * var(--space-2)); }
  .steps { gap: 0; padding: var(--space-1) 0; grid-template-columns: repeat(4, minmax(0, 1.1fr)) minmax(0, .9fr); }
  .step { padding: var(--space-2) 0; }
  .step-label { font-size: .6875rem; letter-spacing: -.01em; }
  .ws-head { margin-bottom: var(--space-4); }
  .ws-rail { grid-template-columns: minmax(0, 1fr); }
  .ws-rail > .card { padding: var(--space-4); }
  .next-action { padding: var(--space-4); }
  .next-action .button.wide { width: 100%; }
  .row, .row.three { grid-template-columns: minmax(0, 1fr); }
  .checkfield { padding-bottom: 0; margin-top: calc(-1 * var(--space-2)); }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .alloc-head { display: none; }
  .alloc-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); padding-bottom: var(--space-2); border-bottom: 1px dashed var(--line-strong); margin-bottom: var(--space-2); }
  .alloc-row .field:first-child { grid-column: 1 / -1; }
  .alloc-row .sr-mobile { position: static; width: auto; height: auto; clip: auto; clip-path: none; font-size: var(--text-xs); }
  .ff-head { flex-wrap: wrap; }
  .ff-section { min-width: 0; flex-basis: 100%; }
  .copy { min-height: 2.5rem; }
  .link-button { display: inline-flex; align-items: center; min-height: 2.5rem; }
  .back { min-height: 2.5rem; margin-bottom: var(--space-2); }
  .card-head > a { display: inline-flex; align-items: center; min-height: 2.5rem; }
  details > summary { min-height: 2.75rem; }
  .check { min-height: 2.5rem; }
  .check input { width: 1.25rem; height: 1.25rem; margin-top: .15rem; }
  .table th, .table td { padding: var(--space-2); }
  .toast { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); max-width: none; }
  .auth-card { padding: var(--space-6) var(--space-5); }
  .rating, .segmented { display: flex; }
  .rating-option, .segment { flex: 1 1 auto; }
  .rating-option span, .segment span { width: 100%; min-width: 2.5rem; padding: 0 var(--space-2); }
  .command { flex-wrap: wrap; }
}
@media (max-width: 380px) {
  .brand-org { font-size: var(--text-md); }
  .brand-mark { width: 28px; height: 30px; }
  .mainnav a { padding: 0 var(--space-1); font-size: .78rem; }
  .mainnav a::after { left: var(--space-1); right: var(--space-1); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}

/* Central server (ADR 0010): the pieces its pages add to the components above. */
.menu-group { margin: 0; padding: var(--space-2) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.menu-label { display: block; padding: 0 var(--space-3) var(--space-1); font-size: var(--text-xs); font-weight: 650; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.menu-mark { width: 1rem; text-align: center; color: var(--primary); }
.inline-form { display: inline; margin: 0; }
.inline-form + .inline-form { margin-left: var(--space-3); }
.inline-row { display: flex; gap: var(--space-3); align-items: flex-end; flex-wrap: wrap; margin-top: var(--space-4); }
.inline-row .field { margin-bottom: 0; }
.inline-row .grow { flex: 1; min-width: 14rem; }
.inline-row .field .help { position: static; }
.plain-list { list-style: none; margin: 0 0 var(--space-4); padding: 0; }
.plain-list li { padding: var(--space-2) 0; border-top: 1px solid var(--line); }
.plain-list li:first-child { border-top: 0; }
.list-row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); flex-wrap: wrap; }
.nowrap { white-space: nowrap; }
/* A table that keeps its columns readable and scrolls sideways inside its frame on a phone. */
.table-wide { min-width: 34rem; }
.grid-2 + .card { margin-top: var(--space-5); }
html.js .no-js-only { display: none; }
.prose h2 { margin-top: var(--space-6); }
.prose ul { padding-left: 1.2rem; }
.prose li { margin-bottom: var(--space-2); }
.reveal .copybox { margin-bottom: var(--space-3); background: var(--surface); }
.auth-help { margin-top: var(--space-5); margin-bottom: 0; }
.auth-foot { margin-top: var(--space-5); text-align: center; }
.auth-restart { margin: var(--space-3) 0 0; }

/* Second factor on the account page (ADR 0013). */
.sf-status { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; margin: 0; }
.sf-intro:focus { outline: none; }
.sf-grid h3 { font-size: var(--text-base); }
.sf-grid > form .button, .sf-grid > div > form .button { margin-top: var(--space-1); }
.sf-codes { box-shadow: none; padding: var(--space-5); }
.sf-codes h3 { color: var(--ok); }
.sf-codes .copybox { margin-bottom: var(--space-3); background: var(--surface); max-width: 30rem; }
.sf-codes > p:last-child { margin-bottom: 0; }
/* Ten short codes: two columns where there is room, one per line in the copied text. */
.sf-code-list { columns: 2 9rem; column-gap: var(--space-8); font-size: var(--text-base); line-height: 1.9; letter-spacing: .04em; }
.sf-steps { list-style: none; counter-reset: sf-step; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--space-6); }
.sf-steps > li { counter-increment: sf-step; min-width: 0; }
.sf-steps h3 { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-base); }
.sf-steps h3::before { content: counter(sf-step); flex: none; display: inline-flex; align-items: center; justify-content: center; width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--selected-soft); color: var(--primary); font-size: var(--text-sm); font-weight: 700; }
.sf-scan { display: flex; gap: var(--space-5); align-items: flex-start; flex-wrap: wrap; }
/* The code is black on white in any theme, with a white margin of its own, so every camera reads it. */
.sf-qr { flex: none; width: 180px; height: 180px; padding: var(--space-2); background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); image-rendering: crisp-edges; }
.sf-manual { flex: 1 1 14rem; min-width: 0; }
.sf-manual .copybox { margin-bottom: var(--space-3); }
.sf-manual .copybox-value { font-size: var(--text-base); letter-spacing: .04em; }
@media (max-width: 1000px) {
  .sf-steps { grid-template-columns: minmax(0, 1fr); }
}
.table td form .link-button { white-space: nowrap; }

/* The form window of a central server, shown in the dashboard (ADR 0011). */
.form-view { position: relative; }
.form-view-tools { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-2); }
.form-view-tools form { margin: 0; display: flex; gap: var(--space-2); }
.form-view-text { flex: 1; min-width: 14rem; }
.form-view-screen { margin: 0; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); overflow: auto; line-height: 0; box-shadow: var(--shadow-sm); }
.form-view:focus-within .form-view-screen { border-color: var(--focus); box-shadow: var(--ring); }
/* Catches the keyboard for the picture above it; nothing to look at. */
.form-view-keys { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; resize: none; overflow: hidden; }
.form-view-screen input[type="image"] { display: block; max-width: none; }
html.js .form-view-screen { overflow: hidden; }
html.js .form-view-screen input[type="image"] { width: 100%; height: auto; cursor: default; }
@media (max-width: 640px) {
  .form-view-text { flex-basis: 100%; }
}
