/* ==========================================================================
   StaySmart ERP — design system
   Tokens taken from _source/design/StaySmart ERP.dc.html
   Mobile-first: the phone layout is the base, desktop is the enhancement.
   ========================================================================== */

/* Self-hosted webfonts. Drop the .woff2 files into public/assets/fonts/ and
   they take over automatically; until then the system stack is used, so
   nothing is ever fetched from a third party (GDPR + our CSP forbid it). */
@font-face {
    font-family: 'Plus Jakarta Sans';
    src: url('/assets/fonts/PlusJakartaSans-Variable.woff2') format('woff2-variations');
    font-weight: 400 800;
    font-display: swap;
}
@font-face {
    font-family: 'JetBrains Mono';
    src: url('/assets/fonts/JetBrainsMono-Variable.woff2') format('woff2-variations');
    font-weight: 400 500;
    font-display: swap;
}

:root {
    /* Brand */
    --brand:        #5B4BF0;
    --brand-purple: #9B1FE8;
    --brand-blue:   #2F8FF0;
    --brand-cyan:   #22C6F5;
    --gradient: linear-gradient(118deg, var(--brand-purple), var(--brand) 45%, var(--brand-cyan));
    --gradient-soft: linear-gradient(135deg, var(--brand-purple), var(--brand-cyan));

    /* Link text, which is not the same job as --brand.
       --brand is a fill with white on top of it, so it is free to be as deep
       as the mark is. A link is ink on the page's own background and has to
       clear 4.5:1 against it — which this does on white and does not on the
       dark canvas, hence the override in the dark block. */
    --link: var(--brand);

    /* Neutrals — LIGHT.
       Everything below the token block references these, so a theme is a
       matter of redefining tokens, never of restyling components. */
    --ink:      #14141c;
    --ink-70:   rgba(20, 20, 40, .70);
    --ink-60:   rgba(20, 20, 40, .60);
    --ink-50:   rgba(20, 20, 40, .50);
    --ink-42:   rgba(20, 20, 40, .42);
    --ink-30:   rgba(20, 20, 40, .32);
    --canvas:   #f6f7fb;
    --surface:  #ffffff;
    --surface-2: rgba(20, 20, 40, .05);   /* subtle fills: chips, file button */
    --line:        rgba(20, 20, 40, .07);
    --line-2:      rgba(20, 20, 40, .10);
    --line-strong: rgba(20, 20, 40, .14);

    /* Always dark, in either theme — the landing footer and the floating
       "night close" chip are dark by design, not by palette. */
    --night:    #14141c;
    --on-night: #ffffff;

    /* Sidebar — LIGHT. It follows the theme: a light nav panel in light mode,
       separated from the canvas by a surface step plus a hairline border. */
    --sidebar-bg:        var(--surface);
    --sidebar-fg:        rgba(20, 20, 40, .62);
    --sidebar-fg-mute:   rgba(20, 20, 40, .40);
    --sidebar-fg-strong: #14141c;
    --sidebar-hover:     rgba(20, 20, 40, .05);
    --sidebar-fill:      rgba(20, 20, 40, .04);
    --sidebar-line:      rgba(20, 20, 40, .08);
    --sidebar-border:    rgba(20, 20, 40, .09);

    /* State */
    --ok:    #3ddc97;
    --warn:  #f0a92f;
    --error: #e5484d;
    --ok-fg:    #0f6b4c;
    --warn-fg:  #8a5c00;
    --error-fg: #a3191d;
    --ok-bg:    rgba(61, 220, 151, .12);
    --warn-bg:  rgba(240, 169, 47, .16);
    --error-bg: rgba(229, 72, 77, .09);
    --info-fg:  #3a2fb0;
    --info-bg:  rgba(91, 75, 240, .08);

    /* Shape */
    --r-sm: 8px;
    --r-md: 10px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-pill: 99px;
    --ring: 0 0 0 4px rgba(91, 75, 240, .12);
    --shadow-card: 0 1px 2px rgba(20, 20, 40, .04);
    --shadow-pop:  0 14px 30px -14px rgba(91, 75, 240, .55);
    --shadow-lift: 0 18px 40px -24px rgba(20, 20, 40, .45);

    /* Type */
    --font: 'Plus Jakarta Sans', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    /* Controls — inputs, selects and buttons share ONE height so any row of
       them lines up without per-component tweaking. Change it here only. */
    --control-h:    46px;   /* default; comfortably above the 44px touch target */
    --control-h-sm: 36px;   /* .btn--sm and inline table controls */
    --control-h-lg: 52px;   /* hero / primary sign-in */
    --control-pad-x: 15px;

    /* Layout */
    /* Breakpoints. Not usable in a media query — custom properties are not —
       but written down so the next one added is one of these rather than a
       tenth width nobody can account for:

         640  phone, tight    max-width: 640px  / (no min pair)
         720  phone → tablet  max-width: 719px  / min-width: 720px
         900  tablet → laptop max-width: 899px  / min-width: 900px
        1100  laptop → wide                       min-width: 1100px

       720 is the one that matters: it is where tables stop being tables. */
    --sidebar-w: 232px;
    /* Derived from the control height so the bar always fits a full-size
       control; the sticky sidebar offsets against this same value. */
    --topbar-h: calc(var(--control-h) + 14px);
    --bottom-nav-h: calc(58px + env(safe-area-inset-bottom));
    --gap: clamp(12px, 1.6vw, 18px);
    --pad: clamp(14px, 2.4vw, 26px);

    color-scheme: light;
}

/* ==========================================================================
   Dark theme

   LIGHT IS THE DEFAULT. The OS preference is honoured only when the user has
   explicitly chosen "auto" — so a visitor whose laptop is in dark mode still
   gets the light product unless they ask otherwise.

     [data-theme="light"] — default, and what everyone gets until they choose
     [data-theme="dark"]  — the user picked dark
     [data-theme="auto"]  — the user opted into following the OS

   The attribute is rendered server-side on <html>, so there is no flash.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] {
        color-scheme: dark;

        --ink:      #eef0f6;
        --ink-70:   rgba(238, 240, 246, .72);
        --ink-60:   rgba(238, 240, 246, .62);
        --ink-50:   rgba(238, 240, 246, .50);
        --ink-42:   rgba(238, 240, 246, .40);
        --ink-30:   rgba(238, 240, 246, .28);
        /* The brand violet is 3.15:1 on this canvas — readable as a shape,
           not as a sentence. Lightened until it clears AA. */
        --link:     #a99cff;
        --canvas:   #0e0e14;
        --surface:  #17171f;
        --surface-2: rgba(255, 255, 255, .06);
        --line:        rgba(255, 255, 255, .09);
        --line-2:      rgba(255, 255, 255, .13);
        --line-strong: rgba(255, 255, 255, .18);

        --sidebar-bg:        #08080c;
        --sidebar-fg:        rgba(255, 255, 255, .68);
        --sidebar-fg-mute:   rgba(255, 255, 255, .38);
        --sidebar-fg-strong: #ffffff;
        --sidebar-hover:     rgba(255, 255, 255, .06);
        --sidebar-fill:      rgba(255, 255, 255, .05);
        --sidebar-line:      rgba(255, 255, 255, .07);
        --sidebar-border:    rgba(255, 255, 255, .07);

        --ok-fg:    #5fe0ac;
        --warn-fg:  #f0b95a;
        --error-fg: #ff8a8d;
        --ok-bg:    rgba(61, 220, 151, .14);
        --warn-bg:  rgba(240, 169, 47, .14);
        --error-bg: rgba(229, 72, 77, .16);
        --info-fg:  #b3a9ff;
        --info-bg:  rgba(91, 75, 240, .18);

        --shadow-card: 0 1px 2px rgba(0, 0, 0, .5);
        --shadow-lift: 0 18px 40px -24px rgba(0, 0, 0, .8);
        --ring: 0 0 0 4px rgba(123, 108, 255, .25);
    }
}

/* Explicit dark: the same palette, applied regardless of the OS setting. */
:root[data-theme="dark"] {
    --ink:      #eef0f6;
    --ink-70:   rgba(238, 240, 246, .72);
    --ink-60:   rgba(238, 240, 246, .62);
    --ink-50:   rgba(238, 240, 246, .50);
    --ink-42:   rgba(238, 240, 246, .40);
    --ink-30:   rgba(238, 240, 246, .28);
    --link:     #a99cff;
    --canvas:   #0e0e14;
    --surface:  #17171f;
    --surface-2: rgba(255, 255, 255, .06);
    --line:        rgba(255, 255, 255, .09);
    --line-2:      rgba(255, 255, 255, .13);
    --line-strong: rgba(255, 255, 255, .18);

    --sidebar-bg:        #08080c;
    --sidebar-fg:        rgba(255, 255, 255, .68);
    --sidebar-fg-mute:   rgba(255, 255, 255, .38);
    --sidebar-fg-strong: #ffffff;
    --sidebar-hover:     rgba(255, 255, 255, .06);
    --sidebar-fill:      rgba(255, 255, 255, .05);
    --sidebar-line:      rgba(255, 255, 255, .07);
    --sidebar-border:    rgba(255, 255, 255, .07);

    --ok-fg:    #5fe0ac;
    --warn-fg:  #f0b95a;
    --error-fg: #ff8a8d;
    --ok-bg:    rgba(61, 220, 151, .14);
    --warn-bg:  rgba(240, 169, 47, .14);
    --error-bg: rgba(229, 72, 77, .16);
    --info-fg:  #b3a9ff;
    --info-bg:  rgba(91, 75, 240, .18);

    --shadow-card: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-lift: 0 18px 40px -24px rgba(0, 0, 0, .8);
    --ring: 0 0 0 4px rgba(123, 108, 255, .25);
}

/* ==========================================================================
   Page transitions
   The prototype cross-faded between screens with a diagonal gradient sweep
   (ss-sweep). This is a multi-page app, so the same effect is produced with
   cross-document View Transitions — no JS, no SPA router.

   Browsers without support simply navigate instantly, which is the behaviour
   they have today; app.js adds a short fade for them as a consolation.
   ========================================================================== */
@view-transition { navigation: auto; }

@keyframes vt-fade-in   { from { opacity: 0; } }
@keyframes vt-drift-out { to { opacity: 0; transform: translateX(-2.5%); } }

/* The incoming page is revealed behind a slanted edge, left to right. */
@keyframes vt-wipe-in {
    from { clip-path: polygon(0 0, 0 0, -16% 100%, -16% 100%); }
    to   { clip-path: polygon(0 0, 130% 0, 114% 100%, -16% 100%); }
}

/* Marketing + sign-in: the full branded sweep. */
html[data-vt="marketing"]::view-transition-old(root) {
    animation: vt-drift-out .34s cubic-bezier(.5, 0, .3, 1) forwards;
}
html[data-vt="marketing"]::view-transition-new(root) {
    animation: vt-wipe-in .46s cubic-bezier(.5, 0, .3, 1) forwards,
               vt-fade-in .26s ease-out;
}

/* Inside the ERP a plain, quick cross-fade — staff navigate constantly and a
   showy transition on every click gets old fast. */
html[data-vt="app"]::view-transition-old(root) { animation: vt-drift-out .16s ease-in forwards; }
html[data-vt="app"]::view-transition-new(root) { animation: vt-fade-in .2s ease-out; }

/* The gradient bar that travels across during the reveal. Straight from the
   prototype's `wipe` element. */
.sweep {
    position: fixed; inset: 0; z-index: 200;
    overflow: hidden; pointer-events: none;
}
.sweep::before {
    content: '';
    position: absolute; top: 0; bottom: 0; left: 0; width: 46%;
    background: linear-gradient(100deg,
        rgba(155, 31, 232, 0),
        rgba(123, 43, 238, .22),
        rgba(34, 198, 245, .30),
        rgba(34, 198, 245, 0));
    animation: ss-sweep .46s cubic-bezier(.5, 0, .3, 1) forwards;
}
@keyframes ss-sweep {
    0%   { transform: translateX(-110%) skewX(-9deg); }
    100% { transform: translateX(210%) skewX(-9deg); }
}

/* JS fallback for browsers without cross-document view transitions. */
html.is-leaving body { opacity: 0; transition: opacity .14s ease-in; }

@media (prefers-reduced-motion: reduce) {
    @view-transition { navigation: none; }
    .sweep { display: none; }
    html.is-leaving body { opacity: 1; transition: none; }
}

@keyframes ss-spin     { to { transform: rotate(360deg); } }
@keyframes ss-rise     { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes ss-float    { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes ss-shimmer  { 0% { background-position: 200% 0; } 100% { background-position: -140% 0; } }
@keyframes ss-pulse    { 0%, 100% { opacity: .25; transform: scale(.84); } 50% { opacity: 1; transform: scale(1); } }

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

/* The UA's [hidden] rule is display:none at the lowest specificity, so ANY
   component that sets its own display (flex, grid, inline-flex …) silently
   defeats it and the element stays visible when toggled with the attribute.
   This is the normalize.css idiom and the one place !important is warranted. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
    /* Avoid iOS zooming on input focus and keep content clear of the notch. */
    padding-bottom: env(safe-area-inset-bottom);
}

h1, h2, h3, h4 { margin: 0; letter-spacing: -.025em; line-height: 1.15; }
h1 { font-size: clamp(22px, 4vw, 30px); font-weight: 800; }
h2 { font-size: clamp(17px, 2.6vw, 21px); font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
p  { margin: 0 0 .75em; }
p:last-child { margin-bottom: 0; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--brand-purple); }

img, svg { max-width: 100%; }
::selection { background: rgba(123, 43, 238, .18); }

.visually-hidden, .skip-link:not(:focus) {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
.skip-link:focus {
    position: fixed; top: 8px; left: 8px; z-index: 200;
    background: var(--surface); padding: 10px 14px; border-radius: var(--r-md);
    box-shadow: var(--shadow-lift);
}

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ── App shell ───────────────────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 10px;
    min-height: var(--topbar-h);
    padding: 6px 12px;
    padding-top: env(safe-area-inset-top);
    background: color-mix(in srgb, var(--canvas) 92%, transparent);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--line);
}

.topbar__brand {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 15px; color: var(--ink); letter-spacing: -.02em;
}
.topbar__brand img { width: 26px; height: 26px; object-fit: contain; }
.topbar__brand span { display: none; }

/* A customer's own logo replaces the name, so it is not confined to the
   square the mark sits in — it keeps its aspect ratio and is bounded by the
   bar's height instead. */
.topbar__brand--logo img {
    width: auto; height: auto;
    max-width: min(180px, 42vw);
    max-height: calc(var(--control-h) - 12px);
}

/* A customer's logo is a file they uploaded, drawn for their letterhead —
   dark ink on an assumed white page. On the dark canvas that wordmark all
   but disappears, and we cannot recolour somebody else's mark. So it gets
   the white page back, as a small plate just big enough to sit on. */
