/* ============================================================================
   GOBIMANS Client-Ops — DESIGN TOKENS (single source of truth)
   ----------------------------------------------------------------------------
   The machine-readable spine of the CRM's look. Everything visual references a
   token from here; styles.css holds only component rules. To re-skin the whole
   app, you edit this file and nothing else.

   Loaded BEFORE styles.css (see index.html) so every rule inherits these vars.

   Why plain CSS custom properties and not a Style-Dictionary / W3C-JSON build:
   the app is vanilla, no bundler, no build step. CSS vars give us the same
   "one source, machine-readable, swap-to-reskin" contract at this scale without
   adding a toolchain. (Per the no-overengineering rule — solutions to real size.)

   LOCKED by brand: the colour roles (ultramarine / terracotta / orange on honest
   cool-white + coal) AND the type family — Geologica, decided by Andrei 25.07.2026
   (GOBIMANS-332, closing the GOBIMANS-182 hold). Этот файл — единственный источник
   правды по шрифту: AGENTS.md ссылается сюда, а не повторяет. Менять семейство —
   значит менять --font-ui ниже, остальные шрифтовые токены следуют за ним.
   Structure below the colour roles — spacing, radii, elevation, the type scale —
   is free to evolve.
   ============================================================================ */

:root {
  --content-max: none;   /* полная ширина экрана; вернуть 1100px — одна строка */
  /* Honest cool neutrals — no warm cream, no pure #fff/#000. --ink carries the ultramarine hue
     (coal-ultramarine #14122A) so it doubles as both body text and the rail/topbar surface —
     De Stijl logic: white + coal carry the structure, ultramarine/terracotta/orange are the POV. */
  /* GOBIMANS-326: был чистый #ffffff — вопреки строке комментария прямо над ним и правилу в
     AGENTS.md. Теперь холодный белый в тон бренда: OKLCH L 0.99 · C 0.005 · H 285 — это тот же
     оттенок, что у --ink (#14122a → H 285.1), взятый почти без насыщенности.
     Контраст проверен, AA держится: --muted 5.01:1 (было 5.17), --ink-2 8.19, --bronze-ink 5.21.
     Фон QR (--qr-bg) остаётся литеральным #ffffff — там белый нужен для сканера, а не для глаза. */
  --surface:    #fbfbff;   /* card surfaces — cold white, ultramarine-tinted */
  --parch:      #efefef;   /* page canvas (neutral light gray) */
  --parch-2:    #f5f5f5;   /* alt surface / inset / column background */
  --parch-3:    #e8e8e8;   /* stronger inset / divider */
  --ink:        #14122a;   /* coal-ultramarine — text + rail/topbar surface + primary button. GOBIMANS-182. */
  --ink-2:      #4d4d4d;   /* secondary text, body emphasis */
  /* GOBIMANS-537: было #6d6d6d — ровно 4,50:1 на --parch, то есть AA без единой сотой запаса:
     любой сдвиг любого из двух токенов молча ронял контраст всех 12-пиксельных подписей.
     Шаг темнее даёт 4,83:1 и оставляет тот же нейтральный серый. */
  --muted:      #676767;   /* darkened for AA >4.5:1 on white */
  --line:       #e2e2e2;   /* border */
  --line-soft:  #ededed;
  --bronze:     #ff682c;   /* PRIMARY accent — Signal Orange (active/focus/marks, NOT button bg) */
  --bronze-2:   #ff7d47;   /* on-dark accent — lighter orange */
  /* --bronze on white is ~2.9:1 — fails the 3:1 UI-component-contrast floor for a focus
     ring (WCAG 2.2 SC 1.4.11). A touch darker clears it while staying visibly "the orange"
     and still reads fine on the dark rail. GOBIMANS-195.
     GOBIMANS-709: the same arithmetic holds for every THIN orange UI graphic on a light plane — the
     active-tab underline (.vtab.is-active, .tctab[aria-selected]) sat at 2,51:1 on --parch. One
     token for that role, --bronze-ui, and the focus ring is its first consumer: 4,20:1 on a card,
     3,77:1 on the canvas. Solid orange FILLS (counters, the toast icon) are the other case — they
     keep --bronze and take dark ink, see --ink-on-accent below. */
  --bronze-ui:  color-mix(in oklch, var(--bronze) 85%, black);
  --focus-ring: var(--bronze-ui);
  --bronze-ink: #816729;   /* Sienna Bronze — muted brand tone for headings/links/marks */
  --terra:      #c4633b;   /* terracotta — secondary accent (kept, Andrei's) */
  /* GOBIMANS-709: --terra itself is brand and stays, but as TEXT on a card it is 3,92:1 (the tax in a
     finance line, the over-limit column header). The text derivative — same hue, a tone deeper —
     reads 5,65:1 on --surface and 5,07:1 on --parch; the relation --bronze-ink has to --bronze. In
     the dark theme it resolves to that theme's --terra, which already reads 4,64:1 there. */
  --terra-ink:  oklch(0.52 0.13 40);
  --orange:     #ff682c;

  /* Client-portal QR (GOBIMANS-144). Literal, NOT var(--ink) — --ink flips light in dark mode,
     which would kill contrast. A QR needs a light quiet zone + dark modules to scan in either
     theme; this is coal-ultramarine (brand dark), not pure #000. */
  --qr-fg:      #14122a;
  --qr-bg:      #ffffff;

  /* Светлая половина пары к --ink-on-fill (тёмный блок ниже объясняет, зачем она нужна):
     здесь статусные заливки тёмные, значит текст на них — светлый. GOBIMANS-709: чтобы этот светлый
     текст держал AA, статусные заливки ниже опущены до L ≈ 0,51–0,54 — см. комментарий у статусов. */
  --ink-on-fill: #efefef;

  /* GOBIMANS-709 (решение 13, 18.10.2026). Две роли чернил, которых не было, и обе — про поверхности,
     не знающие темы.
     --ink-chrome / --parch-chrome: рельс, шапка и тост всегда угольные со светлым текстом —
     .rail/.topstrip (layout/shell.css) и .toast (components/dialog.css) переназначают на них свои
     --ink/--parch. До этого рельс и шапка держали литералы, а тост следовал теме, и «Отменить»
     (--bronze-2) на светлом тосте тёмной темы давало 2,23:1; закреплённый тост даёт 7,20:1 в обеих.
     --ink-on-accent: чернила на ЯРКОЙ заливке, которая сама с темой не меняется — --bronze (счётчик
     активной вкладки, аватар в шапке, значок тоста), --s-prod и --s-none (чипы «В работе» и «Без
     статуса»). Светлые чернила на оранжевом — 2,5–2,8:1 в любой теме, уголь — 6,3–7,9:1. Не путать
     с --ink-on-fill, который переворачивается вместе со статусными заливками.
     Все три объявлены один раз и в тёмном блоке не переопределяются — это пинит test_tokens.mjs. */
  --ink-chrome:    #14122a;
  --parch-chrome:  #efefef;
  --ink-on-accent: #14122a;
  /* GOBIMANS-713: третий закреплённый тон — холодный белый угла. Подсветки, рамки и приглушённый текст на
     рельсе, шапке и панели пакетных действий были белым с альфой (rgba(255,255,255,.06–.85) и #fff) —
     57 литералов в семи файлах: чистый белый, который бренд запрещает, и мимо токенов. Теперь это --surface-chrome с
     той же альфой — color-mix(in srgb, var(--surface-chrome) N%, transparent), — от прежнего ≤ 4 из 255
     на канал. Значение то же, что у светлой --surface, но тему не знает, как и две соседние. */
  --surface-chrome: #fbfbff;

  /* GOBIMANS-713: палитра аватаров людей — переехала сюда из AV_COLORS (app/i18n.js), personColor()
     отдаёт var(--av-N). Кружок с темой не меняется, и инициалы на нём тоже: --ink-on-avatar — холодный
     белый вне темы. GOBIMANS-690 подбирал палитру под чистый белый (4,70–5,32); под --ink-on-avatar —
     4,55–5,15, каждый ≥ 4,5 пинит test_tokens.mjs. «Я» — оранжевый --bronze с --ink-on-accent, не отсюда. */
  --ink-on-avatar: var(--surface-chrome);
  --av-1: #5b6f8c;  --av-2: #5c7968;  --av-3: #836994;  --av-4: #97684d;
  --av-5: #6b784f;  --av-6: #886c79;  --av-7: #566f7a;  --av-8: #7d6f4f;

  /* GOBIMANS-713: затемнение страницы под модальным слоем — диалог, палитра ⌘K, нижние шторки и рельс-
     шторка на телефоне. Было четыре литерала: тёплый rgba(33,31,28,.45), нейтральный rgba(20,20,20,.44),
     угольный rgba(20,18,42,.45) и oklch(0.20 0.05 265 / .40) — дрейф, а не замысел. Один, угольный, вне
     темы: подложка гасит страницу одинаково в обеих темах. */
  --scrim: color-mix(in srgb, var(--ink-chrome) 45%, transparent);

  /* status — backlog · brief · production · review · approval · done
     GOBIMANS-709 (решение 13): светлые значения опущены с L 0,55–0,60 до 0,51–0,54, чтобы ОДИН токен
     держал AA в обеих своих ролях — текстом на карточке (--s-appr/--s-done были 4,43:1, стали
     5,48/5,24) и сплошной заливкой под --ink-on-fill (чипы фильтра были 3,44–3,98, стали 4,70–5,00).
     Это зеркало того, что GOBIMANS-537 сделал в тёмной теме подъёмом до L ≈ 0,70: там один светлый
     токен читается на тёмной карточке и несёт тёмные чернила. Тёмные чернила --ink на прежних
     заливках не вариант: для 4,5:1 заливке нужна L ≥ 0,62, а такой токен текстом на карточке падает
     до 3,7. --s-prod остаётся янтарным (L 0,70): прямым текстом он не стоит — только примесью к --ink
     (.statussel, .tagchip, .rolebadge: 65 % хью + 35 % --ink, ≥ 4,8:1 на своей размывке), а чип
     «В работе» берёт --ink-on-accent. */
  --s-backlog:  oklch(0.51 0.025 265);
  /* W3 retired the «В брифе» column, but this token is NOT the column's: TAG_COLORS borrows it as
     one of six tag hues and .ctr-badge--renewing paints renewing contracts with it. Deleting it
     with the status would have taken two unrelated features down. It also still paints the retired
     status wherever the journal shows it. */
  --s-brief:    oklch(0.56 0.15 264);
  --s-prod:     oklch(0.70 0.16 58);
  --s-review:   oklch(0.54 0.15 300);
  --s-appr:     oklch(0.53 0.15 38);
  --s-done:     oklch(0.51 0.13 150);
  --s-none:     oklch(0.74 0.018 265);

  /* Chain-progress segment that has NOT been reached yet (GOBIMANS-401, audit 6.21). It used to be
     var(--line) at opacity .55 — 1,15:1 on the card, so «цепочка на 1 из 5» and «цепочка готова»
     looked the same, and at 4× zoom the bar read as one solid strip. A pending segment is a real
     part of the picture, not a hairline: it gets its own token and clears ~3:1 in both themes. */
  --chain-pending: #8e8ea0;

  /* urgency / priority — A hot(red)/B warn(amber) already existed; C ("understood") had no
     dedicated colour and fell back to the near-invisible --s-none grey (GOBIMANS-252). A calm
     cool teal reads clearly as "no rush" without clashing with any existing status/urgency hue
     (27 hot, 58-64 warn/prod, 150 done, 264 brief, 300 review, 38 approval). */
  --u-hot:      oklch(0.55 0.20 27);
  /* GOBIMANS-709: --u-warn and --u-ok are TEXT too (the expiring-contract badge, the quota status) and
     sat at 2,51 and 3,39:1 on a card. Both step down to the depth of the statuses above — 5,55 and
     5,10:1 — and as a fill (#dueWeek.is-on) --u-warn carries --ink-on-fill at 4,99. The amber the
     light theme used to have moves to the dark block, where it reads 4,99:1 on a dark card. */
  --u-warn:     oklch(0.52 0.14 60);
  --u-ok:       oklch(0.52 0.09 200);

  /* ── Tinted status surfaces (GOBIMANS-336, audit slice 2 S2-2) ──────────
     The pale plaques behind overdue tags, "stuck"/"silent" age chips, journal
     icons and access tags. These were 20 bare hex literals in styles.css, so
     the dark theme could not reach them: it overrides tokens, and there was no
     token to override — the plaques stayed light and glowed on a dark page.

     Three families, not twenty values. The old set carried two near-identical
     ambers (#F6ECD8/#FDEFD6, borders #E7D2A8/#F0D9A8, ink #95661F/#9A6400);
     that was drift, not intent, so they collapse into one warn family.

     Dark is not the light tint dimmed. A tinted plaque needs a dark surface of
     the same hue and a LIGHTER ink than the light theme uses: --u-hot and
     --s-done sit at L=0.55, which reads fine on a pale plaque and badly on a
     dark one, so the dark inks step up to ~L=0.80. */
  --tint-bad-bg:    #F6E4E1;
  --tint-bad-line:  #E6C3BD;
  /* GOBIMANS-709: the three inks were var(--u-hot) / #95661F / var(--s-done) — 4,38 / 4,27 / 3,92:1 on
     their own pale plaques; a plaque lighter than a card is what costs the margin. Each family now
     owns its ink: same hue, a tone deeper — 5,39 / 5,68 / 5,30:1. */
  --tint-bad-ink:   oklch(0.50 0.19 27);
  --tint-warn-bg:   #F6ECD8;
  --tint-warn-line: #E7D2A8;
  --tint-warn-ink:  oklch(0.48 0.10 75);
  --tint-ok-bg:     #E7F0E7;
  --tint-ok-line:   #CADCC9;
  --tint-ok-ink:    oklch(0.48 0.12 150);

  /* ── Structural scale system ────────────────────────────────────────────
     A real design-system spine, tuned to GOBIMANS values. 4px spacing ladder,
     a radii ramp, and a 5-tier elevation ramp — every shadow tinted to the
     ultramarine hue so depth reads as the brand, never a generic grey drop.
     De Stijl logic holds: structural planes stay flat (border + whisper-lift);
     only things that genuinely float earn real elevation. */
  --sp-1:  4px;  --sp-2:  8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 20px;
  --sp-6: 24px;  --sp-8: 32px;  --sp-10: 40px; --sp-12: 48px; --sp-16: 64px; --sp-20: 80px;

  --r-xs:    4px;
  --r-sm:    6px;
  --r-md:    8px;     /* cards + inputs */
  --r-lg:    16px;
  --r-full:  9999px;
  --r-pill:  999px;   /* buttons / tags — pill */
  --radius:    var(--r-md);    /* back-compat aliases — existing rules keep working */
  --radius-sm: var(--r-sm);

  /* elevation ramp — resting < hover/menu < modal/popover < toast < dragging */
  --e-1:    0 1px 2px rgba(32,32,32,.04);
  --e-2:    0 1px 3px rgba(32,32,32,.04), 0 4px 12px rgba(32,32,32,.03);
  --e-3:    0 2px 6px rgba(32,32,32,.06), 0 16px 40px rgba(32,32,32,.08);
  --e-4:    0 4px 10px rgba(32,32,32,.08), 0 24px 60px rgba(32,32,32,.10);
  --e-drag: 0 10px 24px rgba(32,32,32,.14), 0 2px 6px rgba(32,32,32,.10);
  --shadow: var(--e-2);        /* legacy alias → hover / menu tier */
  /* GOBIMANS-713: тень «есть ещё» у края прокручиваемой таблицы (css/primitives/table-wrap.css) — тот же
     тон, что у ступеней подъёма выше, и так же одна на обе темы. */
  --scroll-shade: rgba(32,32,32,.16);
  --topbar-h:  54px;
  /* GOBIMANS-199: was a magic number in .kanban's min-height calc — chrome above/below the board
     (filter strip, paddings) not covered by --topbar-h.
     GOBIMANS-401: 188 → 132. Two of the strips it accounted for are gone — the status-proportion
     bar (audit 4.6) and the separate tab band, now folded into the project-header row (audit 4.7). */
  --kanban-chrome: 132px;

  /* motion — ease-out only, short durations (product register) */
  --ease:       cubic-bezier(.22, 1, .36, 1);   /* ease-out-quint */
  --t-fast:     120ms;
  --t-base:     200ms;
}

