/*
 * One stylesheet for the whole site (see docs/design-guide.md). Dark, calm
 * and dense by default: a near-black page, panels barely lighter, thin
 * borders, one accent. The light theme is the reader's explicit choice
 * (data-theme on the root element, set by the server from a cookie); the
 * system setting is never followed. Print has its own rules at the end.
 *
 * Everything is sized from the tokens below. Rows, buttons and inputs take
 * their height from line-height and padding, never from a fixed height, so
 * the interface font can be swapped in the one place it is named.
 */

/*
 * The interface font, Outfit (SIL Open Font License, see fonts/Outfit-OFL.txt), bundled so the pages look
 * the same on every machine. Its default digits are proportional, so every figure asks for tabular numerals.
 */
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/outfit-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Outfit';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/static/fonts/outfit-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  /* The interface font is named here and nowhere else. */
  --font-ui: 'Outfit', system-ui, sans-serif;
  --font-numeric: var(--font-ui);

  /* Type scale */
  /* Only the names under the rail's icons are this small. */
  --text-rail: 10px;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-lg: 15px;
  --text-xl: 18px;
  --text-headline: 30px;
  --line: 18px;
  --weight-regular: 400;
  --weight-medium: 500;

  /* Spacing scale */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* Radii */
  --r-chip: 6px;
  --r-button: 8px;
  --r-panel: 12px;

  --sidebar-width: 208px;
  --rail-width: 72px;

  /* Colour roles: dark theme */
  color-scheme: dark;
  --bg: #07070d;
  --panel: #0d0d14;
  --raised: #14141d;
  --input: #101018;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #ececf1;
  --text-2: #a6a6b4;
  --muted: #8b8b9a;
  --accent: #5b5bf0;
  --accent-hover: #6d6dff;
  --accent-contrast: #ffffff;
  --accent-text: #9a9aff;
  --accent-tint: rgba(91, 91, 240, 0.18);
  --positive: #3fb97f;
  --positive-tint: rgba(63, 185, 127, 0.14);
  --negative: #f07a68;
  --negative-tint: rgba(229, 96, 77, 0.16);
  --warning: #d9a23a;
  --warning-tint: rgba(217, 162, 58, 0.14);
  --revised: #b08cf5;
  --revised-tint: rgba(176, 140, 245, 0.15);
  --focus: #9a9aff;
  --backdrop: rgba(0, 0, 0, 0.6);
}

:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f1f2f6;
  --panel: #ffffff;
  --raised: #f5f6fa;
  --input: #ffffff;
  --border: rgba(16, 16, 40, 0.1);
  --border-strong: rgba(16, 16, 40, 0.22);
  --text: #17171f;
  --text-2: #4c4c5c;
  --muted: #666676;
  --accent: #4646d8;
  --accent-hover: #3838c4;
  --accent-contrast: #ffffff;
  --accent-text: #3a3ac8;
  --accent-tint: rgba(70, 70, 216, 0.1);
  --positive: #17734a;
  --positive-tint: rgba(23, 115, 74, 0.1);
  --negative: #b83322;
  --negative-tint: rgba(184, 51, 34, 0.09);
  --warning: #855c00;
  --warning-tint: rgba(196, 140, 20, 0.14);
  --revised: #6a3fc4;
  --revised-tint: rgba(106, 63, 196, 0.1);
  --focus: #4646d8;
  --backdrop: rgba(20, 20, 40, 0.35);
}

/* Base */

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

html { font-family: var(--font-ui); font-size: var(--text-md); line-height: var(--line); font-weight: var(--weight-regular); font-variant-numeric: tabular-nums; }

body { margin: 0; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; }

h1, h2, h3, strong, b, th, dt, label, legend, summary { font-weight: var(--weight-medium); }
h1 { font-size: var(--text-xl); line-height: 24px; margin: 0; }
h2 { font-size: var(--text-md); margin: 0; }
h3 { font-size: var(--text-md); margin: 0 0 var(--s2); }
p { margin: 0 0 var(--s3); }
ul, ol { margin: 0 0 var(--s3); padding-left: var(--s5); }
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }

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

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--s2); top: -60px; z-index: 50; background: var(--accent); color: var(--accent-contrast); padding: var(--s2) var(--s3); border-radius: var(--r-button); }
.skip-link:focus { top: var(--s2); }

/* Every figure in digits of one width: tables, totals, headline numbers, and the fields amounts and dates are typed into. */
table, input, select, textarea, time, .num, .amount, .date, .headline-value, .key-figure dd, .setting-value, .count { font-family: var(--font-numeric); font-variant-numeric: tabular-nums; }
.negative { color: var(--negative); }
.muted, .hint, .unset { color: var(--muted); }
.hint { font-size: var(--text-sm); margin: var(--s1) 0 0; }
.unset { font-style: italic; }
.strong { font-weight: var(--weight-medium); }
.lead { color: var(--text-2); margin-bottom: var(--s4); }
.empty { color: var(--text-2); margin: 0; }
.code { font-size: var(--text-xs); color: var(--muted); border: 1px solid var(--border); border-radius: var(--r-chip); padding: 0 var(--s1); }
.icon { flex: none; width: 16px; height: 16px; vertical-align: -3px; }
.icon-large { width: 28px; height: 28px; color: var(--muted); }

