/*
 *  Admintool – the design system. One file, commented sections, no build step.
 *
 *  Calm personal-finance look: light grey-blue canvas, white rounded cards on
 *  a soft shadow, one confident blue, pill buttons and chips, Mona Sans type,
 *  Phosphor icons as inline SVG. 4/8 px spacing, 40 px controls (44 px inputs
 *  and fingers), tabular figures, de-CH money (1'250.00). The prefix is at_ in
 *  PHP and plain BEM here. docs/UI.md says which class belongs to which situation.
 */

/* ---- Fonts: Mona Sans (OFL), variable weight 200-900, see media/fonts/ ---- */

@font-face {
  font-family: "Mona Sans";
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/mona-sans-wght.woff2") format("woff2");
}
@font-face {
  font-family: "Mona Sans";
  font-style: italic;
  font-weight: 200 900;
  font-display: swap;
  src: url("fonts/mona-sans-italic-wght.woff2") format("woff2");
}

/* ---- Tokens ---------------------------------------------------------- */

:root {
  --c-main: #2f5bea;                 /* lib/template.php overrides from the configuration */
  --font: "Mona Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* type scale */
  --fs-2xs: 0.6875rem;  /* 11 */
  --fs-xs: 0.75rem;     /* 12 */
  --fs-sm: 0.8125rem;   /* 13 */
  --fs-base: 0.875rem;  /* 14 */
  --fs-md: 1rem;        /* 16 */
  --fs-lg: 1.125rem;    /* 18 */
  --fs-xl: 1.375rem;    /* 22 */
  --fs-2xl: 1.75rem;    /* 28 page title */
  --fs-hero: 2.125rem;  /* 34 big number */

  /* spacing scale, 4/8 px */
  --s-1: 0.25rem; --s-2: 0.5rem; --s-3: 0.75rem; --s-4: 1rem; --s-5: 1.25rem; --s-6: 1.5rem; --s-8: 2rem; --s-10: 2.5rem; --s-12: 3rem;

  /* controls and radii: cards 16, controls 12, small 8, buttons and chips pill */
  --h-ctl: 40px;          /* desktop button height */
  --h-input: 44px;        /* fields */
  --h-touch: 44px;        /* finger */
  --r-lg: 16px; --r-md: 12px; --r-sm: 8px; --r-pill: 999px;
  --content-w: 1130px;
  --side-w: 264px;
  --rail-w: 260px;
  --topbar-h: 64px;       /* 56 px below 1024 px, see the shell media query */
  --tabbar-h: 56px;       /* phone tab bar; content, sticky bars and the selection bar clear it */

  /* colour: light */
  --bg: #f3f5f9;
  --bg-side: #ffffff;
  --surface: #ffffff;
  --surface-2: #f7f8fb;
  --surface-3: #eceff5;
  --text: #0f1a33;
  --text-2: #36425d;
  --text-muted: #5b6680;
  --border: #e4e8f0;
  --border-strong: #c9d0de;
  /* edge of controls (fields, switches): 3.6:1 on white, 3.3:1 on the canvas (WCAG 1.4.11); cards and dividers keep the fine --border */
  --border-input: #7d8899;
  --card-edge: transparent;          /* dark mode draws a 1px edge instead of a shadow */
  --brand: var(--c-main);
  --brand-hover: color-mix(in srgb, var(--c-main) 85%, #000);
  --brand-soft: color-mix(in srgb, var(--c-main) 10%, transparent);
  --brand-soft-hover: color-mix(in srgb, var(--c-main) 18%, transparent);
  --on-brand: #ffffff;
  --ink: #0f1a33; --on-ink: #ffffff;
  /* ok/warn/danger are text-safe (4.5:1 on surface, canvas and their own soft tint); -fill is for dots, bars and charts only */
  --ok: #0e7545; --ok-fill: #1fbf75; --ok-soft: color-mix(in srgb, #1fbf75 12%, transparent);
  --warn: #965000; --warn-fill: #f5a524; --warn-soft: color-mix(in srgb, #f5a524 14%, transparent);
  --danger: #bd3027; --danger-fill: #f0625a; --danger-soft: color-mix(in srgb, #f0625a 12%, transparent);
  --info-soft: color-mix(in srgb, var(--c-main) 8%, transparent);
  --ok-text: var(--ok); --warn-text: var(--warn); --danger-text: var(--danger); --brand-text: color-mix(in srgb, var(--brand) 85%, #000); --muted-text: var(--text-muted);
  --on-danger: #ffffff;
  /* series and avatar colours: fill, and a text tone that reads on its own 14% tint (4.5:1) */
  --chart-0: #2f5bea; --chart-1: #19b5a5; --chart-2: #8b5cf6; --chart-3: #f5a524; --chart-4: #ec4899; --chart-5: #0ea5e9;
  --chart-0-text: #2a4fd0; --chart-1-text: #0b6b62; --chart-2-text: #6d3fd6; --chart-3-text: #8a4a00; --chart-4-text: #b0215f; --chart-5-text: #075f8e;
  /* focus: 3px brand ring, 5.5:1 on white (WCAG 1.4.11 asks 3:1) */
  --ring: color-mix(in srgb, var(--brand) 35%, transparent);
  --focus: 0 0 0 3px var(--brand);
  --shadow-1: 0 1px 2px rgba(15, 26, 51, 0.05), 0 2px 6px rgba(15, 26, 51, 0.04);
  --shadow-2: 0 4px 16px rgba(15, 26, 51, 0.08);
  --shadow-up: 0 -2px 12px rgba(15, 26, 51, 0.06);   /* tab bar */
  --shadow: var(--shadow-2); --shadow-sm: var(--shadow-1);
  --backdrop: rgba(15, 26, 51, 0.4);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1220; --bg-side: #151c2c; --surface: #151c2c; --surface-2: #1b2336; --surface-3: #232c42;
    --text: #e8ecf5; --text-2: #c3cbdc; --text-muted: #95a0b8; --border: #2a3349; --border-strong: #3d4863; --border-input: #6b7a90; --card-edge: var(--border);
    --brand: color-mix(in srgb, var(--c-main) 55%, #fff); --brand-hover: color-mix(in srgb, var(--c-main) 40%, #fff);
    --brand-soft: color-mix(in srgb, var(--c-main) 28%, transparent); --brand-soft-hover: color-mix(in srgb, var(--c-main) 38%, transparent); --on-brand: #0d1220;
    --ink: #e8ecf5; --on-ink: #0d1220;
    --ok: #45d38f; --ok-fill: #45d38f; --ok-soft: color-mix(in srgb, #45d38f 16%, transparent);
    --warn: #f2b54a; --warn-fill: #f2b54a; --warn-soft: color-mix(in srgb, #f2b54a 16%, transparent);
    --danger: #ff8a80; --danger-fill: #ff8a80; --danger-soft: color-mix(in srgb, #ff8a80 16%, transparent);
    --info-soft: color-mix(in srgb, var(--brand) 14%, transparent);
    --brand-text: var(--brand); --on-danger: #0d1220;
    --chart-0: #7b9bff; --chart-1: #3fd0c0; --chart-2: #b093ff; --chart-3: #f2b54a; --chart-4: #f57cb8; --chart-5: #4cc0f5;
    --chart-0-text: #9db5ff; --chart-1-text: #5fe0d1; --chart-2-text: #c7b3ff; --chart-3-text: #f7c978; --chart-4-text: #f99cc9; --chart-5-text: #7dd2fa;
    --shadow-1: none; --shadow-up: none; --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.5); --backdrop: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1220; --bg-side: #151c2c; --surface: #151c2c; --surface-2: #1b2336; --surface-3: #232c42;
  --text: #e8ecf5; --text-2: #c3cbdc; --text-muted: #95a0b8; --border: #2a3349; --border-strong: #3d4863; --border-input: #6b7a90; --card-edge: var(--border);
  --brand: color-mix(in srgb, var(--c-main) 55%, #fff); --brand-hover: color-mix(in srgb, var(--c-main) 40%, #fff);
  --brand-soft: color-mix(in srgb, var(--c-main) 28%, transparent); --brand-soft-hover: color-mix(in srgb, var(--c-main) 38%, transparent); --on-brand: #0d1220;
  --ink: #e8ecf5; --on-ink: #0d1220;
  --ok: #45d38f; --ok-fill: #45d38f; --ok-soft: color-mix(in srgb, #45d38f 16%, transparent);
  --warn: #f2b54a; --warn-fill: #f2b54a; --warn-soft: color-mix(in srgb, #f2b54a 16%, transparent);
  --danger: #ff8a80; --danger-fill: #ff8a80; --danger-soft: color-mix(in srgb, #ff8a80 16%, transparent);
  --info-soft: color-mix(in srgb, var(--brand) 14%, transparent);
  --brand-text: var(--brand); --on-danger: #0d1220;
  --chart-0: #7b9bff; --chart-1: #3fd0c0; --chart-2: #b093ff; --chart-3: #f2b54a; --chart-4: #f57cb8; --chart-5: #4cc0f5;
  --chart-0-text: #9db5ff; --chart-1-text: #5fe0d1; --chart-2-text: #c7b3ff; --chart-3-text: #f7c978; --chart-4-text: #f99cc9; --chart-5-text: #7dd2fa;
  --shadow-1: none; --shadow-up: none; --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.5); --backdrop: rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}
/* nothing below 12 px on phones and tablets */
@media (max-width: 1023px), (pointer: coarse) { :root { --fs-2xs: 0.75rem; } }

/* ---- Base ------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body {
  margin: 0; min-height: 100dvh; background: var(--bg); color: var(--text);
  font: 400 var(--fs-base)/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, p, ul, ol, dl, figure { margin: 0; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.25; }
a { color: var(--brand-text); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
small { font-size: var(--fs-xs); }
code, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.9em; }
:focus-visible { outline: 2px solid transparent; box-shadow: var(--focus); border-radius: var(--r-sm); }
@media (forced-colors: active) { :focus-visible { outline: 2px solid CanvasText; } }
[hidden] { display: none !important; }
.skip { position: absolute; left: var(--s-3); top: -100px; z-index: 100; padding: var(--s-2) var(--s-4); border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink); font-weight: 600; text-decoration: none; }
.skip:focus { top: var(--s-3); box-shadow: var(--focus); }
main:focus, main:focus-visible { outline: none; box-shadow: none; border-radius: 0; }  /* focused by js/app.js after a page swap, not a control */
/* a soft navigation that takes longer than 150 ms: say so without moving anything */
html.is-nav, html.is-nav a { cursor: progress; }
html.is-nav #main { opacity: .72; transition: opacity .2s; }
html.is-nav::before { content: ""; position: fixed; inset: 0 0 auto 0; z-index: 100; height: 2px; background: var(--brand); transform-origin: left; animation: at-nav 8s cubic-bezier(0.1, 0.8, 0.2, 1) forwards; }
@keyframes at-nav { from { transform: scaleX(0); } to { transform: scaleX(0.9); } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.num, .money { font-variant-numeric: tabular-nums; }
.money small, .money .cur { color: var(--text-muted); font-weight: 500; font-size: var(--fs-xs); margin-left: 0.3em; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.stack--tight { gap: var(--s-2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.btn-row { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.btn-row--left { justify-content: flex-start; }
.fineprint { color: var(--text-muted); font-size: var(--fs-xs); }
.fineprint code { font-size: inherit; }
/* helpers, not yet applied: narrow fields and line-break handling instead of inline styles */
.input--w-xs { max-width: 4.5rem; } .input--w-sm { max-width: 6rem; } .input--w-md { max-width: 8rem; }
.pre { white-space: pre-line; } .pre-wrap { white-space: pre-wrap; }
pre:not([class]) { max-width: 100%; margin: 0; padding: var(--s-3); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: auto; }
/* section label: sentence case, no capitals (also .ph__eyebrow, .nav-label, .menu__label) */
.eyebrow { font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
/* taps answer at once: no double-tap-to-zoom wait on controls */
a, button, summary, label, select, input, [role="button"] { touch-action: manipulation; }

/* ---- Icons (Phosphor Regular as inline SVG: lib/ui.php at_icon, at_svg; js icon()) */

.i, .svg { display: inline-block; width: 1em; height: 1em; flex: none; vertical-align: -0.15em; fill: currentColor; }
.i { width: 1.1em; height: 1.1em; vertical-align: -0.2em; }
/* the theme icon shows what a click switches to: moon in light, sun in dark */
.i--theme-sun { display: none; }
:root[data-theme="dark"] .i--theme-sun { display: inline-block; }
:root[data-theme="dark"] .i--theme-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i--theme-sun { display: inline-block; }
  :root:not([data-theme="light"]) .i--theme-moon { display: none; }
}

/* ---- Shell: sidebar, top bar, content ---------------------------------- */

.app { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100dvh; }
.side {
  position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s-2);
  padding: var(--s-4) var(--s-3); background: var(--bg-side); box-shadow: var(--shadow-1); border-right: 1px solid var(--card-edge);
}
.account { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2); border-radius: var(--r-md); color: var(--text); text-decoration: none; min-height: 48px; }
.account:hover { background: var(--surface-2); text-decoration: none; }
.account__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.account__name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account__sub { color: var(--text-muted); font-size: var(--fs-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account .svg { margin-left: auto; color: var(--text-muted); }
.side__nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3); height: 44px; padding: 0 var(--s-3); border-radius: var(--r-md);
  color: var(--text-2); font-weight: 600; text-decoration: none; transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.nav-item .i { width: 1.25rem; height: 1.25rem; font-size: 1.25rem; color: var(--text-muted); }
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.nav-item[aria-current="page"] .i { color: var(--brand-text); }
.nav-label { margin: var(--s-4) 0 var(--s-1); padding: 0 var(--s-3); font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); }
.side__foot .icon-btn[aria-current="page"] { background: var(--brand-soft); color: var(--brand-text); }
.side__foot { margin-top: auto; padding-top: var(--s-3); display: flex; align-items: center; gap: var(--s-2); }
.who { display: flex; align-items: flex-start; gap: var(--s-2); min-width: 0; flex: 1; padding: var(--s-1); border-radius: var(--r-md); color: var(--text); text-decoration: none; }
.who:hover { background: var(--surface-2); text-decoration: none; }
.who__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.who__text b { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who__text small { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: var(--fs-sm); flex: none; text-decoration: none; }

.shell { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: var(--s-3); height: var(--topbar-h); padding: 0 max(var(--s-8), env(safe-area-inset-right)) 0 max(var(--s-8), env(safe-area-inset-left));
  background: var(--bg);                                          /* solid, no backdrop blur: the blur is repainted on every scroll frame, costly on phones */
}
.topbar .topbar__menu { display: none; }
.search { position: relative; flex: 1; max-width: 420px; display: flex; align-items: center; }
.search .svg { position: absolute; left: 16px; color: var(--text-muted); pointer-events: none; }
.topbar .search input { width: 100%; height: var(--h-ctl); padding: 0 2.6rem 0 2.75rem; border: 1px solid var(--border-input); border-radius: var(--r-pill); background: var(--surface); box-shadow: none; }
.topbar .search input::placeholder { color: var(--text-muted); }
.topbar .search input:focus { border-color: var(--brand); box-shadow: var(--focus); outline: none; }
.search kbd { position: absolute; right: 14px; padding: 0 5px; border: 1px solid var(--border); border-radius: 4px; color: var(--text-muted); font-size: var(--fs-xs); line-height: 16px; background: var(--surface-2); }
.topbar__actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-1); }
.topbar__timer { display: inline-flex; align-items: center; gap: var(--s-2); height: var(--h-ctl); padding: 0 var(--s-3); border-radius: var(--r-pill); background: var(--brand-soft); color: var(--brand-text); font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none; white-space: nowrap; min-width: 0; }
.topbar__timer:hover { text-decoration: none; background: var(--brand-soft-hover); }
.topbar__timer-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger-fill); flex: none; animation: at-pulse 1.6s ease-in-out infinite; }
.topbar__timer-name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; font-weight: 600; }
@keyframes at-pulse { 50% { opacity: 0.35; } }
@media (max-width: 1023px) { .topbar__timer-name { display: none; } }
.content { width: 100%; max-width: calc(var(--content-w) + 2 * var(--s-8)); margin: 0 auto; padding: var(--s-4) max(var(--s-8), env(safe-area-inset-right)) var(--s-12) max(var(--s-8), env(safe-area-inset-left)); display: flex; flex-direction: column; gap: var(--s-6); }
.content--narrow { max-width: 760px; }
.content--wide { max-width: none; }
.footer { margin-top: auto; padding: var(--s-4) var(--s-6); color: var(--text-muted); font-size: var(--fs-xs); }
/* Pages without the frame: sign-in, installer, the customer's offer. */
.bare { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: var(--s-6) var(--s-4) var(--s-10); gap: var(--s-6); }
.bare .content { padding: 0; align-items: center; }
.bare .footer { padding: 0; text-align: center; }
.bare .card { width: 100%; max-width: 26rem; }
.tabbar, .sheet { display: none; }

@media (max-width: 1023px) {
  :root { --topbar-h: 56px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .topbar { padding: 0 max(var(--s-4), env(safe-area-inset-right)) 0 max(var(--s-4), env(safe-area-inset-left)); gap: var(--s-2); }
  .topbar__menu { display: inline-flex; }
  .content { padding: var(--s-3) max(var(--s-4), env(safe-area-inset-right)) calc(var(--s-12) + var(--tabbar-h) + env(safe-area-inset-bottom)) max(var(--s-4), env(safe-area-inset-left)); gap: var(--s-5); }
  .footer { display: none; }
  .search { max-width: none; }
  .search kbd { display: none; }
  /* phone navigation: a tab bar at the foot and a sheet with the rest */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--surface); box-shadow: var(--shadow-up); border-top: 1px solid var(--card-edge);
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .tabbar__item {
    flex: 1 1 0; min-width: 0; min-height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    border: 0; background: none; color: var(--text-muted); font: inherit; font-size: var(--fs-2xs); font-weight: 600; text-decoration: none;
  }
  /* the pill sits behind the icon itself, so the markup stays an icon over a label */
  .tabbar__item .i { box-sizing: content-box; width: 1.4rem; height: 1.4rem; padding: 4px 16px; border-radius: var(--r-pill); transition: background 0.15s var(--ease); }
  .tabbar__dots { padding: 4px 16px; border-radius: var(--r-pill); }
  .tabbar__item { position: relative; }
  .tabbar__badge { position: absolute; top: 8px; left: calc(50% + 14px); width: 8px; height: 8px; border-radius: 50%; background: var(--danger-fill); border: 2px solid var(--surface); box-sizing: content-box; }
  .tabbar__dots { font-style: normal; font-size: 1.1rem; line-height: 1.3rem; }
  .tabbar__item[aria-current="page"], .tabbar__item.is-current, .tabbar__item[aria-expanded="true"] { color: var(--brand-text); font-weight: 700; }
  .tabbar__item[aria-current="page"] .i, .tabbar__item.is-current .tabbar__dots, .tabbar__item[aria-expanded="true"] .tabbar__dots { background: var(--brand-soft); }
  .sheet { display: block; position: fixed; inset: 0; z-index: 50; }
  .sheet__backdrop { position: absolute; inset: 0; background: var(--backdrop); }
  .sheet__panel {
    position: absolute; left: 0; right: 0; bottom: 0; max-height: 85dvh; overflow-y: auto; background: var(--surface);
    border-radius: 20px 20px 0 0; padding: var(--s-2) var(--s-2) calc(var(--s-2) + env(safe-area-inset-bottom)); box-shadow: var(--shadow-2); border: 1px solid var(--card-edge); border-bottom: 0;
  }
  .sheet__item {
    display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 48px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-md);
    background: none; color: var(--text); font: inherit; text-align: left; text-decoration: none;
  }
  .sheet__item:hover { background: var(--surface-2); }
  .sheet__item .i { width: 1.3rem; height: 1.3rem; color: var(--text-muted); }
  .sheet__item small { margin-left: auto; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 50%; }
  .sheet__item[aria-current="page"] { color: var(--brand-text); font-weight: 700; background: var(--brand-soft); }
  .sheet__item[aria-current="page"] .i { color: var(--brand-text); }
  .sheet__label { padding: var(--s-3) var(--s-3) var(--s-1); font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); }
}