:root[data-theme="dark"] .topbar__brand--logo img { background: #fff; padding: 3px 6px; border-radius: var(--r-sm); }
@media (prefers-color-scheme: dark) {
    :root[data-theme="auto"] .topbar__brand--logo img { background: #fff; padding: 3px 6px; border-radius: var(--r-sm); }
}

.topbar__client {
    margin-left: auto;
    font: 500 11px/1 var(--mono); color: var(--ink-42);
    max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.topbar__burger {
    display: flex; flex-direction: column; justify-content: center; gap: 4px;
    flex: none;
    width: 38px; height: 38px; padding: 9px;
    border: 0; border-radius: var(--r-md); background: transparent; cursor: pointer;
}
.topbar__burger span { display: block; height: 2px; border-radius: 2px; background: var(--ink); }

/* Language and appearance, in the bar with the bell.
   The auto margin lives here rather than on the bell, so the two switches and
   the bell travel to the right as one group instead of the bell drifting off
   on its own. */
.topbar__prefs { display: flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }

.topbar__bell {
    position: relative; flex: none;
    display: grid; place-items: center; width: 38px; height: 38px;
    border-radius: var(--r-md); color: var(--ink-60);
}
.topbar__bell svg { fill: currentColor; }

.badge {
    position: absolute; top: 4px; right: 4px;
    min-width: 17px; height: 17px; padding: 0 4px;
    display: grid; place-items: center;
    font: 700 10px/1 var(--mono); color: #fff;
    white-space: nowrap;
    background: var(--brand-purple); border-radius: var(--r-pill);
}

.client-switch { margin-left: auto; min-width: 0; }
/* Inherits the shared control height like every other select — no exception. */
.client-switch select {
    max-width: 46vw;
    font-weight: 600;
    border-radius: var(--r-md);
}

/* "View as": the superadmin wearing one of a customer's roles.
   Sticky directly under the topbar and in the warning colour, because every
   screen below it is a faithful copy of the customer's — this strip is the
   only thing saying so, and it may not scroll away.
   z-index sits under the topbar (40) and well under the sidebar drawer (60):
   it is a notice, not a layer that swallows the navigation. */
.view-as {
    position: sticky; top: var(--topbar-h); z-index: 35;
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 7px 12px;
    font-size: 13px; color: var(--warn-fg);
    background: var(--warn-bg);
    border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.view-as__mark { display: grid; place-items: center; flex: none; }
.view-as__mark svg { fill: currentColor; }
.view-as__text { margin-right: auto; min-width: 0; }
.view-as__text strong { font-weight: 700; }
.view-as__switch select { --control-h: var(--control-h-sm); font-size: 12px; font-weight: 600; }
.view-as__exit { flex: none; }

/* Pick a role and go, as one control: the select and the button are a pair,
   so they sit on one line and share an edge rather than drifting apart in a
   table cell. */
/* ── The offer editor ─────────────────────────────────────────────────────── */
/* A quote is read as "who and when", then "what it costs". So the header is
   one dense grid rather than a column of half-empty rows, the lines get the
   full width, and the running total follows you down the page instead of
   living at the bottom where you have to scroll to it. */
.offer-layout { display: grid; gap: var(--gap); align-items: start; }
/* A grid item is min-width:auto by default, so it grows to whatever is inside
   it — which meant the line table's 920px pushed the column that wide instead
   of scrolling inside it, and on a phone the whole editor was squashed into
   thumbnails. */
.offer-layout > * { min-width: 0; }
@media (min-width: 1180px) {
    .offer-layout { grid-template-columns: minmax(0, 1fr) 320px; }
    /* Sticky, because the total is the number you are watching while you add
       lines — reading it means scrolling away from the row you are typing. */
    .offer-side { position: sticky; top: calc(var(--topbar-h) + 12px); }
}
.offer-side { display: grid; gap: var(--gap); align-content: start; }
.offer-side .card { margin-top: 0 !important; }

/* Header fields: twelve columns, each asking for the width it needs.
   The field--sm/md/lg caps are dropped inside this grid on purpose — in a
   column that is already the right width, a max-width is just dead space to
   the right of the box, which is what this screen was full of. */
.offer-fields { display: grid; gap: 0 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.offer-fields > .field { max-width: none; }
@media (max-width: 719px) { .offer-fields { grid-template-columns: minmax(0, 1fr); } }
/* The whole set, not the handful this screen happens to use today: a span
   class that was never declared falls back to the default silently and the
   field just comes out narrow, which is exactly the dead space this grid
   exists to remove. */
@media (min-width: 900px) {
    .offer-fields { grid-template-columns: repeat(12, minmax(0, 1fr)); }
    .offer-fields > .field          { grid-column: span 3; }
    .offer-fields > .field--span-1  { grid-column: span 1; }
    .offer-fields > .field--span-2  { grid-column: span 2; }
    .offer-fields > .field--span-3  { grid-column: span 3; }
    .offer-fields > .field--span-4  { grid-column: span 4; }
    .offer-fields > .field--span-5  { grid-column: span 5; }
    .offer-fields > .field--span-6  { grid-column: span 6; }
    .offer-fields > .field--span-7  { grid-column: span 7; }
    .offer-fields > .field--span-8  { grid-column: span 8; }
    .offer-fields > .field--span-9  { grid-column: span 9; }
    .offer-fields > .field--span-10 { grid-column: span 10; }
    .offer-fields > .field--span-11 { grid-column: span 11; }
    .offer-fields > .field--span-12 { grid-column: span 12; }
}

/* Adding from the catalogue is a toolbar, not a card of its own: it is one
   action, and giving it a card put a heading and 60px of padding around a
   single row of controls. */
.offer-add {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px 10px;
    padding: 10px 12px;
    background: var(--surface-2); border-radius: var(--r-md);
    margin-bottom: 12px;
}
/* The picker and its fields. A grid inside the bar rather than the bar itself,
   so the blank-line button can sit beside it — they are one pair of actions
   and were reading as two, one crushed into a 64px column at the end of the
   row and one orphaned on a line of its own underneath. */
.offer-add__pick {
    display: grid; gap: 8px;
    grid-template-columns: minmax(0, 1fr);
    flex: 1 1 420px; min-width: 0;
}
@media (min-width: 900px) {
    .offer-add__pick { grid-template-columns: minmax(0, 1fr) 96px 170px auto; align-items: end; }
}
.offer-add .field { margin-bottom: 0; max-width: none; }
.offer-add__note { flex: 1 1 240px; margin: 0; align-self: center; }

/* Both add buttons read as a pair: the same height as the controls beside
   them, and a floor on the width so a four-letter label does not shrink to a
   chip against a 400px picker. */
.offer-add .btn { flex: none; min-width: 112px; }

@media (max-width: 899px) {
    /* Stacked, so the two read as the pair they are. Left to itself the
       primary filled the picker's column at 289px while the ghost stayed at
       its own 127px, which looked like two unrelated controls. */
    .offer-add > form { width: 100%; }
    .offer-add .btn { width: 100%; }
}

/* The totals panel. Figures right-aligned in the mono face so the columns of
   digits line up — the whole point of reading a total. */
.offer-total { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; }
.offer-total dt { font: 500 13px/1.4 var(--font); color: var(--ink-60); }
.offer-total dd { margin: 0; font: 500 14px/1.4 var(--mono); color: var(--ink); }
.offer-total--grand { margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.offer-total--grand dt { font-weight: 700; color: var(--ink); font-size: 14px; }
.offer-total--grand dd { font-weight: 700; font-size: 18px; }

/* Line table: the number columns are numbers, so they are right-aligned and
   sized to their digits rather than stretched across the cell. */
.offer-lines input[type="number"] { text-align: right; }
.offer-lines td { vertical-align: top; }
.offer-lines .offer-lines__sum { text-align: right; font-family: var(--mono); white-space: nowrap; }

@media (max-width: 719px) {
    /* .table--grid re-lays every row out as a table of its own on a phone.
       That is right for a two-column key/value grid, and wrong for nine
       numeric columns: each row then sized itself against the viewport
       independently of the header, and every input collapsed to about 20px.
       A quote's lines stay one table and scroll sideways inside their
       wrapper, which is what the wrapper is for. */
    .offer-lines .table--grid       { display: table; width: 100%; }
    .offer-lines .table--grid thead { display: table-header-group; }
    .offer-lines .table--grid tbody { display: table-row-group; }
    .offer-lines .table--grid tr    { display: table-row; width: auto; }
    .offer-lines .table--grid td    { display: table-cell; }
}

/* Menu order: drag to sort, toggles that save themselves.
   Everything here is keyed off .is-enhanced, which app.js adds — so with no JS
   the number fields and the Save button stay exactly where they were. */
.menu-order__grip { display: none; }
.menu-order__hint { display: none; }

form[data-menu-order].is-enhanced .menu-order__grip {
    display: inline-grid; place-items: center;
    width: 28px; height: 28px;
    color: var(--ink-30); cursor: grab;
}
form[data-menu-order].is-enhanced .menu-order__grip svg { fill: currentColor; }
form[data-menu-order].is-enhanced .menu-order__hint { display: inline; }

/* The order is the row's position now, so the number that used to carry it is
   noise — kept in the DOM because it is still what travels to the server. */
form[data-menu-order].is-enhanced input[data-sort],
form[data-menu-order].is-enhanced button[type="submit"] { display: none; }

form[data-menu-order].is-enhanced tbody tr { cursor: grab; }
form[data-menu-order].is-enhanced tbody tr.is-dragging { cursor: grabbing; }

.menu-order__status {
    font: 500 12px/1 var(--mono); color: var(--ink-42);
    align-self: center;
}
.menu-order__status.is-failed { color: var(--error-fg); }

/* The module-access matrix. Its Save sits below more checkboxes than fit on
   any screen, and every other toggle in the product saves itself — so this one
   stays in view and says out loud when there is something to save. */
.access-save {
    position: sticky; bottom: 0; z-index: 30;
    display: flex; align-items: center; justify-content: flex-end; gap: 12px;
    margin-top: var(--gap);
    padding: 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--canvas) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line-2);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.access-save__note { margin-right: auto; font-size: 13px; color: var(--warn-fg); }

/* The column header's "all" tick, under the role name it governs. */
.access-all {
    display: flex; align-items: center; gap: 5px;
    margin-top: 4px;
    font: 500 11px/1 var(--mono); color: var(--ink-42);
    text-transform: none; letter-spacing: 0;
    cursor: pointer;
}

@media (max-width: 719px) {
    /* The table stacks into rows on a phone, so a header tick has no column
       under it to govern — the per-row boxes are the whole control there. */
    .access-all { display: none; }
}

.view-as-pick { display: flex; align-items: center; gap: 6px; }
.view-as-pick select { --control-h: var(--control-h-sm); font-size: 12px; max-width: 40vw; }

@media (max-width: 719px) {
    /* Same reasoning as the topbar: the way out is the one control that must
       survive a narrow screen, so the sentence gives ground before it does. */
    .view-as { gap: 8px; padding-inline: 8px; font-size: 12px; }
    .view-as__text { flex: 1 1 100%; order: -1; margin-right: 0; }
}

.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }

/* Sidebar: off-canvas drawer on phones, permanent column on desktop. */
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: min(280px, 84vw);
    display: flex; flex-direction: column; gap: 4px;
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom));
    background: var(--sidebar-bg);
    /* A light panel on a light canvas needs an edge to read as a panel. */
    border-right: 1px solid var(--sidebar-border);
    transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.4, 0, .2, 1);
    /* The panel itself holds still. Only the list inside it scrolls, so the
       account and the way out stay on screen however long the menu gets —
       see .sidebar__nav and .sidebar__footer. */
    overflow: hidden;
}
/* min-height: 0 is what lets a flex child scroll at all: without it the track
   grows to fit its contents and the overflow never happens. */
.sidebar__nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.sidebar.is-open { transform: none; }

.sidebar-scrim {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(14, 14, 20, .5);
}

.nav { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 2px; }

.nav__heading {
    margin: 14px 8px 6px;
    font: 500 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
    color: var(--sidebar-fg-mute);
}

.nav__link {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 10px; border-radius: var(--r-md);
    font: 600 13px/1 var(--font); color: var(--sidebar-fg);
    transition: background .15s, color .15s;
}
.nav__link:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); }
.nav__link.is-active { background: var(--brand); color: #fff; }
.nav__link .icon { flex: none; fill: currentColor; }

/* A Font Awesome glyph stands in for a drawn icon and has to take up the
   same room, or the labels beside it stop lining up. */
.icon--fa {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; font-size: 16px; line-height: 1;
}

/* Sub-menus: <details> gives the open/closed state without any JavaScript. */
.nav__group summary { cursor: pointer; list-style: none; }
.nav__group summary::-webkit-details-marker { display: none; }
.nav__chevron { margin-left: auto; fill: currentColor; transition: transform .15s; }
.nav__group[open] > summary .nav__chevron { transform: rotate(90deg); }
.nav--sub { margin: 2px 0 4px; padding-left: 18px; gap: 1px; }
.nav--sub .nav__link { padding: 9px 10px; font-size: 12.5px; }

/* Pinned under the list rather than pushed down by it: flex: none so it never
   gives up height, and a rule along the top because the menu now scrolls
   underneath it instead of ending above it. */
.sidebar__footer {
    flex: none;
    display: flex; flex-direction: column; gap: 10px;
    margin-top: 4px; padding-top: 12px;
    border-top: 1px solid var(--sidebar-line);
}

.sidebar__user {
    display: flex; align-items: center; gap: 10px;
    padding: 10px; border-radius: var(--r-md);
    background: var(--sidebar-fill); color: var(--sidebar-fg-strong);
}
.sidebar__user-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sidebar__user-meta strong { font-size: 12px; font-weight: 600; }
.sidebar__user-meta small { font: 400 10px/1.3 var(--mono); color: var(--sidebar-fg-mute); overflow: hidden; text-overflow: ellipsis; }

.avatar {
    display: grid; place-items: center; flex: none;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--gradient-soft); color: #fff;
    font: 700 11px/1 var(--font);
}

.main {
    flex: 1; min-width: 0;
    padding: var(--pad);
    padding-bottom: calc(var(--bottom-nav-h) + var(--pad));
}

/* Content first on a phone.
   Nearly every index screen puts a card for adding one more thing above the
   list of the things there already are. On a wide screen that costs a glance;
   stacked on a phone it costs the whole first screen, and the list — the
   reason the page was opened — starts below the fold. The form keeps its
   place in the markup and simply sorts last here, so the desktop layout is
   untouched and nothing has to be moved between screens.

   The trade: on a phone the form is still first in tab order. It is a card
   somebody chooses to fill in, not a step on the way to the list, so being
   able to *see* the list without scrolling is worth more. */
@media (max-width: 719px) {
    .main { display: flex; flex-direction: column; }
    .main > .card--form { order: 1; }
}

/* ── Bottom navigation (primary on mobile) ───────────────────────────────── */
.bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    display: flex;
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
}
.bottom-nav__item {
    position: relative; flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 58px; padding: 6px 4px;
    font: 600 10px/1 var(--font); color: var(--ink-50);
}
.bottom-nav__item .icon { fill: currentColor; }
.bottom-nav__item.is-active { color: var(--brand); }
.bottom-nav__item .badge { top: 6px; right: 50%; margin-right: -22px; }

/* ── Cards, tables, lists ────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    padding: 16px;
    box-shadow: var(--shadow-card);
}
/* Cards stacked down the page space themselves. Side by side in a grid they
   must not: the rule fires on the second one and drops it below the first,
   which is what put the two halves of a report out of line. */
.card + .card { margin-top: var(--gap); }
.form-row > .card + .card { margin-top: 0; }
.card__title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card__title h2 { margin-right: auto; }
/* On a phone a badge beside the heading drops under it when the two do not
   fit, and breaks only when it is wider than the card on its own — the
   Russian "используется логотип рабочего пространства" on /company is. */
@media (max-width: 640px) {
    .card__title { flex-wrap: wrap; }
    .card__title .pill { white-space: normal; line-height: 1.35; }
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--gap); }
.stat {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
    padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.stat__label { font: 500 10px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-42); }
.stat__value { font: 800 clamp(24px, 5vw, 32px)/1 var(--font); letter-spacing: -.03em; }

.page-head {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    margin-bottom: var(--gap);
    /* Reserve the height of an action button whether or not the page has one,
       so the heading sits in the same place across a set of pages — Settings
       has tabs with and without an Add button, and the title must not hop. */
    min-height: var(--control-h);
}
/* The title pushes everything else to the right — unless a count follows it,
   in which case the count belongs to the title and the gap opens after them
   both. A row count stranded beside the search box reads as part of the
   search. */
.page-head h1 { margin-right: auto; }
.page-head h1:has(+ .meta) { margin-right: 0; }
.page-head h1 + .meta { margin-right: auto; }

/* Primary action for the page, kept on the same line as the title. */
.page-head__actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Everything in a page head sits on one line with the title.
   A tab strip here is a view switch, not the section nav it is elsewhere, so
   it loses the bottom margin that would otherwise push the row apart; and the
   search box stops claiming the full width of its form, which was enough on
   its own to bump the heading onto a line of its own. */
.page-head .tabs { margin-bottom: 0; flex: 0 0 auto; }
.page-head form { flex: 0 1 auto; min-width: 0; margin: 0; }
.page-head input[type="search"] { width: 24ch; min-width: 12ch; }

/* The bar on a phone.
   Six switch buttons, a burger, a brand and a bell do not fit across 375px at
   the 44px touch size — that is arithmetic, not a preference. The workspace
   name goes first, since the brand beside it already says whose workspace this
   is, and what is left buys the switches as much size as there is. They end up
   around 34px: above the 24px WCAG floor, under the 44px comfort target, and
   the only way to keep them in the bar on a phone at all. */
@media (max-width: 719px) {
    .topbar { gap: 6px; padding-inline: 8px; }
    .topbar__client, .client-switch { display: none; }
    /* The brand is the one thing here that may give ground, so it is the one
       thing allowed to shrink — the burger, the switches and the bell are all
       flex: none and keep the size a finger needs. It scales rather than being
       cropped: half a customer's wordmark reads as a broken image. */
    .topbar__brand { min-width: 0; }
    .topbar__brand--logo img { max-width: min(110px, 24vw); width: 100%; object-fit: contain; }
    .topbar__prefs { gap: 4px; }
}

/* The switcher's second copy, at the top of the menu drawer. A phone has no
   room for it in the bar (above), and without this it could not change
   company at all. From 720px up the bar shows its own, so this one hides. */
.client-switch--drawer { display: none; }
@media (max-width: 719px) {
    .client-switch--drawer {
        display: flex; flex-direction: column; gap: 6px; flex: none;
        margin: 0 0 6px; padding: 0 0 12px;
        border-bottom: 1px solid var(--sidebar-line);
    }
    .client-switch--drawer select { width: 100%; max-width: none; }
}
.client-switch__label {
    margin: 2px 8px 0;
    font: 500 10px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase;
    color: var(--sidebar-fg-mute);
}

/* Narrow screens still wrap — a single line is the intent, not a promise. */
@media (max-width: 719px) {
    .page-head h1 { flex: 1 0 100%; margin-right: 0; }
    .page-head input[type="search"] { width: 100%; }

    /* Except when a count follows the title. Given a row to itself the title
       pushes the count down onto the search line, where a bare number beside
       a search box reads as something to do with the search. The two share a
       line instead — the search row below already takes a full one. */
    .page-head h1:has(+ .meta) { flex: 0 1 auto; }
    .page-head h1 + .meta { margin-right: auto; }
}

/* Data tables collapse into stacked cards on phones. */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: left; padding: 10px 12px;
    font: 500 11px/1 var(--mono); letter-spacing: .07em; text-transform: uppercase;
    color: var(--ink-60); border-bottom: 1px solid var(--line);
}
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

@media (max-width: 719px) {
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table thead { display: none; }
    .table tr {
        background: var(--surface); border: 1px solid var(--line);
        border-radius: var(--r-lg); padding: 4px 12px; margin-bottom: 10px;
    }
    /* Each cell is one line of the record: its label in the left 40%, the
       value in the rest. The value is ordinary flowing text, not a row of flex
       items: laid side by side, an e-mail, a badge and a button ran off the
       card (/settings/employees), and a dotted key like
       platform.cross_tenant_query could not break at all (/admin).

       The label is floated into the cell's left padding, pulled back by a
       negative margin as wide as itself so it never shortens the value's
       lines, and flow-root keeps the cell as tall as a label that wraps. Its
       percentages resolve against the content box — 60% of the cell less
       12px — which is where 66.667% + 8px (= 40% of the cell) and
       -66.667% - 20px (= 40% + 12px) come from. */
    .table td {
        display: flow-root;
        padding: 9px 0 9px calc(40% + 12px);
        border-bottom: 1px solid var(--line);
        text-align: left;
    }
    .table:not(.table--list):not(.table--sheet) td { overflow-wrap: anywhere; }
    /* A button's words stay whole — the row of buttons wraps instead. A badge
       may break mid-word, but only as a last resort: a key such as
       construction.projects.view is wider than the column on its own. */
    .table:not(.table--list):not(.table--sheet) td .btn { overflow-wrap: normal; }
    /* --tight keeps icon buttons abreast on a desk; in a card's 60% column it
       also held worded ones ("Lõpeta aasta", "Majandusaasta aruanne") in a row
       wider than the card. Here they wrap like any other row of buttons. */
    .table:not(.table--list):not(.table--sheet) td .btn-row--tight { flex-wrap: wrap; }
    .table td::before {
        content: attr(data-label);
        float: left;
        width: calc(66.667% + 8px);
        margin-left: calc(-66.667% - 20px);
        overflow-wrap: normal; text-align: left;
        font: 500 11px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-60);
    }
    /* A badge wider than the value column may break rather than overhang it. */
    .table:not(.table--list):not(.table--sheet) td .pill { white-space: normal; }
    .table td:last-child { border-bottom: 0; }
    /* A cell with no label is a value, not a field: no empty 40% gutter. */
    .table td:not([data-label]) { padding-left: 0; }
    .table td:not([data-label])::before { display: none; }

    /* A report is read across, not down. A trial balance stacked into cards
       is four bare amounts per account, so a sheet keeps its grid, scrolls
       sideways inside its .table-wrap, and holds its first column still so
       the row is never anonymous. */
    .table--sheet { display: table; width: max-content; min-width: 100%; }
    .table--sheet thead { display: table-header-group; }
    .table--sheet tbody { display: table-row-group; }
    .table--sheet tfoot { display: table-footer-group; }
    .table--sheet tr {
        display: table-row; background: none; border: 0; border-radius: 0; padding: 0; margin: 0;
    }
    .table--sheet th,
    .table--sheet td {
        display: table-cell; width: auto; padding: 9px 10px;
        border-bottom: 1px solid var(--line);
    }
    /* Words may wrap; figures may not — a split amount is a wrong amount. */
    .table--sheet td { min-width: 7rem; max-width: 16rem; }
    .table--sheet .num, .table--sheet .mono, .table--sheet th { white-space: nowrap; }
    .table--sheet td.num, .table--sheet td.mono { min-width: 0; }
    .table--sheet td::before { display: none; }
    .table--sheet tr > :first-child {
        position: sticky; left: 0; z-index: 1; background: var(--surface);
        min-width: 0; max-width: 42vw;
        box-shadow: 1px 0 0 var(--line);
    }
}

/* ── A list on a phone ────────────────────────────────────────────────────
   The block above turns a table into a record: every field on its own line
   behind its own label. That is right for one thing being read field by
   field, and wrong for a register — fifty rows become fifty of those, and a
   list you cannot scan is a list you cannot use.

   .table--list keeps the rows rows: a name, a line of detail under it, and
   the figure and the controls held to the right. Say what each cell is with
   .cell-main / .cell-sub / .cell-value / .cell-actions; a cell given no part
   is left out on a phone rather than shrunk, because choosing the four
   things worth showing beats showing nine of them badly. Nothing here
   applies above the breakpoint — the desktop table is untouched.
   ------------------------------------------------------------------------ */