/* Shell */

body.with-sidebar { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }
.page { min-width: 0; padding: var(--s2) var(--s2) 0 0; display: flex; flex-direction: column; min-height: 100vh; }
body.without-sidebar .page { padding: 0 var(--s2); }
.panel { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-panel); padding: var(--s4) var(--s5) var(--s6); min-width: 0; }
.main-narrow > * { max-width: 640px; margin-left: auto; margin-right: auto; }
body.without-sidebar .panel { flex: none; margin: var(--s6) auto; width: 100%; max-width: 460px; }
.site-footer { color: var(--muted); font-size: var(--text-xs); padding: var(--s2) var(--s1); }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.nav-backdrop, .rail-toggle, .rail-label, .ribbon-short, .menu-who { display: none; }

/* Above the page's own sticky bars, so the account menu that opens out of the rail is never under one. */
.sidebar { position: sticky; top: 0; z-index: 20; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s2); padding: var(--s2); }
.switcher { display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s2); border: 1px solid var(--border); border-radius: var(--r-button); color: var(--text); background: var(--panel); min-width: 0; }
a.switcher:hover { text-decoration: none; border-color: var(--border-strong); }
.brand-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: var(--r-chip); background: var(--accent); color: var(--accent-contrast); font-size: var(--text-xs); font-weight: var(--weight-medium); }
.brand-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--weight-medium); }
.switcher-chevron { color: var(--muted); width: 14px; height: 14px; }
.demo-ribbon { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 2px var(--s2); border-radius: var(--r-chip); background: var(--warning-tint); color: var(--warning); font-size: var(--text-xs); font-weight: var(--weight-medium); letter-spacing: 0.04em; white-space: nowrap; }
.demo-ribbon .dot { background: var(--warning); }

.site-nav { flex: 1; }
.nav-group { margin-top: var(--s3); }
.nav-group-label { margin: 0 0 var(--s1); padding: 0 var(--s2); font-size: var(--text-xs); color: var(--muted); }
.site-nav ul { list-style: none; margin: 0; padding: 0; }
.site-nav a { display: flex; align-items: center; gap: var(--s2); padding: 7px var(--s2); border-radius: var(--r-button); color: var(--text-2); white-space: nowrap; }
.site-nav a:hover { background: var(--raised); color: var(--text); text-decoration: none; }
.site-nav a[aria-current] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.site-nav a[aria-current] .icon { color: var(--accent-text); }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: var(--s2); }
.user-menu summary { display: flex; align-items: center; gap: var(--s2); padding: 6px var(--s2); border-radius: var(--r-button); cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--raised); }
.user-menu[open] summary .icon { transform: rotate(180deg); }
.avatar { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--raised); border: 1px solid var(--border-strong); font-size: var(--text-xs); }
.user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 15px; }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { font-size: var(--text-xs); color: var(--muted); font-weight: var(--weight-regular); }
.menu-panel { display: flex; flex-direction: column; padding-top: var(--s1); }
.menu-panel form, .theme-switch { margin: 0; }
.menu-who { flex-direction: column; margin: 0; padding: var(--s1) var(--s2) var(--s2); border-bottom: 1px solid var(--border); line-height: 15px; }
.menu-item { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 6px var(--s2); border: 0; border-radius: var(--r-button); background: none; color: var(--text-2); cursor: pointer; text-align: left; white-space: nowrap; }
.menu-item:hover { background: var(--raised); color: var(--text); text-decoration: none; }

.plain-bar { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); }
.plain-bar .switcher { max-width: 60%; }
.plain-bar-end { margin-left: auto; display: flex; gap: var(--s1); }
.plain-bar-end .menu-item { width: auto; }

/*
 * Below 900px the sidebar is a rail. Every destination keeps its own icon with a short name under it
 * (the whole name is the link's tooltip), so nothing has to be guessed; the toggle at the top opens the
 * sidebar in full, and the account menu opens beside the rail with its words.
 */