/* ---------------------------------------------------------------------------
   Dark theme (GOBIMANS-94) — manual toggle (menu + localStorage), not
   prefers-color-scheme. Same coal-ultramarine hue family, inverted for
   content surfaces; the rail/topbar stay their own fixed dark regardless
   (see .rail/.topstrip in styles.css) — only the canvas/cards/text invert.
   Status/accent hues (--s-*, --bronze, --terra, --orange) are left as-is;
   every component that tints against a neutral already reads var(--surface)/
   var(--ink) instead of hardcoded white/black, so they invert correctly too.
   --------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  /* GOBIMANS-401 (audit 6.24): the three planes used to differ on the edge of the threshold —
     page #14122a / column #1a1830 / card #211f38, i.e. 1,05:1 column-over-page and 1,09:1
     card-over-column. The board read as one dark sheet with text on it; cards were not objects.
     The page stays the brand coal (--ink's own colour) and the two surfaces above it step up
     instead: column 1,13:1 over the page, card 1,25:1 over the column, 1,42:1 over the page.
     The borders carry the rest of the separation — they were darker than the card they outlined
     (#2a2748 on #211f38), so a card edge was invisible; now the hairline reads at 1,8:1.
     --muted follows the lighter card so secondary text keeps AA on it (5,0:1, was 4,2:1 on the
     new surface / 5,3:1 on the old darker one). */
  --surface:    #302c58;
  --parch:      #14122a;
  --parch-2:    #201d3c;
  --parch-3:    #3b3568;
  --ink:        #f1eff8;
  --ink-2:      #c9c6d9;
  --muted:      #a29dc2;
  --line:       #565093;
  --line-soft:  #423c73;
  /* GOBIMANS-401 (audit 4.2 / 2.9): --bronze-ink had no dark value at all, so the light-theme
     olive #816729 sat on a dark card at 2,71:1 — below the 3:1 floor for the type badge on the
     portal and for every heading/link/mark that uses it here. Same hue (42°), lifted to read on
     dark: 6,9:1 on a card. This is the token fix the portal's local override waits on. */
  --bronze-ink: #d5ba7b;
  /* Pending chain segment, dark half — see the light value above. 3,1:1 on a dark card. */
  --chain-pending: #7c74ad;

  /* GOBIMANS-336: the tinted status plaques, dark half. Same three hues as the light
     set (27 hot, 75 amber, 150 done), carried by a dark surface instead of a pale one,
     with the ink stepped up to stay legible on it. */
  --tint-bad-bg:    oklch(0.30 0.06 27);
  --tint-bad-line:  oklch(0.40 0.08 27);
  --tint-bad-ink:   oklch(0.80 0.12 27);
  --tint-warn-bg:   oklch(0.30 0.05 75);
  --tint-warn-line: oklch(0.40 0.07 75);
  --tint-warn-ink:  oklch(0.83 0.11 75);
  --tint-ok-bg:     oklch(0.30 0.05 150);
  --tint-ok-line:   oklch(0.40 0.07 150);
  --tint-ok-ink:    oklch(0.80 0.12 150);

  /* GOBIMANS-537 (аудит августа 2026, P1). Шапка этого блока говорит, что статусные и urgency-хью
     оставлены «как есть», потому что все их потребители — плашки, тонирующие себя через
     --tint-*-ink. Это оказалось неправдой примерно для двадцати пяти правил: ошибка гейта,
     просроченный срок, суммы прихода и расхода, алерты дашборда берут эти токены ПРЯМЫМ текстом.
     На тёмной карточке #302c58 светлые значения давали 2,40–2,82:1 — самый срочный текст в
     продукте оказывался наименее читаемым. Хью и хрома те же, поднята светлота: 4,6–4,7:1 на
     карточке и 6,6:1 на холсте. Рецепт тот же, каким выше починили --bronze-ink.
     Не тронуты --u-warn (4,99:1) и --s-prod (4,62:1) — они и так проходят. */
  --u-hot:      oklch(0.71 0.16 27);
  --s-brief:    oklch(0.695 0.15 264);
  --s-review:   oklch(0.705 0.15 300);
  --s-appr:     oklch(0.705 0.15 38);
  --s-done:     oklch(0.675 0.13 150);
  --s-backlog:  oklch(0.69 0.025 265);
  --terra:      oklch(0.70 0.11 40);
  --terra-ink:  var(--terra);
  /* GOBIMANS-709: the two urgency hues that had no dark value. --u-warn keeps here the amber the light
     theme used to carry (4,99:1 on a dark card); --u-ok goes up the way the statuses did — 3,69 → 5,80. */
  --u-warn:     oklch(0.72 0.16 60);
  --u-ok:       oklch(0.74 0.09 200);
  /* GOBIMANS-709: --focus-ring (through --bronze-ui) had no dark value — 2,98:1 on a dark card. The
     on-dark orange is --bronze-2: 5,09:1 on the card, 7,20:1 on the canvas. */
  --bronze-ui:  var(--bronze-2);

  /* Чернила для текста, лежащего на СПЛОШНОЙ заливке этими токенами (фильтр-чипы, бейдж
     «срочно», счётчик непрочитанных). В светлой теме заливка тёмная и текст на ней светлый;
     после подъёма выше заливка стала светлой, и тот же светлый текст исчезает. Один токен
     разводит два случая — так же, как --tint-*-ink разводит плашки. */
  --ink-on-fill: #14122a;
}