/* ---- Page header: crumb, title, sub, actions, tabs ----------------------- */

.ph { display: flex; flex-direction: column; gap: var(--s-2); }
.ph__crumb { font-size: var(--fs-sm); font-weight: 600; display: inline-flex; align-items: center; gap: var(--s-1); align-self: flex-start; }
.ph__row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; }
.ph__main { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.ph__eyebrow { font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); }
.ph__title { font-size: var(--fs-2xl); font-weight: 700; display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; overflow-wrap: break-word; hyphens: auto; }
.ph__title .badge { font-size: var(--fs-xs); }
.ph__sub { color: var(--text-muted); display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
/* one wrapping row of controls */
.ph__actions, .fbar__row, .doc__contact, .oi__more-actions, .inline-form, .mini-form, .cal-nav { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.tabs { display: flex; gap: var(--s-6); border-bottom: 1px solid var(--border); padding: 0 var(--s-1); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: var(--s-2); height: 40px; padding: 0 2px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a[aria-current] { color: var(--text); font-weight: 700; border-color: var(--brand); }
.tabs .count { color: var(--text-muted); font-weight: 500; }
@media (max-width: 640px) {
  .ph__title { font-size: var(--fs-xl); }
  .card { padding: var(--s-4); }
  .ph__actions { width: 100%; }
  .ph__actions .btn--primary { flex: 1; }
}

/* ---- Search form of the reports (reports.php) ------------------------------ */

.filters__search { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.filters__search > .input:first-child { flex: 1 1 14rem; }
.filters__search > select.input { flex: 0 1 auto; width: auto; }

/* ---- Lists: filter bar, summary, month groups, expandable rows (lib/ui.php at_list…) ---- */
/* Every row is its own grid on the list's --cols, so header, rows and groups line up without a table;
   below 1280 px the --cols-md set drops the .lrow__hide-md cells, below 640 px a row is two lines. */

.fbar { display: flex; flex-direction: column; gap: var(--s-3); }
.fbar__row > input[type="search"] { flex: 1 1 14rem; }
.fbar__row select.input, .fbar__row .combo { flex: 0 1 auto; width: auto; max-width: 15rem; }
.fbar__sels { display: contents; }
.btn.fbar__more { display: none; }   /* .btn alone would show it: the button is for phones */
.fbar__more .count { color: var(--text-muted); font-variant-numeric: tabular-nums; }
.fbar__dates { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--text-muted); }
.fbar__dates .input { width: auto; }
.fbar__end { margin-left: auto; }
.seg { display: inline-flex; flex-wrap: wrap; gap: var(--s-2); max-width: 100%; align-self: flex-start; }
.seg__item { display: inline-flex; align-items: center; gap: var(--s-1); height: 36px; padding: 0 var(--s-4); border-radius: var(--r-pill); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: 600; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow-1); border: 1px solid var(--card-edge); transition: background 0.15s var(--ease); }
.seg__item:hover { color: var(--text); background: var(--surface-3); text-decoration: none; }
.seg__item[aria-current] { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; box-shadow: none; }
.seg__item .i { color: var(--text-muted); }
.seg__item[aria-current] .i { color: var(--brand-text); }
.seg__item .count { color: var(--text-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.seg__item[aria-current] .count { color: var(--brand-text); }

.ltiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: var(--s-4); }
.tile__sub { font-size: var(--fs-xs); font-weight: 500; color: var(--text-muted); }
.tile--ok .tile__value { color: var(--ok-text); }

.lst { display: flex; flex-direction: column; padding: var(--s-2) var(--s-3) var(--s-3); font-variant-numeric: tabular-nums; }
.lst--inv { --cols: minmax(0, 1fr) 14rem 8.5rem 36px; --cols-md: minmax(0, 1fr) 14rem 8.5rem 36px; }
.lst--off { --cols: minmax(0, 1fr) 14rem 8.5rem 8px 36px; --cols-md: minmax(0, 1fr) 14rem 8.5rem 8px 36px; }
.lst--cli { --cols: minmax(0, 1fr) 9.5rem 7.5rem 7rem 8.5rem; --cols-md: minmax(0, 1fr) 9.5rem 7rem 8.5rem; }
.lst--prj { --cols: minmax(0, 2fr) minmax(0, 1fr) 7.5rem 7.5rem 6rem 8rem; --cols-md: minmax(0, 2fr) minmax(0, 1fr) 7.5rem 6rem 8rem; }
.lst--con { --cols: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.2fr) 8.5rem 6.5rem; --cols-md: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.2fr) 8.5rem; }
.lrow { display: grid; grid-template-columns: var(--cols); gap: 0 var(--s-3); align-items: center; min-height: 64px; padding: var(--s-2); border-radius: var(--r-md); }
.lst__head { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); border: 0; min-height: 0; }   /* money rows carry no column heads; assistive tech keeps them */
/* Firmen, Projekte, Kontakte: bare figures need their column heads on a desktop */
@media (min-width: 1024px) {
  .lst--cli .lst__head, .lst--prj .lst__head, .lst--con .lst__head { position: static; width: auto; height: auto; min-height: 36px; padding: 0 var(--s-2); overflow: visible; clip: auto; border-radius: 0; border-bottom: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); }
}
.lrow__main { display: flex; flex-direction: column; min-width: 0; }
.lrow__main > a, .lrow__txt > a { width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); font-weight: 600; }
.lrow__main small, .lrow__txt small, .lrow__trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow__main small { color: var(--text-muted); }
.lrow__main--av { flex-direction: row; align-items: center; gap: var(--s-3); }
.lrow__txt { display: flex; flex-direction: column; min-width: 0; }
.lrow__txt small { color: var(--text-muted); font-size: var(--fs-sm); }
.lrow__trunc { color: var(--text-2); }
.lrow__trunc a { color: inherit; }
.lrow__num { text-align: right; white-space: nowrap; }
.lrow__date { color: var(--text-muted); white-space: nowrap; }
.lrow__amt { font-size: var(--fs-md); font-weight: 700; }
.lrow__amt.is-paid { color: var(--ok-text); }
.lrow .is-overdue { color: var(--warn-text); }
.lrow .is-dunned { color: var(--danger-text); }
.lrow__status { min-width: 0; }
.lrow__status .badge { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.lrow__sm { display: none; }
.lrow__chev { display: flex; justify-content: center; color: var(--text-muted); transition: transform 0.15s var(--ease); }
div.lrow:not(.lst__head):hover { background: var(--surface-2); }
.lgroup__head { position: sticky; top: var(--topbar-h); z-index: 2; display: flex; justify-content: space-between; gap: var(--s-4); padding: var(--s-5) var(--s-2) var(--s-2); background: var(--surface); font-size: var(--fs-sm); font-weight: 700; }
.lgroup__head .num { color: var(--text-muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.xrow > .lrow { cursor: pointer; }
.xrow.is-open > .lrow { background: var(--surface-2); }
.lrow__chev { align-self: stretch; }
.xrow__toggle { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; min-height: 32px; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: inherit; cursor: pointer; }
.xrow__toggle:hover { color: var(--text); }
.xrow__toggle:focus-visible { box-shadow: inset 0 0 0 2px var(--brand); }
.xrow.is-open .lrow__chev { transform: rotate(180deg); }
.xrow__body[hidden] { display: none; }
.xrow__body > [role="cell"] { display: flex; flex-direction: column; gap: var(--s-4); }
.xrow__body { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-2) var(--s-4) var(--s-5) calc(var(--s-4) + 52px); background: var(--surface-2); border-radius: 0 0 var(--r-md) var(--r-md); }
.xrow__body .kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: var(--s-3) var(--s-6); }
.xrow__acts { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.badge .i { font-size: 0.85rem; }
.badge__num { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 16px; margin-left: -0.3em; padding: 0 4px; border: 1.5px solid currentColor; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; }
@media (max-width: 1279px) {
  .lrow { grid-template-columns: var(--cols-md, var(--cols)); }
  .lrow > .lrow__hide-md { display: none; }
}
@media (max-width: 640px) {
  .fbar__end { margin-left: 0; }
  .fbar__row select.input, .fbar__row .combo { flex: 1 1 40%; max-width: none; }
  .btn.fbar__more { display: inline-flex; }
  .fbar__sels { display: none; }
  .fbar.is-more .fbar__sels { display: flex; flex: 1 1 100%; flex-wrap: wrap; gap: var(--s-2); }
  .fbar__row > .btn[type="submit"] { display: none; }               /* Enter and the selects submit */
  .ltiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .ltiles .tile { padding: var(--s-4); }
  .ltiles .tile__value { font-size: var(--fs-lg); overflow-wrap: anywhere; }
  .ltiles .tile--main { grid-column: 1 / -1; }
  .lst { padding: var(--s-1) var(--s-3) var(--s-2); }
  .lrow { grid-template-columns: minmax(0, 1fr) auto; gap: 2px var(--s-3); padding: var(--s-3) 0; min-height: 68px; }
  .xrow > .lrow { grid-template-columns: minmax(0, 1fr) auto 36px; }
  .lrow__main--av .av { width: 36px; height: 36px; }
  .lrow__txt > a, .lrow__txt small { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; white-space: normal; overflow: hidden; text-overflow: clip; }
  .lrow__txt > a { width: auto; }
  .lrow__txt > a { overflow-wrap: break-word; hyphens: auto; }
  .lrow__txt small { -webkit-line-clamp: 1; }
  .lrow > .lrow__hide-sm { display: none; }
  .lrow__chev { grid-column: 3; grid-row: 1 / span 2; min-height: 44px; }
  .lrow__main { grid-column: 1; grid-row: 1 / span 2; }
  .lrow__amt { grid-column: 2; grid-row: 1; font-weight: 600; }
  .lrow__status { grid-column: 2; grid-row: 2; justify-self: end; }
  .lrow__sm { display: flex; gap: var(--s-2); }
  .lgroup__head { padding-left: 0; padding-right: 0; }
  .xrow.is-open > .lrow { background: none; }
  .xrow__body { padding: var(--s-3); border-radius: var(--r-md); margin-bottom: var(--s-2); border-bottom: 0; }
  .xrow__body .kv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2); height: var(--h-ctl); padding: 0 var(--s-5); border-radius: var(--r-pill);
  border: 1px solid transparent; background: var(--brand-soft); color: var(--brand-text); font-weight: 700; font-size: var(--fs-base); line-height: 1; text-decoration: none; white-space: nowrap;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.btn:hover { text-decoration: none; background: var(--brand-soft-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn--primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn--outline, .btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border-input); }
.btn--outline:hover, .btn--ghost:hover { background: var(--surface-2); border-color: var(--text-muted); }
.btn--plain { background: none; color: var(--text-2); }
.btn--plain:hover { background: var(--surface-3); }
.btn--danger { background: var(--danger); color: var(--on-danger); border-color: var(--danger); }
.btn--danger:hover { filter: brightness(0.93); }
.btn--link { background: none; border: 0; color: var(--brand-text); padding: 0; height: auto; font-weight: 600; }
.btn--link:hover { background: none; }
.btn--link:hover { text-decoration: underline; }
.btn--sm { height: 32px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.btn--lg { height: 48px; padding: 0 var(--s-6); font-size: var(--fs-md); }
.btn--xl { height: 60px; padding: 0 var(--s-6); font-size: var(--fs-lg); flex: 1 1 10rem; }
.btn--block { width: 100%; }
.btn--round { width: var(--h-ctl); padding: 0; border-radius: 50%; font-size: 1.2rem; }
.btn--round .i, .btn--round .svg { flex: none; }
.btn .i, .btn .svg { width: 1.15em; height: 1.15em; font-size: 1rem; vertical-align: 0; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: var(--h-ctl); height: var(--h-ctl); padding: 0; border-radius: 50%;
  border: 1px solid transparent; background: none; color: var(--text-muted); text-decoration: none; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.icon-btn--outline { border-color: var(--border-input); background: var(--surface); color: var(--text); }
.icon-btn--sm { width: 24px; height: 24px; }
.icon-btn--danger:hover { color: var(--danger-text); background: var(--danger-soft); }
.icon-btn .i, .icon-btn .svg { width: 1.2rem; height: 1.2rem; font-size: 1.2rem; vertical-align: 0; }
/* finger sizes follow the pointer, not the width: an iPad upright is wider than 640 px and still a finger */
@media (pointer: coarse) {
  .btn, .icon-btn, .input, select.input { min-height: var(--h-touch); }
  .btn { padding: 0 var(--s-5); }
  .btn--sm, .icon-btn--sm { min-height: var(--h-touch); }
  .icon-btn { width: var(--h-touch); }
  .icon-btn--sm { width: var(--h-touch); }
  .btn--round { width: var(--h-touch); padding: 0; }   /* the .btn padding above would squeeze the «+» to a dot */
}

/* ---- Inputs, fields, forms ---------------------------------------------- */

.input, select, textarea, input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]) {
  width: 100%; height: var(--h-input); padding: 0 var(--s-4); border: 1px solid var(--border-input); border-radius: var(--r-md); background: var(--surface); color: var(--text);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
textarea, textarea.input { height: auto; min-height: 5rem; padding: var(--s-3) var(--s-4); line-height: 1.5; resize: vertical; }
/* input.combo__input, not .combo__input: the field rule above (input:not(…), background shorthand) would win and tile the arrow */
select, select.input, input.combo__input { padding-right: 2rem; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6680' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
/* the arrow stroke is --text-muted; the dark tone is the dark --text-muted (#95a0b8) */
:root[data-theme="dark"] select, :root[data-theme="dark"] select.input, :root[data-theme="dark"] .combo__input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2395a0b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) select, :root:not([data-theme="light"]) select.input, :root:not([data-theme="light"]) .combo__input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2395a0b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); }
}
/* iOS zooms into any field under 16px on focus and stays zoomed */
@media (max-width: 1023px) {
  .input, select, textarea, input:not([type="checkbox"], [type="radio"], [type="range"], [type="file"]),
  .doc .input, .doc select, .doc textarea, .oi .input, .oi textarea, .calc .input { font-size: 16px !important; }
}
:is(.input, select, textarea, input):focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); outline: none; }
/* a checkbox, radio or slider has no border to recolour: it keeps the full focus ring (WCAG 2.4.7, 1.4.11; the 35 % ring alone was 1.7:1) */
:is(input[type="checkbox"], input[type="radio"], input[type="range"]):focus-visible { box-shadow: var(--focus); }
:is(.input, select, textarea, input)[aria-invalid="true"] { border-color: var(--danger); }
:is(.input, select, textarea, input):disabled, :is(.input, select, textarea, input)[readonly] { background: var(--surface-2); color: var(--text-2); box-shadow: none; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
.input--inline { width: auto; min-width: 9rem; }
.input--code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.2em; text-align: center; font-size: var(--fs-lg); height: 48px; }
.input--num { text-align: right; font-variant-numeric: tabular-nums; }
.field { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.field__label, label.label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.field small { color: var(--text-muted); font-size: var(--fs-xs); }
.field .field__error, .field__error { color: var(--danger-text); font-size: var(--fs-xs); }
.field__error:empty { display: none; }
.field--wide { grid-column: 1 / -1; }
.form { display: flex; flex-direction: column; gap: var(--s-5); }
.form__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.form__grid--pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); }
.form__group { display: flex; flex-direction: column; gap: var(--s-3); }
.form__hint { color: var(--text-muted); font-size: var(--fs-sm); }
.form__actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; padding-top: var(--s-2); }
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; min-height: 28px; }
.switch input { appearance: none; width: 40px; height: 24px; margin: 0; border-radius: var(--r-pill); background: var(--border-input); position: relative; flex: none; cursor: pointer; transition: background 0.15s; border: 0; box-shadow: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.3); transition: transform 0.15s var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.switch input:focus-visible { box-shadow: var(--focus); }
.check { display: flex; align-items: flex-start; gap: var(--s-2); cursor: pointer; }
.check input { width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--brand); flex: none; }
@media (max-width: 640px) {
  .form__grid { grid-template-columns: minmax(0, 1fr); }
  .form__actions { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); margin: 0 calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4); background: var(--bg); z-index: 10; }
  .form__actions .btn--primary { flex: 1; }
}