@media (max-width: 899px) {
  body.with-sidebar { grid-template-columns: var(--rail-width) minmax(0, 1fr); }
  .rail-toggle { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 6px 2px; border-radius: var(--r-button); color: var(--text-2); cursor: pointer; }
  .rail-toggle:hover { background: var(--raised); color: var(--text); }
  .nav-toggle:focus-visible ~ .sidebar .rail-toggle { outline: 2px solid var(--focus); }
  .sidebar { padding: var(--s2) var(--s1); }
  .nav-toggle:not(:checked) ~ .sidebar .rail-label { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-rail); line-height: 12px; font-weight: var(--weight-regular); text-align: center; }
  .nav-toggle:not(:checked) ~ .sidebar .brand-name,
  .nav-toggle:not(:checked) ~ .sidebar .switcher-chevron,
  .nav-toggle:not(:checked) ~ .sidebar .nav-group-label,
  .nav-toggle:not(:checked) ~ .sidebar .nav-label,
  .nav-toggle:not(:checked) ~ .sidebar .ribbon-long,
  .nav-toggle:not(:checked) ~ .sidebar .demo-ribbon .dot,
  .nav-toggle:not(:checked) ~ .sidebar .user-text,
  .nav-toggle:not(:checked) ~ .sidebar .user-menu summary .icon { display: none; }
  .nav-toggle:not(:checked) ~ .sidebar .ribbon-short { display: inline; }
  .nav-toggle:not(:checked) ~ .sidebar .switcher,
  .nav-toggle:not(:checked) ~ .sidebar .demo-ribbon { justify-content: center; padding-left: 0; padding-right: 0; }
  .nav-toggle:not(:checked) ~ .sidebar .site-nav a,
  .nav-toggle:not(:checked) ~ .sidebar .user-menu summary { flex-direction: column; justify-content: center; gap: 2px; padding: 6px 2px; white-space: normal; }
  .nav-toggle:not(:checked) ~ .sidebar .nav-group { margin-top: var(--s1); padding-top: var(--s1); border-top: 1px solid var(--border); }
  /* The account menu leaves the rail: a panel beside it, wide enough for its words. */
  .nav-toggle:not(:checked) ~ .sidebar .user-menu[open] .menu-panel { position: fixed; z-index: 45; left: calc(var(--rail-width) + var(--s1)); bottom: var(--s2); width: 208px; max-width: calc(100vw - var(--rail-width) - var(--s3)); padding: var(--s1); border: 1px solid var(--border-strong); border-radius: var(--r-panel); background: var(--raised); box-shadow: 0 8px 24px var(--backdrop); }
  .nav-toggle:not(:checked) ~ .sidebar .menu-who { display: flex; }
  .nav-toggle:checked ~ .sidebar { position: fixed; z-index: 40; left: 0; top: 0; width: 236px; max-width: 86vw; background: var(--bg); border-right: 1px solid var(--border-strong); }
  .nav-toggle:checked ~ .sidebar .rail-toggle { flex-direction: row; justify-content: flex-start; padding: 7px var(--s2); }
  .nav-toggle:checked ~ .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: var(--backdrop); }
  .nav-toggle:checked ~ .page { grid-column: 2; }
  .panel { padding: var(--s3) var(--s4) var(--s5); }
}

/* Page heading */

.trail ol { list-style: none; display: flex; flex-wrap: wrap; margin: 0 0 var(--s1); padding: 0; font-size: var(--text-sm); color: var(--muted); }
.trail li::after { content: '/'; margin: 0 6px; color: var(--muted); }
.trail a { color: var(--text-2); }
.page-heading, .week-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s4); }
.page-heading h1, .week-title h1 { min-width: 0; }
.page-icon { display: inline-flex; color: var(--text-2); }
.page-actions, .week-links { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--s2); }
.h1-context { color: var(--muted); font-weight: var(--weight-regular); margin-left: var(--s1); }

/* Buttons */

.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-button); background: transparent; color: var(--text); font-size: var(--text-sm); line-height: var(--line); font-weight: var(--weight-medium); cursor: pointer; white-space: nowrap; }
.button:hover { background: var(--raised); text-decoration: none; }
.button .icon { width: 14px; height: 14px; }
.button-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.button-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.button-danger { border-color: var(--negative); color: var(--negative); }
.button-danger:hover { background: var(--negative-tint); }
.button-quiet { border-color: transparent; color: var(--text-2); }
.button-quiet:hover { border-color: var(--border); color: var(--text); }
.button-small { padding: 3px 8px; }
.button[disabled] { opacity: 0.55; cursor: default; }

/* Chips and badges */

