/* Деловодство — admin panel. Design direction A, "Класическа кантора" (approved by the office).
   Own CSS, no framework, no external requests. Works from 375 px; dark mode via prefers-color-scheme.
   The CSP is style-src 'self': no inline style attributes in templates; icons are CSS masks (data: is allowed
   for images).

   Fonts are self-hosted (privacy: the panel never calls Google Fonts): app/admin/static/fonts/, variable woff2
   from Google Fonts (SIL Open Font License 1.1, fonts/LICENSE.md), split by unicode-range into Cyrillic, Latin,
   Latin Extended (Turkish ğ ş İ) and Greek, so a page loads only the subsets it shows:
     Cormorant Garamond 600-700   display only (no Greek: headings are Bulgarian)
     Source Serif 4 400-600, 400 italic   text serif (client messages, drafts, excerpts)
     IBM Plex Sans 400-600        interface
   Every stack falls back to fonts installed with Windows / macOS (Sitka, Cambria, Georgia, Segoe UI, system-ui).

   Contents: 1 fonts · 2 tokens · 3 base · 4 layout · 5 components · 6 screens · 7 utilities · 8 print, motion */

/* 1. Fonts ------------------------------------------------------------------------------------------------------ */
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600 700; font-display: swap;
  src: url("fonts/CormorantGaramond-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600 700; font-display: swap;
  src: url("fonts/CormorantGaramond-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Cormorant Garamond"; font-style: normal; font-weight: 600 700; font-display: swap;
  src: url("fonts/CormorantGaramond-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/IBMPlexSans-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/IBMPlexSans-greek.woff2") format("woff2"); unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/IBMPlexSans-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/IBMPlexSans-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/SourceSerif4-Italic-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/SourceSerif4-Italic-greek.woff2") format("woff2"); unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/SourceSerif4-Italic-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Serif 4"; font-style: italic; font-weight: 400; font-display: swap;
  src: url("fonts/SourceSerif4-Italic-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/SourceSerif4-cyrillic.woff2") format("woff2"); unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/SourceSerif4-greek.woff2") format("woff2"); unicode-range: U+0370-0377, U+037A-037F, U+0384-038A, U+038C, U+038E-03A1, U+03A3-03FF; }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/SourceSerif4-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Source Serif 4"; font-style: normal; font-weight: 400 600; font-display: swap;
  src: url("fonts/SourceSerif4-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

/* 2. Tokens ----------------------------------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;
  /* paper and ink */
  --paper: #F5F1E8;        /* the ground */
  --sheet: #FCFAF5;        /* a sheet laid on it: memorandum, forms, sign-in */
  --sheet-edge: #E2DACB;
  --draft-bg: #FFFEFB;     /* the draft itself, a shade lighter than its sheet */
  --wash: #ECE5D6;         /* the current menu item, a selected row */
  --wash-2: #F0EADD;       /* hover */
  --ink: #17223A;          /* text, primary action, confirmed (●) */
  --ink-2: #2E3A52;
  --ink-hover: #22304F;
  --on-ink: #FCFAF5;
  --muted: #5E5A51;        /* 6.1:1 on paper */
  --placeholder: #6B665C;
  /* rules (hairlines instead of boxes) */
  --rule: #DCD4C4;         /* between rows */
  --rule-2: #CFC6B4;       /* section and table edges */
  --rule-3: #8A8270;       /* control borders, the dashed proposal (◌) line: 3.4:1 */
  --rule-soft: #E6DFD1;    /* inside a sheet */
  --underline: #BFB5A2;    /* link underline, quiet separators */
  /* accents */
  --brass: #9C7A35;        /* rules and marks only: 3.5:1, not for text */
  --brass-text: #6E5322;   /* brass as text: 6.4:1 */
  --warn: #7A4E0E;         /* calm warning (5.6:1 on its ground) */
  --warn-bg: #EFE3C6;
  --warn-tag: #6B430B;
  --refuse: #8C2F2B;       /* quiet refusal (7.3:1) */
  --refuse-rule: #D9B3AF;
  --refuse-bg: #F7ECE8;
  --toast-bg: #17223A; --toast-fg: #FCFAF5; --toast-rule: #9C7A35;
  --shadow: 0 10px 30px rgba(23, 34, 58, .22);
  /* type */
  --font-display: "Cormorant Garamond", "Sitka Heading", Cambria, Georgia, serif;
  --font-text: "Source Serif 4", "Sitka Text", Cambria, Georgia, serif;
  --font-sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  /* measures */
  --radius: 2px; --tap: 44px; --topbar-h: 64px; --side-w: 248px; --bottombar-h: 60px;
  /* earlier names, still used by older markup */
  --bg: var(--paper); --panel: var(--sheet); --text: var(--ink); --line: var(--rule);
  --primary: var(--ink); --primary-text: var(--on-ink); --danger: var(--refuse); --ok: var(--ink);
  --amber: var(--warn); --proposal: var(--ink); --proposal-bg: transparent; --confirmed-bg: var(--wash);
  --focus: var(--brass);
}
@media (prefers-color-scheme: dark) {
  /* the same character at night: an ink ground, paper text, a brass accent */
  :root {
    --paper: #121A2B; --sheet: #18223A; --sheet-edge: #2A3550; --draft-bg: #1C2742;
    --wash: #222D48; --wash-2: #1C2640;
    --ink: #EDE6D6; --ink-2: #D9D1C0; --ink-hover: #FFFBF2; --on-ink: #121A2B;
    --muted: #A9A190; --placeholder: #9C9483;
    --rule: #2A3550; --rule-2: #36425F; --rule-3: #76809A; --rule-soft: #26304A; --underline: #59637E;
    --brass: #C9A45A; --brass-text: #D8B66E;
    --warn: #E5C27F; --warn-bg: #3A2F17; --warn-tag: #F0D49B;
    --refuse: #EE9A92; --refuse-rule: #7A3B37; --refuse-bg: #2E1C24;
    --toast-bg: #EDE6D6; --toast-fg: #121A2B; --toast-rule: #6E5322;
    --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  }
}

/* 3. Base ------------------------------------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); font: 400 .9375rem/1.5 var(--font-sans);
       -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
::selection { background: #E6D7B5; color: #17223A; }
a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--underline); text-decoration-thickness: 1px;
    text-underline-offset: 3px; }
a:hover { color: var(--brass-text); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1 { margin: 0 0 .5rem; font: 600 clamp(2.125rem, 1.55rem + 1.6vw, 3.125rem)/1.02 var(--font-display); letter-spacing: -.005em; color: var(--ink); }
h2, .h-label { margin: 0 0 .875rem; font: 600 .6875rem/1.4 var(--font-sans); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
/* .h-label: a lower heading level drawn as the small-caps label (the outline stays in order when a display title is the h2) */
h2 a { color: inherit; }
h3 { margin: 1.25rem 0 .5rem; font: 600 .8125rem/1.4 var(--font-sans); letter-spacing: .02em; color: var(--ink); }
p { margin: 0 0 .75rem; }
b, strong { font-weight: 600; }
code, .mono { font-family: var(--font-mono); font-size: .85em; }
code { padding: .05em .3em; background: var(--wash); border-radius: var(--radius); overflow-wrap: anywhere; }
img { max-width: 100%; }
::placeholder { color: var(--placeholder); opacity: 1; }

/* 4. Layout ----------------------------------------------------------------------------------------------------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px 28px; height: var(--topbar-h);
          padding: 0 32px; background: var(--paper); border-bottom: 1px solid var(--brass); }
.brand { display: flex; align-items: center; gap: 12px; min-height: var(--tap); color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); }
.brand-mark { margin-top: -3px; font: 700 2.125rem/1 var(--font-display); color: var(--brass); }
.brand-words { display: flex; flex-direction: column; line-height: 1; }
.brand-name { font: 600 1.75rem/1 var(--font-display); letter-spacing: .01em; }
.brand-sub { margin-top: 5px; font-size: .625rem; font-weight: 500; letter-spacing: .26em; text-transform: uppercase; color: var(--muted); }
.search { position: relative; flex: 1 1 280px; max-width: 460px; margin: 0 auto 0 12px; }
.search::before { content: ""; position: absolute; left: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; pointer-events: none;
                  background: var(--muted); -webkit-mask: var(--i-search) center / contain no-repeat; mask: var(--i-search) center / contain no-repeat; }
.search input[type=search] { min-height: 40px; height: 40px; padding: 0 14px 0 38px; font-size: .875rem; }
.mode { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: .78125rem; color: var(--muted); white-space: nowrap; }
.mode-item { display: inline-flex; align-items: center; gap: 7px; }
.mode-item b { color: var(--ink-2); }
.mode-item + .mode-item { padding-left: 16px; border-left: 1px solid var(--rule-2); }
.profile { display: flex; align-items: center; gap: 10px; min-height: var(--tap); margin-left: auto; color: var(--ink); text-decoration: none; white-space: nowrap; }
.profile:hover { color: var(--ink); }
.profile:hover .profile-name { text-decoration: underline; text-decoration-color: var(--underline); text-underline-offset: 3px; }
.profile-initials { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 1px solid var(--ink);
                    border-radius: 50%; font: 600 .9375rem/1 var(--font-display); letter-spacing: .03em; }
.profile-words { display: flex; flex-direction: column; line-height: 1.25; }
.profile-name { font-size: .875rem; font-weight: 600; }
.profile-role { font-size: .65625rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.sidebar { position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: var(--side-w); padding: 28px 16px 40px 18px; overflow-y: auto;
           background: var(--paper); border-right: 1px solid var(--rule); }
.sidebar ul { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.sidebar a { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 9px 10px; border-radius: var(--radius);
             color: var(--ink-2); font-size: .90625rem; text-decoration: none; }
.sidebar a::before { content: ""; flex: 0 0 14px; height: 2px; }
.sidebar a:hover { background: var(--wash-2); color: var(--ink); }
.sidebar a.active, .sidebar a[aria-current] { background: var(--wash); color: var(--ink); font-weight: 600; }
.sidebar a.active::before, .sidebar a[aria-current]::before { background: var(--brass); }
.sidebar li.group { display: flex; align-items: center; gap: 10px; margin: 26px 0 6px; padding: 0 10px 0 34px; font-size: .65625rem; font-weight: 600;
                    letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.sidebar li.group::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--rule); }
.badge { margin-left: auto; padding: 0; background: none; color: var(--muted); font-size: .78125rem; font-weight: 400;
         font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.badge-attn, .active .badge, [aria-current] .badge { color: var(--ink); font-weight: 600; }

.main { min-width: 0; max-width: calc(var(--side-w) + 1200px); margin-left: var(--side-w); padding: 30px 40px 64px; overflow-wrap: break-word; }
body.anon .main { max-width: none; margin-left: 0; padding: 0 16px 48px; }
.bottombar { display: none; }

@media (max-width: 900px) {
  .topbar { position: static; flex-wrap: wrap; height: auto; padding: 10px 16px 12px; gap: 10px 16px; }
  .brand-name { font-size: 1.5rem; }
  .brand-mark { font-size: 1.875rem; }
  .search { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
  .search input[type=search] { height: var(--tap); min-height: var(--tap); font-size: 16px; }
  .mode { display: none; }
  .profile-words { display: none; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 22px 16px calc(var(--bottombar-h) + 28px); }
  .bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; height: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px));
               padding-bottom: env(safe-area-inset-bottom, 0px); background: var(--paper); border-top: 1px solid var(--brass); }
  .bottombar a { position: relative; flex: 1 1 0; display: flex; align-items: center; justify-content: center; min-height: var(--tap); padding: 0 4px;
                 color: var(--ink-2); font-size: .8125rem; line-height: 1.2; text-align: center; text-decoration: none; }
  .bottombar a[aria-current] { color: var(--ink); font-weight: 600; }
  .bottombar a[aria-current]::before { content: ""; position: absolute; top: -1px; left: 22%; right: 22%; height: 2px; background: var(--ink); }
}

/* the page heading: a display title, an italic serif lede, the actions on the same rule */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 32px; margin: 0 0 26px;
             border-bottom: 1px solid var(--rule-2); }
.page-head > .page-title { min-width: 0; padding-bottom: 16px; }
.page-head h1 { margin: 0; }
.page-head .page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding-bottom: 14px; }
.lede { max-width: 72ch; margin: 10px 0 0; font: italic 400 1.0625rem/1.45 var(--font-text); color: var(--muted); }
.kicker { display: block; margin: 0 0 8px; font-size: .6875rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.h1-aside { font-family: var(--font-display); font-weight: 600; color: var(--muted); font-variant-numeric: lining-nums tabular-nums; }
.h1-marks { display: inline-flex; flex-wrap: wrap; gap: 6px; vertical-align: middle; font-size: 1rem; letter-spacing: 0; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; margin: 0 0 10px; font-size: .78125rem; font-weight: 600;
        letter-spacing: .12em; text-transform: uppercase; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--ink); text-decoration: none; }