/* ---- Cards and sections -------------------------------------------------- */

/* One surface box for every bordered panel; each class below adds only its own padding and layout. */
.card, .metric, .doc, .calc, .timer, .sumcard, .lst, .tile, .ov .rail__sec, .cal-list, .cal-month, .kb-gantt, .kb-list { border: 1px solid var(--card-edge); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-1); }
.card { padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.card--wide { max-width: 52rem; width: 100%; }
.card--list { width: 100%; }
.card__head { display: flex; flex-direction: column; gap: var(--s-1); }
.card__title { font-size: var(--fs-md); font-weight: 700; }
.card__subtitle { font-size: var(--fs-md); font-weight: 700; }
.card__subtitle--first { margin-top: 0; }
.card__lead { color: var(--text-muted); }
.section { display: flex; flex-direction: column; gap: var(--s-3); }
.section__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 32px; }
.section__title { font-size: var(--fs-md); font-weight: 700; display: flex; align-items: center; gap: var(--s-2); }
.section__title .count { color: var(--text-muted); font-weight: 500; font-size: var(--fs-base); }
.section__actions { display: flex; align-items: center; gap: var(--s-1); }

/* ---- Alerts and banner --------------------------------------------------- */

.alert { padding: var(--s-3) var(--s-4); border-radius: var(--r-md); border: 1px solid transparent; background: var(--surface-3); display: flex; gap: var(--s-2); align-items: flex-start; }
.alert--error { background: var(--danger-soft); color: var(--danger-text); }
.alert--ok { background: var(--ok-soft); color: var(--ok-text); }
.alert--warn { background: var(--warn-soft); color: var(--warn-text); }
.banner { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--card-edge); color: var(--text-2); }
.banner--warn { background: var(--warn-soft); }
.banner--danger { background: var(--danger-soft); }
.banner--info { background: var(--info-soft); }
.banner > .i { color: var(--text-muted); font-size: 1.25rem; }
.banner p { flex: 1; min-width: 0; }
.banner .btn { flex: none; }
.banner__close { margin-left: auto; }
@media (max-width: 640px) { .banner { flex-wrap: wrap; } .banner p { flex-basis: 100%; } }

/* ---- State of a decision as word and shape (Z35, V9): one set for office, portal, book; colour never alone ---- */
.st { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); font-weight: 600; color: var(--text-2); }
.st::before { content: ""; width: 12px; height: 12px; border-radius: 50%; box-sizing: border-box; flex: none; border: 2px solid var(--text-muted); }
.st__why { font-weight: 400; color: var(--text-muted); }
.st--draft { color: var(--text-muted); }
.st--draft::before { border-style: dashed; }
.st--open::before { border-color: var(--text-2); }
.st--clarify::before { border-color: var(--brand); background: linear-gradient(90deg, var(--brand) 50%, transparent 50%); }
.st--decided { color: var(--ok-text); }
.st--decided::before { border-color: var(--ok); background: var(--ok); box-shadow: inset 0 0 0 2px var(--surface); }
.st--withdrawn { color: var(--text-muted); }
.st--withdrawn::before { border-color: var(--text-muted); background: linear-gradient(135deg, transparent 45%, var(--text-muted) 45%, var(--text-muted) 55%, transparent 55%); }

/* ---- Badges, dots --------------------------------------------------------- */

.badge { display: inline-flex; align-items: center; gap: 0.3em; height: 24px; padding: 0 0.7em; border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; line-height: 1; vertical-align: middle; }
.badge--brand { background: var(--brand-soft); color: var(--brand-text); }
.badge--ok { background: var(--ok-soft); color: var(--ok-text); }
.badge--warn { background: var(--warn-soft); color: var(--warn-text); }
.badge--danger { background: var(--danger-soft); color: var(--danger-text); }
.badge--muted { background: var(--surface-3); color: var(--muted-text); }
.badge--outline { background: none; border: 1px solid var(--border); }
a.badge { text-decoration: none; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); flex: none; vertical-align: middle; }
.dot--green { background: var(--ok-fill); }
.dot--amber { background: var(--warn-fill); }
.dot--red { background: var(--danger-fill); }

/* ---- Tables and stacked rows on a phone ------------------------------------ */

.table-wrap { position: relative; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r-lg); }
/* a table straight on the canvas becomes a card; inside a card it stays flat */
.content .table-wrap { background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--card-edge); }
.card .table-wrap, .doc .table-wrap { background: none; box-shadow: none; border: 0; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { padding: 0 var(--s-3); height: 40px; text-align: left; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); background: var(--surface-2); white-space: nowrap; }
.table th:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.table th:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.table td { padding: 0 var(--s-3); height: 48px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tfoot td, .table__total td, td.table__total { font-weight: 700; border-bottom: 0; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table th:first-child, .table td:first-child { padding-left: var(--s-2); }
.table th:last-child, .table td:last-child { padding-right: var(--s-2); }
.table th.table__num, .table__num { text-align: right; white-space: nowrap; }
td.table__num { font-weight: 600; }
.table__name a { color: var(--text); font-weight: 600; }
.table__name small { display: block; color: var(--text-muted); font-weight: 500; }
.table__id { white-space: nowrap; }
.table__date { white-space: nowrap; color: var(--text-muted); }
.table__wide { width: 40%; }
.table__tiny { width: 1%; }
.table__empty { text-align: center; color: var(--text-muted); padding: var(--s-8) var(--s-3) !important; height: auto !important; }
.table__group td { background: var(--surface-2); font-weight: 700; }
tr.is-muted td { color: var(--text-muted); }
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; }
  /* one record per row: primary line (name + amount right), then the rest small and muted */
  .table tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
  .table tr:last-child { border-bottom: 0; }
  .table td { padding: 0; height: auto; border: 0; order: 3; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; }
  .table tbody tr:hover td { background: none; }
  .table td.table__name { flex: 1 1 60%; order: 1; font-size: var(--fs-base); color: var(--text); }
  .table tr:not(:has(td.is-amount)) td.table__name { flex-basis: 100%; }
  .table td.is-amount { order: 2; flex: 1 0 auto; text-align: right; font-weight: 700; font-size: var(--fs-base); color: var(--text); }
  .table td[data-label]::before { content: attr(data-label) " "; }
  .table td.table__num:not(.is-amount) { text-align: left; white-space: nowrap; }
  .table td.table__hide-sm { display: none; }
  .table__empty { flex: 1; text-align: left; padding: var(--s-6) 0 !important; }
}
@media (max-width: 900px) { .table .table__hide-md { display: none; } }

/* Row lists (Stripe mini tables): a line per record, name left, amount right. */
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: var(--s-3); min-height: 56px; padding: var(--s-2) 0; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; }
.row:last-child { border-bottom: 0; }
a.row:hover { text-decoration: none; background: var(--surface-2); margin: 0 calc(-1 * var(--s-2)); padding-left: var(--s-2); padding-right: var(--s-2); border-radius: var(--r-md); }
.row__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row__main b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__main small { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__end { display: flex; align-items: center; gap: var(--s-2); flex: none; font-variant-numeric: tabular-nums; font-weight: 700; }
/* avatar for money rows: client initials on a series colour (lib helper picks av--0..5 from a hash of the name) */
.av { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; flex: none; font-size: var(--fs-sm); font-weight: 700; background: color-mix(in srgb, var(--av) 16%, transparent); color: var(--av-text); }
.av--0 { --av: var(--chart-0); --av-text: var(--chart-0-text); }
.av--1 { --av: var(--chart-1); --av-text: var(--chart-1-text); }
.av--2 { --av: var(--chart-2); --av-text: var(--chart-2-text); }
.av--3 { --av: var(--chart-3); --av-text: var(--chart-3-text); }
.av--4 { --av: var(--chart-4); --av-text: var(--chart-4-text); }
.av--5 { --av: var(--chart-5); --av-text: var(--chart-5-text); }

/* ---- Empty state, timeline, details rail, key/value --------------------- */

.empty { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); padding: var(--s-8) var(--s-4); border-radius: var(--r-lg); color: var(--text-muted); text-align: center; }
.more { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); margin: var(--s-4) 0 var(--s-2); }
.empty b { color: var(--text); font-weight: 700; }
.empty__icon { width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand-text); font-size: 1.6rem; margin-bottom: var(--s-1); }
.empty .btn { margin-top: var(--s-1); }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 10px; bottom: 10px; width: 2px; background: var(--border); }
.timeline__item { position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 0 var(--s-2); padding: var(--s-2) 0 var(--s-4); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-strong); margin-top: 5px; }
.timeline__item--brand .timeline__dot { border-color: var(--brand); background: var(--brand); }
.timeline__item--warn .timeline__dot { border-color: var(--warn-fill); background: var(--warn-fill); }
.timeline__item--danger .timeline__dot { border-color: var(--danger-fill); background: var(--danger-fill); }
.timeline__title { font-weight: 600; }
.timeline__text { grid-column: 2; color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere; }
.timeline__when { color: var(--text-muted); font-size: var(--fs-xs); white-space: nowrap; }
.timeline__form { grid-column: 2 / -1; }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) var(--rail-w); gap: var(--s-10); align-items: start; }
.detail__main { display: flex; flex-direction: column; gap: var(--s-8); min-width: 0; }
.rail { display: flex; flex-direction: column; gap: var(--s-6); position: sticky; top: calc(64px + var(--s-6)); }
.rail__sec { display: flex; flex-direction: column; gap: var(--s-3); padding-bottom: var(--s-5); border-bottom: 1px solid var(--border); }
.rail__sec:last-child { border-bottom: 0; }
.rail__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.rail__title { font-size: var(--fs-md); font-weight: 700; }
.kv { display: flex; flex-direction: column; gap: var(--s-3); margin: 0; }
.kv > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kv dt { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; display: flex; align-items: flex-start; gap: var(--s-1); }
.kv dd .icon-btn { margin: -4px 0 -4px auto; }
.kv--grid { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2) var(--s-4); }
.kv--grid > div { display: contents; }
.kv--grid dt { align-self: baseline; font-size: var(--fs-base); }
@media (max-width: 900px) {
  .detail { grid-template-columns: minmax(0, 1fr); gap: var(--s-6); }
  .rail { position: static; padding: var(--s-4); border: 1px solid var(--card-edge); box-shadow: var(--shadow-1); border-radius: var(--r-lg); background: var(--surface); gap: var(--s-4); }
  .rail__sec { padding-bottom: var(--s-4); }
}

/* ---- Breakdown, totals, metrics ------------------------------------------ */