.dot { flex: none; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.dot-0 { background: #6d8cff; } .dot-1 { background: #3fb97f; } .dot-2 { background: #d9a23a; } .dot-3 { background: #e5604d; }
.dot-4 { background: #b08cf5; } .dot-5 { background: #38b6c9; } .dot-6 { background: #e07fb0; } .dot-7 { background: #9aa64a; }
.chip, .badge, .role { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 1px 7px; border-radius: var(--r-chip); font-size: var(--text-sm); line-height: 16px; white-space: nowrap; vertical-align: middle; }
.chip { background: var(--raised); border: 1px solid var(--border); color: var(--text); max-width: 24ch; }
.chip-text { overflow: hidden; text-overflow: ellipsis; }
.chip-mark { color: var(--revised); font-size: var(--text-xs); }
.badge .icon { width: 12px; height: 12px; }
.badge-open { background: var(--accent-tint); color: var(--accent-text); }
.badge-awaiting { background: var(--warning-tint); color: var(--warning); }
.badge-approved { background: var(--positive-tint); color: var(--positive); }
.badge-revised { background: var(--revised-tint); color: var(--revised); }
.badge-problem { background: var(--negative-tint); color: var(--negative); }
.badge-neutral, .role { background: var(--raised); color: var(--text-2); border: 1px solid var(--border); }
.role-admin { color: var(--accent-text); }
.count { display: inline-block; margin-left: var(--s1); padding: 0 6px; border-radius: var(--r-chip); background: var(--raised); border: 1px solid var(--border); color: var(--text-2); font-size: var(--text-xs); font-weight: var(--weight-regular); font-variant-numeric: tabular-nums; }
.clip { display: inline-block; max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }

/* Messages, banners, toasts */

.message, .banner, .toast, .readiness { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); margin-bottom: var(--s4); border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-button); background: var(--raised); }
.message > .icon, .banner > .icon, .toast > .icon, .readiness > .icon { margin-top: 1px; }
.message-body, .banner > div, .readiness > div { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.message p:last-child, .banner p:last-child, .readiness p:last-child, .message ul:last-child, .banner ul:last-child, .readiness ul:last-child { margin-bottom: 0; }
.message-error, .banner-warning { border-left-color: var(--negative); background: var(--negative-tint); }
.message-error > .icon, .banner-warning > .icon { color: var(--negative); }
.message-success, .toast, .readiness-ready { border-left-color: var(--positive); background: var(--positive-tint); }
.message-success > .icon, .toast > .icon, .readiness-ready > .icon { color: var(--positive); }
.message-warning, .readiness-waiting { border-left-color: var(--warning); background: var(--warning-tint); }
.message-warning > .icon, .readiness-waiting > .icon { color: var(--warning); }
.message-info, .banner-open { border-left-color: var(--accent); background: var(--accent-tint); }
.message-info > .icon, .banner-open > .icon { color: var(--accent-text); }
.banner-locked { border-left-color: var(--positive); }
.banner-locked > .icon { color: var(--positive); }
.banner-revised { border-left-color: var(--revised); background: var(--revised-tint); }
.banner-revised > .icon { color: var(--revised); }
.toast-close { display: none; margin-left: auto; padding: 2px; border: 0; background: none; color: var(--text-2); cursor: pointer; border-radius: var(--r-chip); }
.js .toast-close { display: inline-flex; }
.error-summary a { color: inherit; text-decoration: underline; }

/* Cards */

.card { border: 1px solid var(--border); border-radius: var(--r-panel); background: var(--panel); margin-bottom: var(--s4); min-width: 0; }
.card-header { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--border); }
.card-aside { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.card-aside .hint { margin: 0; }
.card-body, .card-form, div.card:not(.card-flush) { padding: var(--s4); }
.card > .card-body, .card-form > .card-body, section.card > .card-header + .card-body { padding: var(--s4); }
.card-form, .card-flush, section.card { padding: 0; }
div.card.card-form { padding: var(--s4); }
.card-flush > .card-body { padding: 0; }
/* A form under a flush table (adding a payment) is not a table: it keeps a card's padding. */
.card-flush > .card-body.card-divided { padding: var(--s4); }
.card-flush .empty, .card-note { padding: var(--s3) var(--s4); margin: 0; }
.card-flush .table-scroll { border: 0; border-radius: 0 0 var(--r-panel) var(--r-panel); }
.card-danger { border-color: var(--negative-tint); box-shadow: inset 3px 0 0 var(--negative); }
.card-divided { border-top: 1px solid var(--border); }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: var(--s4); align-items: start; }
.dashboard { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: var(--s4); align-items: start; }
.dashboard .card { margin-bottom: 0; }
.dashboard .current-week { grid-column: 1 / -1; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s6) var(--s4); text-align: center; }
.empty-title { margin: 0; font-weight: var(--weight-medium); }
.empty-text { margin: 0 0 var(--s2); color: var(--text-2); max-width: 52ch; }
.all-clear .icon { color: var(--positive); }

details.disclosure > summary, details.disclosure-card > summary { cursor: pointer; color: var(--text-2); }
details.disclosure-card > summary { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s4); list-style: none; }
details.disclosure-card > summary::-webkit-details-marker { display: none; }
details.disclosure-card[open] > summary { border-bottom: 1px solid var(--border); color: var(--text); }
details.disclosure { margin: var(--s2) 0; }
details.disclosure[open] > summary { margin-bottom: var(--s2); }

/* Figures */