p.back-row { margin: 0; }

/* 5. Components ------------------------------------------------------------------------------------------------- */
/* 5.1 Marks: ◌ dashed = proposal (not active until confirmed), ● solid = confirmed, ⊘ = off / refused */
:root {
  --i-proposal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='4.6' fill='none' stroke='black' stroke-width='1.4' stroke-dasharray='1.9 1.6'/%3E%3C/svg%3E");
  --i-confirmed: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='4.2'/%3E%3C/svg%3E");
  --i-off: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='4.6' fill='none' stroke='black' stroke-width='1.2'/%3E%3Cpath d='M2.9 9.1L9.1 2.9' stroke='black' stroke-width='1.2'/%3E%3C/svg%3E");
  --i-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.2 4.2L19 7' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-cross: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 7l10 10M17 7L7 17' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-hourglass: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 3.5h11M6.5 20.5h11M8 3.5c0 4 4 5.5 4 8.5s-4 4.5-4 8.5M16 3.5c0 4-4 5.5-4 8.5s4 4.5 4 8.5' fill='none' stroke='black' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M12 7.5V12l3 2' fill='none' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='6.5' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M16 16l4 4' stroke='black' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-chat: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4.5 5.5h15v10.5H10l-4.5 3.5V5.5z' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-mail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3.5' y='6' width='17' height='12' rx='1' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M4 7l8 6 8-6' fill='none' stroke='black' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-doc: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 3.5h6.5l4 4v13H7zM13.5 3.5v4h4' fill='none' stroke='black' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E");
  --i-info: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='8.5' fill='none' stroke='black' stroke-width='1.6'/%3E%3Ccircle cx='12' cy='8' r='1.2'/%3E%3Cpath d='M12 11v6' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-lock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='5.5' y='10.5' width='13' height='9.5' rx='1' fill='none' stroke='black' stroke-width='1.6'/%3E%3Cpath d='M8.5 10.5V8a3.5 3.5 0 0 1 7 0v2.5' fill='none' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E");
}
.mark, .ico { display: inline-block; flex: none; width: 11px; height: 11px; vertical-align: -1px; background: currentColor;
              -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.mark-proposal { --i: var(--i-proposal); }
.mark-confirmed { --i: var(--i-confirmed); width: 10px; height: 10px; }
.mark-off { --i: var(--i-off); color: var(--muted); }
.ico { width: 13px; height: 13px; vertical-align: -2px; }
.ico-clock { --i: var(--i-clock); } .ico-hourglass { --i: var(--i-hourglass); } .ico-chat { --i: var(--i-chat); }
.ico-mail { --i: var(--i-mail); } .ico-doc { --i: var(--i-doc); width: 14px; height: 14px; } .ico-lock { --i: var(--i-lock); }
.ico-check { --i: var(--i-check); } .ico-cross { --i: var(--i-cross); }
.legend { display: flex; flex-direction: column; gap: 7px; margin: 0; padding: 0; list-style: none; font-size: .78125rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 8px; }
.legend .mark { color: var(--ink); }
.legend-inline { flex-direction: row; flex-wrap: wrap; gap: 4px 16px; }

/* 5.2 Buttons: primary (ink), secondary (hairline), quiet (underlined text), danger (quiet refusal) */
.btn, .btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 16px;
       border: 1px solid var(--rule-3); border-radius: var(--radius); background: transparent; color: var(--ink);
       font: 500 .90625rem/1.2 var(--font-sans); letter-spacing: .005em; text-align: center; text-decoration: none; cursor: pointer;
       transition: background-color .15s ease, border-color .15s ease, color .15s ease; }