.breakdown { display: flex; flex-direction: column; gap: var(--s-2); margin-left: auto; width: 100%; max-width: 24rem; font-variant-numeric: tabular-nums; }
.breakdown__row { display: flex; justify-content: space-between; gap: var(--s-4); align-items: center; }
.breakdown__row span:first-child { color: var(--text-2); }
.breakdown__row--total { padding-top: var(--s-2); border-top: 1px solid var(--border); font-weight: 700; font-size: var(--fs-md); }
.breakdown__row--total span:first-child { color: var(--text); }
.breakdown__row--muted { color: var(--text-muted); font-size: var(--fs-sm); }
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: var(--s-3); }
/* key-number tile (.tile is the same box for new pages): label, big value, optional soft delta pill, optional 4px track bar */
.metrics { gap: var(--s-4); }
.metric, .tile { display: flex; flex-direction: column; gap: var(--s-1); padding: var(--s-5); color: inherit; text-decoration: none; }
a.metric:hover, a.tile:hover { text-decoration: none; box-shadow: var(--shadow-2); }
.metric.is-selected { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.metric__label, .tile__label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-muted); }
.metric__value, .tile__value { font-size: var(--fs-2xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
/* four figures beside a side column: one row on a wide screen, two by two on a phone; amounts never break */
.metrics--compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
@media (min-width: 1500px) { .metrics--compact { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.metrics--compact .metric { padding: var(--s-4); }
.metrics--compact .metric__value { font-size: var(--fs-lg); }
@media (min-width: 600px) { .metrics--compact .metric__value { font-size: var(--fs-xl); white-space: nowrap; } }
.metric__delta, .tile__delta { align-self: flex-start; padding: 2px 10px; border-radius: var(--r-pill); background: var(--ok-soft); font-size: var(--fs-xs); font-weight: 700; color: var(--ok-text); }
.metric__delta--down { background: var(--danger-soft); color: var(--danger-text); }
.metric__delta--warn { background: var(--warn-soft); color: var(--warn-text); }
.metric__delta--muted { background: var(--surface-3); color: var(--text-muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: var(--s-3); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: var(--s-3) var(--s-4); background: var(--surface-2); border-radius: var(--r-md); color: inherit; text-decoration: none; min-width: 0; }
.stat__label { font-size: var(--fs-xs); color: var(--text-muted); }
.stat__value { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---- Menus («…»), dialogs, sheets, toasts ----------------------------- */

details.menu { position: relative; }
details.menu > summary { list-style: none; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu > summary::marker { content: ""; }
.menu__list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 60; min-width: 14rem; padding: var(--s-2); border: 1px solid var(--card-edge); border-radius: var(--r-lg);
  background: var(--surface); box-shadow: var(--shadow-2); display: flex; flex-direction: column;
}
.menu__list--left { right: auto; left: 0; }
.menu__item { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 40px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-md); background: none; color: var(--text); font-weight: 600; text-align: left; text-decoration: none; white-space: nowrap; }
.menu__item:hover { background: var(--surface-2); text-decoration: none; }
.menu__item .i { color: var(--text-muted); font-size: 1.1rem; }
.menu__item--danger, .menu__item--danger .i { color: var(--danger-text); }
.menu__item:disabled { opacity: 0.5; cursor: not-allowed; }
.menu__label { padding: var(--s-2) var(--s-3) var(--s-1); font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); }
.menu__sep { height: 1px; margin: var(--s-1) 0; background: var(--border); }
/* «+ Position»: the kinds in two columns, the service catalog as a search over a short scrolling list */
.menu__list--add { width: min(30rem, calc(100vw - 2rem)); max-height: calc(100dvh - var(--topbar-h) - 8rem); overflow-y: auto; }
.menu__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.menu__grid .menu__item, .menu__scroll .menu__item { white-space: normal; text-align: left; }
.menu__search { margin: 0 0 var(--s-2); min-height: 40px; }
.menu__scroll { max-height: 15rem; overflow-y: auto; overscroll-behavior: contain; }
.menu__empty { padding: var(--s-2) var(--s-3); }
dialog.dlg { border: 1px solid var(--card-edge); border-radius: var(--r-lg); background: var(--surface); color: var(--text); padding: var(--s-6); width: min(36rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto; box-shadow: var(--shadow-2); }
dialog.dlg--wide { width: min(64rem, calc(100vw - 2rem)); }
dialog.dlg::backdrop { background: var(--backdrop); }
.dlg__title { font-size: var(--fs-lg); font-weight: 700; }
.dlg__meta { overflow-wrap: anywhere; font-size: var(--fs-sm); }
.dlg__hint { display: flex; align-items: center; gap: var(--s-2); color: var(--brand-text); font-size: var(--fs-sm); }
.dlg__actions { display: flex; gap: var(--s-2); justify-content: flex-end; flex-wrap: wrap; padding-top: var(--s-2); }
.toast { position: fixed; left: 50%; bottom: calc(var(--s-6) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; padding: var(--s-2) var(--s-4); border-radius: var(--r-pill); background: var(--ink); color: var(--on-ink); font-size: var(--fs-sm); font-weight: 600; box-shadow: var(--shadow-2); pointer-events: none; opacity: 0; transition: opacity 0.2s; }
.toast.is-on { opacity: 1; }
@media (max-width: 640px) {
  dialog.dlg { width: 100vw; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: 20px 20px 0 0; border-bottom: 0; padding: var(--s-5) var(--s-4) calc(var(--s-5) + env(safe-area-inset-bottom)); }
  .dlg__actions { flex-direction: column-reverse; }
  .dlg__actions .btn { width: 100%; }
  .menu__list { position: fixed; left: var(--s-2); right: var(--s-2); top: auto; bottom: calc(var(--s-2) + env(safe-area-inset-bottom)); min-width: 0; padding: var(--s-2); border-radius: 20px; max-height: 70dvh; overflow: auto; }
  .menu__item { min-height: 48px; }
  /* backdrop-filter makes the top bar the containing block of fixed children: drop its menus below the bar instead */
  .topbar .menu__list { position: absolute; top: calc(100% + 4px); bottom: auto; left: auto; right: 0; min-width: 14rem; }
  .toast { bottom: calc(72px + env(safe-area-inset-bottom)); }
}

/* ---- Status screen (install, errors, customer answers) ----------------------- */

.status { align-items: center; text-align: center; max-width: 26rem; margin: var(--s-8) auto; }
.status__icon { width: 56px; height: 56px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-soft); color: var(--brand-text); font-size: 1.6rem; }
.status__icon--check { background: var(--ok-soft); color: var(--ok-text); }
.status__icon--alert { background: var(--danger-soft); color: var(--danger-text); }
.status__title { font-size: var(--fs-xl); font-weight: 700; }
.status__text { color: var(--text-muted); }
/* the same block inside a card (public invoice): no second box, no outer margin */
.status--inline { display: flex; gap: var(--s-3); margin: var(--s-2) auto; max-width: none; }
.status--inline .status__title { font-size: var(--fs-lg); }

/* ---- Search results page -------------------------------------------------------- */

.results { display: flex; flex-direction: column; gap: var(--s-6); }

/* ---- Offer comparison (offer-diff.php) still uses these older classes ------------------ */

.divider { display: flex; align-items: center; gap: var(--s-3); color: var(--text-muted); font-size: var(--fs-sm); }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.toolbar { display: flex; gap: var(--s-2); align-items: center; }
.toolbar--wrap { flex-wrap: wrap; }
.toolbar--wrap .input { min-width: 0; }
.toolbar--wrap > input.input[type="search"] { flex: 1 1 100%; }
.prev { display: inline-block; transform: rotate(180deg); }
.diff { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.diff__row { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; gap: var(--s-2); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); align-items: start; }
.diff__row:last-child { border-bottom: 0; }
.diff__sign { font-weight: 700; text-align: center; }
.diff__row--added .diff__sign { color: var(--ok-text); }
.diff__row--removed .diff__sign { color: var(--danger-text); }
.diff__row--removed .diff__main b { text-decoration: line-through; }
.diff__row--changed .diff__sign { color: var(--warn-text); }
.diff__main { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.diff__main small { color: var(--text-muted); }
.diff__amount { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.diff__delta--up { color: var(--danger-text); }
.diff__delta--down { color: var(--ok-text); }
.diff s { color: var(--text-muted); }
@media (max-width: 640px) {
  .toolbar--wrap > select.input, .toolbar--wrap > .combo, .toolbar--wrap > .input--inline, .toolbar--wrap > .btn { flex: 1 1 100%; width: 100%; }
}

/* ---- Offer editor: the document (offer-edit.php, js/offer-edit.js) -------------- */

.oe { display: flex; flex-direction: column; gap: var(--s-6); padding-bottom: 72px; }
.oe.is-busy { cursor: progress; }
/* a row whose save is queued or running: its figures are about to change */
.oi.is-saving > .oi__row .oi__total { opacity: 0.55; }
.oe__saved { font-size: var(--fs-xs); color: var(--text-muted); min-width: 5rem; }
.doc { padding: var(--s-10); display: flex; flex-direction: column; gap: var(--s-8); max-width: 960px; width: 100%; }
.doc__head { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s-8); align-items: start; }
.doc__addr { display: flex; flex-direction: column; gap: var(--s-2); }
.doc__addr textarea { min-height: 7.5rem; font-size: var(--fs-base); line-height: 1.45; }
.doc__contact select { width: auto; min-width: 12rem; }
.doc__meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-2) var(--s-4); align-items: center; font-size: var(--fs-sm); }
.doc__meta dt { color: var(--text-muted); }
.doc__meta dd { margin: 0; min-width: 0; }
.doc__meta .input, .doc__meta select { height: 30px; font-size: var(--fs-sm); box-shadow: none; }
.doc__meta .input:focus, .doc__meta select:focus { box-shadow: 0 0 0 3px var(--ring); }   /* the same ring as every other field; box-shadow: none above removed it */
.doc__title { display: flex; flex-direction: column; gap: var(--s-2); }
.doc__title h2 { font-size: var(--fs-xl); }
.doc__title input { font-size: var(--fs-md); font-weight: 500; }
/* Prose fields look like text until they are touched. */
.prose { width: 100%; min-height: 3rem; padding: var(--s-2) var(--s-3); border: 1px solid transparent; border-radius: var(--r-md); background: none; box-shadow: none; line-height: 1.55; resize: vertical; margin: 0 calc(-1 * var(--s-3)); width: calc(100% + 2 * var(--s-3)); }
.prose:hover { border-color: var(--border-input); }
.prose:focus { border-color: var(--brand); background: var(--surface); }
.prose::placeholder { color: var(--text-muted); }
.prose-row { display: flex; align-items: center; gap: var(--s-2); }
.prose-row .field__label { margin-right: auto; }
/* the item table */
.items { display: flex; flex-direction: column; }
.items__head { display: grid; grid-template-columns: 28px minmax(0, 1fr) 64px 64px 96px 108px 36px; gap: var(--s-2); align-items: center; padding: 0 0 var(--s-2); border-bottom: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.items__head .num { text-align: right; }
.items__head .btn--link { font-size: var(--fs-xs); font-weight: 500; justify-self: start; }
.oe.is-plain .items__head, .oe.is-plain .oi__row { grid-template-columns: 28px minmax(0, 1fr) 108px 36px; }
.oe.is-plain .oi__qty, .oe.is-plain .oi__unit, .oe.is-plain .oi__price, .oe.is-plain .items__qty, .oe.is-plain .items__unit, .oe.is-plain .items__price { display: none; }
.oi { position: relative; border-bottom: 1px solid var(--border); }
.oi__row { display: grid; grid-template-columns: 28px minmax(0, 1fr) 64px 64px 96px 108px 36px; gap: var(--s-2); align-items: start; padding: var(--s-2) 0; }
.oi__row .input { height: 30px; box-shadow: none; border-color: transparent; background: none; padding: 0 var(--s-2); }
.oi__row .input:hover { border-color: var(--border-input); }
.oi__row .input:focus { border-color: var(--brand); background: var(--surface); }
.oi__row .input:disabled { background: none; color: var(--text); opacity: 1; }
.oi__grip { position: relative; width: 28px; height: 30px; border: 0; background: none; cursor: grab; border-radius: var(--r-sm); color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; }
.oi__grip:hover, .oi__grip:focus-visible { background: var(--surface-3); }
.oi__grip .svg { pointer-events: none; }
.oi__main { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.oi__line { display: flex; align-items: center; gap: var(--s-1); min-width: 0; }
.oi__line .input { flex: 1; min-width: 0; font-weight: 500; }
.oi__tag { display: inline-flex; align-items: center; gap: 0.3em; height: 22px; padding: 0 0.5em; border-radius: 5px; background: var(--surface-3); color: var(--text-muted); font-size: var(--fs-2xs); font-weight: 500; white-space: nowrap; border: 0; }
button.oi__tag:hover { background: var(--brand-soft); color: var(--brand-text); }
.oi__tag--brand { background: var(--brand-soft); color: var(--brand-text); }
.oi__tag--ok { background: var(--ok-soft); color: var(--ok-text); }
.oi__tag--warn { background: var(--warn-soft); color: var(--warn-text); }
.oi__desc { font-size: var(--fs-sm); color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere; padding: 0 var(--s-2); }
.oi__desc textarea { min-height: 4rem; font-size: var(--fs-sm); }
.oi__desc-view { cursor: text; border-radius: var(--r-sm); }
.oi__desc-view:hover { background: var(--surface-2); }
.oi__desc-view ul { margin: 0; padding-left: 1.1em; list-style: "– "; }
.oi__qty, .oi__price { text-align: right; font-variant-numeric: tabular-nums; }
.oi__total { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; padding: 5px var(--s-2) 0 0; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; }
.oi__total small { font-weight: 500; color: var(--text-muted); font-size: var(--fs-2xs); }
.oi.is-muted .oi__total, .oi.is-muted .oi__line .input { color: var(--text-muted); }
.oi__menu { justify-self: end; }
/* groups and layout rows */
.oi--group > .oi__row .oi__line .input { font-weight: 600; font-size: var(--fs-md); }
.oi__children { padding-left: var(--s-6); }
.oi__children .oi:last-child { border-bottom: 0; }
.oi__foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-2) 0 var(--s-2) var(--s-6); font-size: var(--fs-sm); }
.oi__subtotal { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.oi--heading .oi__line .input { font-weight: 600; font-size: var(--fs-md); }
.oi--subtotal .oi__line .input { font-weight: 600; text-align: right; }
.oi--divider .oi__main { align-self: center; }
.oi__rule { height: 1px; background: var(--border-strong); margin: 14px var(--s-2); }
.oi--pagebreak .oi__main, .oi--divider .oi__main { color: var(--text-muted); font-size: var(--fs-xs); }
.oi__hint { padding: 7px var(--s-2); font-style: italic; }
/* the extra form («Mehr …») of a row */
.oi__more { display: flex; flex-direction: column; gap: var(--s-4); margin: 0 0 var(--s-3) 28px; padding: var(--s-4); border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.oi__grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.oi__internal { margin: 0; padding: var(--s-3) var(--s-4) var(--s-4); border: 1px dashed color-mix(in srgb, var(--danger) 45%, transparent); border-radius: var(--r-md); display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.oi__internal legend { padding: 0 var(--s-1); font-size: var(--fs-xs); color: var(--danger-text); display: inline-flex; gap: var(--s-1); align-items: center; }
.oi__more-actions .spacer { flex: 1; }
.oi__down .i--arrow { transform: rotate(90deg); }
.oi__up .i--arrow { transform: rotate(-90deg); }
.oe-add { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) 0 0; }
.oe-add--in { padding-left: var(--s-6); }
.oe-empty { padding: var(--s-6) 0; text-align: center; color: var(--text-muted); }
/* totals block */
.doc__totals { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-3); }
.doc__totals .breakdown__row select { height: 28px; width: auto; min-width: 9rem; font-size: var(--fs-sm); box-shadow: none; }
.doc__discount { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; }
.doc__discount .input { width: 7rem; height: 28px; font-size: var(--fs-sm); box-shadow: none; }
.doc__discount select { width: auto; height: 28px; font-size: var(--fs-sm); box-shadow: none; }
/* sticky action bar */
.actionbar { position: fixed; left: var(--side-w); right: 0; bottom: 0; z-index: 35; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-8); background: var(--surface); border-top: 1px solid var(--border); }
.actionbar__in { width: 100%; max-width: var(--content-w); margin: 0 auto; display: flex; align-items: center; gap: var(--s-3); }
.actionbar__mid { margin-left: auto; display: flex; align-items: center; gap: var(--s-2); }
.actionbar__total { margin-left: var(--s-4); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.actionbar__total small { color: var(--text-muted); font-size: var(--fs-2xs); }
.actionbar__total b { font-size: var(--fs-lg); color: var(--brand-text); font-variant-numeric: tabular-nums; }
/* calculation dialog */
.calc { border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.calc__head { display: flex; align-items: center; gap: var(--s-2); }
.calc__head h2 { font-size: var(--fs-md); flex: 1; }
.calc .table-wrap { min-width: 0; max-width: 100%; }
.calc table td, .calc table th { padding: 0 var(--s-2); height: 34px; vertical-align: middle; }
.calc table { min-width: 44rem; }
.calc .input { height: 28px; box-shadow: none; font-size: var(--fs-sm); text-align: right; width: 6.5rem; }
.calc td .field__error:empty { display: none; }
.calc__total td { font-weight: 600; border-top: 1px solid var(--border); }
.calc .is-pos { color: var(--ok-text); }
.calc .is-neg { color: var(--danger-text); }
.calc tr.is-off td { color: var(--text-muted); }
@media (max-width: 1023px) { .actionbar { left: 0; padding: var(--s-2) var(--s-4); } .oe { padding-bottom: 64px; } }
@media (max-width: 640px) {
  .doc { padding: var(--s-4); border: 0; border-radius: 0; margin: 0 calc(-1 * var(--s-4)); width: auto; gap: var(--s-6); }
  .doc__head { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .items__head { display: none; }
  .oi__row, .oe.is-plain .oi__row { grid-template-columns: 28px minmax(0, 1fr) 36px; grid-template-areas: "grip main menu" "grip fields fields"; }
  .oi__grip { grid-area: grip; height: 44px; }
  .oi__main { grid-area: main; }
  .oi__menu { grid-area: menu; }
  .oi__fields { grid-area: fields; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--s-2); align-items: end; }
  .oe.is-plain .oi__fields { grid-template-columns: 1fr; }
  .oi__fields .input { border-color: var(--border-input); height: 36px; }
  .oi__fields .oi__total { grid-column: 1 / -1; padding: var(--s-1) 0 0; }
  .oi__f { display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-2xs); color: var(--text-muted); }
  .oi__children { padding-left: var(--s-3); }
  .oi__more { margin-left: 0; }
  .oi__grid { grid-template-columns: minmax(0, 1fr); }
  .oe-add--in { padding-left: var(--s-3); }
  .actionbar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }
  .actionbar__in { flex-wrap: nowrap; }
  .actionbar__total { flex: none; }
  .actionbar__total small { white-space: nowrap; }
  .oi__line { flex-wrap: wrap; }
  .oi__line .input { flex: 1 1 100%; order: -1; }
  /* visually hidden but still the accessible name of the icon-only buttons */
  /* the main button keeps its word: a lone check mark does not say «done» */
  .actionbar__in > .btn span:not(.dot), .actionbar__mid .btn:not(.btn--primary) span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .actionbar__in { gap: var(--s-2); }
  .actionbar__total { margin-left: auto; min-width: 0; }
  .actionbar__total b { font-size: var(--fs-md); }
  .actionbar__mid { margin-left: 0; }
  .oe { padding-bottom: 72px; }
}
@media (min-width: 641px) {
  .oi__fields { display: contents; }
  .oi__f > .field__label { display: none; }
  .oi__f { display: contents; }
  .oi__main { grid-column: 2; }
  .oi__qty { grid-column: 3; } .oi__unit { grid-column: 4; } .oi__price { grid-column: 5; } .oi__total { grid-column: 6; } .oi__menu { grid-column: 7; }
  .oe.is-plain .oi__total { grid-column: 3; } .oe.is-plain .oi__menu { grid-column: 4; }
}
/* drag and drop */
.oi.is-dragging { opacity: 0.35; }
.oi__ghost { position: fixed; z-index: 200; pointer-events: none; background: var(--surface); border: 1px solid var(--brand); border-radius: var(--r-md); box-shadow: var(--shadow); opacity: 0.95; padding: var(--s-2); }
.oe-drop { position: fixed; z-index: 199; height: 3px; border-radius: 2px; background: var(--brand); pointer-events: none; display: none; }
.oe-drop.is-bad { background: var(--danger-fill); }
.is-drop-target { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: var(--r-sm); }
body.is-dragging { -webkit-user-select: none; user-select: none; cursor: grabbing; }

/* ---- The customer's offer (offer.php): one calm document ---------------------- */

.pub { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: var(--s-6); }
.pub__brand { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); color: var(--text-muted); font-size: var(--fs-sm); }
.pub__brand img { max-height: 36px; width: auto; }
.pub__logo { height: 24px; width: auto; max-width: 12rem; }
:root[data-theme="dark"] .pub__logo { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .pub__logo { filter: invert(1); } }
.pub__paper { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s-10); display: flex; flex-direction: column; gap: var(--s-8); }
.pub__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-6); align-items: start; }
.pub__to { white-space: pre-line; line-height: 1.5; }
.pub__meta { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-1) var(--s-4); font-size: var(--fs-sm); }
.pub__meta dt { color: var(--text-muted); }
.pub__meta dd { margin: 0; }
.pub__title { font-size: var(--fs-xl); }
.pub__title small { display: block; font-size: var(--fs-base); color: var(--text-muted); font-weight: 500; margin-top: var(--s-1); }
.pub__text { white-space: pre-line; line-height: 1.6; }
.pub__text ul { margin: var(--s-1) 0; padding-left: 1.2em; list-style: "–  "; white-space: normal; }
.pitems { display: flex; flex-direction: column; }
.pitems__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; padding: 0 0 var(--s-2); border-bottom: 1px solid var(--text); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }
.pi { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-1) var(--s-4); padding: var(--s-3) 0; border-bottom: 1px solid var(--border); align-items: start; }
.pi__title { font-weight: 500; }
.pi__sub { grid-column: 1; font-size: var(--fs-sm); color: var(--text-2); white-space: pre-line; overflow-wrap: anywhere; }
.pi__sub ul { margin: var(--s-1) 0 0; padding-left: 1.2em; list-style: "–  "; white-space: normal; }
.pi__qty { grid-column: 1; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.pi__amount { grid-column: 2; grid-row: 1 / span 3; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.pi__pick { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--s-2); padding: var(--s-1) 0 0; }
.pi__pick .switch { min-height: 32px; }
.pi.is-muted .pi__title, .pi.is-muted .pi__amount { color: var(--text-muted); }
.pi--group { border-bottom: 0; padding-bottom: var(--s-1); }
.pi--group .pi__title { font-size: var(--fs-md); font-weight: 600; }
.pi--heading .pi__title { font-size: var(--fs-md); font-weight: 600; padding-top: var(--s-3); }
.pi--sub { padding: var(--s-2) 0; }
.pi--sub .pi__title { font-weight: 600; text-align: right; font-size: var(--fs-sm); color: var(--text-2); }
.pi--divider { padding: var(--s-2) 0; border-bottom: 2px solid var(--border-strong); }
.pi--level-2 { padding-left: var(--s-4); }
.pi--level-3 { padding-left: var(--s-8); }
.pub__totals { display: flex; justify-content: flex-end; }
.pub__accept { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-6); border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }
.pub__accept h2 { font-size: var(--fs-lg); }
.pub__accept .form__grid--pair { gap: var(--s-4); }
.pub__cta { display: flex; gap: var(--s-3); align-items: center; flex-wrap: wrap; }
.pub__decline { display: flex; flex-direction: column; gap: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .pub { gap: var(--s-4); }
  .pub__paper { padding: var(--s-5) var(--s-4); gap: var(--s-6); }
  .pub__head { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .pub__accept { padding: var(--s-4); }
  .pub__cta { position: sticky; bottom: 0; margin: 0 calc(-1 * var(--s-4)) calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  .pub__cta .btn--primary { flex: 1; }
}

/* ---- Print --------------------------------------------------------------------- */

@media print {
  .side, .topbar, .tabbar, .sheet, .footer, .actionbar, .ph__actions { display: none !important; }
  .app { display: block; }
  .content { max-width: none; padding: 0; }
  .doc, .pub__paper, .card { border: 0; padding: 0; }
}

/* ---- Offers, stage 5c (rich text, cover, details, files, calculation overlay, offer view) ---- */
/* Everything below is scoped to the offer pages; appended as one block so other pages merge cleanly. */

.rich { min-height: 3rem; line-height: 1.55; overflow-wrap: anywhere; outline: none; }
.rich:empty::before, .rich:has(> p:only-child:empty)::before { content: attr(data-placeholder); color: var(--text-muted); pointer-events: none; }
.rich p { margin: 0 0 0.45em; }
.rich p:last-child { margin-bottom: 0; }
.rich ul, .rich ol { margin: 0.2em 0 0.45em; padding-left: 1.4em; }
.rich ul { list-style: "–  "; }
.rich a { color: var(--brand-text); text-decoration: underline; }
.rich b { font-weight: 600; }
.input.rich { height: auto; padding: var(--s-2) var(--s-3); }
.rich__bar { display: none; gap: 2px; padding: 2px; margin: 0 0 var(--s-1); border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface); width: max-content; }
.rich__bar.is-on { display: inline-flex; }
.rich__btn { height: 26px; min-width: 28px; padding: 0 6px; border: 0; border-radius: 4px; background: none; color: var(--text); font-size: var(--fs-xs); font-weight: 600; cursor: pointer; }
.rich__btn:hover { background: var(--surface-3); }
.rich__btn--italic { font-style: italic; font-weight: 500; }
.rich__btn--underline { text-decoration: underline; font-weight: 500; }
.oi__desc .rich { font-size: var(--fs-sm); }
.oi__desc .input.rich { border-color: var(--border-input); background: var(--surface); }
.oi__desc-view .rich p, .pi__sub.rich p { margin-bottom: 0.3em; }
/* cover block in the editor */
.doc__cover { display: flex; flex-direction: column; gap: var(--s-3); padding-bottom: var(--s-6); border-bottom: 1px solid var(--border); }
.doc__cover-fields { display: none; grid-template-columns: 200px minmax(0, 1fr); gap: var(--s-5); align-items: start; }
.doc__cover.is-on .doc__cover-fields { display: grid; }
.doc__cover-img { display: flex; flex-direction: column; gap: var(--s-2); align-items: flex-start; }
.doc__cover-img img { width: 200px; max-height: 150px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border); }
.doc__cover-empty { width: 200px; height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-1); border: 1px dashed var(--border-strong); border-radius: var(--r-md); color: var(--text-muted); font-size: var(--fs-xs); }
.oe-upload { cursor: pointer; }
/* image rows */
.oi__image { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); padding: var(--s-1) var(--s-2) var(--s-2); }
.oi__image img { max-width: min(320px, 100%); max-height: 180px; width: auto; height: auto; border-radius: var(--r-md); border: 1px solid var(--border); }
/* terms and attachments under the outro */
.doc__terms, .doc__files { display: flex; flex-direction: column; gap: var(--s-2); }
.doc__terms .check { font-size: var(--fs-sm); }
.doc__files .row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); }
.doc__files .row__main { display: flex; flex-direction: column; min-width: 0; }
/* total mode under the breakdown */
.doc__mode { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; justify-content: flex-end; font-size: var(--fs-sm); }
.doc__mode .input { height: 28px; font-size: var(--fs-sm); box-shadow: none; width: auto; }
.doc__mode .input--num { width: 7rem; }
.field--inline { display: inline-flex; align-items: center; gap: var(--s-2); }
.field--inline .field__label { margin: 0; }
/* flat dialog (the calculation overlay is .calc above) */
.flat { display: flex; flex-direction: column; gap: var(--s-3); }
.flat .input--num { height: 28px; box-shadow: none; font-size: var(--fs-sm); text-align: right; width: 6.5rem; }
.flat__table td { vertical-align: middle; padding: var(--s-1) var(--s-2); }
.flat__table .input { height: 30px; box-shadow: none; }
.flat__table td.table__name .input { width: 100%; min-width: 10rem; }
.flat__table td.table__num .input { width: 6rem; }
.flat__table td:nth-child(3) .input { width: 5rem; }
.flat__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
@media (max-width: 640px) {
  dialog.dlg--wide { max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .doc__cover-fields { grid-template-columns: minmax(0, 1fr); }
  .calc table { min-width: 40rem; }
  .flat__table { display: table; }
  .flat__table tr { display: table-row; }
  .flat__table td { display: table-cell; }
}
/* the offer view: PDF on a wide screen with a mouse, the HTML document on a phone or tablet (iOS shows only page one of a PDF in a frame) */
.ov .detail__main { min-width: 0; }
.ov__pdf { display: none; width: 100%; height: calc(100dvh - 180px); min-height: 640px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.ov__html { max-width: 760px; }
@media (min-width: 900px) and (pointer: fine) {
  .ov__pdf { display: block; }
  .ov__html { display: none; }
}
/* the customer's page: cover, images, details, terms, files */
.pub__cover { display: flex; flex-direction: column; gap: var(--s-3); padding-bottom: var(--s-8); border-bottom: 1px solid var(--border); }
.pub__cover img { width: 100%; max-height: 360px; object-fit: cover; border-radius: var(--r-md); }
.pub__cover h1, .pub__cover h2, .pub__cover h3 { font-size: var(--fs-2xl); }
.pub__cover p { color: var(--text-muted); font-size: var(--fs-md); }
.pi--image { display: block; margin: 0; padding: var(--s-3) 0; }
.pi--image img { max-width: 100%; height: auto; border-radius: var(--r-md); }
.pi--image figcaption { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--s-1); }
.pi--text { display: block; }
.pi__sub.rich, .pub__text.rich { white-space: normal; }
.pi__details { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-xs); color: var(--text-muted); padding-left: var(--s-3); }
.pi__detail { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: var(--s-3); }
.pi__detail .num { font-variant-numeric: tabular-nums; min-width: 5rem; text-align: right; }
.pi__details--text { margin: 0; padding-left: 1.4em; list-style: "–  "; }
.pub__terms, .pub__files { display: flex; flex-direction: column; gap: var(--s-2); }
.pub__terms h2, .pub__files h2 { font-size: var(--fs-md); }
.pub__term { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); }
.pub__term summary { cursor: pointer; font-weight: 500; }
.pub__term .rich { padding-top: var(--s-2); font-size: var(--fs-sm); }
/* ==== Rollout (stage 5b): settings shell, sign-in, dashboard, projects, time pages ======
   Appended as one block so it merges cleanly; nothing above is reordered. */