.headline-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s4) var(--s6); margin-bottom: var(--s4); }
.headline-label { margin: 0; font-size: var(--text-xs); color: var(--muted); }
.headline-value { margin: 2px 0 6px; font-size: var(--text-headline); line-height: 1.15; font-weight: var(--weight-medium); letter-spacing: -0.01em; }
.headline-status { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0; }
.headline-note { font-size: var(--text-sm); color: var(--muted); }
.key-figures { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); margin: 0; }
.key-figure dt { font-size: var(--text-xs); color: var(--muted); font-weight: var(--weight-regular); }
.key-figure dd { margin: 0; font-size: var(--text-lg); line-height: 22px; }
.key-figure-strong dd.num { font-weight: var(--weight-medium); }
.key-figure dd.key-figure-note { font-size: var(--text-xs); line-height: var(--line); color: var(--muted); }
.confirm-figures { padding: var(--s4); margin-bottom: var(--s4); border: 1px solid var(--border); border-radius: var(--r-panel); }
.setting-value { font-size: var(--text-headline); line-height: 1.15; font-weight: var(--weight-medium); margin-bottom: var(--s2); font-variant-numeric: tabular-nums; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s3) var(--s4); margin: 0; }
.facts dt { font-size: var(--text-xs); color: var(--muted); font-weight: var(--weight-regular); }
.facts dd { margin: 0; }

/* The week */