.btn:hover, .btn-secondary:hover { border-color: var(--ink); background: var(--wash-2); color: var(--ink); text-decoration: none; }
.btn-primary { padding: 0 22px; border-color: var(--ink); background: var(--ink); color: var(--on-ink); font-weight: 600; letter-spacing: .01em; }
.btn-primary:hover { border-color: var(--ink-hover); background: var(--ink-hover); color: var(--on-ink); }
.btn-quiet, .btn-link { min-height: var(--tap); padding: 0 6px; border-color: transparent; background: none; color: var(--muted);
                        text-decoration: underline; text-decoration-color: var(--underline); text-underline-offset: 4px; }
.btn-quiet:hover, .btn-link:hover { border-color: transparent; background: none; color: var(--ink); text-decoration-color: currentColor; }
.btn-danger { padding: 0 8px; border-color: transparent; background: none; color: var(--refuse); text-decoration: underline;
              text-decoration-color: var(--refuse-rule); text-underline-offset: 5px; }
.btn-danger:hover { border-color: transparent; background: var(--refuse-bg); color: var(--refuse); text-decoration-color: currentColor; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: .84375rem; }
.btn-small.btn-danger, .btn-small.btn-quiet { padding: 0 6px; }
.btn-block { width: 100%; }
.btn-undo { min-height: 40px; border-color: var(--toast-rule); background: transparent; color: var(--toast-fg); font-weight: 600; }
.btn-undo:hover { border-color: var(--toast-fg); background: transparent; color: var(--toast-fg); }
button[disabled], .btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn-primary[disabled]:hover { background: var(--ink); }
@media (pointer: coarse) { .btn-small, .btn-undo { min-height: var(--tap); } }

/* 5.3 Forms */
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  display: block; width: 100%; min-height: var(--tap); padding: .5rem .75rem; border: 1px solid var(--rule-3); border-radius: var(--radius);
  background: var(--sheet); color: var(--ink); font: 400 1rem/1.35 var(--font-sans); letter-spacing: normal; text-transform: none;
  transition: border-color .15s ease, box-shadow .15s ease; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--ink); outline: 2px solid var(--focus); outline-offset: 1px; }
select { padding-right: 2rem; }
textarea { min-height: 7rem; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--ink); vertical-align: -3px; }
label { display: block; margin: 0 0 14px; font-size: .8125rem; font-weight: 600; color: var(--ink); }
label > input, label > select, label > textarea { margin-top: 6px; }
/* a label around a checkbox or radio: the whole line is the 44 px target (:where keeps the specificity low) */
label.inline, label:where(:has(> input[type=checkbox]), :has(> input[type=radio])) {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); margin: 0 16px 0 0; font-size: .90625rem; font-weight: 400; }
fieldset { margin: 0 0 14px; padding: 10px 14px 14px; border: 1px solid var(--rule-2); border-radius: var(--radius); }
legend { padding: 0 6px; font-size: .8125rem; font-weight: 600; color: var(--ink); }
.choices { display: flex; flex-direction: column; }
.choices label { margin-right: 0; }
.hint { margin: 6px 0 0; font-size: .78125rem; font-weight: 400; color: var(--muted); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 28px; }
.form-grid > .span-2, .form-grid > div:last-child { grid-column: 1 / -1; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-top: 6px; }
.code-input { max-width: 8.5em; display: inline-block; font-variant-numeric: tabular-nums; letter-spacing: .08em; }
input.code-input { min-height: 36px; padding: .25rem .5rem; }