/* Settings shell: menu left, content right; a stacked menu on a phone. */
.sx { display: grid; grid-template-columns: 15rem minmax(0, 1fr); gap: var(--s-10); align-items: start; }
.sx__nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(64px + var(--s-6)); }
.sx__nav a { display: flex; align-items: center; gap: var(--s-2); min-height: var(--h-ctl); padding: 0 var(--s-3); border-radius: var(--r-md); color: var(--text-2); font-weight: 600; text-decoration: none; }
.sx__nav a:hover { background: var(--surface-2); color: var(--text); }
.sx__nav a[aria-current] { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.sx__nav a[aria-current] .i { color: var(--brand-text); }
.sx__nav .i { color: var(--text-muted); }
.sx__nav .nav-label:first-child { margin-top: 0; }
.sx__main { min-width: 0; max-width: 44rem; display: flex; flex-direction: column; gap: var(--s-8); }
.sx__main > .section + .section { padding-top: var(--s-8); border-top: 1px solid var(--border); }
.section__lead { color: var(--text-muted); max-width: 40rem; }
.sx__back { display: none; align-items: center; gap: var(--s-1); width: fit-content; min-height: var(--h-touch); color: var(--text-2); font-weight: 500; text-decoration: none; }
.sxl { display: flex; flex-direction: column; max-width: 44rem; border-top: 1px solid var(--border); }
.sxl__item { display: flex; align-items: center; gap: var(--s-3); min-height: var(--h-touch); padding: var(--s-2); border-bottom: 1px solid var(--border); color: var(--text); font-weight: 500; text-decoration: none; }
h2.nav-label { margin: var(--s-5) 0 var(--s-1); }
.sxl__item:hover { background: var(--surface-2); text-decoration: none; }
.sxl__item > span { flex: 1; }
.sxl__item .i, .sxl__item .svg { color: var(--text-muted); }
@media (max-width: 800px) {
  .sx { grid-template-columns: minmax(0, 1fr); gap: var(--s-5); }
  .sx__nav { display: none; }
  .sx__back { display: inline-flex; }
  main:has(.ph__crumb) .sx__back { display: none; }   /* the page header already links back to «Einstellungen»: one back link */
}

/* Sign-in and installer: one calm centred card. */
.auth { max-width: 26rem; gap: var(--s-5); padding: var(--s-8) var(--s-6); box-shadow: var(--shadow-sm); }
.bare .auth--wide { max-width: 36rem; }
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); text-align: center; }
.auth__brand h1 { font-size: var(--fs-xl); font-weight: 700; }
.auth__brand p { color: var(--text-muted); }
.auth .divider[hidden] { display: none; }

/* Progress meter */
.meter { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--brand); }
.meter--warn > span { background: var(--warn-fill); }
.meter--over > span { background: var(--danger-fill); }
.ctl { display: flex; flex-direction: column; gap: var(--s-2); }
.ctl__row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.ctl__row b { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.ctl__row span { color: var(--text-muted); font-size: var(--fs-sm); }

/* Dashboard chart: bars from tokens, labels in HTML so they stay readable on a phone. */
.chart { margin: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.chart__plot { position: relative; padding-top: var(--s-4); }
.chart__max { position: absolute; top: 0; right: 0; font-size: var(--fs-xs); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart__svg { display: block; width: 100%; height: 140px; overflow: visible; }
.chart__grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; opacity: 0.7; }
.chart__bar { fill: var(--brand); rx: 4px; }
.chart__hit { fill: transparent; }
.chart g:hover .chart__bar { fill: var(--brand-hover); }
.chart__axis { display: grid; font-size: var(--fs-xs); color: var(--text-muted); }
.chart__legend { display: flex; gap: var(--s-4); font-size: var(--fs-xs); color: var(--text-muted); flex-wrap: wrap; }
.chart__legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-right: var(--s-1); }

/* Timer: a large clock, big buttons, recent projects as chips. */
.timer { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-6); }
.timer__clock { font-size: clamp(2.6rem, 14vw, 4rem); font-weight: 700; font-variant-numeric: tabular-nums; text-align: center; line-height: 1.1; }
.timer__clock--idle { color: var(--text-muted); }
.timer__label, .timer__what { text-align: center; }
.timer__label { display: flex; align-items: center; justify-content: center; gap: var(--s-2); color: var(--ok-text); font-weight: 500; }
.timer__label::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok-fill); }
.timer__what { display: flex; flex-direction: column; }
.timer__what small { color: var(--text-muted); }
.timer__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.quick { display: flex; flex-direction: column; gap: var(--s-2); }
.quick__label { font-size: var(--fs-sm); color: var(--text-muted); }
.quick__chip { text-align: left; display: flex; flex-direction: column; min-height: 56px; padding: var(--s-2) var(--s-3); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface); color: var(--text); min-width: 0; }
.quick__chip:hover { background: var(--surface-2); }
.quick__chip b, .quick__chip small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick__chip small { color: var(--text-muted); }
@media (min-width: 641px) { .quick { flex-direction: row; flex-wrap: wrap; } .quick__label { flex: 1 0 100%; } .quick__chip { max-width: 16rem; } }
/* billed entries step back by colour, not opacity: opacity dropped the text below 4.5:1 */
.row--locked, .row--locked .row__dur { color: var(--text-muted); }
.row--locked .row__main b { font-weight: 500; }
.row--locked .badge { background: var(--surface-3); color: var(--muted-text); }
.row__main small.row__text { white-space: normal; overflow-wrap: anywhere; }
.row__dur { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.day-total { font-weight: 600; font-variant-numeric: tabular-nums; }
.stepper { display: flex; align-items: center; gap: var(--s-2); }
.pick-list .row { cursor: pointer; }
.pick-list input[type="checkbox"] { width: 18px; height: 18px; flex: none; margin: 0; accent-color: var(--brand); }
.fold summary { cursor: pointer; font-weight: 500; color: var(--text-muted); min-height: 44px; display: flex; align-items: center; gap: var(--s-2); list-style: none; }
.fold summary::-webkit-details-marker, .vat-line__detail > summary::-webkit-details-marker { display: none; }
/* display: flex removes the triangle: a chevron says the line opens */
.fold > summary::after, .vat-line__detail > summary::after { content: ""; flex: none; align-self: center; width: 0.5em; height: 0.5em; margin: 0 0.25em; border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted); transform: rotate(-45deg); transition: transform 0.15s var(--ease); }
.fold[open] > summary::after, .vat-line__detail[open] > summary::after { transform: rotate(45deg); }
.fold[open] summary { margin-bottom: var(--s-2); }
.inline-form > select, .inline-form > .input { flex: 1 1 10rem; min-width: 0; }
.mini-form .input { width: 7rem; text-align: right; }
@media (max-width: 640px) { .timer { padding: var(--s-4); } }
.ctl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-6); }
@media (max-width: 900px) { .ctl-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); } }
.form__group > legend { font-size: var(--fs-md); font-weight: 600; padding: 0; margin-bottom: var(--s-1); }
fieldset.form__group { border: 0; padding: 0; margin: 0; min-width: 0; }
/* a fieldset that is a card: keep the card padding, and float the legend so it sits inside instead of on the edge */
fieldset.form__group.card { padding: var(--s-5); }
fieldset.form__group.card > legend { float: left; width: 100%; }
@media (max-width: 640px) { fieldset.form__group.card { padding: var(--s-4); } }
.form__actions-start { margin-right: auto; }
.qr { width: 188px; padding: var(--s-2); background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); line-height: 0; }
.qr svg { width: 100%; height: auto; display: block; }
.bare:has(.auth) { justify-content: center; }
.section > .btn--link { align-self: flex-start; }
@media (max-width: 640px) {
  .metrics--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
  .metrics--3 .metric { padding: var(--s-3); }
  .metrics--3 .metric__value { font-size: var(--fs-lg); }
  .metrics--3 .metric__label { font-size: var(--fs-xs); }
}