.week-header { margin-bottom: var(--s4); }
.week-title { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.week-dates { display: flex; flex-wrap: wrap; gap: var(--s1) var(--s4); margin: calc(-1 * var(--s2)) 0 var(--s4); color: var(--text-2); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
/* The steps scroll within their own frame when they do not fit. No scrollbar is drawn (it was thicker than the control); a fade at an edge says there is more that way. */
.stepper { position: relative; }
.stepper ol { overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
.stepper ol::-webkit-scrollbar { display: none; }
.stepper::before, .stepper::after { content: ''; position: absolute; top: 1px; bottom: 1px; width: 36px; pointer-events: none; opacity: 0; transition: opacity 0.12s; }
.stepper::before { left: 1px; border-radius: 9px 0 0 9px; background: linear-gradient(to right, var(--bg) 20%, transparent); }
.stepper::after { right: 1px; border-radius: 0 9px 9px 0; background: linear-gradient(to left, var(--bg) 20%, transparent); }
.stepper[data-more-before]::before, .stepper[data-more-after]::after { opacity: 1; }
/* Inside the frame, so the ring is not cut off where the steps scroll. */
.stepper a:focus-visible { outline-offset: -2px; }
.stepper ol, .progress-steps { list-style: none; display: flex; margin: 0; padding: 3px; gap: 3px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.stepper li, .progress-steps li { flex: 1 1 auto; min-width: 0; }
.stepper a, .progress-steps a { display: flex; align-items: center; gap: var(--s2); padding: 6px 8px; border-radius: 7px; color: var(--text-2); border: 1px solid transparent; }
.stepper a:hover, .progress-steps a:hover { background: var(--raised); text-decoration: none; color: var(--text); }
.step-current a { background: var(--raised); border-color: var(--border-strong); color: var(--text); }
.step-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.step-mark .icon { width: 12px; height: 12px; }
.step-done .step-mark { background: var(--positive-tint); border-color: transparent; color: var(--positive); }
.step-partial .step-mark { background: var(--warning-tint); border-color: transparent; color: var(--warning); }
.step-current .step-mark { border-color: var(--accent); }
.step-text { display: flex; flex-direction: column; min-width: 0; line-height: 15px; }
.step-label { font-weight: var(--weight-medium); white-space: nowrap; }
.step-detail { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress-steps { flex-wrap: wrap; margin: var(--s4) 0; }
.progress-steps li { flex: 1 1 150px; }
.step-footer { display: flex; justify-content: space-between; gap: var(--s2); margin-top: var(--s4); }
.current-week-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s2) var(--s3); margin-bottom: var(--s3); }
.week-name { font-size: var(--text-lg); font-weight: var(--weight-medium); color: var(--text); }
.next-action { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.next-note { color: var(--text-2); margin-right: var(--s2); }
.attention { list-style: none; margin: 0; padding: 0; }
.attention li { display: flex; gap: var(--s2); padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.attention li:last-child { border-bottom: 0; }
.attention .icon { color: var(--warning); margin-top: 1px; }
.share-bar { display: block; width: 100%; min-width: 60px; height: 6px; }
.share-track { fill: var(--raised); }
.share-fill { fill: var(--accent); }
.checklist { list-style: none; margin: 0 0 var(--s3); padding: 0; }
.checklist li { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--border); }
.check-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: var(--r-chip); border: 1px solid var(--border-strong); }
.checked .check-mark { background: var(--positive-tint); border-color: transparent; color: var(--positive); }
.check-mark .icon { width: 13px; height: 13px; }
.check-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.check-label { font-weight: var(--weight-medium); }
.check-description, .check-who { font-size: var(--text-sm); color: var(--text-2); }
.statement { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: var(--s4); align-items: start; margin-bottom: var(--s4); }
.statement .card { margin-bottom: 0; }
.section-key { display: inline-block; min-width: 22px; margin-right: var(--s1); padding: 0 5px; border-radius: var(--r-chip); background: var(--accent-tint); color: var(--accent-text); font-size: var(--text-xs); text-align: center; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: var(--s2); padding: var(--s5) var(--s4); border: 1px dashed var(--border-strong); border-radius: var(--r-panel); background: var(--raised); text-align: center; }
.dropzone.is-dragging { border-color: var(--accent); background: var(--accent-tint); }
.dropzone .field { align-items: center; margin: 0; }

/* Forms */

.field { display: flex; flex-direction: column; gap: var(--s1); margin-bottom: var(--s3); min-width: 0; }
.field label { font-size: var(--text-sm); color: var(--text-2); }
.required { color: var(--negative); }
input:not([type='checkbox']):not([type='radio']):not([type='hidden']), select, textarea { width: 100%; padding: 5px 8px; line-height: var(--line); border: 1px solid var(--border-strong); border-radius: var(--r-chip); background: var(--input); color: var(--text); }
input[type='file'] { padding: 4px; }
input::placeholder { color: var(--muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
input[type='checkbox'] { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); vertical-align: -2px; }
input.amount { text-align: right; }
[aria-invalid='true'] { border-color: var(--negative) !important; }
.field-error { margin: 2px 0 0; color: var(--negative); font-size: var(--text-sm); white-space: normal; }
.field-check label { display: flex; align-items: center; gap: var(--s2); color: var(--text); font-weight: var(--weight-regular); font-size: var(--text-md); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr)); gap: 0 var(--s3); align-items: start; }
.field-row-end { align-items: end; }
.fieldset { border: 0; padding: 0; margin: 0 0 var(--s2); min-width: 0; }
.fieldset legend { padding: 0; margin-bottom: var(--s2); font-size: var(--text-sm); color: var(--muted); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.form-narrow { max-width: 320px; }
form.inline, .inline-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin: 0; }
.inline-form label { font-size: var(--text-sm); color: var(--text-2); }
.inline-form select, form.inline select { width: auto; max-width: 220px; padding: 3px 6px; }
.js [data-autosubmit] + button { display: none; }

.action-bar, .save-bar { position: sticky; bottom: var(--s2); z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--s2) var(--s4); padding: var(--s3) var(--s4); margin-top: var(--s3); border: 1px solid var(--border-strong); border-radius: var(--r-panel); background: var(--raised); }
.save-bar { margin: var(--s3); justify-content: flex-start; }
.action-summary { flex: 1 1 220px; margin: 0; color: var(--text-2); }
.action-summary strong { color: var(--text); }
.action-bar .field { margin: 0; flex-direction: row; align-items: center; gap: var(--s2); }
.action-bar .field input { width: auto; }
.action-bar .field label { white-space: nowrap; }
.save-note { color: var(--warning); font-size: var(--text-sm); }

/* Tables */

.table-scroll { max-width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-button); }
.table-tall { max-height: min(68vh, 640px); }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
caption { text-align: left; padding: var(--s2) 10px; color: var(--text-2); font-weight: var(--weight-medium); caption-side: top; }
th, td { padding: 6px 8px; line-height: var(--line); text-align: left; white-space: nowrap; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: middle; }
th:last-child, td:last-child { border-right: 0; }
tbody tr:last-child > *, tfoot tr:last-child > * { border-bottom: 0; }
table:has(tfoot) tbody tr:last-child > * { border-bottom: 1px solid var(--border); }
thead th { position: sticky; top: 0; z-index: 2; background: var(--panel); color: var(--muted); font-weight: var(--weight-regular); }
tbody th { font-weight: var(--weight-regular); }
tbody tr:hover > * { background: var(--raised); }
tfoot th, tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--raised); border-top: 1px solid var(--border-strong); font-weight: var(--weight-medium); }
td.num, th.num { text-align: right; }
td.wrap, td.memo, .wrap { white-space: normal; overflow-wrap: anywhere; }
td.memo { min-width: 16ch; }
td.check, th.check { width: 1%; text-align: center; }
td.actions { width: 1%; }
td.actions a + a { margin-left: var(--s3); }
td.bar { width: 30%; }
.row-total > *, .row-subtotal > * { font-weight: var(--weight-medium); background: var(--raised); }
.row-total > * { border-top: 1px solid var(--border-strong); }
.row-group > th { background: var(--bg); color: var(--text-2); font-weight: var(--weight-medium); }
tr.retired > * { color: var(--muted); }
table.figures th { width: 60%; white-space: normal; color: var(--text-2); }
table.figures .row-total th { color: var(--text); }
table.figures td.note { color: var(--muted); white-space: normal; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th[data-sort] a { color: inherit; }
th[aria-sort='ascending']::after { content: ' ↑'; }
th[aria-sort='descending']::after { content: ' ↓'; }
.is-filtered [data-aggregate], tr[hidden] { display: none; }
ul.plain { list-style: none; margin: 0; padding: 0; }

.table-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s2) var(--s3); border-bottom: 1px solid var(--border); }
.filter-box { display: flex; align-items: center; gap: var(--s2); flex: 1 1 240px; margin: 0; color: var(--muted); }
.filter-box input[type='search'] { flex: 1; min-width: 0; max-width: 320px; padding: 3px 8px; }
.js .filter-box button { display: none; }
.table-count { margin: 0 0 0 auto; color: var(--muted); font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.segmented { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border); border-radius: var(--r-button); background: var(--bg); }
.segmented a { padding: 3px 10px; border-radius: var(--r-chip); color: var(--text-2); font-size: var(--text-sm); white-space: nowrap; }
.segmented a:hover { color: var(--text); text-decoration: none; }
.segmented a[aria-current] { background: var(--raised); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }

td.input { padding: 3px 4px; }
td.input input, td.input select { min-width: 7ch; padding: 3px 6px; }
td.input-wide input, td.input-wide select { min-width: 9ch; }
table.grid-cards th, table.grid-cards td { padding-left: 6px; padding-right: 6px; }
/* In a grid wider than its box, the name of the row stays in view while the rest scrolls under it. */
table.grid-cards tbody th, table.grid-cards tfoot th { position: sticky; left: 0; z-index: 1; background: var(--panel); }
table.grid-cards tfoot th { z-index: 3; background: var(--raised); }
.input-with-button { display: flex; gap: var(--s1); }

@media (max-width: 999px) {
  .col-optional { display: none; }
  /* The steps keep to one row and their names to one line: the few words under each give way, and what still does not fit scrolls within the stepper. */
  .stepper .step-detail { display: none; }
  .stepper li { flex: 1 0 auto; }
  .stepper a { padding: 6px; gap: 6px; }
  .chip { max-width: 18ch; }
  td.input-wide input, td.input-wide select { min-width: 8ch; }
}

@media (max-width: 899px) {
  /* Two cards side by side leave each too little room for a form: one under the other. */
  .columns { grid-template-columns: minmax(0, 1fr); }
  /* The bar under a list to tick from is two deliberate rows: what is ticked, then the date and the button. */
  .action-bar .action-summary { flex-basis: 100%; }
}

/* A grid of inputs has too many columns for a narrow window: there each row becomes a small card. */
@media (max-width: 639px) {
  table.grid-cards, table.grid-cards tbody, table.grid-cards tfoot { display: block; }
  table.grid-cards thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.grid-cards tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2) var(--s3); padding: var(--s3); border-bottom: 1px solid var(--border-strong); }
  table.grid-cards th, table.grid-cards td, table.grid-cards tbody th, table.grid-cards tfoot th { display: block; position: static; padding: 0; border: 0; white-space: normal; text-align: left; background: none; }
  table.grid-cards tbody th, table.grid-cards tfoot th { grid-column: 1 / -1; font-weight: var(--weight-medium); }
  table.grid-cards td:empty { display: none; }
  table.grid-cards td::before { content: attr(data-label); display: block; font-size: var(--text-xs); color: var(--muted); }
  table.grid-cards td.input input, table.grid-cards td.input select { min-width: 0; }
  table.grid-cards tbody tr:hover > * { background: none; }
}

/* Reports */

.report-viewer { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s4); }
.report-picker ul { list-style: none; display: flex; gap: 2px; margin: 0; padding: 3px; overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.report-picker a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--text-2); white-space: nowrap; border: 1px solid transparent; }
.report-picker a:hover { color: var(--text); text-decoration: none; background: var(--raised); }
.report-picker a[aria-current] { background: var(--raised); border-color: var(--border-strong); color: var(--text); }
.report-name { font-weight: var(--weight-medium); }
.report-description { display: none; }
.report-body { min-width: 0; }
.report-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); margin-bottom: var(--s3); }
.report-title { font-size: var(--text-lg); }
.report-tools { margin-left: auto; display: flex; flex-wrap: wrap; gap: var(--s2); }
.variant-picker, .pager-inline { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.report-part { margin-bottom: var(--s5); }
.report-part-heading { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s2); }
.report-actions { display: flex; flex-wrap: wrap; gap: var(--s1); margin: 0 0 var(--s2); }
.report-part-heading .report-actions { margin: 0 0 0 auto; }
.document-section { margin-bottom: var(--s4); }
.document-section .table-scroll + .table-scroll { margin-top: var(--s3); }

@media (min-width: 1280px) {
  .report-viewer { grid-template-columns: 232px minmax(0, 1fr); align-items: start; }
  .report-picker ul { flex-direction: column; overflow: visible; }
  .report-picker a { white-space: normal; }
  .report-description { display: block; font-size: var(--text-xs); color: var(--muted); }
}