/* filter bar: small-caps field labels, hairline beneath */
form.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; margin: 0 0 22px; padding: 0 0 18px; border-bottom: 1px solid var(--rule); }
form.filters label { flex: 1 1 150px; max-width: 280px; margin: 0; font-size: .65625rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
form.filters label.inline, form.filters label:has(> input[type=checkbox]) { flex: 0 1 auto; max-width: none; font-size: .875rem; font-weight: 400;
  letter-spacing: normal; text-transform: none; color: var(--ink); }
form.filters .btn { align-self: flex-end; }
form.filters .filters-actions { display: flex; flex-wrap: wrap; gap: 8px; align-self: flex-end; }

/* 5.4 Tables, ledger style: a ruled head, hairlines between rows, tabular figures */
.table-wrap { overflow-x: auto; margin: 0 0 22px; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; background: none; font-size: .90625rem; font-variant-numeric: tabular-nums lining-nums; }
.table th, .table td { padding: 12px 12px; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.table thead th { padding-top: 0; padding-bottom: 10px; border-bottom: 1px solid var(--ink); font-size: .65625rem; font-weight: 600; line-height: 1.3;
                  letter-spacing: .14em; text-transform: uppercase; color: var(--muted); vertical-align: bottom; white-space: nowrap; }
.table thead th.num { text-align: right; }
.table th:first-child, .table td:first-child { padding-left: 0; }   /* the ledger starts on the page edge */
.table th:last-child, .table td:last-child { padding-right: 0; }
.table tr.confirmed > td:first-child, .table tr.proposal > td:first-child { padding-left: 10px; }
.table tbody tr:last-child > * { border-bottom-color: var(--rule-2); }
.table tbody tr:hover > td { background: var(--wash-2); }
.table a { text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table td.num, .table th.num { text-align: right; white-space: nowrap; }
.table .row { flex-wrap: wrap; }
.table td.actions { min-width: 15rem; }
.table td.actions .row { gap: 6px 4px; }
.table .check-cell { width: 44px; padding: 0; vertical-align: top; }
.check-hit { display: flex; align-items: center; justify-content: center; width: 44px; min-height: 44px; margin: 0; cursor: pointer; }
.table tbody tr:has(input[name=ids]:checked) > td { background: var(--wash); }
.table td.empty-cell, .table td[colspan].muted { padding: 22px 12px; font: italic 400 1rem/1.5 var(--font-text); color: var(--muted); }
.table tr.confirmed > td { background: var(--wash); }
.table tr.confirmed > td:first-child { box-shadow: inset 2px 0 0 var(--ink); }
.table tr.proposal > td { border-bottom-style: dashed; border-bottom-color: var(--rule-3); }
.table tr.muted > td { color: var(--muted); }
.table-compact th, .table-compact td { padding: 8px 10px; }
.cell-title { font-weight: 600; }
.cell-sub { display: block; margin-top: 2px; font-size: .78125rem; color: var(--muted); }
.cell-sub + .cell-sub { margin-top: 0; }

/* 5.5 Chips: small hairline labels; dashed = proposal, solid ink = confirmed */
.chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 8px 1px; border: 1px solid var(--rule-2); border-radius: var(--radius);
        background: transparent; color: var(--ink-2); font: 500 .75rem/1.5 var(--font-sans); letter-spacing: .01em; text-decoration: none;
        vertical-align: middle; }
/* A chip is laid out as one piece and only wraps inside when it alone is wider than its line (a sentence or a long
   name on a 375 px phone), so the page never scrolls sideways. In a ledger cell a short label stays on one line. */
.table .chip:not(.chip-amber), .tab .chip { white-space: nowrap; }
a.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip-proposal { border: 1px dashed var(--rule-3); background: transparent; color: var(--ink); }
.chip-confirmed { border-color: var(--ink); color: var(--ink); background: transparent; }
.chip-muted { border-color: var(--rule); color: var(--muted); }
.chip-danger { border-color: var(--refuse-rule); color: var(--refuse); }
.chip-amber { border-color: transparent; background: var(--warn-bg); color: var(--warn); }
.tag { display: inline-block; padding: 4px 6px 3px; border-radius: var(--radius); font-size: .625rem; font-weight: 600; line-height: 1;
       letter-spacing: .12em; text-transform: uppercase; }
.tag-soon { background: var(--warn-bg); color: var(--warn-tag); }
.tag-lang { border: 1px solid var(--underline); color: var(--ink); letter-spacing: .08em; }
.state { display: inline-flex; align-items: center; gap: 7px; font-size: .8125rem; color: var(--ink); }
.state.is-proposal .mark { color: var(--ink); }
.state.is-off { color: var(--muted); }
.proposal { border: 1px dashed var(--rule-3); border-radius: var(--radius); background: var(--proposal-bg); }
dd.proposal { padding: 6px 10px; }
.confirmed { border-left: 2px solid var(--ink); }

/* 5.6 Tabs (filter chips of a list): underline tabs on the heading rule */
.tabs { display: flex; flex-wrap: wrap; gap: 0 26px; margin: 0; padding: 0; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: var(--tap); margin-bottom: -1px; padding: 10px 0 11px;
       border-bottom: 2px solid transparent; color: var(--muted); font-size: .875rem; font-weight: 500; text-decoration: none; white-space: nowrap;
       font-variant-numeric: tabular-nums lining-nums; }
.tab:hover { color: var(--ink); border-bottom-color: var(--rule-3); text-decoration: none; }
.tab[aria-current], .tab.is-active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.tabs-ruled { margin: -12px 0 22px; border-bottom: 1px solid var(--rule-2); gap: 0 22px; }
@media (max-width: 760px) {
  .tabs-ruled, .page-head .tabs { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; scrollbar-width: none; }
}

/* 5.7 Ruled sections (the former cards), sheets, key-value ledgers, figures */
.card { margin: 0 0 10px; padding: 18px 0 24px; border: 0; border-top: 1px solid var(--rule-2); border-radius: 0; background: none; }
.card > h2:first-child, .section-head { margin-top: 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; margin-bottom: 14px; }
.section-head h2 { margin: 0; }
.section-head .aside { font-size: .75rem; color: var(--muted); }
.sheet { margin: 0 0 24px; padding: 24px 28px; background: var(--sheet); border: 1px solid var(--sheet-edge); border-top: 2px solid var(--ink); }
.sheet > :last-child { margin-bottom: 0; }
.sheet.proposal { border: 1px dashed var(--rule-3); }  /* a proposal is never drawn solid */
.sheet.proposal h2 { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 32px; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); } }
.kv { display: grid; grid-template-columns: minmax(8.5rem, max-content) minmax(0, 1fr); gap: 0 24px; margin: 0 0 18px; font-variant-numeric: tabular-nums lining-nums; }
.kv dt, .kv dd { padding: 8px 0; border-bottom: 1px solid var(--rule); }
.kv dt { color: var(--muted); font-size: .8125rem; line-height: 1.6; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 600px) {
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dt { padding-bottom: 0; border-bottom: 0; font-size: .65625rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
}
.plain { margin: 0; padding: 0; list-style: none; }
.plain li { padding: 9px 0; border-bottom: 1px solid var(--rule); }
.plain li:last-child { border-bottom-color: var(--rule-2); }
.plain li.muted, .plain .empty-item { font: italic 400 1rem/1.5 var(--font-text); }
.timeline li { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr); gap: 0 16px; font-size: .875rem; }
.timeline li.muted { display: block; }
.timeline .when { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums lining-nums; }
@media (max-width: 600px) { .timeline li { grid-template-columns: minmax(0, 1fr); } }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 0 0 30px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule-2); }
.figure { display: flex; flex-direction: column; gap: 6px; min-height: 120px; padding: 18px 22px 20px; border-left: 1px solid var(--rule); color: var(--ink); text-decoration: none; }
.figure:first-child { border-left: 0; padding-left: 0; }
a.figure:hover { color: var(--ink); text-decoration: none; }
a.figure:hover .figure-n { color: var(--brass-text); }
.figure-n { font: 600 2.75rem/1 var(--font-display); font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.01em; }
.figure-l { font-size: .8125rem; color: var(--muted); }
a.figure .figure-l { text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
a.figure:hover .figure-l { color: var(--ink); text-decoration-color: var(--underline); }
.figure .bar { margin-top: auto; }
@media (max-width: 600px) {
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .figure { min-height: 0; padding: 14px 12px 16px; border-bottom: 1px solid var(--rule); }
  .figure:nth-child(2n+1) { border-left: 0; padding-left: 0; }
  .figure-n { font-size: 2.125rem; }
}
.stat { font: 600 2.5rem/1.05 var(--font-display); font-variant-numeric: lining-nums tabular-nums; color: var(--ink); margin: 0 0 6px; }
.stat-unit { font-family: var(--font-sans); font-size: .875rem; font-weight: 500; color: var(--muted); }

/* progress: <progress class="bar"> (inline style widths are blocked by the CSP); .bar > span kept for older markup */
.bar { display: block; width: 100%; height: 6px; margin: 8px 0; overflow: hidden; border: 0; border-radius: 0; background: var(--rule); color: var(--ink);
       -webkit-appearance: none; appearance: none; }
.bar > span { display: block; height: 100%; background: var(--ink); }
progress.bar::-webkit-progress-bar { background: var(--rule); }
progress.bar::-webkit-progress-value { background: var(--ink); }
progress.bar::-moz-progress-bar { background: var(--ink); }
.bar-sm { width: 120px; }

/* 5.8 Flash notices and the undo toast */
.flash { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--rule-2); border-left: 3px solid var(--ink);
         border-radius: var(--radius); background: var(--sheet); color: var(--ink); font-size: .90625rem; line-height: 1.5; }