@media (max-width: 719px) {
    .table--list, .table--list tbody { display: block; }
    .table--list thead { display: none; }

    .table--list tr {
        display: grid;
        /* Both tracks may shrink. A plain `auto` trailing column sizes to its
           contents and will happily starve the name beside it down to a single
           clipped character. */
        grid-template-columns: minmax(0, 1fr) minmax(0, auto);
        align-items: center;
        column-gap: 12px; row-gap: 2px;
        padding: 10px 13px; margin-bottom: 8px;
        background: var(--surface);
        border: 1px solid var(--line);
        border-radius: var(--r-lg);
    }
    .table--list td { display: block; min-width: 0; padding: 0; border: 0; }
    .table--list td::before { content: none; }

    /* :where() so this weighs nothing — a row that needs to opt out (the
       ledger's month heading below) can do so without an !important. */
    .table--list td:where(:not(.cell-main):not(.cell-sub):not(.cell-value):not(.cell-actions):not(.cell-flag):not(.cell-tag):not(.cell-note)) {
        display: none;
    }

    /* A heading between the groups, not a record: it keeps its full width and
       drops the card the rows around it wear. */
    .table--list tr.ledger__month { display: block; padding: 0; margin: 16px 0 8px; background: none; border: 0; }
    .table--list tr.ledger__month td { display: block; border-radius: var(--r-md); }
    .table--list tr.ledger__month:first-child { margin-top: 0; }

    .table--list .cell-main  { grid-area: 1 / 1; font-weight: 600; }
    .table--list .cell-sub   { grid-area: 2 / 1; }
    .table--list .cell-value { grid-area: 1 / 2; text-align: right; white-space: nowrap; }

    /* A status glyph earns a column of its own down the left — it is what the
       eye runs along when scanning for the one row that needs attention. The
       column only exists on rows that have one, so a list without status is
       not indented past a gap holding nothing. */
    .table--list tr:has(.cell-flag) { grid-template-columns: auto minmax(0, 1fr) auto; }
    .table--list .cell-flag { grid-column: 1; grid-row: 1 / -1; align-self: center; }
    .table--list tr:has(.cell-flag) .cell-main,
    .table--list tr:has(.cell-flag) .cell-sub { grid-column: 2; }
    .table--list tr:has(.cell-flag) .cell-value,
    .table--list tr:has(.cell-flag) .cell-actions { grid-column: 3; }

    /* With a figure above it the row is two lines and the controls take the
       lower one; with nothing above, they centre against the whole row. */
    .table--list .cell-actions { grid-column: 2; grid-row: 1 / -1; align-self: center; justify-self: end; }
    .table--list tr:has(.cell-value) .cell-actions { grid-row: 2; }

    /* Only icon buttons are small enough to ride in the trailing column. A
       group of worded ones — Preview, Download, Delete — is wider than the
       name it belongs to, so it takes a row of its own underneath instead of
       squeezing the record it acts on down to nothing.

       Rows 3 and 4 are named rather than left to auto-placement: the cells
       above sit on explicitly numbered rows, which auto-placement does not
       count, and an `auto` here lands back on top of the detail line. */
    .table--list tr .cell-actions:not(:has(.btn--icon)) {
        grid-column: 1 / -1; grid-row: 4;
        justify-self: start; align-self: start;
        margin-top: 6px;
    }
    .table--list tr .cell-actions:not(:has(.btn--icon)) .btn-row { flex-wrap: wrap; }

    /* A control parked in the right-hand column takes the width it needs and
       no more: a role picker is still a picker, but it must not squeeze the
       name it belongs to off the screen. */
    .table--list .cell-value select,
    .table--list .cell-value .btn,
    .table--list .cell-value input { max-width: 40vw; }

    /* Unless the value *is* the control. A full-height picker in the narrow
       column leaves the row lopsided — two short lines on one side, ninety
       pixels of select on the other — so it drops to a line of its own under
       the record it belongs to. */
    .table--list .cell-value:has(select),
    .table--list .cell-value:has(input:not([type="hidden"])) {
        grid-column: 1 / -1;
        grid-row: 3;
        margin-top: 5px;
        text-align: left; white-space: normal;
    }
    .table--list .cell-value:has(select) select { width: 100%; max-width: none; }

    /* Long values — an address, an e-mail — end in an ellipsis rather than
       being cut mid-character by the edge of the screen. */
    .table--list .cell-sub,
    .table--list .cell-main .meta {
        display: block;
        overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
        font-weight: 400;
    }

    /* Short facts — a type, a language, a status — as a line of badges under
       the name, where a labelled line each would make the card three times as
       tall. A row with them is laid out as wrapping lines instead of the
       two-column grid: the name, the badges side by side, then the controls. */
    .table--list tr:has(.cell-tag, .cell-note) {
        display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    }
    .table--list tr:has(.cell-tag, .cell-note) > .cell-main,
    .table--list tr:has(.cell-tag, .cell-note) > .cell-sub,
    .table--list tr:has(.cell-tag, .cell-note) > .cell-value,
    .table--list tr:has(.cell-tag, .cell-note) > .cell-note,
    .table--list tr:has(.cell-tag, .cell-note) > .cell-actions { flex: 1 0 100%; }
    /* A fact that needs its label to mean anything — "Mitte kunagi" alone is
       not an answer — gets a muted line of its own after the badges, label
       first. The controls always come last, whatever the column order. */
    .table--list .cell-note { font-size: 12px; color: var(--ink-60); }
    .table--list .cell-note::before {
        content: attr(data-label) " · ";
        /* Not the floated field label of a stacked record — inline, in the
           note's own type. */
        float: none; display: inline; width: auto; margin: 0;
        font: inherit; letter-spacing: normal; text-transform: none; color: inherit;
    }
    .table--list .cell-note .meta { font: inherit; color: inherit; }
    .table--list tr:has(.cell-tag, .cell-note) > .cell-note { order: 1; }
    .table--list tr:has(.cell-tag, .cell-note) > .cell-actions { order: 2; }
    /* The row's buttons share one line, each as wide as its label wants. */
    .table--list tr:has(.cell-tag, .cell-note) .cell-actions .btn-row:not(:has(.view-as-pick)) { flex-wrap: nowrap; width: 100%; }
    .table--list tr:has(.cell-tag, .cell-note) .cell-actions .btn-row:not(:has(.view-as-pick)) > * { flex: 1 1 auto; min-width: 0; }
    /* Only a button inside a form stretches to it; a bare link button given
       width: 100% would claim the whole row as its flex basis. */
    .table--list tr:has(.cell-tag, .cell-note) .cell-actions .btn-row:not(:has(.view-as-pick)) > form .btn { width: 100%; }
    .table--list tr:has(.cell-tag, .cell-note) > .cell-main { margin-bottom: 2px; }
    .table--list .cell-tag { flex: none; width: auto; }
    /* A fact with nothing to show (no sign-in method yet) leaves no gap. */
    .table--list .cell-tag:not(:has(*)) { display: none; }
    /* A bare code (the language) gets the badge shape too, so the line reads
       as one set rather than two pills and a stray word. */
    .table--list .cell-tag > .meta {
        display: inline-flex; align-items: center;
        padding: 4px 9px; border-radius: var(--r-pill);
        background: var(--surface-2); font: 600 11px/1 var(--font);
    }

    /* The client list's controls: open the client, or view it as one of its
       roles. Both buttons share a row, each column as wide as its label wants
       (a 50/50 split broke "Ava kliendi vaade" in two while its neighbour had
       room to spare); the role picker the second one reads takes the full row
       above them — squeezed in beside them it would be 35px wide on a phone.
       The form around the picker steps aside (display: contents) so its
       pieces can sit in the same grid as the other button. */
    .table--list .cell-actions .btn-row:has(.view-as-pick) {
        display: grid; grid-template-columns: auto auto; gap: 8px; width: 100%;
    }
    .table--list .cell-actions .btn-row:has(.view-as-pick) .btn { width: 100%; }
    .table--list .cell-actions .view-as-pick { display: contents; }
    /* select2 hides the <select> and draws its own box beside it; both move. */
    .table--list .cell-actions .view-as-pick select,
    .table--list .cell-actions .view-as-pick .select2-container { order: -1; grid-column: 1 / -1; max-width: none; }
}

/* Under 360px the value column of a stacked record is ~130px — narrower than
   one long word ("Суперадминистратор", "Заблокировать"). There the label goes
   above its value and the value has the card's whole width. */
@media (max-width: 359px) {
    .table:not(.table--list):not(.table--sheet) td { padding-left: 0; }
    .table:not(.table--list):not(.table--sheet) td[data-label]::before {
        float: none; display: block; width: auto; margin: 0 0 3px;
    }
}

.table-wrap { overflow-x: auto; }

.empty {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 40px 20px; text-align: center; color: var(--ink-50);
}
.empty img { width: 110px; height: auto; animation: ss-float 5s ease-in-out infinite; }

.pill {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 9px; border-radius: var(--r-pill);
    font: 600 11px/1 var(--font);
    /* A badge is a label, not a paragraph: broken across two lines it stops
       reading as one and the pill shape falls apart. */
    white-space: nowrap;
    background: rgba(91, 75, 240, .1); color: var(--brand);
}
.pill--ok    { background: var(--ok-bg);    color: var(--ok-fg); }
.pill--warn  { background: var(--warn-bg);  color: var(--warn-fg); }
.pill--muted { background: var(--surface-2); color: var(--ink-60); }
/* The exception to the rule above: an exam answer is a sentence often enough
   that holding it on one line pushes the rest of the table off the screen. */
.pill--text  { white-space: normal; text-align: left; line-height: 1.35; max-width: 52ch; }

.meta { font: 500 12px/1.4 var(--mono); color: var(--ink-60); }

/* For strings that are read a character at a time — an IBAN, a BIC, a
   registry code. Monospace so the digit groups line up down a column and a
   transposed pair is visible; .meta already sets its own size, this only
   swaps the family. */
.mono { font-family: var(--mono); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.field__label { font: 600 11.5px/1 var(--font); color: var(--ink-60); }
.field__hint  { font: 400 11px/1.4 var(--font); color: var(--ink-42); }

.field__input, .field select, select, textarea, input[type="text"], input[type="email"],
input[type="password"], input[type="search"], input[type="number"], input[type="tel"],
input[type="date"], input[type="file"] {
    width: 100%;
    /* Height comes from the shared token, not from padding, so inputs, selects
       and buttons in the same row are always exactly the same height. */
    height: var(--control-h);
    padding: 0 var(--control-pad-x);
    /* 16px keeps iOS Safari from zooming the viewport on focus. */
    font: 500 16px/1.2 var(--font);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-lg);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
    appearance: none;
}

/* Native select needs its own arrow once appearance is stripped. */
.field select, select {
    padding-right: calc(var(--control-pad-x) + 18px);
    /* Arrow drawn as a mask so it inherits the theme's text colour;
       a data: URI cannot resolve currentColor. */
    background-image: none;
}
.field, .client-switch, .form-row label, .page-head form { position: relative; }
select { background-image: none; }
select::-ms-expand { display: none; }
/* Chevron via a mask on a wrapper-free pseudo is impossible on <select>,
   so the arrow is painted with a CSS gradient triangle instead. */
select {
    background-image:
        linear-gradient(45deg, transparent 50%, currentColor 50%),
        linear-gradient(135deg, currentColor 50%, transparent 50%);
    background-position:
        right calc(var(--control-pad-x) + 5px) center,
        right var(--control-pad-x) center;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}

/* File inputs render a native button; centre it in the shared height. */
input[type="file"] { padding: 0 var(--control-pad-x); line-height: calc(var(--control-h) - 2px); }
input[type="file"]::file-selector-button {
    height: var(--control-h-sm);
    margin-right: 10px;
    padding: 0 12px;
    font: 600 12.5px/1 var(--font);
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    cursor: pointer;
}

/* Textareas are the one control that must grow. */
textarea { height: auto; min-height: calc(var(--control-h) * 2); padding: 12px var(--control-pad-x); }

@media (min-width: 720px) {
    .field__input, .field select, select, textarea, input[type="text"], input[type="email"],
    input[type="password"], input[type="search"], input[type="number"], input[type="tel"],
    input[type="date"] { font-size: 14px; }
}
.field__input:focus, select:focus, textarea:focus, input:focus {
    border-color: var(--brand); box-shadow: var(--ring);
}
.field--error .field__input { border-color: var(--error); }
.field__error { font: 500 11.5px/1.4 var(--font); color: var(--error); }


/* One column on a phone, and minmax(0, …) rather than 1fr: a bare 1fr grows
   to its widest field, and a select2 holding a long account name ("1260 ·
   Ettemakstud tulevaste perioodide kulud") pushed /settings/accounting past
   a 320px screen. The selection is ellipsised inside the field instead. */
.form-row { display: grid; gap: 0 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .form-row--2 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 720px) { .form-row--3 { grid-template-columns: 2fr 1fr 1fr; } }
@media (min-width: 720px) { .form-row--4 { grid-template-columns: 1fr 1fr 1fr 1fr; } }
/* Equal columns, for a set of boxes that are the same thing in each language —
   no one of the three is the main one, so none of them is wider. */
@media (min-width: 640px) { .form-row--langs { grid-template-columns: repeat(3, 1fr); } }

/* Controls sized to what they hold.
   Everything is width:100% by default, which is right in a narrow column and
   silly for a registry code or a locale — a field five characters wide should
   not be as wide as an address. Measured in ch so the width tracks the font
   rather than a guess in pixels, and applied as a max so a narrow column still
   shrinks them. */
.field--xs { max-width: 11ch; }   /* port, sort order, room count */
.field--sm { max-width: 20ch; }   /* registry code, phone, locale, a date */
.field--md { max-width: 32ch; }   /* a person's or company's name */
.field--lg { max-width: 46ch; }   /* e-mail, address */

/* A control inside a table row belongs to its cell, not to the column width:
   a role picker stretched across the column reads as an input box the row is
   trapped in. */
.table select, .table input[type="search"] { width: auto; min-width: 14ch; }

/* Two cards side by side on a wide screen, stacked on a narrow one. Used
   where a pair of blocks are peers — logo and mascot, say. */
/* The phone column is minmax(0, 1fr) like .form-row's: the implicit auto
   column grew to its widest content and pushed /company (ru) off a phone. */
.grid-2 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.grid-2 > .card { margin-top: 0 !important; }

/* Three abreast where there are three of a kind — the brand images on the
   company page. Two columns first, because three cards of 300px do not fit a
   tablet, and one on a phone. */
.grid-3 { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px)  { .grid-3 { grid-template-columns: 1fr 1fr; align-items: start; } }
@media (min-width: 1080px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }
.grid-3 > .card { margin-top: 0 !important; }

/* Forms are dense by default.
   Every input, select and button takes its height from --control-h, so
   redefining that token on the form is the whole change — no control has to
   know it is inside one. */
form {
    --control-h: var(--control-h-sm);
}
form .field { gap: 4px; margin-bottom: 8px; }
form .field__label { font-size: 11px; }
form .field__input, form select { font-size: 13px; }
form .form-row { gap: 0 10px; }
form h3 { margin: 14px 0 6px; font-size: 12px; }
form .check { margin: 2px 0 10px; }

/* Touch is the exception. 36px is comfortable with a mouse and a miss with a
   fingertip, so on a touch screen the controls go back above the 44px target
   — density is worth less than being able to hit the thing.

   This used to reach only inside a form, which left out most of what a thumb
   actually goes for: the row of edit and delete buttons on every list (those
   are .btn--sm, 36px), the bar's burger and bell, the drawer's links, and the
   language and theme switches in its footer. Everything grows by padding, so
   no ink changes size — only the area that answers to a finger. */
@media (pointer: coarse) {
    :root { --control-h-sm: 44px; }

    form { --control-h: 46px; }
    form .field { gap: 6px; margin-bottom: 12px; }
    form .field__input, form select { font-size: 15px; }

    .topbar__burger, .topbar__bell { width: 44px; height: 44px; }
    .topbar__brand { min-height: 44px; }
    .nav__link, .nav--sub .nav__link { min-height: 44px; }
    .btn--icon { min-width: 44px; }

    /* The name in a list row is the way into the record, and as a line of text
       it is fifteen pixels tall. It gets the whole row as its target instead —
       an overlay behind the row's own controls, which stay above it and keep
       their own taps. */
    .table--list tr { position: relative; }
    .table--list .cell-main > a::after { content: ""; position: absolute; inset: 0; }
    .table--list .cell-flag,
    .table--list .cell-value,
    .table--list .cell-actions { position: relative; z-index: 1; }

    /* The cells of the invoice line grid are the deliberate exception: it is a
       spreadsheet, and a 44px row would put a quarter of the table on screen.
       It keeps the height it has — see .table--grid, which never collapses to
       cards for the same reason. */
    .table--grid .btn--sm { height: var(--control-h-sm-grid, 36px); }
}

/* Signing in and the public pages stay generous: each is a single short task
   on an otherwise empty page, and shrinking it buys nothing. .auth is the
   sign-in wrapper — the auth layout carries no body class of its own. */
.auth form, .bare form, .public form { --control-h: 46px; }
.auth form .field, .bare form .field, .public form .field { gap: 7px; margin-bottom: 12px; }
.auth form .field__input, .bare form .field__input, .public form .field__input { font-size: 15px; }
.auth form .field__label, .bare form .field__label, .public form .field__label { font-size: 11.5px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    /* Same token as the inputs — that is what keeps a row of controls aligned. */
    height: var(--control-h);
    padding: 0 18px;
    font: 700 14px/1 var(--font);
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-lg);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s, transform .08s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: rgba(91, 75, 240, .45); color: var(--brand); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }

.btn--primary {
    color: #fff; border: 0;
    background: var(--gradient);
    box-shadow: var(--shadow-pop);
}
.btn--primary:hover { color: #fff; filter: brightness(1.06); }

.btn--ghost { background: transparent; border-color: var(--sidebar-border); color: var(--sidebar-fg); }
.btn--ghost:hover { background: var(--sidebar-hover); color: var(--sidebar-fg-strong); border-color: var(--line-strong); }

.btn--danger { color: var(--error); border-color: rgba(229, 72, 77, .35); }
.btn--danger:hover { background: var(--error-bg); color: var(--error); border-color: var(--error); }

.btn--sm { height: var(--control-h-sm); padding: 0 13px; font-size: 12.5px; border-radius: var(--r-md); }

/* Square, label-less button — the accessible name lives in aria-label. */
.btn--icon { width: var(--control-h); padding: 0; gap: 0; }
.btn--sm.btn--icon { width: var(--control-h-sm); }
.btn--block { width: 100%; }

.btn--google { font-weight: 600; }

.btn__spinner {
    width: 15px; height: 15px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
    animation: ss-spin .7s linear infinite;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 9px; }
/* Row actions: icon buttons that stay side by side rather than wrapping into
   a column when the cell is narrow. */
.btn-row--tight { flex-wrap: nowrap; gap: 6px; align-items: center; }
.btn--icon .icon { width: 16px; height: 16px; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert {
    margin-bottom: var(--gap);
    padding: 12px 14px;
    border-radius: var(--r-lg);
    font-size: 13px; font-weight: 500;
    border: 1px solid transparent;
    animation: ss-rise .3s ease-out;
}
.alert ul { margin: 0; padding-left: 18px; }
.alert--ok    { background: var(--ok-bg);    border-color: color-mix(in srgb, var(--ok) 30%, transparent);    color: var(--ok-fg); }
.alert--error { background: var(--error-bg); border-color: color-mix(in srgb, var(--error) 30%, transparent); color: var(--error-fg); }
.alert--info  { background: var(--info-bg);  border-color: color-mix(in srgb, var(--brand) 28%, transparent); color: var(--info-fg); }


/* ── Login / bare pages ──────────────────────────────────────────────────── */
.bare {
    min-height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 18px;
    padding: clamp(16px, 5vw, 44px);
    background: radial-gradient(120% 90% at 50% 0%, #ffffff 0%, #f2f1fd 55%, #eaf4fe 100%);
}
.bare__main { width: 100%; max-width: 420px; }
.bare__footer { display: flex; justify-content: center; }

.card--auth { padding: clamp(20px, 5vw, 32px); border-radius: 20px; box-shadow: var(--shadow-lift); }
.card__brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 22px; text-align: center; }
.card__brand img { width: 56px; height: 56px; object-fit: contain; }
.card__brand h1 { font-size: clamp(22px, 5vw, 28px); }

.divider { display: flex; align-items: center; gap: 12px; margin: 16px 0; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }
.divider span { font: 500 10.5px/1 var(--mono); color: var(--ink-42); text-transform: uppercase; }

/* ── Error page ──────────────────────────────────────────────────────────── */
.error-page { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.error-page__code { font: 800 clamp(52px, 14vw, 84px)/1 var(--font); letter-spacing: -.04em; background: var(--gradient); -webkit-background-clip: text; background-clip: text; color: transparent; }
/* height:auto lets the browser derive the box from the width/height attributes,
   which is what stops lazy images from shifting the layout when they land. */
.error-page img { width: 120px; height: auto; animation: ss-float 5s ease-in-out infinite; }
.error-page pre { max-width: 100%; overflow: auto; text-align: left; font: 400 11px/1.5 var(--mono); background: var(--surface-2); padding: 12px; border-radius: var(--r-md); }

/* ==========================================================================
   Public landing page
   ========================================================================== */
.public { background: var(--canvas); }

.gradient-text {
    background: var(--gradient);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}

.eyebrow {
    display: flex; align-items: center; gap: 8px; margin: 0;
    font: 500 10.5px/1 var(--mono); letter-spacing: .09em; text-transform: uppercase;
    color: var(--brand-purple);
}
.eyebrow__dot {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--brand-purple); animation: ss-pulse 1.8s ease-in-out infinite;
}

.btn--lg { height: var(--control-h-lg); padding: 0 24px; font-size: 14.5px; border-radius: 13px; }

.lp-nav {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 10px;
    padding: 12px clamp(16px, 4vw, 64px);
    padding-top: calc(12px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--canvas) 88%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
}
.lp-nav__logo { margin-right: auto; display: flex; min-width: 0; }
.lp-nav__logo img { height: clamp(20px, 2.6vw, 30px); width: auto; }

/* The language switch stays visible on phones — picking a language is the
   first thing an et/ru/en audience needs, so it must not be buried. */
@media (max-width: 560px) {
    .lp-nav { gap: 8px; padding-inline: 14px; }
    .lp-nav .btn--sm { padding: 0 12px; }
}

.lp-hero {
    display: grid; grid-template-columns: 1fr;
    gap: clamp(40px, 5vw, 56px);
    align-items: center;
    padding: clamp(34px, 5vw, 84px) clamp(18px, 4vw, 64px) clamp(30px, 4vw, 62px);
}
@media (min-width: 960px) { .lp-hero { grid-template-columns: 1.05fr .95fr; } }

.lp-hero__copy { display: flex; flex-direction: column; gap: clamp(16px, 1.8vw, 22px); animation: ss-rise .5s ease-out; }
.lp-hero__copy h1 { font-size: clamp(33px, 6vw, 62px); line-height: 1.03; letter-spacing: -.035em; text-wrap: pretty; }
.lp-hero__sub { max-width: 34em; font-size: clamp(15px, 1.6vw, 19px); line-height: 1.55; color: var(--ink-60); text-wrap: pretty; }
.lp-hero__trust {
    display: flex; flex-wrap: wrap; gap: 6px 16px;
    font-size: 12.5px; font-weight: 500; color: var(--ink-50);
}

.lp-hero__visual { position: relative; animation: ss-rise .7s ease-out; }
.lp-hero__glow {
    position: absolute; inset: -8% -6%;
    border-radius: 40px; filter: blur(6px);
    background:
        radial-gradient(60% 60% at 70% 20%, rgba(34, 198, 245, .22), transparent 70%),
        radial-gradient(55% 55% at 20% 80%, rgba(155, 31, 232, .18), transparent 70%);
}
/* On a phone the hero's side padding (18px) is smaller than 6% of the card,
   so the glow poked past the viewport and made the page scroll sideways. */
@media (max-width: 640px) { .lp-hero__glow { inset: -8% -4%; } }

.lp-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: clamp(16px, 2vw, 24px);
    box-shadow: 0 34px 70px -30px rgba(20, 20, 60, .32);
}
.lp-card__head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; font-weight: 700; font-size: 13.5px; }
.lp-live {
    display: flex; align-items: center; gap: 5px; margin-left: auto;
    font: 500 10px/1 var(--mono); color: #10804d;
    background: rgba(34, 198, 120, .12); padding: 5px 8px; border-radius: 6px;
}
.lp-live__dot { width: 5px; height: 5px; border-radius: 50%; background: #16a35f; animation: ss-pulse 1.6s ease-in-out infinite; }

.lp-card__body { display: flex; align-items: center; gap: clamp(14px, 2vw, 22px); flex-wrap: wrap; }

.lp-dial {
    position: relative; flex: none;
    width: clamp(94px, 16vw, 120px); aspect-ratio: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.lp-dial::before {
    content: ''; position: absolute; inset: 0; border-radius: 50%;
    background: conic-gradient(var(--brand-purple) 0deg, var(--brand) 150deg, var(--brand-cyan) 313deg, var(--line) 313deg);
    mask: radial-gradient(farthest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 11px), #000 calc(100% - 10px));
}
.lp-dial__value { font: 800 clamp(22px, 3vw, 30px)/1 var(--font); letter-spacing: -.03em; }
.lp-dial__label { font: 500 9px/1 var(--mono); color: var(--ink-42); }

.lp-rows { flex: 1 1 150px; margin: 0; display: flex; flex-direction: column; gap: 9px; }
.lp-rows > div { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; color: var(--ink-60); }
.lp-rows > div + div { border-top: 1px solid var(--line); padding-top: 9px; }
.lp-rows dt { margin: 0; }
.lp-rows dd { margin: 0; color: var(--ink); font-weight: 700; }

.lp-bars { display: flex; align-items: flex-end; gap: 5px; height: 58px; margin-top: 20px; }
.lp-bars span {
    flex: 1; border-radius: 5px 5px 2px 2px;
    background: linear-gradient(180deg, var(--brand-cyan), var(--brand));
    transform-origin: bottom;
    animation: ss-grow .7s cubic-bezier(.2, .8, .2, 1) backwards;
}
.lp-bars span:nth-last-child(-n+2) { background: linear-gradient(180deg, var(--brand-cyan), var(--brand-purple)); }
@keyframes ss-grow { from { transform: scaleY(.05); } to { transform: scaleY(1); } }

.lp-chip {
    position: absolute; z-index: 2;
    display: flex; align-items: center; gap: 7px;
    padding: 8px 12px; border-radius: 11px;
    font: 600 11.5px/1 var(--font);
    box-shadow: 0 14px 30px -14px rgba(20, 20, 60, .3);
    animation: ss-float 4s ease-in-out infinite;
}
.lp-chip--light { top: -14px; right: -8px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
/* Always-dark chip: --ink is the *text* colour and inverts with the theme, so
   this must use the token that stays dark in both. */
.lp-chip--dark  { bottom: 22px; left: -10px; background: var(--night); color: var(--on-night); animation-duration: 4.6s; animation-delay: .6s; }
.lp-chip__dot { width: 6px; height: 6px; border-radius: 50%; background: #16a35f; }

.lp-mascot {
    position: absolute; right: -14px; bottom: -38px; z-index: 2;
    width: clamp(74px, 12vw, 116px); height: auto;
    animation: ss-float 5.2s .3s ease-in-out infinite;
}
@media (max-width: 640px) { .lp-chip, .lp-mascot { display: none; } }

.lp-section { padding: clamp(30px, 4vw, 58px) clamp(18px, 4vw, 64px); }

/* Rendering-level lazy loading: the browser skips layout and paint for these
   until they approach the viewport. contain-intrinsic-size reserves a plausible
   height first, so the scrollbar does not jump as they come into view.
   The #pillars section is deliberately excluded — it is an anchor target. */
.lp-section--deferred,
.lp-stats,
.lp-cta,
.lp-footer {
    content-visibility: auto;
    contain-intrinsic-size: auto 600px;
}
.lp-section__head {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px 20px;
    margin-bottom: clamp(22px, 2.6vw, 36px);
}
.lp-section__head h2 { flex: 1 1 320px; font-size: clamp(25px, 3.6vw, 42px); letter-spacing: -.03em; text-wrap: pretty; }
.lp-section__head--stack { flex-direction: column; align-items: flex-start; gap: 10px; }

.lp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: clamp(12px, 1.4vw, 18px); }
.lp-grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-top: clamp(18px, 2.2vw, 30px); }

.lp-tile {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
    padding: clamp(18px, 2vw, 26px);
    display: flex; flex-direction: column; gap: 10px;
    transition: border-color .18s, box-shadow .18s, transform .18s;
}
.lp-tile:hover { border-color: rgba(91, 75, 240, .35); box-shadow: 0 18px 40px -22px rgba(20, 20, 60, .28); transform: translateY(-2px); }
.lp-tile h3 { font-size: 16.5px; line-height: 1.25; }
.lp-tile p { font-size: 13.5px; line-height: 1.55; color: var(--ink-60); }
.lp-tile__num {
    display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-md);
    background: linear-gradient(135deg, rgba(155, 31, 232, .12), rgba(34, 198, 245, .16));
    font: 500 11px/1 var(--mono); color: var(--brand);
}
.lp-tile__num--wide { width: auto; padding: 0 10px; height: 26px; justify-self: start; letter-spacing: .08em; }

.lp-quote { gap: 16px; }
.lp-quote p { font: 600 clamp(16px, 1.9vw, 22px)/1.4 var(--font); color: var(--ink); letter-spacing: -.015em; text-wrap: pretty; }
.lp-quote footer { display: flex; align-items: center; gap: 11px; margin-top: auto; }
.lp-quote footer > span:last-child { display: flex; flex-direction: column; gap: 2px; }
.lp-quote strong { font-size: 12.5px; }
.lp-quote small { font-size: 11.5px; color: var(--ink-50); }
.lp-quote .avatar { width: 36px; height: 36px; }

.lp-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.lp-steps li { display: flex; align-items: center; gap: 11px; font-size: 13.5px; font-weight: 500; color: var(--ink-60); }
.lp-steps li > span {
    flex: none; width: 22px; height: 22px; border-radius: 7px; text-align: center;
    font: 600 11px/22px var(--mono);
    background: var(--line); color: var(--ink-50);
}
.lp-steps li.is-done { color: var(--ink); }
.lp-steps li.is-done > span { background: rgba(34, 198, 120, .14); color: #10804d; }

.lp-stats {
    margin: 0 clamp(18px, 4vw, 64px);
    border-radius: 22px;
    background: linear-gradient(118deg, #2A0B52, #3B2A9E 45%, #0E5C93);
    padding: clamp(24px, 3.2vw, 44px);
    display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: clamp(18px, 2.4vw, 32px);
}
.lp-stats > div { display: flex; flex-direction: column; gap: 5px; }
.lp-stats__value { font: 800 clamp(26px, 3.8vw, 44px)/1 var(--font); color: #fff; letter-spacing: -.035em; }
.lp-stats__label { font-size: 12px; font-weight: 500; line-height: 1.3; color: rgba(255, 255, 255, .6); }

.lp-marquee {
    overflow: hidden;
    padding: 8px 0;
    /* Fade both edges so items enter and leave rather than popping. */
    mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
    -webkit-mask: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}

.lp-marquee__track {
    display: flex;
    align-items: center;
    gap: clamp(28px, 4vw, 56px);
    width: max-content;
}
/* app.js sets --marquee-duration from the measured width, so the row always
   travels at the same speed no matter how many logos there are. */
.lp-marquee.is-rolling .lp-marquee__track {
    animation: ss-marquee var(--marquee-duration, 26s) linear infinite;
}
.lp-marquee.is-rolling:hover .lp-marquee__track,
.lp-marquee.is-rolling:focus-within .lp-marquee__track { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
    .lp-marquee.is-rolling .lp-marquee__track { animation: none; }
    .lp-marquee__track { flex-wrap: wrap; width: auto; justify-content: center; }
}

@keyframes ss-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

.lp-mark {
    display: inline-flex; align-items: center;
    font-size: clamp(15px, 2vw, 21px);
    color: var(--ink-30);
    white-space: nowrap;
    transition: color .2s, opacity .2s, filter .2s;
}
/* Links must be reachable and obviously clickable. */
a.lp-mark:hover, a.lp-mark:focus-visible { color: var(--brand); }
a.lp-mark:focus-visible { outline: 2px solid var(--brand); outline-offset: 4px; border-radius: var(--r-sm); }

.lp-mark--0 { font-weight: 700; letter-spacing: .16em; }
.lp-mark--1 { font-family: var(--mono); font-weight: 400; }
.lp-mark--2 { font-weight: 800; letter-spacing: -.03em; }
.lp-mark--3 { font-weight: 600; letter-spacing: .3em; }
.lp-mark--4 { font-weight: 700; letter-spacing: -.02em; }
.lp-mark--5 { font-family: var(--mono); font-weight: 500; letter-spacing: .06em; }

.lp-cta {
    margin: 0 clamp(18px, 4vw, 64px) clamp(24px, 3vw, 44px);
    border-radius: 22px; border: 1px solid var(--line-2);
    background: linear-gradient(135deg, #ffffff, #f0eefe 55%, #e8f5fe);
    padding: clamp(24px, 3.2vw, 48px);
    display: flex; flex-wrap: wrap; align-items: center; gap: clamp(18px, 2.4vw, 34px);
}
.lp-cta > div:first-child { flex: 1 1 300px; display: flex; flex-direction: column; gap: 10px; }
.lp-cta h2 { font-size: clamp(22px, 3vw, 36px); letter-spacing: -.03em; text-wrap: pretty; }
.lp-cta p { font-size: 14px; line-height: 1.55; color: var(--ink-60); }
.lp-cta__form { flex: 1 1 280px; display: flex; flex-wrap: wrap; gap: 9px; }
.lp-cta__form input { flex: 1 1 170px; min-width: 0; }
.lp-cta__form button { white-space: nowrap; }

.lp-footer { background: var(--night); padding: clamp(28px, 3.4vw, 52px) clamp(18px, 4vw, 64px); }
.lp-footer__cols {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: clamp(20px, 2.4vw, 36px);
    padding-bottom: clamp(20px, 2.4vw, 32px);
    border-bottom: 1px solid rgba(255, 255, 255, .09);
}
.lp-footer__cols > div { display: flex; flex-direction: column; gap: 9px; }
.lp-footer__brand { display: flex; align-items: center; gap: 9px; font: 700 15px/1 var(--font); color: #fff; letter-spacing: -.02em; }
.lp-footer p { max-width: 22em; font-size: 12.5px; line-height: 1.6; color: rgba(255, 255, 255, .45); }
.lp-footer__head { font: 500 10px/1 var(--mono); letter-spacing: .09em; color: rgba(255, 255, 255, .35); }
.lp-footer a { font-size: 13px; font-weight: 500; color: rgba(255, 255, 255, .72); }
.lp-footer a:hover { color: #fff; }
.lp-footer__legal {
    display: flex; flex-wrap: wrap; gap: 10px 20px; padding-top: 18px;
    font-size: 11.5px; color: rgba(255, 255, 255, .35);
}
.lp-footer__slogan { margin-left: auto; }

/* ==========================================================================
   Split login
   ========================================================================== */
.auth {
    display: grid; min-height: 100vh; background: var(--canvas);
    /* Stacked on phones: the panel hugs its content, the form takes the rest.
       Without the explicit rows, grid stretches both to half the viewport. */
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
}
@media (min-width: 900px) { .auth { grid-template-columns: 1.05fr 1fr; grid-template-rows: 1fr; } }

.auth__panel {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; gap: 18px;
    padding: clamp(22px, 3vw, 44px);
    padding-top: calc(clamp(22px, 3vw, 44px) + env(safe-area-inset-top));
    background: linear-gradient(150deg, #2A0B52, #4A2AB0 42%, #0E5C93);
}
.auth__panel::after {
    content: ''; position: absolute; left: -40%; bottom: -55%;
    width: 120%; aspect-ratio: 1; border-radius: 50%;
    background: radial-gradient(circle, rgba(34, 198, 245, .36), transparent 62%);
}
.auth__brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 10px; font: 700 16px/1 var(--font); color: #fff; letter-spacing: -.02em; }
.auth__brand img { background: #fff; border-radius: 9px; padding: 3px; }

.auth__panel-copy { position: relative; z-index: 1; margin-top: auto; display: flex; flex-direction: column; gap: 16px; }
.auth__panel-h { margin: 0; max-width: 20em; font: 700 clamp(19px, 2.6vw, 32px)/1.25 var(--font); color: #fff; letter-spacing: -.025em; text-wrap: pretty; }
.auth__panel-sub { margin: 0; max-width: 26em; font-size: 13.5px; line-height: 1.6; color: rgba(255, 255, 255, .6); }

.auth__status { display: flex; align-items: flex-end; gap: 14px; margin-top: 6px; }
.auth__mascot { width: clamp(72px, 12vw, 120px); height: auto; animation: ss-float 5s ease-in-out infinite; }
.auth__status > div { display: flex; flex-direction: column; gap: 6px; padding-bottom: 10px; }
.auth__status-label { font: 500 10px/1 var(--mono); letter-spacing: .08em; color: rgba(255, 255, 255, .5); }
.auth__status-bars { display: flex; gap: 4px; }
.auth__status-bars span { width: 26px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .25); }
.auth__status-bars span.is-on { background: var(--ok); }

/* On phones the panel becomes a compact header strip. */
@media (max-width: 899px) {
    .auth__panel { padding-bottom: 26px; }
    .auth__panel-copy { margin-top: 14px; gap: 10px; }
    .auth__panel-sub, .auth__status { display: none; }
    .auth__panel-h { font-size: 16px; font-weight: 600; color: rgba(255, 255, 255, .85); }
}

.auth__form-side {
    display: flex; align-items: center; justify-content: center;
    padding: clamp(24px, 3.4vw, 52px) clamp(20px, 3vw, 44px);
    padding-bottom: calc(clamp(24px, 3.4vw, 52px) + env(safe-area-inset-bottom));
}
.auth__form { width: 100%; max-width: 400px; }
.auth__head { display: flex; flex-direction: column; gap: 7px; margin-bottom: 20px; animation: ss-rise .3s ease-out; }
.auth__head h1 { font-size: clamp(24px, 3.2vw, 34px); letter-spacing: -.03em; }
.auth__head p { margin: 0; font-size: 13.5px; color: var(--ink-60); }
.auth__foot { display: flex; justify-content: center; margin-top: 22px; }
.auth__foot--split { flex-direction: column; align-items: center; gap: 14px; }

.field__label { display: flex; align-items: center; }
.field__aside { margin-left: auto; font-weight: 600; color: var(--brand); }

/* position: relative keeps the hidden input inside the label. Without it the
   input's containing block lay outside a scrolling .table-wrap, so a tick
   box in a wide table (the menu links in /admin/settings) widened the page. */
.check { position: relative; display: flex; align-items: center; gap: 9px; margin: 4px 0 18px; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check__box {
    display: grid; place-items: center; flex: none;
    width: 19px; height: 19px; border-radius: 6px;
    border: 1.5px solid var(--line-strong); background: var(--surface);
    transition: background .15s, border-color .15s;
}
.check__box::after { content: '✓'; font: 700 11px/1 var(--font); color: #fff; opacity: 0; }
.check input:checked + .check__box { background: var(--brand); border-color: var(--brand); }
.check input:checked + .check__box::after { opacity: 1; }
.check input:focus-visible + .check__box { box-shadow: var(--ring); }
.check__label { font-size: 12.5px; font-weight: 500; color: var(--ink-60); }

/* ── Skeletons ───────────────────────────────────────────────────────────── */
.skeleton {
    border-radius: var(--r-xl);
    background: linear-gradient(90deg, var(--surface-2) 0%, var(--line-2) 45%, var(--surface-2) 90%);
    background-size: 220% 100%;
    animation: ss-shimmer 1.4s linear infinite;
}

/* ── Desktop ─────────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
    .topbar__burger { display: none; }
    .topbar__brand span { display: inline; }

    .sidebar {
        position: sticky; top: var(--topbar-h); inset-inline: auto;
        width: var(--sidebar-w); flex: none;
        height: calc(100vh - var(--topbar-h));
        transform: none;
    }
    .sidebar-scrim { display: none !important; }

    .bottom-nav { display: none; }
    .main { padding-bottom: var(--pad); }

    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(178px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* Printing an ERP screen usually means a document — drop the chrome. */
@media print {
    .topbar, .sidebar, .bottom-nav, .alert, .btn { display: none !important; }
    .main { padding: 0; }
    body { background: #fff; }
}

/* ==========================================================================
   Theme switch
   ========================================================================== */
.pref-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }

/* ── Language and appearance: one dropdown each ──────────────────────────────
   A native <details>, so it opens without JavaScript; app.js closes it on an
   outside click or Escape. The button shows the current choice — a language
   code, or the theme's icon — and the list holds every option. */
.pref-menu { position: relative; flex: none; }
.pref-menu__btn {
    display: inline-flex; align-items: center; gap: 5px;
    height: 32px; padding: 0 8px 0 10px;
    border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface-2); color: var(--ink-60);
    font: 600 11px/1 var(--mono); letter-spacing: .04em;
    cursor: pointer; list-style: none; user-select: none;
    transition: background .15s, color .15s, border-color .15s;
}
.pref-menu__btn::-webkit-details-marker { display: none; }
.pref-menu__btn:hover, .pref-menu[open] > .pref-menu__btn { color: var(--ink); border-color: var(--line-2); }
.pref-menu__btn:focus-visible { outline: 0; box-shadow: var(--ring); }
.pref-menu__icon { fill: currentColor; flex: none; }
.pref-menu__chevron { opacity: .6; transition: transform .15s; }
.pref-menu[open] .pref-menu__chevron { transform: rotate(180deg); }

.pref-menu__list {
    position: absolute; z-index: 60; top: calc(100% + 6px); right: 0;
    min-width: 168px; margin: 0; padding: 4px; list-style: none;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lift), var(--shadow-card);
}
.pref-menu__item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: var(--r-sm);
    color: var(--ink); font: 500 13.5px/1.2 var(--font); text-decoration: none;
}
.pref-menu__item:hover, .pref-menu__item:focus-visible { background: var(--surface-2); outline: 0; }
.pref-menu__item .pref-menu__code { width: 22px; font: 600 11px/1 var(--mono); color: var(--ink-50); }
.pref-menu__item .pref-menu__icon { color: var(--ink-50); }
.pref-menu__item.is-active { color: var(--brand); font-weight: 600; }
.pref-menu__item.is-active .pref-menu__code,
.pref-menu__item.is-active .pref-menu__icon { color: var(--brand); }
.pref-menu__item.is-active::after { content: '✓'; margin-left: auto; }

/* Where the switches sit at the foot of a page, the list opens upward
   instead of off the bottom edge; centred there, it grows from the middle. */
.auth__foot .pref-menu__list,
.bare__footer .pref-menu__list { top: auto; bottom: calc(100% + 6px); right: auto; left: 50%; transform: translateX(-50%); }

@media (max-width: 719px) {
    .pref-menu__btn { height: 38px; }
    .pref-menu__item { min-height: 44px; }
}

/* The landing hero glow and the auth panel are painted on brand gradients that
   already work on both themes; only the light-tinted CTA panel needs a dark
   counterpart so text keeps its contrast. */
:root[data-theme="dark"] .lp-cta,
:root[data-theme="dark"] .bare {
    background: linear-gradient(135deg, #17171f, #191728 55%, #10202b);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .lp-cta,
    :root:not([data-theme="light"]) .bare {
        background: linear-gradient(135deg, #17171f, #191728 55%, #10202b);
    }
}

/* ==========================================================================
   Editable grid — the superadmin Texts screen
   Desktop-only by design: it keeps the table layout at every width instead of
   collapsing into cards, and scrolls horizontally if it must.
   ========================================================================== */
.table--grid { table-layout: fixed; min-width: 900px; }

.table--grid th { position: sticky; top: 0; z-index: 2; background: var(--surface); }

.table--grid td { padding: 4px 6px; vertical-align: middle; }
.table--grid .col-key { width: 24%; }
.table--grid .col-key code {
    font: 400 11.5px/1.4 var(--mono);
    color: var(--ink-60);
    overflow-wrap: anywhere;
}

/* Compact controls: an explicit opt-in for a dense admin grid, not a silent
   exception to the shared --control-h. */
.table--grid input[type="text"] {
    height: var(--control-h-sm);
    padding: 0 10px;
    font-size: 13px;
    border-color: transparent;
    background: transparent;
    border-radius: var(--r-sm);
}
.table--grid input[type="text"]:hover { border-color: var(--line-2); }
.table--grid input[type="text"]:focus { border-color: var(--brand); background: var(--surface); box-shadow: var(--ring); }

/* A cell that differs from the shipped text, and one with nothing shipped. */
.table--grid .cell.is-overridden input { background: var(--info-bg); }
.table--grid .cell.is-missing input   { background: var(--warn-bg); }

.table--grid .cell.is-saving input { border-color: var(--brand); }
.table--grid .cell.is-saved  input { border-color: var(--ok); }
.table--grid .cell.is-error  input { border-color: var(--error); background: var(--error-bg); }

.autosave {
    margin-left: auto;
    font: 500 11px/1 var(--mono);
    color: var(--ink-42);
    min-height: 1em;
}
.autosave.is-saving { color: var(--brand); }
.autosave.is-saved  { color: var(--ok-fg); }
.autosave.is-error  { color: var(--error-fg); }

.filters { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .filters { grid-template-columns: 2fr 1fr 1fr; } }

/* Never collapse the grid into cards — this screen is not used on phones. */
@media (max-width: 719px) {
    .table--grid, .table--grid tbody, .table--grid tr { display: table; width: 100%; }
    .table--grid thead { display: table-header-group; }
    .table--grid tr { display: table-row; border: 0; padding: 0; margin: 0; }
    .table--grid td { display: table-cell; border-bottom: 1px solid var(--line); }
    .table--grid td::before { content: none; }
}

/* Uploaded customer logos in the rolling row. Height-capped and desaturated so
   a mixed bag of brand colours still reads as one strip. */
.lp-mark__img {
    height: clamp(20px, 2.4vw, 30px);
    width: auto;
    object-fit: contain;
    opacity: .55;
    filter: grayscale(1);
    transition: opacity .2s, filter .2s;
}
.lp-mark:hover .lp-mark__img,
.lp-mark:focus-visible .lp-mark__img { opacity: 1; filter: none; }

/* ==========================================================================
   Cookie disclaimer + legal pages
   ========================================================================== */
.cookie-notice {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 150;
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    padding: 14px clamp(14px, 3vw, 28px);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    background: var(--surface);
    border-top: 1px solid var(--line-strong);
    box-shadow: 0 -8px 30px -18px rgba(0, 0, 0, .4);
    animation: ss-rise .3s ease-out;
}
.cookie-notice__text {
    flex: 1 1 320px; margin: 0;
    font-size: 12.5px; line-height: 1.5; color: var(--ink-60);
}
.cookie-notice form { flex: none; }

/* The app shell has a bottom nav on phones — sit above it. */
.app .cookie-notice { bottom: var(--bottom-nav-h); }
@media (min-width: 900px) { .app .cookie-notice { bottom: 0; } }

.legal {
    max-width: 68ch;
    margin: 0 auto;
    padding: clamp(24px, 5vw, 56px) clamp(18px, 4vw, 32px) clamp(40px, 6vw, 80px);
}
.legal h1 { margin-bottom: 10px; }
.legal__lead { font-size: 15px; color: var(--ink-60); margin-bottom: 26px; }
.legal__section { margin-top: 28px; }
.legal__section h2 { font-size: 17px; margin-bottom: 8px; }
.legal__section p { color: var(--ink-70); line-height: 1.65; }
.legal__updated { margin-top: 36px; font: 500 11.5px/1 var(--mono); color: var(--ink-42); }
.legal__edit { margin: -2px 0 18px; }

/* The policy as written in the rich-text editor: whatever structure it has,
   it should read like the built-in sections. */
.legal__body { color: var(--ink-70); line-height: 1.65; overflow-wrap: anywhere; }
.legal__body > :first-child { margin-top: 0; }
.legal__body h2 { font-size: 17px; margin: 28px 0 8px; color: var(--ink); }
.legal__body h3 { font-size: 15px; margin: 22px 0 6px; color: var(--ink); }
.legal__body h4, .legal__body h5, .legal__body h6 { font-size: 14px; margin: 18px 0 6px; color: var(--ink); }
.legal__body p, .legal__body ul, .legal__body ol, .legal__body blockquote, .legal__body table { margin: 0 0 12px; }
.legal__body ul, .legal__body ol { padding-left: 1.4em; }
.legal__body li + li { margin-top: 4px; }
.legal__body blockquote { padding-left: 14px; border-left: 3px solid var(--line-strong); }
.legal__body img { max-width: 100%; height: auto; }
.legal__body table { width: 100%; border-collapse: collapse; }
.legal__body td, .legal__body th { padding: 6px 8px; border: 1px solid var(--line); text-align: left; vertical-align: top; }

.tabs__tab .pill { margin-left: 8px; }

/* ==========================================================================
   Platform file explorer
   ========================================================================== */
/* minmax(0, …), not 1fr: a bare 1fr track grows to its widest child, so the
   mailbox table (640px) widened the whole page on a phone instead of
   scrolling inside its own .table-wrap. */
.explorer { display: grid; gap: var(--gap); grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 900px) { .explorer { grid-template-columns: 260px 1fr; } }

.explorer__tree { position: sticky; top: calc(var(--topbar-h) + var(--gap)); max-height: 70vh; overflow: auto; }

.tree { list-style: none; margin: 0; padding: 0 0 0 14px; }
.explorer__tree > .tree { padding-left: 0; }
/* Collapsed branches stay in the DOM so the open path can be pre-expanded. */
.tree__item:not(.is-open) > .tree { display: none; }

.tree__row { display: flex; align-items: center; gap: 2px; border-radius: var(--r-sm); }
.tree__row.is-current { background: var(--surface-2); }
.tree__row.is-current .tree__link { color: var(--brand); font-weight: 600; }

.tree__toggle {
    display: grid; place-items: center; flex: none;
    width: 18px; height: 26px; padding: 0;
    background: none; border: 0; cursor: pointer;
    color: var(--ink-42);
}
.tree__toggle svg { fill: currentColor; transition: transform .15s; }
.tree__item.is-open > .tree__row > .tree__toggle svg { transform: rotate(90deg); }
.tree__toggle--leaf { cursor: default; }

.tree__link {
    display: flex; align-items: center; gap: 7px;
    padding: 5px 6px; min-width: 0;
    font-size: 13px; color: var(--ink-70);
}
.tree__link:hover { color: var(--brand); }
.tree__link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree__icon { flex: none; fill: currentColor; opacity: .55; }

.explorer__new-folder { display: flex; gap: 6px; margin-top: 12px; }
.explorer__new-folder input { height: var(--control-h-sm); font-size: 13px; }
.explorer__new-folder .btn { flex: none; width: var(--control-h-sm); padding: 0; }

.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 12px; font-size: 13px; }
.breadcrumb span { color: var(--ink-30); }

.explorer__upload { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: var(--gap); }
.explorer__upload input[type="file"] { flex: 1 1 260px; }

.explorer__toolbar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
    padding: 10px 12px; margin-bottom: 12px;
    background: var(--info-bg); border-radius: var(--r-lg);
}
.explorer__toolbar select { width: auto; min-width: 180px; height: var(--control-h-sm); font-size: 13px; }

.explorer__name { display: flex; align-items: center; gap: 8px; }
.explorer__name svg { flex: none; fill: currentColor; opacity: .5; }
.explorer__folder-row { background: var(--surface-2); }
.explorer__folder-row .explorer__name svg { opacity: .75; color: var(--brand); }

.explorer__folder-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--gap); padding-top: var(--gap); border-top: 1px solid var(--line); }
.explorer__folder-actions form { display: flex; gap: 6px; }
.explorer__folder-actions input { height: var(--control-h-sm); font-size: 13px; width: auto; }

.table--grid input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--brand); }

/* ── File explorer drag and drop ─────────────────────────────────────────── */
[data-drag-file], [data-drag-folder] { cursor: grab; }
.is-dragging { opacity: .45; }

/* A folder highlights while something hovers over it. */
.is-drop-target { outline: 2px dashed var(--brand); outline-offset: -2px; border-radius: var(--r-sm); background: var(--info-bg); }
tr.is-drop-target > td { background: var(--info-bg); }

.explorer__main { position: relative; }
.explorer__main.is-dropping::after {
    content: '';
    position: absolute; inset: 6px;
    border: 2px dashed var(--brand);
    border-radius: var(--r-lg);
    background: var(--info-bg);
    pointer-events: none;
}
.explorer__main.is-uploading { opacity: .6; pointer-events: none; }

/* ── File preview panel ──────────────────────────────────────────────────── */
.explorer__preview {
    background: none; border: 0; padding: 0;
    font: inherit; color: inherit; text-align: left; cursor: pointer;
}
.explorer__preview:hover span { color: var(--brand); text-decoration: underline; }
.explorer__preview:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-sm); }

.preview {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 120;
    width: min(520px, 100vw);
    display: flex; flex-direction: column; gap: 12px;
    padding: var(--pad);
    padding-top: calc(var(--pad) + env(safe-area-inset-top));
    background: var(--surface);
    border-left: 1px solid var(--line-strong);
    box-shadow: -18px 0 40px -30px rgba(0, 0, 0, .5);
    overflow: auto;
    animation: preview-in .2s cubic-bezier(.4, 0, .2, 1);
}
@keyframes preview-in { from { transform: translateX(16px); opacity: 0; } }

.preview__scrim { position: fixed; inset: 0; z-index: 110; background: rgba(14, 14, 20, .35); }

.preview__head { display: flex; align-items: flex-start; gap: 12px; }
.preview__head h2 { flex: 1; font-size: 16px; overflow-wrap: anywhere; }

.preview__meta { display: grid; gap: 4px; margin: 0; }
.preview__meta > div { display: flex; gap: 10px; font-size: 12.5px; }
.preview__meta dt { flex: 0 0 90px; color: var(--ink-42); }
.preview__meta dd { margin: 0; color: var(--ink-70); overflow-wrap: anywhere; }

.preview__body { flex: 1; min-height: 240px; display: flex; }
.preview__body img { max-width: 100%; height: auto; object-fit: contain; border-radius: var(--r-md); }
.preview__body iframe { flex: 1; width: 100%; min-height: 60vh; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.preview__body pre {
    flex: 1; margin: 0; padding: 12px; overflow: auto;
    font: 400 12px/1.6 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
    background: var(--surface-2); border-radius: var(--r-md);
}

@media (max-width: 640px) { .preview { width: 100vw; } }

/* ── Webmail ─────────────────────────────────────────────────────────────── */
.mail-unread td { font-weight: 600; }
.mail-unread td::before { color: var(--brand); }
.mail-body { margin-top: 12px; }
.mail-body pre {
    margin: 0; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere;
    font: 400 13px/1.65 var(--font);
    background: var(--surface-2); border-radius: var(--r-md);
}
/* ── Add/edit form behind a button ───────────────────────────────────────── */
.form-card > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.form-card > summary::-webkit-details-marker { display: none; }
.form-card[open] > summary { margin-bottom: 16px; }
/* The span inside is styled as a button; the summary itself carries the click. */
.form-card > summary .btn { pointer-events: none; }

/* ── Customer image (logo, mascot) ──────────────────────────────────────────────────────── */
.image-manage { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: flex-start; }
.image-manage__preview {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    padding: 16px; border: 1px solid var(--line); border-radius: var(--r-lg);
    background: var(--surface-2);
}
/* The tag carries its own width; this is only a ceiling, and a logo is
   allowed to be wider than a mascot. */
.image-manage__preview img { max-width: 180px; height: auto; }
.image-manage__actions { flex: 1; min-width: 260px; }

/* ── Bottom-bar picker (profile) ─────────────────────────────────────────── */
.nav-picker { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; padding: 0; list-style: none; }
.nav-picker__item {
    display: inline-flex; align-items: center; gap: 9px;
    min-height: var(--control-h-sm); padding: 8px 14px;
    font: 600 13px/1 var(--font); color: var(--ink-70);
    background: var(--surface); border: 1px solid var(--line-strong);
    border-radius: var(--r-lg); cursor: pointer;
    transition: border-color .15s, color .15s, background .15s;
}
.nav-picker__item:hover { border-color: rgba(91, 75, 240, .45); }
.nav-picker__item .icon { width: 18px; height: 18px; }
.nav-picker__item input { width: 16px; height: 16px; accent-color: var(--brand); }
.nav-picker__item.is-on { color: var(--brand); border-color: var(--brand); background: var(--info-bg); }

/* Summernote sits inside our own form styling — borders and radii follow the
   app tokens, and dark mode gets the surface colours the vendor CSS has no
   notion of. */
.note-editor.note-frame {
    margin: 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--surface);
}
.note-editor.note-frame .note-toolbar,
.note-editor.note-frame .note-statusbar {
    background: var(--surface-2);
    border-color: var(--line);
}
.note-editor.note-frame .note-editing-area .note-editable {
    background: var(--surface);
    color: var(--ink);
    font: 400 14px/1.6 var(--font);
}
.note-editor.note-frame .note-placeholder { color: var(--ink-42); }

:root[data-theme="dark"] .note-editor.note-frame .note-btn,
:root[data-theme="dark"] .note-editor.note-frame .note-editable {
    color: var(--ink);
}
:root[data-theme="dark"] .note-editor.note-frame .note-btn { background: var(--surface); border-color: var(--line); }
:root[data-theme="dark"] .note-editor.note-frame .note-dropdown-menu,
:root[data-theme="dark"] .note-editor.note-frame .note-modal-content {
    background: var(--surface); color: var(--ink); border-color: var(--line);
}
:root[data-theme="dark"] .note-editor.note-frame .note-codable { background: var(--surface-2); color: var(--ink); }

/* Row actions stay out of the way until the row is hovered. Where there is no
   hover (touch), they are simply always visible. */
.mail-actions { text-align: right; }
.mail-actions form { display: inline-flex; }

@media (hover: hover) {
    .mail-actions .btn { opacity: 0; pointer-events: none; transition: opacity .12s; }
    tr:hover > .mail-actions .btn,
    .mail-actions .btn:focus-visible { opacity: 1; pointer-events: auto; }
}

.mail-body iframe {
    width: 100%; min-height: 55vh; border: 1px solid var(--line);
    border-radius: var(--r-md); background: #fff;
}

/* ── Modals ──────────────────────────────────────────────────────────────── */
/* <dialog> so the browser owns focus trapping, Escape and the top layer.
   ::backdrop belongs to the top layer, which sits above every stacking
   context on the page — nothing here needs a z-index. */
.modal {
    width: min(680px, calc(100vw - 2 * var(--pad)));
    max-height: min(86vh, 900px);
    padding: 0; border: 0; background: transparent;
    color: var(--ink);
    overflow: visible;
}
/* For a form that holds the same field in three languages side by side: the
   default width gives each of them about a dozen characters, which is not a
   box you can write a question in. */
.modal--wide { width: min(940px, calc(100vw - 2 * var(--pad))); }
/* Wider still, for a pane that is a table rather than a form. The invoice
   line grid is nine columns before the row controls, and at --wide it spent
   its life scrolling sideways inside a modal that had room to spare. */
.modal--xl { width: min(1360px, calc(100vw - 2 * var(--pad))); }
.modal::backdrop { background: rgba(20, 20, 40, .45); backdrop-filter: blur(2px); }

.modal__panel {
    display: flex; flex-direction: column;
    max-height: inherit;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lift);
    overflow: hidden;
}
.modal__head {
    display: flex; align-items: center; gap: 12px;
    padding: 16px var(--pad);
    border-bottom: 1px solid var(--line);
}
.modal__title { margin: 0; margin-right: auto; font: 700 16px/1.3 var(--font); letter-spacing: -.01em; }
.modal__close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex: 0 0 auto;
    font: 400 22px/1 var(--font); color: var(--ink-50);
    background: var(--surface-2); border: 0; border-radius: var(--r-md); cursor: pointer;
}
.modal__close:hover { color: var(--ink); }
/* The body scrolls, not the page behind it. */
.modal__body { padding: var(--pad); overflow-y: auto; }
.modal__body > form > :last-child { margin-bottom: 0; }