/* Type system — ONE Cyrillic-capable family carries the whole product UI (headings, labels,
   body, numbers); hierarchy comes from weight + tracking, not a second face. Bricolage
   Grotesque (Latin-only — it has NO Cyrillic) is kept STRICTLY for the GOBIMANS wordmark logo.
   Swap --font-ui to retypeset the entire app. */
:root {
  --font-ui:      "Geologica", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* GOBIMANS-325: Space Grotesk убран и из этой строки, и из запроса к Google Fonts.
     Находка S3-4 говорила «грузится и не используется» — это верно для styles.css, но
     НЕ для токенов: семейство стояло здесь первым, а --font-display висит на 25 правилах,
     включая .eh__name (H1 проекта). У Space Grotesk нет кириллицы, поэтому русский заголовок
     «Клиент А — июль 2026» и так распадался: латиница шла одним шрифтом, кириллица падала на
     Inter — посреди одной строки. Убрать семейство из запроса, не тронув токен, значило бы
     оставить это как есть.
     Дисплейное начертание теперь берёт ту же семью, что и весь интерфейс — ровно то, что
     обещает комментарий выше («ONE Cyrillic-capable family carries the whole product UI»),
     и то, что даёт --font-ui как единственную ручку для смены шрифта целиком. */
  --font-display: var(--font-ui);
  /* GOBIMANS-332: цифры больше не называют семью отдельно — иначе смена --font-ui перестаёт
     перетипографировать продукт целиком, ровно как это случилось со Space Grotesk (GOBIMANS-325).
     Табличные цифры включает font-variant-numeric ниже, а не отдельный шрифт. */
  --font-num:     var(--font-ui);
  --font-logo:    "Bricolage Grotesque", var(--font-ui);   /* GOBIMANS wordmark stays */
  /* optical tracking ramp — larger type sets tighter */
  --tk-display: -0.022em;
  --tk-head:    -0.013em;
  --tk-tight:   -0.006em;
  /* type scale — weight + tracking carry hierarchy (GOBIMANS-332: шкала снята с Geologica) */
  --fs-display:  33px;
  --fs-h1:       28px;
  --fs-h2:       24px;
  --fs-h3:       18px;
  --fs-body-lg:  16px;
  --fs-body:     15px;
  --fs-sm:       14px;
  --fs-caption:  12.5px;
  --fs-overline: 11px;
}