/* ==== House style per installation: a wordmark (config logo) ====== */
.account__wordmark { height: 18px; width: auto; max-width: 9.5rem; flex: none; }
.account__wordmark + .account__text { display: none; }   /* the wordmark stands alone: no company or user name beside it */
:root[data-theme="dark"] .account__wordmark { filter: invert(1); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .account__wordmark { filter: invert(1); } }

/* ---- Invoices, stage 6 (invoices.php, invoice-edit.php, invoice-view.php, recurring.php) ---- */
/* The editor reuses the offer editor's .oe/.doc/.oi classes; only what is new is below. */
/* overdue is orange, dunned is red (at_invoice_late_tone); the lists use the same two tones */
.is-overdue, .table td.is-overdue { color: var(--warn-text); font-weight: 500; }
.is-dunned, .table td.is-dunned { color: var(--danger-text); font-weight: 500; }
.ph__open { font-size: var(--fs-sm); color: var(--text-muted); font-variant-numeric: tabular-nums; }
.ph__open.is-overdue { color: var(--warn-text); }
.ph__open.is-dunned { color: var(--danger-text); }
/* «Aktuell abrechenbar» */
.bn { border-bottom: 1px solid var(--border); padding-bottom: var(--s-2); }
.bn__sum { display: flex; align-items: center; gap: var(--s-3); min-height: 44px; cursor: pointer; list-style: none; font-weight: 600; }
.bn__sum::-webkit-details-marker { display: none; }
.bn__sum:focus-visible { box-shadow: var(--focus); border-radius: var(--r-sm); }
.cnt { min-width: 22px; padding: 0 var(--s-2); border-radius: var(--r-pill); background: var(--surface-3); color: var(--text-2); font-size: var(--fs-sm); font-weight: 500; text-align: center; font-variant-numeric: tabular-nums; }
/* Dashboard: running timer bar, «Zu erledigen», key numbers and the quiet facts line. The top bar pill is the same timer, so it hides here. */
.is-home .topbar__timer { display: none; }
.tbar { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-radius: var(--r-md); background: var(--brand-soft); color: var(--brand-text); text-decoration: none; min-width: 0; }
.tbar:hover { text-decoration: none; background: var(--brand-soft-hover); }
.tbar__clock { font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; }
.tbar__what { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.tbar__what b, .tbar__what small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbar__what small { color: inherit; opacity: 0.8; }
.tbar__go { display: inline-flex; align-items: center; gap: var(--s-1); font-weight: 500; white-space: nowrap; }
@media (max-width: 640px) { .tbar__go { font-size: 0; gap: 0; } }
.todo__row { gap: var(--s-3); }
.todo__row .i { color: var(--text-muted); }
.todo__row.is-warn .i { color: var(--warn-text); }
.todo__row .row__main { flex: 1; min-width: 0; }
.todo__row .row__main small { white-space: normal; }
.todo__go { color: var(--text-muted); }
.bn__total { margin-left: auto; color: var(--text-muted); font-weight: 500; font-variant-numeric: tabular-nums; }
/* on phones the sum takes its own line under the title instead of pushing the chevron out */
@media (max-width: 599px) {
  .bn__sum { flex-wrap: wrap; row-gap: 0; }
  .bn__chev { margin-left: auto; }
  .bn__total { order: 4; flex-basis: 100%; margin-left: 0; font-size: var(--fs-sm); }
}
.bn__chev { color: var(--text-muted); transition: transform 0.15s var(--ease); }
.bn:not(:has(.bn__total)) .bn__chev { margin-left: auto; }
.bn[open] .bn__chev { transform: rotate(180deg); }
.bn__drafts { margin: 0 0 var(--s-1); }
.bn .row { flex-wrap: wrap; row-gap: var(--s-2); }
.bn__amount { min-width: 8rem; justify-content: flex-end; }
.bn__acts { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; }
@media (max-width: 640px) {
  .bn__acts { width: 100%; justify-content: flex-start; }
  .bn__amount { min-width: 0; }
}
/* Pick lists in the creation dialogs (time entries, offer rows, projects) */
.pick { display: flex; flex-direction: column; max-height: 46dvh; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-md); }
.pick > p { padding: var(--s-4); }
.pick__head, .pick__row, .pick__legend { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; cursor: pointer; }
.pick__head { background: var(--surface-2); position: sticky; top: 0; }
.pick__head b { flex: 1; }
.pick__row:last-child { border-bottom: 0; }
.pick__row .num, .pick__head .num { min-width: 5.5rem; text-align: right; }
.pick__main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pick__main small { color: var(--text-muted); }
.pick input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); flex: none; }
.pick__row--offer { display: grid; grid-template-columns: 20px minmax(0, 1fr) 6.5rem 6.5rem 6.5rem 7rem; cursor: default; }
.pick__row--offer .input { height: 30px; }
.pick__row.is-done { color: var(--text-muted); }
.pick__legend { display: grid; grid-template-columns: 20px minmax(0, 1fr) 6.5rem 6.5rem 6.5rem 7rem; background: var(--surface-2); font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); cursor: default; position: sticky; top: 0; z-index: 1; }
.pick__legend .num { text-align: right; min-width: 0; }
.pick__sum { font-weight: 500; font-variant-numeric: tabular-nums; min-height: 1.4em; }
.empty-note { color: var(--text-muted); }
.dlg__actions .spacer { flex: 1; }
@media (max-width: 640px) {
  .pick__legend { display: none; }
  .pick__row--offer { grid-template-columns: 20px minmax(0, 1fr) auto; row-gap: var(--s-1); }
  .pick__row--offer .num { grid-column: 2 / -1; text-align: left; min-width: 0; }
  .pick__row--offer .num::before { content: attr(data-label) ": "; color: var(--text-muted); }
  .pick__row--offer .input { grid-column: 2 / -1; height: 40px; }
}
/* Recurring rows */
.recrows { display: flex; flex-direction: column; gap: var(--s-2); }
.recrow { display: grid; grid-template-columns: minmax(0, 1fr) 5rem 5rem 7rem 8rem 32px; gap: var(--s-2); align-items: center; }
@media (max-width: 760px) { .recrow { grid-template-columns: minmax(0, 1fr) 4.5rem 4.5rem; } .recrow input[name="r_title"] { grid-column: 1 / -1; } .recrow select, .recrow input[name="r_price"] { grid-column: span 1; } }
/* Mail preview in the send dialog */
.send-preview { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-2) var(--s-3); }
.send-preview summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); }
.mailprev { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-3) 0; }
.mailprev__facts { display: grid; grid-template-columns: max-content 1fr; gap: var(--s-1) var(--s-4); margin: 0; font-size: var(--fs-sm); }
.mailprev__facts > div { display: contents; }
.mailprev__facts dt { color: var(--text-muted); }
.mailprev__facts dd { margin: 0; }
.mailprev__body { white-space: pre-line; overflow-wrap: anywhere; font-size: var(--fs-sm); }
.mailprev .btn { align-self: flex-start; pointer-events: none; }

/* ---- Stage 7: lists, payments, dunning ---------------------------------------- */

/* The client sits in its own column on a desktop and in the small line on a phone only; rows stay one line high. */
.sm-only { display: none; }
@media (max-width: 640px) { .sm-only { display: inline; } }
@media (min-width: 641px) {
  .table--list td.table__name { max-width: 0; }
  .table--list td.table__name > a, .table--list td.table__name > span, .table--list td.table__name > small, .table--list .who__txt > a, .table--list .who__txt > span, .table--list .who__txt > small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table--list td.table__name > a, .table--list .who__txt > a { width: fit-content; max-width: 100%; }
  .table--list .who__txt { min-width: 0; }
  .table--list td.table__trunc { max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .table--list td.table__ref { max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
}
.nav-count, .sheet__count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--brand); color: var(--on-brand); font-size: var(--fs-xs); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }

.dz { display: flex; flex-direction: column; align-items: center; gap: var(--s-1); padding: var(--s-6) var(--s-4); border: 1.5px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); color: var(--text-2); text-align: center; cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.dz:hover, .dz.is-over, .dz:focus-visible { border-color: var(--brand); background: var(--brand-soft); outline: none; }
.dz b { color: var(--text); font-weight: 600; }
.dz small { color: var(--text-muted); }
.dz .i { font-size: 1.5rem; color: var(--text-muted); }
.dz.is-busy { opacity: 0.6; pointer-events: none; }
.sumcard { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4); }
.sumcard__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.sumcard__head b { font-size: var(--fs-md); }
.sumcard__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: var(--s-3); }
.sumcard__grid div { display: flex; flex-direction: column; }
.sumcard__grid b { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.sumcard__grid span { font-size: var(--fs-xs); color: var(--text-muted); }
.row-acts { display: flex; gap: var(--s-1); justify-content: flex-end; flex-wrap: nowrap; }
.table--list td.table__acts { width: 1%; white-space: nowrap; }
.pay-inv { display: inline-flex; align-items: center; gap: var(--s-2); max-width: 100%; }
.pay-inv a { white-space: nowrap; }

.selbar { position: fixed; left: var(--side-w); right: 0; bottom: 0; z-index: 35; display: flex; justify-content: center; padding: var(--s-3) var(--s-8); background: var(--surface); border-top: 1px solid var(--border); }
.selbar[hidden] { display: none; }
.selbar__in { width: 100%; max-width: var(--content-w); display: flex; align-items: center; gap: var(--s-3); }
.selbar__in span { color: var(--text-2); font-variant-numeric: tabular-nums; }
.selbar__in .btn { margin-left: auto; }
@media (max-width: 1023px) { .selbar { left: 0; padding: var(--s-2) var(--s-4); } }
@media (max-width: 640px) { .selbar { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); } .selbar__in { flex-wrap: wrap; } .selbar__in .btn { flex: 1; } }
.dun-group { margin-top: var(--s-6); }
.dun-send li { display: flex; justify-content: space-between; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.dun-send { list-style: none; padding: 0; margin: 0; }
.dun-send small { color: var(--text-muted); display: block; }
.dun-send .is-bad { color: var(--danger-text); }   /* «Nicht versendet» and its reason */
.dlg--pdf { width: min(60rem, calc(100vw - 2rem)); }
.dlg--pdf iframe { width: 100%; height: 70dvh; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.lv-help { font-size: var(--fs-sm); color: var(--text-muted); }
.lv-help code { font-size: var(--fs-xs); background: var(--surface-3); padding: 1px 4px; border-radius: 4px; }
.lv-text { white-space: pre-line; overflow-wrap: anywhere; color: var(--text-muted); max-width: 28rem; }
@media (max-width: 640px) {
  .table--list td.table__acts { width: auto; margin-left: auto; order: 4; }
  .pay-inv { flex-wrap: wrap; }
  .table td.table__name > small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
}
.table__sel { width: 1%; }
.table__sel input { width: 16px; height: 16px; margin: 0; display: block; accent-color: var(--brand); }
@media (max-width: 640px) {
  .table tr:has(td.table__sel) { position: relative; padding-left: 36px; }
  .table td.table__sel { position: absolute; left: 2px; top: var(--s-3); }
  .table td.table__sel input { width: 22px; height: 22px; }
  .table thead { display: none; }
}
@media (max-width: 640px) { .table--list td.table__name { min-width: 0; } }
td.lv-text { min-width: 0; max-width: 14rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Reports and the ESTV form: amounts stay beside their labels on a phone. */
.report-chart { margin-bottom: var(--s-6); }
.report-chart figcaption { font-weight: 600; margin-bottom: var(--s-3); }
.report-chart__svg { display: block; width: 100%; height: auto; max-height: 240px; }
.report-chart__line { fill: none; stroke: var(--brand); stroke-width: 2; }
.report-chart__point { fill: var(--brand); }
.report-chart details { margin-top: var(--s-3); }
.vat-line { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: var(--s-2); border-bottom: 1px solid var(--border); padding: var(--s-3) 0; }
.vat-line__code { color: var(--text-muted); }
.vat-line__detail { min-width: 0; }
.vat-line__detail > summary { display: flex; gap: var(--s-3); justify-content: space-between; cursor: pointer; list-style: none; }
.vat-line__detail > summary > span:first-child { overflow-wrap: anywhere; margin-right: auto; }
.vat-line__amount { white-space: nowrap; flex-shrink: 0; }
.vat-line--total { font-weight: 600; }
.report-filter { display: flex; flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3); margin-bottom: var(--s-5); padding: 0; border: 0; background: none; box-shadow: none; }
.report-filter .field { min-width: 0; flex: 0 1 12rem; display: flex; flex-direction: column; gap: var(--s-1); }
.report-filter .input { width: 100%; }
.report-chart__label { fill: var(--text-muted); font-size: var(--fs-xs); }
@media (max-width: 639px) {
  .report-filter .field { flex: 1 1 140px; }
  .vat-line { grid-template-columns: 2.5rem minmax(0, 1fr); }
  .vat-line__detail > summary { font-size: var(--fs-xs); gap: var(--s-2); }
}

/* ---- Section 10 B: calendar proposals (times-calendar.php), client portal (portal.php) ---- */

.calp { display: flex; flex-direction: column; }
.calp__item { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4) 0; border-bottom: 1px solid var(--border); }
.calp__item:last-child { border-bottom: 0; }
.calp__item.is-done { color: var(--text-muted); }
.calp__item.is-error { border-left: 3px solid var(--danger); padding-left: var(--s-3); }
.calp__head { display: flex; align-items: flex-start; gap: var(--s-3); cursor: pointer; }
.calp__head input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.calp__what { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.calp__what b { font-weight: 500; overflow-wrap: anywhere; }
.calp__what small { color: var(--text-muted); }
.calp__end { flex: none; font-variant-numeric: tabular-nums; }
.calp__more { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s-4); align-items: end; }
.portal .qr { width: 180px; height: 180px; margin-top: var(--s-2); }
.portal__qr { padding: var(--s-2) 0; }
@media (max-width: 640px) {
  .calp__more { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
}

/* Installer: requirement checklist and next steps */
.install-checks { list-style: none; padding: 0; margin: 0 0 var(--s-4); display: grid; gap: var(--s-2); }
.install-checks small { display: block; color: var(--text-muted); margin-left: calc(1.8em + var(--s-1)); }
.install-steps { text-align: left; display: grid; gap: var(--s-2); padding-left: 1.2em; color: var(--text-muted); }
.install-steps code { overflow-wrap: anywhere; }

/* ---- Touch devices (placed last so they win over the rules above) ------------------------ */

@media (pointer: coarse) {
  .seg__item { min-height: var(--h-touch); }
  .rich__btn { height: var(--h-touch); min-width: var(--h-touch); }
  .switch { min-height: var(--h-touch); }
  .cal-chip, .tabs a, .xrow__toggle, .oi__grip, .btn--link { min-height: var(--h-touch); }
  /* 40 px: a colour dot at 44 px would look like a button */
  .kb-sw span { min-width: 40px; min-height: 40px; }
  /* a checkbox stays 22 px to look right; the padding of its cell makes the touch area 44 px */
  .table__sel input { width: 22px; height: 22px; }
  .table td.table__sel, .table th.table__sel { padding: 11px; }
}
@media (pointer: coarse) and (max-width: 640px) {
  .table tr:has(td.table__sel) { padding-left: 46px; }
  .table td.table__sel { left: 0; top: 1px; }
}
/* the editor's fields look like text until hovered; there is no hover on a touch screen, so they show their edge */
@media (hover: none) {
  .oi__row .input:not(:disabled), .prose, .oi__desc .input.rich { border-color: var(--border-input); }
}
/* «select all» on the dunning page: the table head is hidden on a phone, so the box sits above the group */
.dun-selall { display: none; }
@media (max-width: 640px) { .dun-selall { display: flex; margin-bottom: var(--s-2); } }

/* ---- Dashboard (index.php) --------------------------------------------------------------- */
.dpills { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.dpill { display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--h-ctl); padding: 0 var(--s-4); border-radius: var(--r-pill); background: var(--brand-soft); color: var(--brand-text); font-weight: 700; font-size: var(--fs-base); text-decoration: none; transition: background 150ms var(--ease); }
.dpill:hover { text-decoration: none; background: var(--brand-soft-hover); }
.dpill--primary { background: var(--brand); color: var(--on-brand); }
.dpill--primary:hover { background: var(--brand-hover); }
.dtiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
.dtiles .tile { transition: transform 150ms var(--ease); }
.dtiles .tile:hover { text-decoration: none; transform: translateY(-1px); }
.dtiles .tile__value { font-size: var(--fs-xl); overflow-wrap: anywhere; }
.tile__delta--muted { background: var(--surface-3); color: var(--text-muted); }
.tile__delta--down { background: var(--danger-soft); color: var(--danger-text); }
.tile__delta--warn { background: var(--warn-soft); color: var(--warn-text); }
.tile--danger .tile__value { color: var(--danger-text); }
.tile--warn .tile__value { color: var(--warn-text); }
.dgrid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--s-4); align-items: stretch; }
.dc { min-width: 0; grid-column: span 12; }
.dhead { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.dhead .card__title { margin: 0; }
.dnum { font-variant-numeric: tabular-nums; color: var(--ok-text); }
@media (min-width: 900px) {
  .dc--8 { grid-column: span 8; }
  .dc--4 { grid-column: span 4; }
  .dc--6 { grid-column: span 6; }
}
/* cash flow */
.dflow .dflow__svg { height: 180px; }
@media (min-width: 900px) { .dflow .dflow__svg { height: 240px; } }
.dbar--paid { fill: var(--ok-fill); }
.dbar--issued { fill: color-mix(in srgb, var(--brand) 55%, transparent); }
.dbar--exp { fill: url(#dhatch); stroke: var(--brand); stroke-width: 1; vector-effect: non-scaling-stroke; }
.dhatch__bg { fill: transparent; }
.dhatch__ln { stroke: var(--brand); stroke-width: 1.5; opacity: 0.55; }
.dflow__axis span { text-align: center; }
.chart__legend i.dl { border-radius: 3px; }
.dl--paid { background: var(--ok-fill) !important; }
.dl--out { background: var(--danger-fill) !important; }
.dl--stand { background: var(--brand) !important; }
.dl--issued { background: color-mix(in srgb, var(--brand) 55%, transparent) !important; }
.dl--exp { background: repeating-linear-gradient(45deg, var(--brand) 0 1.5px, transparent 1.5px 4px) !important; box-shadow: inset 0 0 0 1px var(--brand); }
@media (max-width: 640px) { .dflow__axis span:nth-child(even) { visibility: hidden; } }
/* donut: pathLength 100, so dash lengths are percentages */
.ddonut { position: relative; width: min(100%, 11rem); margin: 0 auto; }
.ddonut svg { display: block; width: 100%; transform: rotate(-90deg); }
.ddonut circle { fill: none; stroke-width: 14; }
.ddonut__track { stroke: var(--surface-3); }
.ddonut__seg--0 { stroke: var(--ok-fill); }
.ddonut__seg--1 { stroke: var(--warn-fill); }
.ddonut__seg--2 { stroke: color-mix(in srgb, var(--danger-fill) 55%, var(--warn-fill)); }
.ddonut__seg--3 { stroke: var(--danger-fill); }
.ddonut__seg--4 { stroke: var(--danger); }
.ddonut__mid { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ddonut__mid small { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.ddonut__mid b { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.dlegend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.dlegend li { display: flex; align-items: center; gap: var(--s-2); min-height: 32px; font-size: var(--fs-base); }
.dlegend li span { flex: 1; color: var(--text-2); }
.dlegend b { font-variant-numeric: tabular-nums; font-weight: 700; }
.ddot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ddot--0 { background: var(--ok-fill); } .ddot--1 { background: var(--warn-fill); }
.ddot--2 { background: color-mix(in srgb, var(--danger-fill) 55%, var(--warn-fill)); } .ddot--3 { background: var(--danger-fill); } .ddot--4 { background: var(--danger); }
/* due soon and payments */
.ddate { width: 44px; height: 44px; border-radius: var(--r-md); flex: none; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; background: var(--surface-3); color: var(--text-2); }
.ddate b { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }
.ddate small { font-size: var(--fs-2xs); font-weight: 700; text-transform: uppercase; }
.ddate--brand { background: var(--brand-soft); color: var(--brand-text); }
.ddate--warn { background: var(--warn-soft); color: var(--warn-text); }
.dwhen { font-size: var(--fs-sm); white-space: nowrap; }
.dpaid { color: var(--ok-text); font-size: var(--fs-md); }
.doffsum { margin: 0 0 var(--s-2); font-size: var(--fs-sm); }
.dgrid .row { min-height: 60px; }
.dgrid .timeline { margin-top: var(--s-1); }
@media (max-width: 640px) {
  .dtiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
  .dtiles .tile { padding: var(--s-4); }
  .dtiles .tile__value { font-size: var(--fs-lg); }
  .dgrid { gap: var(--s-3); }
  .dgrid .card { padding: var(--s-4); }
  .dpills { gap: 6px; flex-wrap: nowrap; }
  .dpill { min-height: var(--h-touch); padding: 0 var(--s-3); gap: 6px; font-size: var(--fs-sm); }
  .dwhen { display: none; }
}
@media (prefers-reduced-motion: reduce) { .dpill, .dtiles .tile { transition: none; } .dtiles .tile:hover { transform: none; } }

/* ---- Offers and invoices ------------------------------------------------------------------ */
/* detail pages: every rail section is its own card, the document sits on the canvas as paper */
.ov .rail { padding: 0; border: 0; box-shadow: none; background: none; gap: var(--s-4); }
.ov .rail__sec { padding: var(--s-5); }
.ov .rail__sec:last-child { border: 1px solid var(--card-edge); }
.ov .rail__title { font-size: var(--fs-md); }
.rail__hero { gap: var(--s-1); }
.rail__amount { font-size: var(--fs-2xl); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.rail__amount.is-ok { color: var(--ok-text); }
.rail__amount.is-danger { color: var(--danger-text); }
.rail__pill { align-self: flex-start; margin: var(--s-1) 0; }
.ov__pdf { border: 0; box-shadow: var(--shadow-1); }
.ov .ph__actions .btn--primary { box-shadow: var(--shadow-1); }
@media (max-width: 640px) {
  .ov .rail__sec { padding: var(--s-4); }
  .ov .ph__sub { gap: var(--s-1); }
}
/* table rows that read like money rows: avatar + title/subtitle, roomier rows, no rules */
.who { display: flex; align-items: flex-start; gap: var(--s-3); min-width: 0; }
.who__txt { display: flex; flex-direction: column; min-width: 0; }
.who__txt a { color: var(--text); font-weight: 600; }
.who__txt small { display: block; color: var(--text-muted); font-weight: 500; }
.table--list td { border-bottom: 0; }
@media (min-width: 641px) { .table--list td { height: 64px; } }
.table--list tbody tr:hover td:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.table--list tbody tr:hover td:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
@media (max-width: 640px) { .who .av { width: 36px; height: 36px; } }
/* no min-width: the cell cannot grow (max-width: 0 above), so a wider .who lay over the next column (dunning.php at 1280 px); the title cuts with … instead */
@media (min-width: 641px) { .table--list td.table__name .who { align-items: center; } }
/* the dunning proposals have ten columns: tighter cells leave the title room on a laptop */
@media (min-width: 901px) and (max-width: 1439px) { .table--list:has(th.table__sel) th:not(.table__sel), .table--list:has(th.table__sel) td:not(.table__sel) { padding-inline: var(--s-1); } }
@media (max-width: 1199px) { .table--list:has(th.table__sel) .table__hide-md { display: none; } }   /* beside the sidebar there is no room for Tage, Offen, Gebühr, Zins: «Neu total» stays */
.ov > .banner { margin-bottom: var(--s-4); }

/* ---- Calendar (calendar.php, project milestones, dashboard card) ------------------------------ */
[data-cal-page] { display: flex; flex-direction: column; gap: var(--s-4); }
.cal-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); }
.cal-bar__label { margin: 0 0 0 var(--s-2); font-size: var(--fs-md); font-weight: 700; }
.cal-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.cal-chips [data-cal-reset] { margin-left: var(--s-2); }
.cal-chip { min-height: 36px; padding: 0 var(--s-4); border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--surface); color: var(--text-muted); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; }
.cal-chip[aria-pressed="true"] { background: var(--brand-soft); border-color: transparent; color: var(--brand-text); font-weight: 700; }
.cal-day { display: flex; flex-direction: column; gap: var(--s-2); }
.cal-day__h { margin: var(--s-4) 0 0; font-size: var(--fs-sm); font-weight: 700; color: var(--text-muted); }
.cal-day.is-today > .cal-day__h { color: var(--brand-text); }
.cal-day--overdue > .cal-day__h { color: var(--danger-text); }
.cal-list { display: flex; flex-direction: column; padding: var(--s-1); }
.cal-row { display: flex; align-items: center; min-height: 56px; }
.cal-item { flex: 1; min-width: 0; display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3); border: 0; border-radius: var(--r-md); background: none; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer; }
.cal-item:hover { background: var(--surface-2); text-decoration: none; }
.cal-item__icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border-radius: 50%; background: var(--surface-3); color: var(--text-2); }
.cal-item--brand .cal-item__icon { background: var(--brand-soft); color: var(--brand-text); }
.cal-item--warn .cal-item__icon { background: var(--warn-soft); color: var(--warn-text); }
.cal-item--danger .cal-item__icon { background: var(--danger-soft); color: var(--danger-text); }
.cal-item--ok .cal-item__icon { background: var(--ok-soft); color: var(--ok-text); }
.cal-item__txt { display: flex; flex-direction: column; min-width: 0; }
.cal-item__txt b { font-size: var(--fs-base); font-weight: 600; overflow-wrap: break-word; }
.cal-item__txt small { font-size: var(--fs-sm); color: var(--text-muted); overflow-wrap: anywhere; }
.cal-item.is-done .cal-item__txt b { text-decoration: line-through; color: var(--text-muted); }
.cal-tick { position: relative; flex: none; width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 0; background: none; cursor: pointer; }
.cal-tick::before { content: ""; position: absolute; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border-input); }
.cal-tick .i { position: relative; font-size: 13px; color: transparent; }
.cal-tick[aria-checked="true"]::before { background: var(--ok-fill); border-color: var(--ok-fill); }
.cal-tick[aria-checked="true"] .i { color: var(--bg); }
.cal-del { margin-right: auto; color: var(--danger-text); }
/* the tick replaces the icon, so both kinds of row start their text at the same x */
.cal-tick { margin-left: var(--s-2); }
.cal-tick + .cal-item { padding-left: var(--s-2); }
.cal-tick + .cal-item .cal-item__icon { display: none; }
/* week */
.cal-week { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
.cal-col { display: flex; flex-direction: column; gap: var(--s-1); min-width: 0; }
.cal-col__h { display: flex; gap: var(--s-2); align-items: baseline; margin: var(--s-2) 0 0; font-size: var(--fs-sm); color: var(--text-muted); }
.cal-col__h b { font-weight: 700; color: var(--text); }
.cal-col.is-today > .cal-col__h b { color: var(--brand-text); }
.cal-col__none { margin: 0; color: var(--text-muted); }
.cal-col .cal-list:empty { display: none; }
@media (min-width: 900px) {
  .cal-week { grid-template-columns: repeat(7, minmax(0, 1fr)); align-items: start; }
  .cal-col__h { flex-direction: column; gap: 0; align-items: center; margin: 0; }
  .cal-col .cal-item { padding: var(--s-2); gap: var(--s-2); align-items: flex-start; }
  .cal-col .cal-item__icon { display: none; }
  .cal-col .cal-tick { width: 32px; height: 32px; }
  .cal-col .cal-row { min-height: 0; }
  .cal-col .cal-item__txt b, .cal-col .cal-item__txt small { font-size: var(--fs-sm); }
}
/* month: items on desktop, dots on a phone; the day below the grid is the agenda of the selected day */
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); overflow: hidden; }
.cal-month__wd { padding: var(--s-2); text-align: center; font-size: var(--fs-xs); font-weight: 700; color: var(--text-muted); background: var(--surface-2); }
.cal-cell { min-height: 56px; padding: var(--s-1); border-top: 1px solid var(--border); border-left: 1px solid var(--border); min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.cal-cell:nth-child(7n + 1) { border-left: 0; }
.cal-cell.is-off { background: var(--surface-2); }
.cal-cell.is-off .cal-cell__n { color: var(--text-muted); }
.cal-cell.is-selected { background: var(--brand-soft); }
.cal-cell__n { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; color: var(--text); text-decoration: none; }
.cal-cell__n:hover { background: var(--surface-3); text-decoration: none; }
.cal-cell.is-today .cal-cell__n { background: var(--brand); color: var(--on-brand); font-weight: 700; }
.cal-cell__items { display: none; }
.cal-cell__dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.cal-dot--brand { background: var(--brand); } .cal-dot--warn { background: var(--warn-fill); } .cal-dot--danger { background: var(--danger-fill); } .cal-dot--ok { background: var(--ok-fill); }
.cal-selected { scroll-margin-top: var(--s-4); }
@media (min-width: 900px) {
  .cal-cell { min-height: 124px; align-items: stretch; padding: var(--s-2); }
  .cal-cell__n { align-self: flex-start; }
  .cal-cell__dots { display: none; }
  .cal-cell__items { display: flex; flex-direction: column; gap: 2px; }
  .cal-cell .cal-row { min-height: 0; }
  .cal-cell .cal-item { padding: 2px var(--s-2); border-radius: var(--r-sm); border-left: 3px solid var(--border-input); background: var(--surface-2); }
  .cal-cell .cal-item--brand { border-left-color: var(--brand); } .cal-cell .cal-item--warn { border-left-color: var(--warn-fill); } .cal-cell .cal-item--danger { border-left-color: var(--danger-fill); }
  .cal-cell .cal-item__icon, .cal-cell .cal-tick { display: none; }
  .cal-cell .cal-item__txt b { font-size: var(--fs-xs); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cal-cell__more { font-size: var(--fs-xs); color: var(--text-muted); padding: 0 var(--s-2); }
}
/* dashboard card and project section */
.cal-mini .ddate--danger { background: var(--danger-soft); color: var(--danger-text); }
.cal-mini .row.is-done b { text-decoration: line-through; color: var(--text-muted); }
@media (prefers-reduced-motion: reduce) { .cal-item { transition: none; } }

/* ---- Accounting: expenses, journal, chart of accounts, settings (stage A3/A4) ---- */
.lst--exp, .lst--jrn { --cols: minmax(0, 1fr) 11rem 9rem 36px; --cols-md: minmax(0, 1fr) 11rem 9rem 36px; }
.jr-nr { --av: var(--text-muted); --av-text: var(--text-muted); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.jr-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.input--amount { text-align: right; font-variant-numeric: tabular-nums; }
.jr-lines { display: flex; flex-direction: column; gap: var(--s-2); }
.jr-line { display: grid; grid-template-columns: minmax(0, 1fr) 8rem 8rem; gap: var(--s-2); }
.acc-sheet { padding: var(--s-2) var(--s-3); }
.led-open td { padding-top: var(--s-1); padding-bottom: var(--s-1); }
.led-open .input { width: 10rem; margin-left: auto; }
.led-open .field__error { display: block; }
.exp-form { gap: var(--s-4); }
.exp-form fieldset { min-width: 0; }
.exp-form legend { margin-bottom: var(--s-2); }
.exp-form .card { border: 0; }
.exp-receipt__pick { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.exp-camera { cursor: pointer; }
.exp-paid { align-self: stretch; }
.exp-paid .seg__item { position: relative; cursor: pointer; }
.exp-paid input { position: absolute; opacity: 0; inset: 0; }
.exp-paid .seg__item:has(input:checked) { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; }
.exp-paid .seg__item:has(input:focus-visible) { outline: 3px solid var(--brand); outline-offset: 2px; }
.exp-fx__chf { align-self: end; padding-bottom: var(--s-3); font-variant-numeric: tabular-nums; }
.exp-bar { display: flex; flex-wrap: wrap; gap: var(--s-2); }
/* Receipts by e-mail: the «Eingang» card above the expense list */
.inbox { gap: var(--s-3); }
.inbox .section__head { flex-wrap: wrap; }
.inbox__item { display: flex; flex-direction: column; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--border); }
.inbox__thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border); display: block; }
.inbox__text { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: var(--fs-sm); color: var(--text-muted); max-height: 16rem; overflow: auto; margin: var(--s-2) 0 0; }
.inbox summary { cursor: pointer; color: var(--text-muted); font-size: var(--fs-sm); }
.inbox__rejected { padding-top: var(--s-3); border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .exp-nofile { display: none; }
  .lst--exp, .lst--jrn { --cols: minmax(0, 1fr) auto; }
  .jr-line { grid-template-columns: 1fr 1fr; }
  .jr-line select { grid-column: 1 / -1; }
  .exp-bar { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); margin: 0 calc(-1 * var(--s-4)); padding: var(--s-3) var(--s-4); background: var(--bg); z-index: 10; }
  .exp-bar .btn--primary { flex: 1 1 100%; height: 48px; }
  .led-open .input { width: 7.5rem; }
}