/* No-<dialog> fallback: the element is a plain block with an `open`
   attribute, so it has to place and dim itself. */
@supports not selector(dialog::backdrop) {
    .modal[open] {
        position: fixed; inset: 0; z-index: 90;
        display: grid; place-items: center;
        padding: var(--pad); background: rgba(20, 20, 40, .45);
    }
}

/* ── The site clock ──────────────────────────────────────────────────────── */
/* Built for a phone held in a cold hand, outdoors, in a hurry. One decision on
   the screen at a time, the running shift stated in numbers big enough to read
   at arm's length, and the button that ends it larger than anything else. */

/* The hero, while a shift is running. The one place in the app that uses the
   brand gradient at full strength: this is the screen that has to say "yes,
   it is counting" from across a room. */
.clock-hero {
    position: relative; overflow: hidden;
    padding: clamp(18px, 4vw, 28px);
    border-radius: var(--r-xl);
    background: var(--gradient); color: #fff;
    box-shadow: var(--shadow-pop);
}
.clock-hero__top { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.clock-hero__where { flex: 1 1 220px; min-width: 0; }
.clock-hero__site {
    margin: 6px 0 2px;
    font: 800 clamp(20px, 5vw, 30px)/1.15 var(--font); letter-spacing: -.02em;
}
.clock-hero__sub { margin: 0; font: 500 12.5px/1.5 var(--font); color: rgba(255, 255, 255, .78); }

/* "On site", with a dot that breathes. Motion is the cheapest possible way to
   say "still running" without a second of reading. */
.clock-hero__state {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 5px 11px 5px 9px; border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .18);
    font: 700 11px/1 var(--font); letter-spacing: .04em; text-transform: uppercase;
}
.clock-hero__dot {
    width: 8px; height: 8px; border-radius: 50%; background: #fff;
    animation: ss-pulse 2s ease-in-out infinite;
}
@keyframes ss-pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.8); } }
@media (prefers-reduced-motion: reduce) { .clock-hero__dot { animation: none; } }