.flash::before { content: ""; flex: none; width: 10px; height: 10px; margin-top: 6px; background: currentColor; -webkit-mask: var(--i) center / contain no-repeat;
                 mask: var(--i) center / contain no-repeat; --i: var(--i-confirmed); }
.flash-ok { border-left-color: var(--ink); }
.flash-info { border-color: var(--warn-bg); border-left-color: var(--brass); background: var(--sheet); }
/* an informational notice is not a proposal: an (i), never the dashed ◌ */
.flash-info::before { --i: var(--i-info); width: 15px; height: 15px; margin-top: 3px; background: var(--brass-text); }
.flash-warn { border-color: transparent; border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn); }
.flash-warn::before { --i: var(--i-hourglass); width: 14px; height: 14px; margin-top: 4px; }
.flash-error { border-color: var(--refuse-rule); border-left-color: var(--refuse); background: var(--refuse-bg); color: var(--refuse); }
.flash-error::before { --i: var(--i-cross); width: 14px; height: 14px; margin-top: 4px; }
.flash.small { font-size: .8125rem; }
.flash a { color: inherit; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
         gap: 10px 18px; width: max-content; max-width: min(680px, calc(100vw - 32px)); padding: 10px 12px 10px 18px; translate: -50% 0;
         border-top: 2px solid var(--toast-rule); border-radius: var(--radius); background: var(--toast-bg); color: var(--toast-fg);
         box-shadow: var(--shadow); font-size: .90625rem; animation: toast-in .24s ease-out both; }
.toast .count { font-variant-numeric: tabular-nums lining-nums; }
.toast.gone { display: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (max-width: 600px) { .toast { left: 16px; right: 16px; width: auto; max-width: none; translate: none; } }

/* 5.9 Pagination, empty states, sticky action bars */
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 8px 0 24px; padding-top: 14px; border-top: 1px solid var(--rule); }
.pager .btn { min-width: 8.5rem; }
.pager-page { font-size: .6875rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.empty { margin: 0 0 24px; padding: 26px 0; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
         font: italic 400 1.0625rem/1.5 var(--font-text); color: var(--muted); }
.empty::before { content: "§"; display: block; margin-bottom: 4px; font: 600 1.5rem/1 var(--font-display); font-style: normal; color: var(--brass); }
.card > .empty, .card .empty { border: 0; padding: 6px 0; }
.card .empty::before { display: none; }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 18px 0 0;
                  padding: 14px 0 16px; border-top: 1px solid var(--rule-2); background: var(--paper); }
.sheet .sticky-actions { margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px; background: var(--sheet); }
.bulkbar { position: sticky; top: var(--topbar-h); z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 0;
           padding: 10px 0; border-bottom: 1px solid var(--ink); background: var(--paper); }
.bulkbar .bulk-hint { font-size: .78125rem; color: var(--muted); }
.bulkbar .spacer { flex: 1 1 8px; }
@media (max-width: 900px) {
  .sticky-actions { bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px)); }
  .toast { bottom: calc(var(--bottombar-h) + 16px); }
  .bulkbar { position: static; }  /* on a phone the bar would only cover the list */
  .sheet { padding: 18px 16px; }
  .sheet .sticky-actions { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
}