/* Audit trail */

table.audit td.when { white-space: nowrap; }
.when-ago { display: block; }
.when-exact { display: block; font-size: var(--text-xs); color: var(--muted); }
table.audit td.what { min-width: 28ch; }
.what-line { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
table.audit .memo { display: block; color: var(--text-2); }
table.diff th { color: var(--text-2); }
table.diff td { white-space: normal; overflow-wrap: anywhere; }
.diff-before { color: var(--negative); }
.diff-after { color: var(--positive); }
.list-footer { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s4); }
.pager { display: flex; gap: var(--s2); }
.list-footer .hint { margin: 0 0 0 auto; }
.filter-card .field-row { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }

/* The ledger: search, quick actions, a record's headline, the three ledger panels */

.sidebar-search { display: flex; align-items: center; gap: var(--s1); margin: 0; padding: 0 var(--s2); border: 1px solid var(--border); border-radius: var(--r-button); background: var(--input); color: var(--muted); }
.sidebar-search input[type='search'] { border: 0; background: transparent; padding: 4px 0; min-width: 0; font-size: var(--text-sm); }
.sidebar-search input[type='search']:focus { outline: none; }
.sidebar-search:focus-within { border-color: var(--accent); }
.search-box { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); flex: 1 1 420px; margin: 0; color: var(--muted); }
.search-box input[type='search'] { flex: 1 1 200px; min-width: 0; max-width: 340px; padding: 3px 8px; }
.search-box select { width: auto; padding: 3px 8px; }
.chip-link { display: inline-flex; max-width: 100%; }
.chip-link:hover { text-decoration: none; }
.chip-link:hover .chip { border-color: var(--border-strong); background: var(--accent-tint); }
.quick-actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin: 0 0 var(--s4); padding: var(--s2) var(--s3); border: 1px solid var(--border); border-radius: var(--r-panel); background: var(--raised); align-items: center; }
.quick-actions-label { margin: 0 var(--s2) 0 0; font-size: var(--text-xs); color: var(--muted); }
.record-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s3) var(--s6); margin-bottom: var(--s4); }
.headline { margin: 0; }
.headline dt { font-size: var(--text-xs); color: var(--muted); }
.headline-figure { margin: 0; font-size: 30px; line-height: 36px; font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.ledger-panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr)); gap: var(--s4); align-items: start; margin-top: var(--s4); }
.upload-card .dropzone { margin-bottom: var(--s3); }
@media (max-width: 899px) {
  .nav-toggle:not(:checked) ~ .sidebar .sidebar-search { display: none; }
}

/* Print views, and paper */

.print-view { background: #ffffff; color: #000000; padding: var(--s5); }
.print-controls { display: flex; gap: var(--s2); margin-bottom: var(--s5); }
.print-header { margin-bottom: var(--s5); padding-bottom: var(--s3); border-bottom: 2px solid #000000; }
.print-company { font-size: var(--text-sm); color: var(--text-2); }
.print-view .table-scroll { overflow: visible; border: 0; max-height: none; }
.print-view thead th, .print-view tfoot th, .print-view tfoot td { position: static; }
.print-view .report-part.new-page + .report-part.new-page { margin-top: var(--s6); padding-top: var(--s5); border-top: 1px dashed var(--border-strong); }

@media print {
  :root, :root[data-theme='light'] {
    color-scheme: light;
    --bg: #ffffff; --panel: #ffffff; --raised: #ffffff; --input: #ffffff;
    --border: #bbbbbb; --border-strong: #666666;
    --text: #000000; --text-2: #222222; --muted: #444444;
    --accent-text: #000000; --accent-tint: transparent;
    --positive: #000000; --negative: #000000; --warning: #000000; --revised: #000000;
    --positive-tint: transparent; --negative-tint: transparent; --warning-tint: transparent; --revised-tint: transparent;
  }
  html { font-size: 11px; }
  body, body.with-sidebar { display: block; background: #ffffff; }
  .sidebar, .nav-toggle, .nav-backdrop, .plain-bar, .site-footer, .print-controls, .page-actions, .week-links, .stepper, .step-footer,
  .action-bar, .save-bar, .table-toolbar, .quick-actions, .sidebar-search, .report-picker, .report-tools, .report-actions, .toast, .skip-link, form.inline, .variant-picker { display: none !important; }
  .page, .panel, .print-view { padding: 0; border: 0; }
  .card { break-inside: avoid; }
  .table-scroll { overflow: visible; max-height: none; border: 0; }
  thead th, tfoot th, tfoot td { position: static; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  .col-optional { display: table-cell; }
  .report-part.new-page { break-before: page; }
  .report-part.new-page:first-child { break-before: auto; }
  .print-view .report-part.new-page + .report-part.new-page { border-top: 0; margin-top: 0; padding-top: 0; }
  a { color: inherit; }
}