/* The elapsed time. Tabular figures so the seconds ticking over do not shove
   the rest of the number sideways twice a second. */
.clock-hero__time {
    margin: clamp(10px, 3vw, 18px) 0 0;
    font: 700 clamp(38px, 12vw, 62px)/1 var(--mono);
    letter-spacing: -.03em; font-variant-numeric: tabular-nums;
}
.clock-hero__meta {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    margin-top: 10px; font: 500 12px/1 var(--mono); color: rgba(255, 255, 255, .8);
}
.clock-hero__tag {
    padding: 4px 9px; border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .16);
}
.clock-hero__stop { margin-top: clamp(14px, 3vw, 20px); }
/* White on the gradient: the stop button has to out-shout the background it
   sits on, and a red button on purple is a fight nobody wins. */
.clock-hero__stop .btn {
    width: 100%; max-width: 320px;
    background: #fff; color: var(--error-fg); border: 0;
    font-weight: 700;
}
.clock-hero__stop .btn:hover { background: rgba(255, 255, 255, .9); color: var(--error-fg); }

/* Choosing where you are. The nearest site is the answer nine times in ten, so
   it gets a card and everything else gets a row. */
.clock-pick__lead { margin: 0 0 14px; font: 700 clamp(17px, 4vw, 21px)/1.3 var(--font); }

.site-card {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 16px;
    border-radius: var(--r-xl);
    background: var(--surface);
    border: 2px solid var(--brand);
    box-shadow: var(--shadow-pop);
}
.site-card__what { flex: 1 1 200px; min-width: 0; }
.site-card__name { margin: 0 0 2px; font: 800 17px/1.25 var(--font); letter-spacing: -.01em; }
.site-card__where { font: 500 12.5px/1.4 var(--font); color: var(--ink-50); }
.site-card .btn { flex: 0 0 auto; min-width: 132px; }

.site-list {
    list-style: none; margin: 12px 0 0; padding: 0;
    display: grid; gap: 8px;
}
.site-list__row {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 14px;
    background: var(--surface); border: 1px solid var(--line-2);
    border-radius: var(--r-lg);
    transition: border-color .12s, box-shadow .12s;
}
.site-list__row:hover { border-color: rgba(91, 75, 240, .4); box-shadow: var(--shadow-card); }
.site-list__what { flex: 1 1 180px; min-width: 0; }
.site-list__name { font: 700 14px/1.3 var(--font); }
.site-list__row .btn { flex: 0 0 auto; }

/* A photograph of the place, beside its name. Fixed and square so a row of
   sites reads as a column of names rather than as a ragged edge, and so one
   portrait snap does not make its row twice the height of the others. */
.site-thumb {
    flex: 0 0 auto; width: 56px; height: 56px;
    object-fit: cover; border-radius: var(--r-md);
    background: var(--surface-2);
}
.site-card .site-thumb { width: 68px; height: 68px; border-radius: var(--r-lg); }

.site-row { display: flex; align-items: center; gap: 10px; }
.site-row__thumb {
    flex: 0 0 auto; width: 40px; height: 40px;
    object-fit: cover; border-radius: var(--r-sm);
    background: var(--surface-2);
}