/* 5.10 The client strip (who this page is about) */
.client-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 14px; padding: 0 0 12px; border-bottom: 1px solid var(--rule);
              background: none; font-size: .875rem; }
.initials { --hue: 35; display: inline-flex; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%;
            background: hsl(var(--hue) 26% 32%); color: #FCFAF5; font: 600 .875rem/1 var(--font-display); letter-spacing: .04em; text-transform: uppercase; }
@media (prefers-color-scheme: dark) { .initials { background: hsl(var(--hue) 30% 74%); color: #121A2B; } }
.initials-lg { width: 44px; height: 44px; font-size: 1.1875rem; }
.initials-sm { width: 22px; height: 22px; font-size: .625rem; letter-spacing: .02em; }
.client-bar-name { font-weight: 600; }
.client-bar-name a { text-decoration: none; }
.client-bar-case { color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.client-bar-case a { color: var(--ink-2); }

/* 5.11 Sign-in and other pages without a session: a centred sheet */
.anon-mark { display: flex; justify-content: center; padding: 8vh 0 18px; }
.anon-mark .brand-mark { font-size: 2.25rem; }
.auth-card { width: 100%; max-width: 440px; margin: 10vh auto 8vh; padding: 30px 32px 26px; background: var(--sheet); border: 1px solid var(--sheet-edge);
             border-top: 2px solid var(--ink); box-shadow: 0 1px 0 var(--rule-soft); }
.auth-card.wide { max-width: 580px; }
.anon-mark ~ .main .auth-card { margin-top: 0; }
.auth-card h1 { margin: 0 0 6px; font-size: 2.25rem; text-align: left; }
.auth-card .lede { margin: 0 0 22px; font-size: 1rem; }
.auth-card .btn-block { margin-top: 8px; }
.auth-card form.inline { display: block; margin-top: 10px; text-align: center; }
.auth-foot { margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--rule-soft); font-size: .78125rem; color: var(--muted); }
.auth-seal { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 0 0 22px; padding-bottom: 20px; border-bottom: 1px solid var(--rule-soft); text-align: center; }
.auth-seal .brand-mark { margin: 0; font-size: 2.5rem; }
.auth-seal h1 { margin: 0; font-size: 2.5rem; text-align: center; }
.auth-seal .brand-sub { margin: 0; }
.qr { display: block; margin: 10px 0 6px; padding: 8px; background: #fff; border: 1px solid var(--rule-2); border-radius: var(--radius); }
.secret { display: inline-block; padding: .2em .45em; font-size: 1.05rem; letter-spacing: .08em; word-break: break-all; }
.steps { margin: 0 0 18px; padding-left: 1.4rem; }
.steps li { margin: .65rem 0; padding-left: .25rem; }
.steps li::marker { font-family: var(--font-display); font-weight: 600; color: var(--brass-text); }
@media (max-width: 600px) { .anon-mark { padding-top: 32px; } .auth-card { padding: 24px 18px 20px; } }

/* 5.12 Etap 2 slots (app/admin/etap2.py): where Etap 2 will live, shown now and inactive. Their mark is their own:
   small capitals in a double brass rule, a frame nothing else uses - never dashed (◌ = a proposal) and never solid
   ink (● = confirmed). The slots are text, not controls: muted, an arrow cursor, nothing changes on hover. The tag is
   always followed by a visible "още не работи" (.e2-state), in the italic voice of a note, so no slot reads as a
   working feature. A slot never takes a ledger column: on "Дела" its future columns are one titled line above it. */
.tag-e2 { flex: none; padding: 3px 5px 2px; border: 3px double var(--brass); border-radius: 0; background: transparent;
          color: var(--brass-text); font-family: var(--font-sans); font-style: normal; letter-spacing: .1em; white-space: nowrap;
          vertical-align: middle; }
.e2-state { font: italic 400 .8125rem/1.35 var(--font-text); letter-spacing: normal; text-transform: none; color: var(--muted);
            white-space: nowrap; }
[data-etap2] { cursor: default; }
.sidebar li.e2-slot { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; align-items: center; gap: 1px 10px;
                      min-height: var(--tap); padding: 9px 10px; color: var(--muted); font-size: .90625rem; }
.sidebar li.e2-slot::before { content: ""; height: 2px; }
.sidebar li.e2-slot .e2-state { grid-column: 2 / -1; }   /* under the label: the menu is too narrow for one line */
.e2-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.e2-desc { display: block; max-width: 62ch; margin: 0; font: italic 400 1rem/1.5 var(--font-text); color: var(--muted); }
.e2-group { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: -8px 0 26px; }
form.filters + .e2-group { margin: -4px 0 18px; }   /* "Дела": between the filters and the ledger */
.e2-group-title { font-size: .65625rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.e2-chips { display: flex; flex-wrap: wrap; gap: 6px 8px; margin: 0; padding: 0; list-style: none; }
.chip-e2 { border-color: var(--rule-2); color: var(--muted); }
.legend .tag-e2 { padding: 2px 4px 1px; }

/* 6. Screens ---------------------------------------------------------------------------------------------------- */
/* 6.1 Одобрение — the queue */
.queue-layout { display: grid; grid-template-columns: minmax(0, 46rem) minmax(13rem, 1fr); gap: 28px 56px; align-items: start; }
.queue-aside { position: sticky; top: calc(var(--topbar-h) + 26px); padding-top: 4px; font-size: .8125rem; color: var(--muted); }
.queue-aside p { margin: 0 0 18px; font: italic 400 .9375rem/1.5 var(--font-text); }
@media (max-width: 1100px) { .queue-layout { grid-template-columns: minmax(0, 1fr); } .queue-aside { position: static; } }
.queue { margin: 0 0 24px; padding: 0; list-style: none; border-top: 1px solid var(--rule); }
.queue > li { border-bottom: 1px solid var(--rule); }
.queue-item { display: block; padding: 15px 16px 15px 14px; color: var(--ink); text-decoration: none; transition: background-color .15s ease; }
.queue-item:hover { background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); text-decoration: none; }
.qi-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
/* The client's name is never cut at the end (docs/08 4.7: two names that differ only at the end must not look the
   same): it wraps. The question and the draft are shortened in the middle on the server (|mid) and wrap too. */
.qi-name { display: inline-flex; align-items: flex-start; gap: 8px; min-width: 0; font-size: .9375rem; font-weight: 600; line-height: 1.45; }
.qi-name > .mark { margin-top: 5px; }
.qi-name > span:last-child { min-width: 0; overflow-wrap: anywhere; }
.qi-when, .qi-meta, .qi-foot { font-size: .78125rem; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.qi-when { flex: none; white-space: nowrap; }
.qi-meta, .qi-msg, .qi-draft, .qi-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 5px; padding-left: 19px; }
.qi-msg { display: block; margin-top: 7px; font: 400 .90625rem/1.45 var(--font-text); color: var(--ink-2); overflow-wrap: anywhere; }
.qi-draft { display: block; font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.qi-draft b { font-weight: 600; letter-spacing: .12em; text-transform: uppercase; font-size: .65625rem; color: var(--ink-2); }
.qi-foot { margin-top: 8px; }
.qi-foot .sep { width: 1px; height: 12px; background: var(--rule-2); }
.win { display: inline-flex; align-items: center; gap: 6px; }
.win-soon { color: var(--warn); font-weight: 600; }
.win-amber { color: var(--warn); }
.win-closed { color: var(--refuse); font-weight: 600; }

/* 6.2 Одобрение — the memorandum (six regions with roman-numbered margin headings) */
.memo { max-width: 64rem; margin: 0 0 24px; background: var(--sheet); border: 1px solid var(--sheet-edge); border-top: 2px solid var(--ink); overflow-wrap: anywhere; }
.memo-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; padding: 12px 28px; border-bottom: 1px solid var(--rule-soft); }
.memo-bar .aside { font-size: .78125rem; color: var(--muted); }
.steps-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0; padding: 0; list-style: none; }
.steps-line li { display: inline-flex; align-items: center; gap: 6px; font-size: .78125rem; color: var(--muted); }
.steps-line li + li::before { content: ""; display: inline-block; width: 18px; height: 1px; margin-right: 4px; background: var(--underline); }
.steps-line .is-done, .steps-line .is-current { color: var(--ink); }
.steps-line .is-current { font-weight: 600; }
.steps-line .is-off { color: var(--muted); font-weight: 600; }
.memo-sec { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px 24px; padding: 18px 28px; border-bottom: 1px solid var(--rule-soft); }
.memo-sec:last-child { border-bottom: 0; }
.memo-marg { min-width: 0; }
.roman { display: block; font: 600 1.3125rem/1 var(--font-display); color: var(--ink); }
.memo-marg h3 { margin: 7px 0 0; font-size: .65625rem; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.memo-marg p { margin: 6px 0 0; font-size: .71875rem; line-height: 1.35; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.memo-marg .mark { width: 18px; height: 18px; color: var(--ink); }
.memo-body { min-width: 0; }
.memo-body > :last-child { margin-bottom: 0; }
.memo-note { margin: 0 0 10px; font-size: .78125rem; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.memo-object { display: flex; align-items: flex-start; gap: 16px; }   /* region I: the client strip */
.memo-object > .initials { margin-top: 2px; }
.memo-object-text { flex: 1 1 auto; min-width: 0; }
.memo-name { margin: 0; font: 600 1.875rem/1.1 var(--font-display); color: var(--ink); }
.memo-name a { text-decoration: none; }
.memo-line { margin: 8px 0 0; font-size: .90625rem; }
.memo-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 8px 0 0; font-size: .8125rem; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.memo-meta > span { display: inline-flex; align-items: center; gap: 6px; }
.memo-meta strong { color: var(--ink); font-weight: 500; }
.memo-decision { position: sticky; bottom: 0; z-index: 2; margin-top: -1px; padding: 16px 28px 18px; border-top: 1px solid var(--rule-2); background: var(--sheet); }
.decision-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.decision-row .spacer { flex: 1 1 8px; }
.decision-note { display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0; font-size: .78125rem; color: var(--muted); }
.decision-note > .initials { margin-top: -2px; }   /* the same colour as region I, in sight when the thumb is on "Изпрати" */
.memo-decision details[open] { flex-basis: 100%; }
.memo-decision details > summary { display: inline-flex; }
.memo-decision .refuse-form { margin-top: 12px; }
.label-draft { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .6875rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.label-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 16px; margin-bottom: 10px; }
.label-row .aside { font-size: .78125rem; color: var(--muted); }
.draft { padding: 16px 18px; border: 1px dashed var(--rule-3); border-radius: var(--radius); background: var(--draft-bg); color: var(--ink);
         font: 400 1.0625rem/1.62 var(--font-text); white-space: pre-wrap; }
.draft-subject { margin: 0 0 8px; font-size: .8125rem; color: var(--muted); }
.draft-subject b { color: var(--ink); }
.memo-edit { margin-top: 12px; }
.memo-edit textarea { font: 400 1.0625rem/1.6 var(--font-text); border-style: dashed; border-color: var(--ink); background: var(--draft-bg); }
.memo-edit .hint { margin-bottom: 10px; }
@media (max-width: 900px) { .memo-decision { bottom: calc(var(--bottombar-h) + env(safe-area-inset-bottom, 0px)); } }
@media (max-width: 760px) {
  .memo-bar, .memo-sec, .memo-decision { padding-left: 16px; padding-right: 16px; }
  .memo-sec { grid-template-columns: minmax(0, 1fr); }
  .memo-marg { display: flex; align-items: baseline; gap: 10px; }
  .memo-marg h3, .memo-marg p { margin: 0; }
  .memo-marg .mark { width: 14px; height: 14px; align-self: center; }
  .memo-decision { padding-top: 12px; padding-bottom: 12px; }
  .memo-decision .memo-marg { display: none; }
  .decision-row .btn-primary { flex: 1 1 auto; }
}

/* the conversation (region II) */
.transcript { display: flex; flex-direction: column; gap: 14px; margin: 0; padding: 0; list-style: none; }
.bubble { max-width: none; margin: 0; padding: 0; border: 0; border-radius: 0; background: none; white-space: pre-wrap; }
.bubble .meta { display: block; margin-bottom: 4px; font-family: var(--font-sans); font-size: .78125rem; font-style: normal; color: var(--muted);
                white-space: normal; font-variant-numeric: tabular-nums lining-nums; }
.bubble.in { position: relative; padding-left: 24px; font: 400 1.0625rem/1.5 var(--font-text); color: var(--ink); }
.bubble.in::before { content: "\201C"; position: absolute; left: -2px; top: 14px; font: 600 2.875rem/1 var(--font-display); color: var(--underline); }
.bubble.out { margin-left: 24px; padding-left: 14px; border-left: 2px solid var(--rule-2); font: italic 400 .9375rem/1.5 var(--font-text); color: var(--ink-2); }
.bubble.out .meta { font-style: normal; }

/* the sources (region IV) */
.sources { display: flex; flex-direction: column; gap: 12px; margin: 0 0 16px; padding: 0; list-style: none; counter-reset: src; }
.sources > li { display: flex; gap: 12px; align-items: flex-start; counter-increment: src; }
.sources > li::before { content: counter(src); flex: 0 0 14px; font: 600 1.1875rem/1.1 var(--font-display); color: var(--muted); font-variant-numeric: lining-nums; }
.source-file { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; margin: 0; font-size: .84375rem; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.source-file a { font-weight: 500; color: var(--ink); }
.source-quote { margin: 4px 0 0; font: italic 400 .9375rem/1.5 var(--font-text); color: var(--ink-2); }
.kv-memo { margin-top: 4px; }

/* the checks (region V): <li class="ok"> and <li class="bad"> */
.checks { display: flex; flex-direction: column; gap: 7px; margin: 0 0 12px; padding: 0; list-style: none; }
.checks li { display: flex; align-items: flex-start; gap: 10px; font-size: .875rem; line-height: 1.4; color: var(--ink); }
.checks li::before { content: ""; flex: none; width: 15px; height: 15px; margin-top: 2px; background: currentColor;
                     -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.checks li.ok::before { --i: var(--i-check); }
.checks li.bad { color: var(--refuse); font-weight: 600; }
.checks li.bad::before { --i: var(--i-cross); }
.checks li .small { font-weight: 400; }

/* 6.3 За свързване */
.cat { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--rule); }
.cat:last-child { border-bottom-color: var(--rule-2); }
.cat-name { font-weight: 600; }
.cat-counts { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 3px; font-size: .78125rem; color: var(--muted); font-variant-numeric: tabular-nums lining-nums; }
.cat-counts span { display: inline-flex; align-items: center; gap: 5px; }
.cat-counts .mark { color: var(--ink); }
.cat-side { display: flex; align-items: center; gap: 16px; }
.cat-side .bar { margin: 0; }
@media (max-width: 600px) { .cat { grid-template-columns: minmax(0, 1fr); } .cat-side { justify-content: space-between; } }
.folder-name { display: inline-flex; align-items: baseline; gap: 8px; }
.folder-name .mark { align-self: center; color: var(--ink); }
.consequence { margin: 0 0 14px; padding: 12px 16px; border-left: 2px solid var(--brass); background: var(--sheet); font-size: .90625rem; }
.consequence b:first-child { font-weight: 600; }
.sub-list { margin: 8px 0 14px; padding: 0; list-style: none; }
.sub-list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--rule); font-size: .875rem; }
.sub-list li .mark { color: var(--ink); }
.entry-title { margin: 0 0 4px; font: 600 1.5rem/1.15 var(--font-display); color: var(--ink); letter-spacing: 0; text-transform: none; }
.entry-title a { text-decoration: none; }
.entry-title .chip { font-family: var(--font-sans); }

/* 6.4 Профил: "Още" lists the side-menu screens on a phone */
.more-menu { display: none; }
.more-menu a { display: flex; align-items: center; justify-content: space-between; min-height: var(--tap); font-size: 1rem; text-decoration: none; }
.more-menu a::after { content: "\203A"; color: var(--muted); }
.more-menu .plain li { padding: 0; }
.more-menu .plain li.e2-more { display: flex; flex-direction: column; gap: 4px; padding: 10px 0 12px; color: var(--muted); }
.e2-more-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-height: 28px; font-size: 1rem; }
.e2-more .e2-desc { font-size: .875rem; }
@media (max-width: 900px) { .more-menu { display: block; } .desktop-only { display: none; } }

/* 6.5 Система */
.light { display: inline-block; width: 14px; height: 14px; margin-right: .55rem; border-radius: 50%; vertical-align: .18em; }
.light-green { background: var(--ink); }
.light-amber { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.light-red { background: var(--refuse); box-shadow: 0 0 0 3px var(--refuse-bg); }
.problems { margin: 0 0 26px; padding: 0; list-style: none; }
.problems li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--rule); color: var(--warn); font-weight: 500; }
.problems li::before { content: ""; flex: none; width: 14px; height: 14px; margin-top: 3px; background: currentColor; --i: var(--i-hourglass);
                       -webkit-mask: var(--i) center / contain no-repeat; mask: var(--i) center / contain no-repeat; }
.all-well { display: inline-flex; align-items: center; gap: 8px; margin: 0 0 26px; font: italic 400 1.0625rem/1.4 var(--font-text); color: var(--ink-2); }

/* the extracted text */
.text-view { max-height: 70vh; overflow: auto; padding: 18px 20px; border: 1px solid var(--sheet-edge); border-top: 2px solid var(--ink); background: var(--sheet);
             font: .875rem/1.6 var(--font-mono); white-space: pre-wrap; }

/* details: summaries look like quiet links unless they are buttons */
details > summary { cursor: pointer; color: var(--ink); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary:not(.btn) { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; text-decoration: underline; text-decoration-color: var(--underline);
                              text-underline-offset: 3px; }
details > summary:not(.btn)::after { content: "\203A"; transition: transform .15s ease; }
details[open] > summary:not(.btn)::after { transform: rotate(90deg); }
details code { display: block; margin-top: 6px; padding: 8px 10px; white-space: pre-wrap; }

/* 7. Utilities -------------------------------------------------------------------------------------------------- */
.muted { color: var(--muted); }
.small { font-size: .8125rem; }
.serif { font-family: var(--font-text); }
.italic { font-style: italic; }
.mt { margin-top: 14px; }
.mb-0 { margin-bottom: 0; }
.inline { display: inline; }
form.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.right { text-align: right; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.row.actions-row { gap: 10px 14px; margin: 0 0 22px; }
.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.footnote { margin: 18px 0 0; font-size: .78125rem; color: var(--muted); }
.footnote::before { content: "\2014\00a0"; }

/* 8. Print, reduced motion ------------------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media print {
  :root { --paper: #fff; --sheet: #fff; --ink: #000; --muted: #444; }
  .topbar .search, .mode, .sidebar, .bottombar, .toast, .bulkbar, .sticky-actions, .memo-decision, .pager, form.filters { display: none !important; }
  [data-etap2], .e2-group, .e2-legend, .e2-sections { display: none !important; }   /* a printout shows only what works */
  .topbar { position: static; border-bottom: 1px solid #000; }
  .main { margin: 0; padding: 0; max-width: none; }
  .memo, .sheet { border-color: #999; }
  a { text-decoration: none; }
}