/* ---- Bank: reconciliation page and the two editors in the ledger settings (stage A5) ---- */
.lst--bank { --cols: minmax(0, 1fr) 9rem 10rem 36px; --cols-md: minmax(0, 1fr) 9rem 10rem 36px; }
.lst--bankover { --cols: minmax(0, 1fr) 9rem 9rem; --cols-md: minmax(0, 1fr) 9rem 9rem; }
.bank-in .money { color: var(--ok-text); }
.bank-hint { display: flex; gap: var(--s-2); align-items: flex-start; margin: 0; color: var(--text-2); }
.bank-hint .i { flex: none; margin-top: 3px; color: var(--text-muted); }
.bank-sug { align-items: center; }
.bank-sug .btn { height: auto; min-height: 32px; max-width: 100%; padding-top: 6px; padding-bottom: 6px; white-space: normal; text-align: left; line-height: 1.25; }
.bank-book { display: grid; grid-template-columns: minmax(0, 18rem) minmax(15rem, 1fr) auto; gap: var(--s-3); align-items: end; }
.bank-book__go { display: flex; gap: var(--s-2); align-items: center; }
.bank-note { margin-top: var(--s-2); font-size: var(--fs-sm); }
.bank-remember { margin-right: auto; }
.bank-cert { display: grid; gap: var(--s-2); margin-top: var(--s-3); }
.bank-cert__row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px var(--s-3); align-items: center; padding: var(--s-3); border: 1px solid var(--card-edge); border-radius: var(--r-md); }
.bank-cert__row input { grid-row: 1 / span 3; }
.bank-cert__who { display: grid; min-width: 0; overflow-wrap: anywhere; }
.bank-cert__who small, .bank-cert__do { color: var(--text-2); font-size: var(--fs-sm); }
.bank-cert__do { grid-column: 2 / -1; overflow-wrap: anywhere; }
.bank-cert__res:not(:empty) { grid-column: 2 / -1; font-size: var(--fs-sm); font-weight: 600; }
.bank-cert__row.is-ok .bank-cert__res { color: var(--ok-text); }
.bank-cert__row.is-fail .bank-cert__res { color: var(--danger-text); }
.led-roles td { padding-top: var(--s-1); padding-bottom: var(--s-1); }
.led-roles select.input { width: min(22rem, 100%); margin-left: auto; }
.led-roles .field__error { display: block; }
@media (max-width: 640px) {
  .bank-book { grid-template-columns: minmax(0, 1fr); }
  .bank-book__go .btn--primary { flex: 1; height: 48px; }
  .lst--bankover .lrow__status { grid-row: 2; }
  .led-roles select.input { width: 11rem; }
}

/* ---- Statements: Bilanz, Erfolgsrechnung, Saldenliste, VAT reconciliation, year-end (stage A6) ---- */
.stmt { padding: var(--s-2) var(--s-3); }
@media (min-width: 641px) { .stmt__table td { height: 40px; } }
.stmt__nr { width: 5rem; }
.stmt__head td { height: 56px; vertical-align: bottom; padding-bottom: var(--s-2); font-size: var(--fs-lg, 16px); font-weight: 700; border-bottom: 0; }
.stmt__total td { font-weight: 700; border-top: 2px solid var(--text); border-bottom: 0; }
.stmt__table tbody tr.stmt__head:hover td { background: none; }
.stmt__prev, .stmt__prev .money { color: var(--text-muted); font-weight: 500; }
.stmt__diff .money { color: var(--danger-text); }
.stmt__files a { margin-right: var(--s-3); white-space: nowrap; }
.stmt__hint { margin-top: var(--s-2); max-width: 46rem; }
@media (max-width: 640px) {
  .stmt__total { border-top: 2px solid var(--text); }
  .stmt__total td { border-top: 0; }
  .stmt__head td { height: auto; padding-top: var(--s-3); }
  /* stacked rows: a heading spans the row as plain bold text instead of a tinted cell */
  .stmt__table .table__group td, .stmt__table .stmt__head td { flex: 1 1 100%; background: none; color: var(--text); font-weight: 700; font-size: var(--fs-base); }
  .stmt__table .table__group { border-bottom: 0; padding-bottom: 0; }
}

/* liquidity forecast (liquidity.php): bars up and down from the zero line, the balance as a line, a red band where it goes below zero */
.fc-stack { display: grid; gap: var(--s-4); }
.fc-svg { height: 220px; }
.fc-in { fill: var(--ok-fill); }
.fc-out { fill: var(--danger-fill); }
.fc-line { fill: none; stroke: var(--brand); stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.fc-neg { fill: var(--danger-fill); opacity: 0.14; }
.fc-axis span { text-align: center; }
.lst--fc { --cols: minmax(0, 1fr) 9rem 9rem 10rem 36px; --cols-md: minmax(0, 1fr) 9rem 9rem 10rem 36px; }
.fc-neg-text { color: var(--danger-text); }
.fc-items .row__end { font-variant-numeric: tabular-nums; }
.fc-items form { margin: 0; }
@media (max-width: 640px) { .lst--fc { --cols: minmax(0, 1fr) auto; } .fc-axis span:nth-child(even) { visibility: hidden; } }

/* ---- Searchable combobox (js/combo.js) ----------------------------------- */
/* The native select stays underneath (submitted, validated, source of truth) and only catches focus. */
.combo { position: relative; display: block; min-width: 0; }
.combo--inline { display: inline-block; width: auto; min-width: 9rem; }
.combo__native { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.combo__input { text-overflow: ellipsis; cursor: pointer; }
.combo__input:focus { cursor: text; }
.combo__list {
  position: fixed; z-index: 60; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-1);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-2);
}
.combo__list[hidden] { display: none; }
.combo__opt { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: 36px; padding: 0 var(--s-3); border-radius: var(--r-sm, 8px); cursor: pointer; }
.combo__opt.is-active { background: var(--brand-soft); }
.combo__opt[aria-selected="true"] { color: var(--brand-text); font-weight: 600; }
.combo__opt.is-empty .combo__label { color: var(--text-muted); }
.combo__opt.is-disabled { opacity: 0.5; cursor: default; }
.combo__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo__hint { flex: none; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 400; }
.combo__mark { background: none; color: inherit; font-weight: 700; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; text-decoration-color: var(--brand); }
.combo__heading { padding: var(--s-2) var(--s-3) var(--s-1); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; }
.combo__none { padding: var(--s-3); color: var(--text-muted); text-align: center; }
@media (max-width: 640px), (pointer: coarse) { .combo__opt { min-height: 44px; } }

/* ---- Address suggestions (js/address-ac.js): the combobox list, anchored under the street field ---- */
.addr-host { position: relative; }
.addr__list { position: absolute; inset: calc(100% + 4px) 0 auto 0; max-height: 18rem; }

/* ---- Boards (board.php): columns of cards, scrolling sideways; dragging is HTML5, the card sheet is the touch fallback ---- */
.kb-bar { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0 0 var(--s-4); }
.kb { display: flex; align-items: stretch; gap: var(--s-3); overflow-x: auto; scroll-snap-type: x proximity; }
.kb-col { flex: 1 1 240px; min-width: 220px; scroll-snap-align: start; display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-lg); background: var(--surface-2); }
[data-color="red"] { --kb-c: var(--kb-red); } [data-color="orange"] { --kb-c: var(--kb-orange); } [data-color="yellow"] { --kb-c: var(--kb-yellow); } [data-color="green"] { --kb-c: var(--kb-green); }
[data-color="teal"] { --kb-c: var(--kb-teal); } [data-color="blue"] { --kb-c: var(--kb-blue); } [data-color="purple"] { --kb-c: var(--kb-purple); } [data-color="pink"] { --kb-c: var(--kb-pink); }
/* Gantt: one row per card, a day is --dw wide; the label column stays while the timeline scrolls sideways */
.kb, .kb-colors, .kb-list, .kb-gantt { --kb-red: #d64545; --kb-orange: #e8833a; --kb-yellow: #d9a514; --kb-green: #2f9e63; --kb-teal: #1d9aa6; --kb-blue: #3b63e0; --kb-purple: #8a5cd6; --kb-pink: #d6538f; }
.kb-gantt { overflow-x: auto; }
.kb-g__row { display: grid; grid-template-columns: 14rem calc(var(--days) * var(--dw)); border-top: 1px solid var(--border); cursor: pointer; width: max-content; min-width: 100%; }
.kb-g__row--head { cursor: default; border-top: 0; }
.kb-g__row:not(.kb-g__row--head):hover { background: var(--surface-2); }
.kb-g__lab { position: sticky; left: 0; z-index: 2; background: inherit; background-color: var(--surface); padding: var(--s-3) var(--s-4); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-right: 1px solid var(--border); }
.kb-g__row:not(.kb-g__row--head):hover .kb-g__lab { background-color: var(--surface-2); }
.kb-g__lab.is-done { text-decoration: line-through; color: var(--text-muted); }
.kb-g__row--head .kb-g__lab { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.kb-g__track { position: relative; display: flex; min-height: 44px; background-image: linear-gradient(to right, var(--today-line, transparent), transparent); }
.kb-g__row:not(.kb-g__row--head) .kb-g__track::before { content: ""; position: absolute; top: 0; bottom: 0; left: calc(var(--today) * var(--dw) + var(--dw) / 2); width: 2px; background: var(--brand); opacity: .5; }
.kb-g__day { flex: 0 0 var(--dw); display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: var(--fs-xs); color: var(--text-muted); padding: var(--s-1) 0; }
.kb-g__day small { font-size: var(--fs-2xs); font-weight: 600; text-transform: uppercase; }
.kb-g__day.is-we { background: color-mix(in srgb, var(--border) 35%, transparent); }
.kb-g__day.is-today { color: var(--brand); font-weight: 700; }
.kb-g__bar { position: absolute; top: 10px; bottom: 10px; border-radius: var(--r-pill); background: var(--kb-c, var(--brand)); min-width: var(--dw); }
.kb-g__bar.is-done { opacity: .4; }
.kb-g__bar { cursor: grab; touch-action: none; user-select: none; }
.kb-g__bar.is-moving { cursor: grabbing; box-shadow: var(--shadow-1); }
.kb-g__h { position: absolute; top: 0; bottom: 0; width: 10px; cursor: ew-resize; }
.kb-g__h--l { left: 0; } .kb-g__h--r { right: 0; }
.kb-g__row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.kb-g__none { margin: 0; padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); color: var(--text-2); font-size: var(--fs-sm); position: sticky; left: 0; }
.design-logo { max-height: 72px; max-width: 100%; padding: var(--s-2); background: #fff; border: 1px solid var(--border); border-radius: var(--r-md); }
[data-kb] > .kb-add { margin-bottom: var(--s-3); }
.kb-list { display: flex; flex-direction: column; overflow: hidden; }
.kb-row { display: grid; grid-template-columns: minmax(0, 1fr) 9rem 8rem 12rem 5rem; gap: var(--s-3); align-items: center; padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border); cursor: pointer; }
.kb-row:first-child { border-top: 0; }
.kb-row:hover { background: var(--surface-2); }
.kb-row:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.kb-row--head { cursor: default; font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.kb-row--head:hover { background: transparent; }
.kb-row .kb-card__t.is-done { text-decoration: line-through; color: var(--text-muted); }
.kb-row__col { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); }
.kb-row__col::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--kb-c, var(--border-strong)); }
.kb-row__n { font-size: var(--fs-sm); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767px) { .kb-row { grid-template-columns: minmax(0, 1fr) auto; } .kb-row > :nth-child(n+3) { display: none; } .kb-row--head { display: none; } }
.kb-col[data-color] { background: color-mix(in srgb, var(--kb-c) 12%, var(--surface-2)); box-shadow: inset 0 3px 0 var(--kb-c); }
.kb-colors { display: flex; flex-wrap: wrap; gap: var(--s-2); border: 0; padding: 0; margin: 0; }
.kb-colors legend { padding: 0; margin-bottom: var(--s-2); }
.kb-sw { position: relative; display: inline-flex; }
.kb-sw input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.kb-sw span { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 var(--s-2); border-radius: var(--r-pill); border: 2px solid transparent; background: var(--kb-c, transparent); font-size: 0; }
.kb-sw--none span { font-size: var(--fs-sm); border-color: var(--border-strong); background: transparent; }
.kb-sw input:checked + span { border-color: var(--text); box-shadow: 0 0 0 2px var(--surface); }
.kb-sw input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.kb-col--new { flex: 0 0 200px; min-width: 0; align-self: flex-start; background: transparent; border: 1px dashed var(--border-strong); }
@media (max-width: 767px) { .kb-col { flex: 0 0 84vw; } .kb-col--new { flex-basis: 70vw; } }
.kb-col__h { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.kb-col__t { margin: 0; font-size: var(--fs-base); font-weight: 600; display: flex; align-items: center; gap: var(--s-2); }
.kb-col__cards { display: flex; flex-direction: column; gap: var(--s-2); min-height: 40px; border-radius: var(--r-md); }
.kb-col__cards.is-over { outline: 2px dashed var(--brand); outline-offset: 2px; }
.kb-card { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); border: 1px solid var(--card-edge); cursor: pointer; }
.kb-card:hover { border-color: var(--border-strong); }
.kb-card:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.kb-card.is-drag { opacity: .45; }
.kb-card.is-done .kb-card__t { text-decoration: line-through; color: var(--text-muted); }
.kb-card__t { font-weight: 500; overflow-wrap: anywhere; }
.kb-card__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-muted); }
.kb-card__p { display: inline-flex; align-items: center; gap: var(--s-1); }
.kb-card__p svg { width: 14px; height: 14px; }
.kb-add .input { width: 100%; }
.kb-time { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-3); display: grid; gap: var(--s-3); }
.kb-time legend { padding: 0 var(--s-2); font-weight: 600; }
.kb-time__sum { margin: 0; font-weight: 500; }
.kb-time__list { margin: 0; padding-left: var(--s-4); font-size: var(--fs-sm); color: var(--text-2); max-height: 8rem; overflow: auto; }
.kb-time__acts { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.kb-del { color: var(--danger-text); }

/* ---- Finger targets, last in the file so they win: 44 px on a touch screen and on a phone-wide window ---- */
@media (pointer: coarse), (max-width: 640px) {
  .topbar .search input { height: var(--h-touch); }
  .ph__crumb, .cal-chip, .check { min-height: var(--h-touch); }
  .check { align-items: center; }
  .check input { margin-top: 0; }
  .icon-btn--sm { width: var(--h-touch); height: var(--h-touch); }
  .xrow__toggle { min-width: var(--h-touch); margin-inline: -4px; }   /* its column is 36 px */
  .oi__grip { min-width: var(--h-touch); }
  .cal-cell__n { min-width: var(--h-touch); height: var(--h-touch); }
  .vat-line__detail > summary { min-height: var(--h-touch); align-items: center; }
  .vat-line { padding-block: var(--s-1); }
  .vat-line__code { display: flex; align-items: center; height: var(--h-touch); }
  .pub__term summary { padding-block: var(--s-3); }
  /* plain list rows: the whole text block (title and sub-line) is the link, not only the 21 px of the title.
     Not on expandable rows (.xrow): there a tap on the row opens it, and the link must not take that over. */
  .lrow__main, .lrow__txt { min-height: var(--h-touch); }
  .lrow__main:not(.lrow__main--av), .lrow__txt { justify-content: center; }
  :not(.xrow) > .lrow > .lrow__main, :not(.xrow) > .lrow .lrow__txt { position: relative; }
  :not(.xrow) > .lrow > .lrow__main > a::after, :not(.xrow) > .lrow .lrow__txt > a::after { content: ""; position: absolute; inset: 0; }
}
@media (max-width: 640px) {
  .topbar__actions > a.icon-btn[href$="settings.php"] { display: none; }   /* Einstellungen is in the «Mehr» sheet; the gear squeezed the search */
  .status--inline { flex-direction: column; align-items: center; text-align: center; }
  .status--inline .btn { max-width: 100%; }
}