/* The caption and the remove button under a thumbnail in a gallery. */
.photo-grid__foot { display: flex; align-items: center; gap: 8px; }
.photo-grid__foot .meta { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* How far away, as a chip. Green means "you are at this one" — inside the
   site's own radius, which is why the radius is per site. */
.distance {
    flex: 0 0 auto;
    display: inline-flex; align-items: center; gap: 5px;
    padding: 5px 10px; border-radius: var(--r-pill);
    font: 600 11.5px/1 var(--mono);
    background: var(--surface-2); color: var(--ink-60);
}
.distance--here { background: var(--ok-bg); color: var(--ok-fg); }
.distance--far  { background: var(--warn-bg); color: var(--warn-fg); }

/* The day at a glance: the total, and where the hours actually fell. A list of
   times says what happened; the bar says what the day looked like. */
.day-bar { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.day-bar__total { margin-left: auto; font: 800 clamp(22px, 5vw, 28px)/1 var(--font); letter-spacing: -.02em; }
.day-bar__label { font: 700 15px/1.3 var(--font); }

.day-track {
    position: relative; height: 34px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    overflow: hidden;
}
.day-track__span {
    position: absolute; top: 0; bottom: 0;
    background: var(--gradient-soft); opacity: .85;
    border-radius: 5px;
    /* A one-minute shift is still a thing that happened; without a floor it
       would render as nothing at all. */
    min-width: 3px;
}
.day-track__span--open {
    background: repeating-linear-gradient(
        135deg, var(--brand) 0 8px, rgba(91, 75, 240, .55) 8px 16px
    );
}
.day-scale {
    display: flex; justify-content: space-between;
    margin-top: 4px; font: 500 10.5px/1 var(--mono); color: var(--ink-42);
}

/* One record of the day. Collapsed by default; the running one is open. */
.shift { border-top: 1px solid var(--line); padding: 10px 0; }
.shift:first-of-type { border-top: 0; }
.shift__head {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    cursor: pointer; list-style: none;
}
.shift__head::-webkit-details-marker { display: none; }
.shift__site { font: 700 14px/1.3 var(--font); }
.shift__hours { margin-left: auto; font: 600 13px/1 var(--mono); }
.shift__body { padding: 12px 0 4px; }

/* Dropping pictures onto a shift. Full width so the target is hard to miss
   with a gloved thumb, with the caption and the button under it. */
/* Search, on the screen where finding a site by name is the exception rather
   than the rule — so it sits above the list without competing with it. */
.clock-search { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.clock-search .field__input { flex: 1 1 220px; }

/* A tighter grid, for the galleries that sit inside a record rather than on a
   page of their own. */
.photo-grid--tight { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); margin-bottom: 12px; }

/* A few pictures in a table cell.
   Wrapping, not scrolling: a flex row with overflow-x inside a table cell that
   has no resolved width collapses to zero, and fixed-size thumbnails then
   spill out of it and sit on top of the next column. Wrapping needs no width
   to resolve, so it cannot do that. The view caps how many are drawn, which is
   what keeps the row from growing tall. */
/* A grid of fixed columns, not a flex row.
   A table cell resolves no width for its children, so both `overflow-x` and
   `width:100%` came out as zero and the fixed-size thumbnails spilled over the
   next column. Fixed grid tracks have an intrinsic width instead — 5 × 44 plus
   the gaps — which the cell has to make room for, so nothing can escape it.
   Five columns because the view draws at most four pictures plus a "+N". */
.photo-strip {
    display: grid; grid-template-columns: repeat(5, 44px);
    gap: 6px; margin-top: 6px; justify-content: start;
}
.photo-strip a { display: block; }
.photo-strip img {
    width: 44px; height: 44px; object-fit: cover;
    border-radius: var(--r-sm); background: var(--surface-2);
}
/* "+3" when there are more than the row shows. */
.photo-strip__more {
    flex: 0 0 auto;
    display: inline-grid; place-items: center;
    width: 44px; height: 44px; border-radius: var(--r-sm);
    background: var(--surface-2); color: var(--ink-60);
    font: 700 11.5px/1 var(--mono); text-decoration: none;
}
.photo-strip__more:hover { color: var(--ink); }

.clock-drop { flex: 1 1 100%; margin-top: 14px; }
.clock-drop__row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.clock-drop__row .field__input { flex: 1 1 180px; }

/* Both clocks side by side, for the office. The corrected time reads as the
   figure that counts; what the button recorded sits under it, quieter. */
.times { display: grid; gap: 2px; }
.times__was { font: 500 11px/1.3 var(--mono); color: var(--ink-42); text-decoration: line-through; }

/* ── A file tree ─────────────────────────────────────────────────────────── */
/* Folders and files in one list, folders first. Deliberately not an indented
   outline: on a phone an indented tree runs out of width by the third level,
   and a breadcrumb plus one level is the same information without the cliff. */
.crumbs {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    margin-bottom: var(--gap); font: 500 13px/1.4 var(--font);
}
.crumbs__sep { color: var(--ink-30); }
.crumbs__here { font-weight: 700; }

.tree { list-style: none; margin: 0; padding: 0; }
.tree__row {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 10px 4px; border-bottom: 1px solid var(--line);
}
.tree__row:last-child { border-bottom: 0; }
.tree__name {
    display: flex; align-items: center; gap: 10px;
    flex: 1 1 220px; min-width: 0;
    color: var(--ink); text-decoration: none;
}
.tree__name:hover { color: var(--brand); }
.tree__icon { color: var(--ink-42); display: inline-flex; }

/* ── A person's months ───────────────────────────────────────────────────── */
/* One row per month, with a bar against the busiest. The shape of a year's
   work is something you see; a column of numbers is something you decode. */
.month-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.month-row {
    display: grid; align-items: center; gap: 12px;
    grid-template-columns: 130px 1fr 100px;
    padding: 10px 12px; border-radius: var(--r-md);
    color: var(--ink); text-decoration: none;
}
.month-row:hover { background: var(--surface-2); color: var(--ink); }
.month-row.is-on { background: var(--info-bg); }
.month-row__name { font: 700 13.5px/1.3 var(--font); }
.month-row__bar { height: 10px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.month-row__bar > span { display: block; height: 100%; background: var(--gradient-soft); border-radius: var(--r-pill); }
.month-row__hours { font: 700 13px/1 var(--mono); text-align: right; }
/* The counts sit under the bar rather than in a fourth column: on a phone
   there is no fourth column, and this is the part you can do without. */
.month-row__meta { grid-column: 2 / -1; }

@media (max-width: 560px) {
    .month-row { grid-template-columns: 1fr auto; }
    .month-row__bar { grid-column: 1 / -1; }
    .month-row__meta { grid-column: 1 / -1; }
}

/* ── Date picker ─────────────────────────────────────────────────────────── */
/* Ours rather than the browser's, because the browser's speaks the browser's
   language. Month names, weekday letters and the buttons all come from the
   customer's locale, and the week starts on Monday. */
.dp {
    position: absolute; z-index: 120;
    width: 268px; padding: 12px;
    background: var(--surface); color: var(--ink);
    border: 1px solid var(--line-2); border-radius: var(--r-lg);
    box-shadow: var(--shadow-lift);
}
.dp__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.dp__head strong { font: 700 13.5px/1 var(--font); }
.dp__nav {
    width: 28px; height: 28px; border: 0; border-radius: var(--r-sm); cursor: pointer;
    background: var(--surface-2); color: var(--ink-60); font: 400 18px/1 var(--font);
}
.dp__nav:hover { color: var(--ink); }

.dp__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp__wd {
    display: grid; place-items: center; height: 26px;
    font: 700 10.5px/1 var(--mono); color: var(--ink-42); text-transform: uppercase;
}
.dp__day {
    height: 32px; border: 0; border-radius: var(--r-sm); cursor: pointer;
    background: transparent; color: var(--ink);
    font: 500 12.5px/1 var(--font);
}
.dp__day:hover { background: var(--surface-2); }
/* Today is outlined, the chosen day is filled — one says where you are, the
   other says what you picked, and they are often not the same day. */
.dp__day.is-today { box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.dp__day.is-on { background: var(--brand); color: #fff; }

.dp__time { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.dp__time label { font: 600 11px/1 var(--font); color: var(--ink-60); }
.dp__time input { flex: 1 1 auto; height: var(--control-h-sm); padding: 0 8px;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); }

.dp__foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }

/* ── Photo viewer ────────────────────────────────────────────────────────── */
/* Deliberately unlike the modal: no panel, no card, no chrome. The picture is
   the content, so everything else gets out of its way. */
.lightbox {
    width: min(1100px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    padding: 0; border: 0; background: transparent; overflow: visible;
}
.lightbox::backdrop { background: rgba(10, 10, 18, .82); backdrop-filter: blur(3px); }

.lightbox__stage { margin: 0; display: grid; gap: 10px; justify-items: center; }
.lightbox__stage img {
    max-width: 100%; max-height: calc(100vh - 110px);
    width: auto; height: auto;
    border-radius: var(--r-lg);
    background: rgba(255, 255, 255, .04);
}
.lightbox__caption {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    justify-content: center;
    font: 500 12.5px/1.4 var(--font); color: rgba(255, 255, 255, .8);
}
.lightbox__count { font: 600 11.5px/1 var(--mono); color: rgba(255, 255, 255, .55); }

.lightbox__step, .lightbox__close {
    position: absolute; z-index: 1;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%; cursor: pointer;
    background: rgba(255, 255, 255, .14); color: #fff;
    backdrop-filter: blur(4px);
    transition: background .12s, opacity .12s;
}
.lightbox__step:hover, .lightbox__close:hover { background: rgba(255, 255, 255, .26); }
.lightbox__step:disabled { opacity: .25; cursor: default; }

.lightbox__step {
    top: 50%; transform: translateY(-50%);
    width: 48px; height: 48px;
    font: 400 30px/1 var(--font); padding-bottom: 4px;
}
.lightbox__step--prev { left: -6px; }
.lightbox__step--next { right: -6px; }

.lightbox__close {
    top: -6px; right: -6px; width: 38px; height: 38px;
    font: 400 24px/1 var(--font);
}

/* On a phone the arrows cannot hang outside the picture — there is no outside.
   They move onto it, at the bottom, where a thumb already is. */
@media (max-width: 640px) {
    .lightbox__step { top: auto; bottom: 8px; transform: none; width: 44px; height: 44px; }
    .lightbox__step--prev { left: 8px; }
    .lightbox__step--next { right: 8px; }
}

/* Pictures taken on site. Square thumbnails so a row of them reads as a set
   rather than as a ragged edge. */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-grid__item { margin: 0; display: grid; gap: 6px; }
.photo-grid__item a {
    display: grid; place-items: center; aspect-ratio: 1;
    overflow: hidden; border-radius: var(--r-lg);
    background: var(--surface-2); border: 1px solid var(--line);
}
.photo-grid__item img { width: 100%; height: 100%; object-fit: cover; }

/* ── Pagination ──────────────────────────────────────────────────────────── */
/* Numbered, so a long list can be crossed rather than walked. The ends are
   always there and a window follows where you are; the runs between them
   collapse to an ellipsis. */
.pagination {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    padding: 14px var(--pad) 2px;
}
.pagination__page, .pagination__step {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 32px; height: 32px; padding: 0 8px;
    font: 600 12.5px/1 var(--font); color: var(--ink-60);
    background: var(--surface-2); border: 1px solid transparent;
    border-radius: var(--r-md); text-decoration: none;
}
.pagination__page:hover, .pagination__step:hover { color: var(--ink); border-color: var(--line); }
.pagination__page.is-on {
    color: #fff; background: var(--brand); border-color: transparent; cursor: default;
}
/* Kept rather than removed at the ends: the row should not shift sideways by
   the width of a button as you move through it. */
.pagination__step.is-off { opacity: .35; pointer-events: none; }
.pagination__gap { padding: 0 2px; color: var(--ink-42); }
.pagination__of { margin-left: auto; font: 500 11px/1.4 var(--mono); color: var(--ink-42); }

@media (max-width: 560px) {
    .pagination__of { width: 100%; margin: 6px 0 0; }
}

/* ── Tabs (settings sections) ────────────────────────────────────────────── */
.tabs {
    display: flex; flex-wrap: wrap; gap: 4px;
    margin-bottom: var(--gap); padding: 4px;
    background: var(--surface-2); border-radius: var(--r-lg);
}
.tabs__tab {
    display: inline-flex; align-items: center;
    min-height: var(--control-h-sm); padding: 0 14px;
    font: 600 13px/1 var(--font); color: var(--ink-60);
    border-radius: var(--r-md); text-decoration: none;
}
.tabs__tab:hover { color: var(--ink); }
.tabs__tab.is-active {
    color: var(--brand); background: var(--surface); box-shadow: var(--shadow-card);
}

/* A checkbox reads left-to-right, unlike the stacked label/control fields. */
.field--check { flex-direction: row; align-items: center; gap: 10px; margin-bottom: 6px; }
.field--check input[type="checkbox"] { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.field--check span { font: 600 13px/1.3 var(--font); color: var(--ink-70); }

/* ── Select2 (vendored) ──────────────────────────────────────────────────── */
/* The plugin ships its own look; these rules bend it to the app's controls so
   a multi-select sits in a form row at the same height and radius as an
   <input>. Selectors are the plugin's, hence the specificity. */
.select2-container { width: 100% !important; }

.select2-container--default .select2-selection--multiple,
.select2-container--default .select2-selection--single {
    min-height: var(--control-h);
    padding: 4px 8px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
}

/* The chip list and the search box are siblings here, not nested — left as
   blocks they stack, and a control holding one chip stands two rows tall.
   Laying the selection out as the flex row puts them side by side. */
.select2-container--default .select2-selection--multiple {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
}
.select2-container--default .select2-selection--multiple .select2-search--inline {
    flex: 1 1 6em; min-width: 6em;
}
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: var(--brand); box-shadow: var(--ring);
}

/* Remove-first is select2 4.1's own markup order and it reads fine; no
   attempt to flip it, which flexbox cannot do to the anonymous text node
   the label sits in anyway. */
.select2-container--default .select2-selection--multiple .select2-selection__choice {
    display: inline-flex; align-items: center; gap: 6px;
    margin: 0; padding: 4px 9px;
    font: 600 11px/1 var(--font);
    background: rgba(91, 75, 240, .1); color: var(--brand);
    border: 0; border-radius: var(--r-pill);
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    margin: 0; padding: 0; border: 0; background: none;
    font-size: 14px; line-height: 1; color: inherit; opacity: .6;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    background: none; color: inherit; opacity: 1;
}
/* The inline search sits *between* the chips, so it must not take the app's
   full-width search-input rule — that pushes it onto its own line and leaves
   a control three rows tall with the chips stranded underneath.
   min-height is reset explicitly: select2 4.1 renders this as a <textarea>,
   and `textarea { min-height: calc(var(--control-h) * 2) }` above beats any
   height set here, whatever the specificity. */
.select2-container--default .select2-search--inline .select2-search__field {
    width: auto; min-width: 6em;
    height: 26px; min-height: 0; margin-top: 0;
    padding: 0; border: 0; background: transparent;
    overflow: hidden; resize: none;
    font: 500 13px/26px var(--font); color: var(--ink);
}
.select2-container--default .select2-selection--multiple .select2-selection__rendered {
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
    margin: 0; padding: 0; list-style: none;
}
.select2-container--default .select2-selection__placeholder { color: var(--ink-42); }

.select2-dropdown {
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lift);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
    height: var(--control-h-sm); padding: 0 10px;
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.select2-container--default .select2-results__option {
    padding: 9px 12px; font: 500 13px/1.3 var(--font); color: var(--ink-70);
}
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[data-selected] {
    background: var(--brand); color: #fff;
}
.select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option[data-selected="true"] {
    background: var(--surface-2); color: var(--ink);
}

/* A badge that is also a button: same shape as .pill, plus the affordances a
   control needs. Used for the in-use toggle on the positions table. */
.pill--toggle {
    border: 0; cursor: pointer; font-family: var(--font);
    transition: filter .12s, box-shadow .12s;
}
.pill--toggle:hover { filter: brightness(.94); }
.pill--toggle:focus-visible { outline: 0; box-shadow: var(--ring); }

/* ── Question answer slots ───────────────────────────────────────────────── */
/* One row per option: the text in each language, and whether it is a right
   answer. Three boxes do not fit a phone side by side, so they wrap — the
   radio keeps its place at the head of the row and the boxes fall under it. */
.answer-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.answer-row .field__input { flex: 1 1 190px; min-width: 0; }
.answer-row__correct {
    display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
    font: 600 12px/1 var(--font); color: var(--ink-60); cursor: pointer;
    white-space: nowrap;
}
.answer-row__correct input { width: 17px; height: 17px; margin: 0; }

/* ── Sitting a test ──────────────────────────────────────────────────────── */
/* Its own shell: nothing but the paper, centred, on a plain canvas. */
.exam { min-height: 100vh; background: var(--canvas); }
.exam__main { max-width: 820px; margin: 0 auto; padding: var(--pad); }

.exam-paper__head {
    display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
    margin-bottom: var(--gap);
}
.exam-paper__head h1 { margin: 0 0 4px; font-size: clamp(19px, 3vw, 24px); }
.exam-paper__head > span { margin-left: auto; }

.exam-q {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-xl); padding: 18px; margin-bottom: 14px;
    box-shadow: var(--shadow-card);
}
.exam-q__body { margin: 0 0 12px; font: 700 15px/1.45 var(--font); display: flex; gap: 9px; }
.exam-q__n { color: var(--ink-42); flex: 0 0 auto; }
.exam-q img { max-width: 100%; height: auto; border-radius: var(--r-md); margin-bottom: 12px; }

.exam-q__answers { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.exam-a {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; cursor: pointer;
    background: var(--surface); border: 1.5px solid var(--line-strong);
    border-radius: var(--r-lg); font: 500 14px/1.35 var(--font);
}
.exam-a:hover { border-color: rgba(91, 75, 240, .45); }
.exam-a input { width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
.exam-a:has(input:checked) { border-color: var(--brand); background: var(--info-bg); }

.exam-paper__foot {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding-top: 6px;
}
.exam-paper__foot .btn { margin-left: auto; }
.btn--lg { height: var(--control-h-lg); padding: 0 26px; font-size: 15px; }

/* Text selection off while a paper is open — copying questions out is the
   thing this discourages; it is a deterrent, not a control. */
.exam-paper { user-select: none; }

/* ── A marked paper (admin) ──────────────────────────────────────────────── */
/* The same question and options as the sitting, with the key on top: green is
   the right answer, red is what they picked instead. Both are stated in words
   as well as colour — a marked paper that only works in colour does not work. */
.exam-a--static { cursor: default; }
.exam-a--right { border-color: var(--ok-fg); background: var(--ok-bg); }
.exam-a--wrong { border-color: var(--error-fg); background: var(--error-bg); }
.exam-a__mark {
    flex: 0 0 auto; width: 20px; text-align: center;
    font: 700 14px/1 var(--font); color: var(--ink-42);
}
.exam-a--right .exam-a__mark { color: var(--ok-fg); }
.exam-a--wrong .exam-a__mark { color: var(--error-fg); }
.exam-a__note { margin-left: auto; font: 600 10.5px/1 var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.exam-a--right .exam-a__note { color: var(--ok-fg); }
.exam-a--wrong .exam-a__note { color: var(--error-fg); }

/* The verdict strip on each question, so a long paper can be skimmed. */
.exam-q__verdict { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }

/* ── Result ──────────────────────────────────────────────────────────────── */
.result { display: flex; flex-wrap: wrap; gap: var(--gap); align-items: center; }
.result__grade {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    min-width: 150px; padding: 22px 26px; border-radius: var(--r-xl);
    font: 800 15px/1 var(--font); text-align: center;
}
.result__mark { font-size: 34px; line-height: 1; }
.result__meta { flex: 1; min-width: 220px; }
.result__meta h2 { margin: 0 0 4px; font-size: 16px; }
.result__meta .stat__value { margin: 0 0 4px; }

/* Gold, silver, and the one that is neither. */
.pill--gold   { background: rgba(214, 158, 46, .16); color: #8a6100; }
.pill--silver { background: rgba(120, 130, 150, .18); color: #4a5468; }
.pill--bad    { background: var(--error-bg); color: var(--error-fg); }
:root[data-theme="dark"] .pill--gold   { color: #f0c674; }
:root[data-theme="dark"] .pill--silver { color: #c3cbdb; }

/* ── Image dropzone ──────────────────────────────────────────────────────── */
/* The input is stretched over the whole zone at zero opacity: that is what
   makes click-to-browse and drag-to-drop work with no JavaScript at all, since
   a file input already does both. Everything below is presentation. */
.dropzone {
    position: relative;
    display: block;
    padding: 18px;
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: rgba(91, 75, 240, .45); }

/* Two classes deep on purpose: the global `input[type="file"]` rule is an
   element+attribute selector and outranks a single class, which would leave
   this 46px tall inside a 190px zone — most of the target dead to a drop. */
.dropzone .dropzone__input {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
    padding: 0; border: 0; min-height: 0;
}
.dropzone .dropzone__input:focus-visible + .dropzone__body { box-shadow: var(--ring); border-radius: var(--r-md); }

.dropzone__body {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    text-align: center; pointer-events: none;
}
.dropzone__body img { max-width: 100%; height: auto; border-radius: var(--r-md); }
.dropzone__icon { color: var(--ink-42); }
.dropzone__text { font: 500 12.5px/1.4 var(--font); color: var(--ink-50); }
.dropzone__file {
    font: 600 11.5px/1.3 var(--mono); color: var(--brand);
    word-break: break-all;
}

/* While a file is over the zone. */
.dropzone.is-over {
    border-color: var(--brand); border-style: solid;
    background: var(--info-bg);
}
.dropzone.is-over .dropzone__text { color: var(--brand); }

/* In a table cell there is no room for the full treatment. */
.dropzone--compact { padding: 8px; }
.dropzone--compact .dropzone__body { flex-direction: row; gap: 7px; }
.dropzone--compact .dropzone__text { font-size: 11px; }

/* ── Toasts ──────────────────────────────────────────────────────────────── */
/* Server-rendered, so they are on screen before any script runs. Fixed to the
   top-right on desktop; across the top on a phone, where a corner card is
   easy to miss and awkward to reach. */
.toasts {
    position: fixed; z-index: 95;
    top: calc(var(--topbar-h) + 10px); right: var(--pad);
    display: flex; flex-direction: column; gap: 10px;
    width: min(420px, calc(100vw - 2 * var(--pad)));
    pointer-events: none;   /* the gaps between toasts stay clickable */
}
@media (max-width: 719px) {
    .toasts { left: var(--pad); right: var(--pad); width: auto; }
}

.toast {
    pointer-events: auto;
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-left: 3px solid var(--ink-30);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lift);
    font: 500 13px/1.45 var(--font); color: var(--ink);
    animation: ss-toast-in .18s ease-out;
}
.toast__body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast__list { margin: 0; padding-left: 18px; }
.toast__list li + li { margin-top: 3px; }

.toast__close {
    flex: 0 0 auto; width: 22px; height: 22px; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font: 400 18px/1 var(--font); color: var(--ink-42);
    background: none; border: 0; border-radius: var(--r-sm); cursor: pointer;
}
.toast__close:hover { color: var(--ink); background: var(--surface-2); }

/* The stripe carries the meaning; the card stays readable in both themes. */
.toast--ok    { border-left-color: var(--ok); }
.toast--error { border-left-color: var(--error); }
.toast--info  { border-left-color: var(--brand); }

/* Leaving is a class app.js adds, so the element is still there to animate. */
.toast.is-leaving { animation: ss-toast-out .16s ease-in forwards; }

@keyframes ss-toast-in  { from { opacity: 0; transform: translateY(-6px); } }
@keyframes ss-toast-out { to   { opacity: 0; transform: translateX(10px); } }

@media (prefers-reduced-motion: reduce) {
    .toast, .toast.is-leaving { animation: none; }
}

/* ── Image dropzone ──────────────────────────────────────────────────────── */
/* The file input is stretched over the whole zone at zero opacity. That is
   what makes this work with no JavaScript at all: a browser already opens the
   picker when a file input is clicked, and already accepts a file dropped on
   one. app.js only adds the drag-over highlight and the preview. */
.dropzone {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    min-height: 120px; padding: 16px;
    text-align: center;
    background: var(--surface-2);
    border: 1.5px dashed var(--line-strong);
    border-radius: var(--r-lg);
    transition: border-color .15s, background .15s;
}
.dropzone:hover { border-color: rgba(91, 75, 240, .45); }
.dropzone.is-over { border-color: var(--brand); background: var(--info-bg); }

.dropzone__input {
    position: absolute; inset: 0;
    width: 100%; height: 100%;
    opacity: 0; cursor: pointer;
    /* Height is forced here: the shared control rule would make it 36px and
       only the top of the zone would accept a drop. */
    padding: 0; border: 0;
}
.dropzone__input:focus-visible + .dropzone__body { box-shadow: var(--ring); border-radius: var(--r-md); }

.dropzone__body {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    pointer-events: none;   /* every click belongs to the input beneath */
}
.dropzone__body img { max-width: 100%; height: auto; border-radius: var(--r-sm); }
.dropzone__icon { color: var(--ink-42); }
.dropzone__text { font: 500 12.5px/1.4 var(--font); color: var(--ink-50); }
.dropzone__file { font: 600 12px/1.3 var(--mono); color: var(--brand); overflow-wrap: anywhere; }

/* In a table cell there is room for a line, not a panel. */
.dropzone--compact { min-height: 0; padding: 8px 10px; }
.dropzone--compact .dropzone__body { flex-direction: row; gap: 8px; }
.dropzone--compact .dropzone__text { font-size: 11.5px; }

/* ── The staff card ──────────────────────────────────────────────────────── */

/* The identity strip at the top of every tab. A face, then the facts that
   answer "who is this" — the row wraps rather than shrinking the photograph,
   because the photograph is the part that is recognised at a glance. */
.person-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.person-head__photo {
    width: 72px; height: 72px; flex: 0 0 auto;
    border-radius: var(--r-lg); object-fit: cover;
    background: var(--surface-2);
}
/* No picture yet: their initial, at the same size, so the row does not jump
   the moment one is uploaded. */
.person-head__photo--blank {
    display: flex; align-items: center; justify-content: center;
    font: 700 28px/1 var(--font); color: var(--ink-42);
}
.person-head__facts { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }

/* The count of tools still out, on the tab that lists them. */
.tabs__badge {
    margin-left: 6px; padding: 0 6px; min-width: 18px;
    font: 700 10px/18px var(--mono); text-align: center;
    color: #fff; background: var(--brand); border-radius: 9px;
}

/* One narrow select per language. auto-fit rather than a fixed count: eleven
   languages on a phone is a column, on a desktop it is three rows. */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.lang-grid .field { margin-bottom: 0; }

/* Label/value pairs for a record that is being read rather than edited — the
   sent invoice, where the form has been replaced by what it says. */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.facts dt { font: 500 10px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-42); }
.facts dd { margin: 0; font: 600 13px/1.5 var(--font); }

/* ── A printable document ────────────────────────────────────────────────── */

/* Always light, whatever the viewer's theme: a dark invoice is not something
   to hand anybody, and printing one wastes a cartridge on the background. */
.printable { background: #f2f3f7; color: #14161c; margin: 0; }

.print-bar {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 16px; background: #fff; border-bottom: 1px solid #e4e6ee;
}

/* A4 at a readable width. mm rather than px because the page it is going to
   is measured in mm, and the two should agree. */
.sheet {
    position: relative;
    max-width: 210mm; margin: 16px auto 48px; padding: 18mm 16mm;
    background: #fff; color: #14161c;
    box-shadow: 0 2px 18px rgba(20, 22, 28, .12);
    font: 400 13px/1.55 var(--font);
}

/* Draft and cancelled say so across the page. Behind the content and pale
   enough to read through, because it is a warning, not a redaction. */
.sheet__stamp {
    position: absolute; inset: 40% 0 auto; margin: 0;
    font: 800 clamp(40px, 12vw, 92px)/1 var(--font); letter-spacing: .04em;
    text-align: center; text-transform: uppercase;
    color: rgba(214, 48, 60, .13);
    transform: rotate(-18deg); pointer-events: none;
}

.sheet__head { display: flex; gap: 24px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 28px; }
.sheet__from h1 { margin: 0 0 6px; font: 700 20px/1.2 var(--font); }
.sheet__from p, .sheet__to p { margin: 0; color: #5a5f6d; }
.sheet__logo { display: block; margin-bottom: 10px; }

.sheet__meta { text-align: right; min-width: 190px; }
.sheet__meta h2 { margin: 0; font: 600 11px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: #5a5f6d; }
.sheet__number { margin: 2px 0 12px; font: 700 22px/1.2 var(--mono); }
.sheet__meta dl { display: grid; grid-template-columns: auto auto; gap: 2px 12px; justify-content: end; margin: 0; }
.sheet__meta dt { font: 500 10px/1.6 var(--mono); text-transform: uppercase; color: #5a5f6d; }
.sheet__meta dd { margin: 0; font-weight: 600; }

.sheet__label { display: block; font: 500 10px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: #5a5f6d; }
.sheet__to { margin-bottom: 24px; }

.sheet__lines { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.sheet__lines th {
    padding: 6px 8px; text-align: left; border-bottom: 2px solid #14161c;
    font: 600 10px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase;
}
.sheet__lines td { padding: 7px 8px; border-bottom: 1px solid #e4e6ee; vertical-align: top; }
/* Figures right-aligned and tabular, so the columns line up down the page and
   a wrong order of magnitude is visible rather than merely present. */
.sheet__lines .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* The totals stack to the right: the figures, then the payable box under
   them. Side by side they would compete, and the box has to win. */
.sheet__totals { display: flex; flex-direction: column; align-items: flex-end; margin-bottom: 22px; }
.sheet__totals dl { display: grid; grid-template-columns: auto auto; gap: 4px 24px; margin: 0; min-width: 300px; }
.sheet__totals dt { color: #5a5f6d; }
.sheet__totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.sheet__totals .grand { padding-top: 6px; border-top: 1px solid #14161c; font: 700 16px/1.4 var(--font); }

.sheet__note { margin-bottom: 20px; color: #5a5f6d; }
.sheet__foot { padding-top: 12px; border-top: 1px solid #e4e6ee; color: #5a5f6d; }
.sheet__foot p { margin: 0 0 2px; }

@media print {
    /* The toolbar is for the screen. Everything else is the document. */
    .print-bar { display: none; }
    .printable { background: #fff; }
    .sheet { max-width: none; margin: 0; padding: 0; box-shadow: none; }
    /* Never split a line's row across two pages — half a charge on each is
       worse than a shorter first page. */
    .sheet__lines tr { break-inside: avoid; }
    .sheet__totals, .sheet__foot { break-inside: avoid; }
}

@page { size: A4; margin: 16mm; }

/* ── The invoice register ────────────────────────────────────────────────── */

/* Balances beside the list on a desk, stacked on a phone — the panel is
   context for the register, so on a narrow screen it belongs above it. */
/* Stacked, the one column is minmax(0, 1fr) so it stays the screen's width;
   the implicit auto column grew to its content and, with the longer Russian
   labels, pushed the register 4px past a 320px phone. */
.ledger { display: grid; gap: var(--gap); align-items: start; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .ledger { grid-template-columns: 300px 1fr; } }
/* Below that the two columns stack, and the balances would land on top of the
   register — a screen and a half of totals before the first invoice. The
   register goes first; the totals are what you scroll to afterwards. */
@media (max-width: 1099px) { .ledger__side { order: 1; } }

.saldo__block { padding: 10px 0; border-bottom: 1px solid var(--line); }
.saldo__period {
    margin: 0 0 4px;
    font: 500 11px/1.4 var(--mono); letter-spacing: .07em; text-transform: uppercase;
    color: var(--ink-60);
}
.saldo__row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 1px 0; }
/* Money in and money out, told apart by more than position: an accountant
   scans this column, they do not read it. */
.saldo__row--in  { color: #10804d; }
.saldo__row--out { color: #c0304a; }
.saldo__row span:first-child { font: 600 13px/1.5 var(--font); font-variant-numeric: tabular-nums; }
.saldo__vat { font: 500 10.5px/1.5 var(--mono); opacity: .75; }

.saldo__total {
    display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
    padding: 7px 0 2px;
}
.saldo__total span {
    font: 500 10px/1.4 var(--mono); letter-spacing: .07em; text-transform: uppercase; color: var(--ink-42);
}
.saldo__total strong { font: 700 15px/1.3 var(--font); font-variant-numeric: tabular-nums; }
.saldo__total--muted strong { font-weight: 600; color: var(--ink-60); }
/* A block's own sum, captioned by the period heading above it rather than by
   a word of its own. */
.saldo__total--sum { justify-content: flex-end; border-top: 1px solid var(--line); margin-top: 4px; }
.saldo__foot { padding-top: 8px; }
.is-in  { color: #10804d; }
.is-out { color: #c0304a; }

.ledger__filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: var(--gap); }
.ledger__filters .tabs { margin-bottom: 0; }
.ledger__filters form { margin-left: auto; }

/* The month bar. A heading inside a table, which is what the register is:
   one continuous list with the months called out as you scroll past them. */
.ledger__month td {
    padding: 7px 10px !important;
    background: var(--surface-2);
    font: 600 12px/1.4 var(--font); letter-spacing: .01em;
}
.table--ledger .num { text-align: right; font-variant-numeric: tabular-nums; }
.table--ledger tr.is-cancelled td { opacity: .5; text-decoration: line-through; }

/* One glyph for the state, so it reads without colour. */
.dot {
    display: inline-flex; align-items: center; justify-content: center;
    width: 20px; height: 20px; border-radius: 50%;
    font: 700 12px/1 var(--font); color: var(--ink-42); background: var(--surface-2);
}
.dot--ok   { color: #fff; background: #10804d; }
.dot--warn { color: #fff; background: #c0304a; }
.dot--muted { opacity: .5; }

/* ── The invoice modal ───────────────────────────────────────────────────── */

/* Tabs driven by radio buttons, so the panes switch with no JavaScript at all
   and the form keeps everything typed into it while you look at the files. */
.modal-tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: var(--gap);
              background: var(--surface-2); border-radius: var(--r-lg); }
/* The radios are siblings of the panes, not children of the strip — see the
   note in the partial. Hidden, but focusable, so the tabs still take a
   keyboard: clip rather than display:none, which would remove them from the
   tab order entirely. */
.modal-tabs__radio { position: absolute; width: 1px; height: 1px; opacity: 0; }
.modal-tabs__radio:focus-visible + .modal-tabs .modal-tabs__tab { outline: 2px solid var(--brand); outline-offset: 2px; }
.modal-tabs__tab {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    min-height: var(--control-h-sm); padding: 0 14px;
    font: 600 13px/1 var(--font); color: var(--ink-60); border-radius: var(--r-md);
}
#inv-tab-data:checked    ~ .modal-tabs [for="inv-tab-data"],
#inv-tab-files:checked   ~ .modal-tabs [for="inv-tab-files"],
#inv-tab-history:checked ~ .modal-tabs [for="inv-tab-history"],
#cust-tab-data:checked      ~ .modal-tabs [for="cust-tab-data"],
#cust-tab-addresses:checked ~ .modal-tabs [for="cust-tab-addresses"],
#cust-tab-contacts:checked  ~ .modal-tabs [for="cust-tab-contacts"],
#cust-tab-banks:checked     ~ .modal-tabs [for="cust-tab-banks"],
#cust-tab-classify:checked  ~ .modal-tabs [for="cust-tab-classify"] {
    color: var(--brand); background: var(--surface); box-shadow: var(--shadow-card);
}
.modal-pane { display: none; }
#inv-tab-data:checked    ~ [data-pane="data"],
#inv-tab-files:checked   ~ [data-pane="files"],
#inv-tab-history:checked ~ [data-pane="history"],
#cust-tab-data:checked      ~ [data-pane="data"],
#cust-tab-addresses:checked ~ [data-pane="addresses"],
#cust-tab-contacts:checked  ~ [data-pane="contacts"],
#cust-tab-banks:checked     ~ [data-pane="banks"],
#cust-tab-classify:checked  ~ [data-pane="classify"] { display: block; }

/* Header fields left, running totals right — the shape of every invoice
   screen an accountant has ever used. */
.inv-grid { display: grid; gap: var(--gap); align-items: start; }
@media (min-width: 900px) { .inv-grid { grid-template-columns: 1fr 240px; } }

.inv-total {
    display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
    padding: 6px 0; border-bottom: 1px solid var(--line);
}
.inv-total span { font: 500 10px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-42); }
.inv-total strong { font: 600 14px/1.3 var(--font); font-variant-numeric: tabular-nums; }
.inv-total--input { display: block; }
.inv-total--input .field__input { margin-top: 4px; text-align: right; }
.inv-total--grand { border-bottom: 2px solid var(--ink); }
.inv-total--grand strong { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.inv-total--owed strong { color: #c0304a; }

/* The line table. Inputs sit flush in the cells: this is a grid to type in,
   not a form with boxes, and the difference is how fast a row goes in. */
.inv-lines { margin-top: var(--gap); }
.table--compact th { padding: 6px 6px; font-size: 10px; }
.table--compact td { padding: 4px 6px; vertical-align: top; }
.table--compact .field__input {
    min-height: 32px; padding: 4px 8px; font-size: 13px; border-radius: var(--r-sm);
}
.table--compact select { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.table--compact .num { text-align: right; font-variant-numeric: tabular-nums; }
.table--compact .field__input.num { text-align: right; }
.field__input--sub { margin-top: 3px; font-size: 11.5px !important; opacity: .8; }

.inv-actions { margin-top: var(--gap); padding-top: var(--gap); border-top: 1px solid var(--line); flex-wrap: wrap; }
.inv-hours { margin-top: var(--gap); }
/* Notes in the action row take a line of their own. Left in the flow beside
   the buttons they would set the row's width and wrap the pay controls onto
   two lines. */
.inv-actions .field__hint { flex: 1 1 100%; margin: 0; }
/* The small forms in that row are a control beside its button, not fields on
   a form: they take the width their value needs rather than growing into
   whatever is going, so the button stays on the line of the box it belongs
   to instead of being pushed under it. */
.inv-actions .clock-drop__row { flex-wrap: nowrap; margin-top: 0; }
.inv-actions .clock-drop__row .field__input { flex: 0 0 auto; width: 148px; }
.inv-actions .clock-drop__row input[type="email"] { width: 232px; }

/* ── The sheet's extra pieces ────────────────────────────────────────────── */

.sheet__parties { display: flex; gap: 20px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 24px; }
.sheet__party { flex: 1 1 260px; }
.sheet__party p { margin: 0; color: #5a5f6d; }
.sheet__context { flex: 0 1 260px; padding: 12px 14px; border: 1px solid #e4e6ee; border-radius: 10px; }
.sheet__context dl { display: grid; grid-template-columns: auto auto; gap: 3px 14px; justify-content: space-between; margin: 6px 0 0; }
.sheet__context dt { color: #5a5f6d; }
.sheet__context dd { margin: 0; font-weight: 600; text-align: right; }

.sheet__line-name { display: block; font-weight: 600; }
.sheet__line-sub { display: block; font: 400 11px/1.5 var(--mono); color: #5a5f6d; }

/* The payable figure, reversed out. The one thing findable at arm's length. */
.sheet__payable {
    display: flex; justify-content: space-between; align-items: center; gap: 24px;
    min-width: 300px; margin-top: 12px; padding: 12px 16px; border-radius: 10px;
    background: #14161c; color: #fff;
}
.sheet__payable span { font: 600 13px/1.4 var(--font); }
.sheet__payable strong { font: 800 22px/1.2 var(--font); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.sheet__part-paid { margin: 8px 0 0; text-align: right; color: #5a5f6d; }

.sheet__pay { display: grid; grid-template-columns: auto 1fr; gap: 2px 16px; margin: 0 0 10px; }
.sheet__pay dt { color: #5a5f6d; }
.sheet__pay dd { margin: 0; font-weight: 600; }
.sheet__legal { font-size: 11px; color: #8a8f9d; }

/* On a phone the A4 margins alone (16mm a side) left 250px for five columns,
   and the 300px totals overran a 320px screen. Screen only — paper keeps A4. */
@media screen and (max-width: 640px) {
    .sheet { margin: 0 0 32px; padding: 24px 16px; box-shadow: none; }
    /* The quote draws its own .sheet inside the layout's; one inset is enough. */
    .sheet .sheet { margin: 0; padding: 0; }
    .sheet__scroll { overflow-x: auto; }
    .sheet__lines th, .sheet__lines td { padding-inline: 4px; }
    .sheet__totals dl, .sheet__payable { min-width: min(300px, 100%); }
}

@media print {
    .sheet__payable { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sheet__parties, .sheet__pay { break-inside: avoid; }
}

/* ── The counterparty card ───────────────────────────────────────────────── */

/* The small form under each child list. Set apart from the table above it so
   it reads as "add one" rather than as another row. */
.child-form {
    margin-top: var(--gap); padding-top: var(--gap);
    border-top: 1px solid var(--line);
}

/* Sectors and categories as tick boxes: both lists are short and closed, a
   company is usually several of each, and seeing what is on offer is half of
   choosing. Columns rather than one long run, because nineteen sectors in a
   single column is a scroll. */
.pick-grid {
    display: grid; gap: 4px 16px; margin-top: 6px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.pick-grid .field--check { margin-bottom: 0; }

/* A search field with its button beside it, in a page head. Shrinks on a
   phone rather than pushing the heading off the row. */
.search-row { display: flex; gap: 6px; align-items: center; flex: 0 1 auto; min-width: 0; }
.search-row input[type="search"] { width: 22ch; min-width: 10ch; }
@media (max-width: 640px) { .search-row { flex: 1 0 100%; } .search-row input[type="search"] { flex: 1; width: auto; } }

/* The one-time code field. Wide-spaced monospace, because six digits copied
   from a phone are read one at a time and a transposed pair has to be
   visible. */
.code-input {
    font: 700 24px/1.2 var(--mono); letter-spacing: .32em; text-align: center;
    padding-left: 12px; padding-right: 0;
}

/* ── The invoice line grid ───────────────────────────────────────────────── */

/* A spreadsheet, not a stack of form controls. Cells butt up against each
   other with one shared rule between them, and the input fills its cell
   entirely — no padding of its own, no border, no rounding. What you are
   typing into should look like the cell it is in. */
.table--grid { border-collapse: collapse; width: 100%; }
.table--grid th {
    padding: 5px 8px; background: var(--surface-2);
    border: 1px solid var(--line);
    font: 600 10px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink-42); text-align: left; white-space: nowrap;
}
.table--grid td { padding: 0; border: 1px solid var(--line); vertical-align: middle; }

.table--grid .field__input,
.table--grid select {
    width: 100%; min-height: 30px; margin: 0;
    padding: 4px 8px; font-size: 13px;
    background: transparent; border: 0; border-radius: 0; box-shadow: none;
}
/* The focused cell is outlined rather than boxed: a border would shift every
   neighbour by a pixel as the caret moves across the row. */
.table--grid .field__input:focus,
.table--grid select:focus { outline: 2px solid var(--brand); outline-offset: -2px; }

.table--grid .num, .table--grid .field__input.num { text-align: right; font-variant-numeric: tabular-nums; }
.table--grid th.num { text-align: right; }
/* The second line under a description: same cell, quieter. */
.table--grid .field__input--sub {
    margin: 0; padding-top: 0; font-size: 11.5px !important;
    color: var(--ink-60); border-top: 1px dashed var(--line);
}
.table--grid tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }

/* Select2 inside a cell has to be the cell. */
.table--grid .select2-container { width: 100% !important; }
.table--grid .select2-container--default .select2-selection--single {
    height: 30px; border: 0; border-radius: 0; background: transparent;
}
.table--grid .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 30px; padding-left: 8px; font-size: 13px;
}
.table--grid .select2-container--default .select2-selection--single .select2-selection__arrow { height: 28px; }

/* The drag handle. Its own column so the cursor has somewhere to grab that is
   not a field somebody is trying to type in. */
.grip-cell { width: 28px; text-align: center; background: var(--surface-2); }
.grip { display: block; cursor: grab; user-select: none; color: var(--ink-42); line-height: 30px; }
.grip:active { cursor: grabbing; }
.table--grid tr.is-dragging { opacity: .45; }

/* Marked for removal. The tick is the only thing left at full strength, so
   the row reads as on its way out and the tick still reads as untickable-back
   -able. Nothing here needs script: :has() is what greys the row. */
.drop-cell { width: 34px; text-align: center; background: var(--surface-2); }
.table--grid tbody tr:has([data-remove]:checked) td { background: var(--error-bg); }
.table--grid tbody tr:has([data-remove]:checked) td:not(.drop-cell) { opacity: .45; }
.table--grid tbody tr:has([data-remove]:checked) .field__input,
.table--grid tbody tr:has([data-remove]:checked) select { text-decoration: line-through; }
.table--grid tr[draggable]:hover .grip { color: var(--brand); }

/* A worked example of the next invoice number. The format string is a small
   language, and one example is worth more than the rules above it. */
.inv-preview {
    display: flex; align-items: baseline; gap: 12px;
    margin-top: var(--gap); padding: 12px 14px;
    background: var(--surface-2); border-radius: var(--r-md);
}
.inv-preview strong { font: 700 18px/1.2 var(--mono); letter-spacing: .02em; }

/* The job's own colour, as a stripe down the row. Narrow on purpose: it is a
   way to recognise a job at a glance, not a decoration competing with the
   name beside it. */
.site-row__colour {
    flex: 0 0 auto; width: 4px; align-self: stretch; min-height: 32px;
    border-radius: 2px;
}

/* How far along a job is. A bar rather than a number, because the question is
   "roughly where is this" and a bar answers it without being read. */
.progress { width: 110px; height: 5px; margin-top: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: 3px; }

/* ── Picture folders ─────────────────────────────────────────────────────── */

/* A folder as a card showing its newest picture. The cover and the count
   answer "what is in there" without opening it, which is the whole reason to
   have folders rather than one long strip. */
.folder-grid {
    display: grid; gap: 12px;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
}
.folder-card {
    position: relative; display: flex; flex-direction: column; gap: 8px;
    padding: 8px; text-decoration: none; color: inherit;
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.folder-card:hover { border-color: var(--brand); box-shadow: var(--shadow-card); }
.folder-card__cover {
    display: block; aspect-ratio: 4 / 3; overflow: hidden;
    background: var(--surface-2); border-radius: var(--r-md);
}
.folder-card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.folder-card__empty {
    display: flex; align-items: center; justify-content: center; height: 100%;
    color: var(--ink-42);
}
.folder-card__name { display: flex; flex-direction: column; gap: 2px; padding: 0 2px 2px; }
.folder-card__name strong { font: 600 13.5px/1.3 var(--font); overflow-wrap: anywhere; }
.folder-card__lock { position: absolute; top: 14px; right: 14px; }

/* ── Statements ──────────────────────────────────────────────────────────── */

/* A balance sheet is read down the indent: the depth says what belongs to
   what, and the subtotals are the only rows in bold. Nothing else is needed —
   colour and rules would fight the numbers for attention. */
.table--statement td { padding: 5px 10px; }
.statement__row--d1 td:first-child { padding-left: 26px; }
.statement__row--d2 td:first-child { padding-left: 42px; }
.statement__row--d3 td:first-child { padding-left: 58px; }
.statement__row--total td {
    font-weight: 650;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
}
.statement__row--total.statement__row--d0 td { border-top-width: 2px; }

/* The entry grid, same idea as the invoice rows: cells, not fields.
   Fixed layout, because an account picker holding "5150 · Reklaam ja turundus"
   otherwise widens the table past its container and pushes the credit column
   off the side of the modal. */
.table--grid { table-layout: fixed; }
.table--grid td { padding: 0; }
.table--grid select, .table--grid .select2 { min-width: 0; max-width: 100%; }
.table--grid .field__input,
.table--grid select {
    width: 100%; border: 0; border-radius: 0; background: transparent;
    padding: 7px 9px;
}
.table--grid .field__input:focus,
.table--grid select:focus { outline: 2px solid var(--brand); outline-offset: -2px; }
.table--grid tfoot td { font-weight: 650; background: var(--surface-2); }

/* Lines shown underneath the entry they belong to. */
.table--nested { margin-top: 4px; background: transparent; }
.table--nested td { padding: 2px 8px; border: 0; font-size: 12.5px; }

/* The annual report is several statements on one sheet. */
.sheet__section { margin-top: 26px; break-inside: avoid; }
.sheet__section h2 { font: 650 15px/1.3 var(--font); margin: 0 0 10px; }
.sheet__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--gap); }

/* The letter, framed. White regardless of theme: it is a preview of what the
   recipient sees in their mail client, not part of this page's design. */
.mail-preview {
    display: block; width: 100%; height: 620px;
    border: 1px solid var(--line); border-radius: var(--r-lg);
    background: #fff;
}

/* A long option wraps rather than being cut off — except while its width is
   being measured, where wrapping would report the width it already has. */
.select2-results__option { white-space: normal; overflow-wrap: anywhere; }
.select2-dropdown.is-measuring .select2-results__option { white-space: nowrap; }
.select2-dropdown.is-measuring { max-width: none; }

/* A picker is never narrower than something you can read and aim at. An empty
   filter select otherwise collapses to its chevron — 46px of nothing, which
   is not a control. Grid cells are the exception: there the column decides. */
.select2-container { min-width: 150px; }
.table--grid .select2-container,
.client-switch .select2-container { min-width: 0; }


/* ── The map on a site card ──────────────────────────────────────────────── */
/* Leaflet paints its own tiles and controls; what belongs here is how the box
   sits in a card, and the two theme touches its stylesheet cannot know about. */
.map {
    width: 100%;
    /* Square, and stated as a ratio rather than a height so it stays square at
       every width without anybody computing one. A letterbox is the wrong
       shape for this job: a site sits in the middle of its surroundings, and
       what you need to see is how far the yard runs in every direction, not a
       wide strip of the street it happens to face. */
    aspect-ratio: 1 / 1;
    /* Bounded by width, not height: capping the height is what would stop it
       being square. A square that fills a 1600px column is one nobody can see
       the bottom of, so it stops growing and the card keeps the rest. */
    max-width: min(78vh, 720px);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    background: var(--surface-2);
    /* Above nothing in particular, but under the drawer and the modal — a map
       that floats over an open menu is a map that has escaped its card. */
    z-index: 0;
}
.map-foot {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    margin-top: 8px;
}
.map-foot .field__hint { margin: 0; }

/* Tiles are photographs of daylight. On the dark theme they are left alone —
   inverting a map makes the labels unreadable — but the frame and the
   attribution strip are ours and follow the theme. */
.leaflet-container { font: inherit; background: var(--surface-2); }
.leaflet-control-attribution {
    background: color-mix(in srgb, var(--surface) 88%, transparent) !important;
    color: var(--ink-60) !important;
    font: 500 10px/1.5 var(--mono) !important;
}
.leaflet-control-attribution a { color: var(--link) !important; }
.leaflet-bar a {
    background: var(--surface); color: var(--ink); border-color: var(--line);
}
.leaflet-bar a:hover { background: var(--surface-2); color: var(--ink); }

/* The picker's clock: two number fields that read as one time. Hand-built
   because <input type="time"> is drawn in the browser's locale, and an
   English-language browser puts AM/PM on a form written in 24-hour time. */
.dp__clock { display: inline-flex; align-items: center; gap: 4px; }
.dp__clock input {
    width: 3.4em; padding: 6px 4px; text-align: center;
    font: 600 14px/1 var(--mono); font-variant-numeric: tabular-nums;
    color: var(--ink); background: var(--surface);
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.dp__clock input:focus { border-color: var(--brand); box-shadow: var(--ring); outline: 0; }
.dp__clock i { font-style: normal; font-weight: 700; color: var(--ink-60); }

/* ── Access explorer ─────────────────────────────────────────────────────── */
/* Three columns per role on a wide screen — people, permissions, sidebar —
   stacked on a phone by .grid-3 itself. Permission keys are long dotted words
   with no natural break, so they are chips that wrap rather than a line that
   pushes the card wider than the screen. */
.access-role__heading {
    margin: 0 0 8px; font: 600 11px/1.3 var(--mono);
    letter-spacing: .06em; text-transform: uppercase; color: var(--ink-42);
}
.access-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.access-people li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.access-people .meta { flex-basis: 100%; overflow-wrap: anywhere; }

.access-perms { margin: 0; display: grid; gap: 6px; }
.access-perms dt { font: 600 12px/1.3 var(--font); color: var(--ink-60); }
.access-perms dd { margin: 0 0 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.access-perms code,
.access-menu__url {
    font: 500 11px/1.5 var(--mono); padding: 0 6px; border-radius: var(--r-sm);
    background: var(--surface-2); color: var(--ink-60); overflow-wrap: anywhere;
}

.access-menu { list-style: none; margin: 6px 0 0; padding: 0; }
.access-menu .access-menu { margin: 2px 0 4px; padding-left: 14px; border-left: 1px solid var(--line); }
.access-menu li { padding: 3px 0; }
.access-menu__label { font-weight: 600; }

.access-hidden { margin-top: 12px; }
.access-hidden summary { cursor: pointer; font: 600 12px/1.4 var(--font); color: var(--ink-60); }
.access-hidden ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; }
.access-hidden li { display: flex; flex-wrap: wrap; gap: 2px 8px; }

/* ── Passkeys ────────────────────────────────────────────────────────────── */
.passkey-login { display: grid; gap: 8px; margin-bottom: 10px; }
.passkey-login .btn svg, .passkey-add .btn svg { width: 16px; height: 16px; }
.passkey-list { list-style: none; margin: 14px 0 0; padding: 0; }
.passkey-list li {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--line);
}
.passkey-list li:last-child { border-bottom: 0; }
.passkey-list li > svg { flex: none; width: 18px; height: 18px; color: var(--ink-42); }
.passkey-list__main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.passkey-list__main .meta { overflow-wrap: anywhere; }
.passkey-add { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; margin-top: 16px; }
.passkey-add .field__error { grid-column: 1 / -1; margin: 0; }
@media (max-width: 560px) { .passkey-add { grid-template-columns: 1fr; } }

/* ── Utilities ───────────────────────────────────────────────────────────── */
/* The handful of one-off adjustments views kept writing as style="" — six
   hundred of them, nine values. Named once here so a spacing change is one
   edit. !important because each replaces an inline style, which outranked
   every rule in this file; anything less would change what renders. */
.mt-gap { margin-top: var(--gap) !important; }
.mb-gap { margin-bottom: var(--gap) !important; }
.mt-0  { margin-top: 0 !important; }
.mb-0  { margin-bottom: 0 !important; }
.m-0   { margin: 0 !important; }
.mt-6  { margin-top: 6px !important; }
.mt-10 { margin-top: 10px !important; }
.mt-12 { margin-top: 12px !important; }
.mt-14 { margin-top: 14px !important; }
.mb-10 { margin-bottom: 10px !important; }
.d-block { display: block !important; }
.text-right { text-align: right !important; }
.uppercase { text-transform: uppercase !important; }
.pre-line { white-space: pre-line !important; }
.span-2 { grid-column: span 2 !important; }
.flex-full { flex: 1 1 100% !important; }
.fs-20 { font-size: 20px !important; }
/* Fixed column widths in tables. */
.w-34  { width: 34px !important; }  .w-80  { width: 80px !important; }
.w-90  { width: 90px !important; }  .w-100 { width: 100px !important; }
.w-104 { width: 104px !important; } .w-110 { width: 110px !important; }
.w-120 { width: 120px !important; } .w-130 { width: 130px !important; }
.w-140 { width: 140px !important; } .w-150 { width: 150px !important; }
.w-170 { width: 170px !important; } .w-180 { width: 180px !important; }
.w-200 { width: 200px !important; } .w-full { width: 100% !important; }
