/* Atelier OS – components. Class-based, no inline styles needed.
   Naming: block, block__part, block--variant, is-state.
   Colour carries meaning only in status marks; everything else is ink on white. */

/* Inter, stored locally (assets/fonts, SIL Open Font License) so the text never jumps while loading */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 600; font-display: optional; src: url('../assets/fonts/inter-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: 'Inter'; font-style: normal; font-weight: 400 600; font-display: optional; src: url('../assets/fonts/inter-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; }

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--canvas); }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 400 var(--text-md)/1.5 var(--font-sans); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
a { color: var(--ink); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
/* keyboard focus in ink everywhere, never the browser's blue; components may refine it */
:where(a, button, input, select, textarea, [tabindex]):focus-visible { outline: var(--bar) solid var(--ink); outline-offset: var(--bar); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--ink-2); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.icon { width: var(--icon); height: var(--icon); flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App frame: sidebar and page area; only the page scrolls ---------- */
.app { height: 100vh; display: flex; overflow: hidden; }
.main { flex: 1 1 auto; min-width: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; position: relative; }
.page { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--gap-6); display: flex; flex-direction: column; gap: var(--gap-5); }
.page > * { flex-shrink: 0; }  /* the page scrolls, its blocks never squeeze */

/* ---------- Sidebar ---------- */
.sidebar { --pad: var(--side-pad); flex: 0 0 var(--sidebar-w); max-width: 100%; height: 100vh; overflow-x: visible; overflow-y: clip; color: var(--side-text); display: flex; flex-direction: column; padding: 0 var(--pad) var(--gap-3); position: relative; z-index: 2; view-transition-name: sidebar; }
.sidebar::before { content: ''; position: absolute; inset: 0; z-index: -1; background: var(--side-bg); border-right: 1px solid var(--side-border); transform: scaleX(var(--side-scale, 1)); transform-origin: left; transition: transform var(--dur-slow) var(--ease-in-out); }
.is-snapping .sidebar::before { transition: none; }
.sidebar__head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-1); height: var(--side-head); }
.brand { padding-left: var(--side-gap); }
.brand__name { font: 500 var(--text-wordmark)/1.2 var(--font-brand); letter-spacing: 0.1em; color: var(--side-brand); white-space: nowrap; }
.brand__sub { margin-top: var(--gap-1); font-size: var(--text-2xs); font-weight: 600; letter-spacing: 0.24em; color: var(--gold); }
.brand__mono { display: none; font: 500 var(--text-wordmark)/1.2 var(--font-brand); letter-spacing: 0.1em; color: var(--side-brand); }
.sidebar__toggle { width: var(--control); height: var(--control); border-radius: var(--radius-sm); color: var(--side-text); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav__item { position: relative; display: flex; align-items: center; gap: var(--side-gap); min-height: var(--side-item); padding: 0 var(--side-gap); border-radius: var(--radius-sm); color: var(--side-text); font-size: var(--text-md); text-decoration: none; outline: 0; }
.nav__item.is-active { color: var(--side-strong); font-weight: 500; }
/* the active mark is its own element (view-transition-name: nav-active) and glides to the new page */
.nav__mark { position: absolute; inset: 0; z-index: -1; border-radius: var(--radius-sm); background: var(--side-active); view-transition-name: nav-active; pointer-events: none; }
.nav__item:focus-visible, .sidebar__toggle:focus-visible, .profile:focus-visible { outline: 0; background: var(--side-active); color: var(--side-strong); }
.nav__divider { height: 1px; background: var(--side-line); margin: var(--gap-2) 0; }
.sidebar__foot { position: relative; margin-top: auto; padding-top: var(--gap-3); }
.profile { position: relative; width: 100%; height: var(--tap); padding: 0 var(--gap-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--side-strong); display: flex; align-items: center; gap: var(--side-gap); text-align: left; cursor: pointer; }
.profile[aria-expanded='true'] { background: var(--side-active); }
.avatar { width: var(--avatar-sm); height: var(--avatar-sm); border-radius: 50%; background: var(--side-avatar); color: var(--side-strong); display: flex; align-items: center; justify-content: center; font-size: var(--text-2xs); font-weight: 500; flex: none; }
.profile__name { flex: 1; min-width: 0; font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .profile__chevron { width: var(--icon-sm); height: var(--icon-sm); color: var(--side-text); }

/* profile menu: language, sidebar colour, log out */
.profile-menu { position: absolute; left: 0; right: 0; bottom: calc(100% + var(--gap-1)); z-index: 5; transform-origin: bottom left; }
.profile-menu__row { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3); min-height: var(--side-item); padding: 0 var(--gap-3); color: var(--ink); text-decoration: none; }
.profile-menu__label { color: var(--ink-2); }
.profile-menu__options { display: flex; gap: var(--gap-3); }
.profile-menu__option { min-height: var(--side-item); padding: 0 var(--gap-1); border: 0; background: transparent; color: var(--ink-2); cursor: pointer; text-decoration: underline 1.5px transparent; text-underline-offset: var(--gap-1); }
.profile-menu__option[aria-checked='true'] { color: var(--ink); font-weight: 500; text-decoration-color: currentColor; }
.profile-menu__option:focus-visible { outline: var(--bar) solid var(--ink); outline-offset: calc(var(--bar) * -1); }
.profile-menu__rule { height: 1px; margin: var(--gap-1) 0; background: var(--line); }
.profile-menu__logout { justify-content: flex-start; gap: var(--gap-2); outline: 0; }
.profile-menu__logout .icon { width: var(--icon-sm); height: var(--icon-sm); }
.profile-menu__logout:focus-visible { background: var(--row-hover); }

/* collapsed sidebar: icons only, labels turn into tooltips. The class sidebar-collapsed is set on <html> before the stylesheets load */
:root.sidebar-collapsed .sidebar { --pad: var(--side-pad-collapsed); flex-basis: var(--sidebar-w-collapsed); }
:root.sidebar-collapsed .brand,
:root.sidebar-collapsed .profile__chevron { display: none; }
:root.sidebar-collapsed .brand__mono { display: block; }
:root.sidebar-collapsed .sidebar__head { flex-direction: column; justify-content: center; gap: var(--gap-1); }
:root.sidebar-collapsed .nav__item,
:root.sidebar-collapsed .profile { justify-content: center; padding: 0; }
:root.sidebar-collapsed .profile-menu { left: calc(100% + var(--side-pad-collapsed) + var(--gap-2)); right: auto; bottom: 0; min-width: calc(var(--sidebar-w) - 2 * var(--side-pad)); }
:root.sidebar-collapsed .nav__label,
:root.sidebar-collapsed .profile__name { position: absolute; left: calc(100% + var(--side-pad-collapsed) + var(--tip-gap)); top: 50%; z-index: 5; flex: none; padding: var(--gap-1) var(--gap-2); border-radius: var(--radius-xs); background: var(--ink); color: var(--canvas); font-size: var(--text-sm); font-weight: 400; white-space: nowrap; overflow: visible; pointer-events: none; opacity: 0; transform: translateY(-50%); transition: opacity var(--dur-fast) var(--ease-out); }
:root.sidebar-collapsed .nav__item:focus-visible .nav__label,
:root.sidebar-collapsed .profile:focus-visible .profile__name { opacity: 1; }
:root.sidebar-collapsed .profile[aria-expanded='true'] .profile__name { opacity: 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--gap-2); min-height: var(--control); padding: 0 var(--pad-x); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--canvas); color: var(--ink); font-size: var(--text-md); font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn--primary { background: var(--ink); border-color: var(--ink); color: var(--canvas); }
.btn--block { width: 100%; }
.btn > .icon, .list-tools__button > .icon { width: var(--icon-sm); height: var(--icon-sm); stroke-width: 1.8; }
.icon-btn { width: var(--control); height: var(--control); border: 0; border-radius: var(--radius); background: transparent; color: inherit; display: inline-flex; align-items: center; justify-content: center; position: relative; cursor: pointer; text-decoration: none; }
.icon-btn.is-copied { color: var(--ink); }
.link-button { min-height: var(--control); padding: 0; border: 0; background: transparent; color: var(--ink); text-decoration: underline; cursor: pointer; }

/* ---------- Search, command bar, key marks ---------- */
.search { flex: 0 1 var(--sidebar-w); min-width: 0; height: var(--control-sm); padding: 0 var(--gap-3); border-radius: var(--radius); background: var(--fill); display: flex; align-items: center; gap: var(--gap-2); }
.search .icon { width: var(--icon-sm); height: var(--icon-sm); color: var(--ink-3); }
.search__input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search__input::placeholder { color: var(--ink-2); }
.search:focus-within { box-shadow: inset 0 0 0 1px var(--line-strong); }
.kbd { min-width: calc(var(--gap-4) + var(--gap-1)); height: calc(var(--gap-4) + var(--gap-1)); padding: 0 var(--gap-1); border: 1px solid var(--line-strong); border-radius: var(--radius-xs); background: var(--canvas); color: var(--ink-2); font-size: var(--text-xs); display: inline-flex; align-items: center; justify-content: center; flex: none; }

/* ---------- Language switch on the sign-in page ---------- */
.lang { display: flex; gap: var(--gap-3); }
.lang__option { min-height: var(--control); padding: 0 var(--gap-1); border: 0; border-bottom: var(--bar) solid transparent; background: transparent; color: var(--ink-2); font-size: var(--text-sm); cursor: pointer; }
.lang__option[aria-pressed='true'] { color: var(--ink); font-weight: 500; border-bottom-color: var(--ink); }

/* ---------- Page head ---------- */
.page-head { display: flex; flex-wrap: wrap; gap: var(--gap-4); align-items: flex-end; justify-content: space-between; }
.page-head__crumb { color: var(--ink-2); font-size: var(--text-sm); }
.page-title { font-size: var(--text-title); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; }
.page-title__count { margin-left: var(--gap-2); color: var(--ink-2); font-size: var(--text-md); font-weight: 400; letter-spacing: 0; }
.page-head__sub { margin-top: var(--gap-1); color: var(--ink-2); }
.page-head__meta { display: flex; flex-wrap: wrap; gap: var(--gap-2) var(--gap-4); margin-top: var(--gap-2); }
.page-head__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-2); }

/* ---------- Key figures ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(calc(var(--sidebar-w) * 0.9), 100%), 1fr)); gap: 0 var(--gap-6); }
.kpi { border-top: 1px solid var(--line); padding: var(--gap-3) 0 var(--gap-1); }
.kpi__label, .eyebrow { color: var(--ink-2); font-size: var(--text-xs); font-weight: 500; }
.kpi__value { margin-top: var(--gap-1); font-size: var(--text-figure); font-weight: 400; letter-spacing: -0.02em; line-height: 1.2; }
.kpi__note { color: var(--ink-2); font-size: var(--text-sm); }

/* ---------- Sections ---------- */
.section { border-top: 1px solid var(--line); padding-top: var(--gap-4); display: flex; flex-direction: column; gap: var(--gap-3); min-width: 0; }
/* right after a tab row the tab line is the only divider */
:is(.tabs, .tabbar) + .section, :is(.tabs, .tabbar) + .columns > .section,
:is(.tabs, .tabbar) ~ .tab-panel > .section:first-child, :is(.tabs, .tabbar) ~ .tab-panel > .columns:first-child > .section { border-top: 0; padding-top: 0; }
/* the content of one tab; switched by js/tabs.js */
.tab-panel { display: flex; flex-direction: column; gap: var(--gap-5); min-width: 0; }
.section__head { display: flex; flex-wrap: wrap; gap: var(--gap-3); align-items: baseline; justify-content: space-between; }
.section__title { font-size: var(--text-md); font-weight: 500; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(calc(var(--sidebar-w) * 1.8), 100%), 1fr)); gap: var(--gap-4) var(--gap-6); }

/* ---------- Lists: one pattern for every table ----------
   Borderless, head 36 px, rows 64 px with a soft divider, fixed column grid per table.
   Rows with a target are clickable as a whole and end in a chevron. */
.table-wrap { overflow-x: auto; }
.list { --cols: minmax(0, 1fr); display: block; width: 100%; border-collapse: separate; }
.list thead, .list tbody { display: block; }
.list tr { display: grid; grid-template-columns: var(--cols) var(--chev,); column-gap: var(--gap-4); align-items: center; padding: 0 var(--gap-3); }
.list th { height: var(--row-head); align-content: center; padding: 0; text-align: left; color: var(--ink-2); font-size: var(--text-xs); font-weight: 500; }
.list td { min-height: var(--row); min-width: 0; align-content: center; padding: var(--gap-2) 0; }
.list tbody tr { border-top: 1px solid var(--line-soft); }
.list th.num, .list td.num { text-align: right; }
.list a { color: var(--ink); text-decoration: none; }
.list--link { --chev: var(--icon-sm); }
.list tr.is-link { position: relative; cursor: pointer; }
.list tr.is-link::after { content: ''; justify-self: center; width: calc(var(--icon-sm) / 2.5); height: calc(var(--icon-sm) / 2.5); border-right: 1.5px solid var(--ink-3); border-bottom: 1.5px solid var(--ink-3); transform: rotate(-45deg); }
.row-link::after { content: ''; position: absolute; inset: 0; }
.list tr.is-link :is(button, input, label, select, textarea, a:not(.row-link)) { position: relative; z-index: 1; }
.list tr.is-selected { background: var(--nav-active); }
.list tr.list__empty > td { grid-column: 1 / -1; color: var(--ink-2); }
.list [data-row]:focus-visible { outline: var(--bar) solid var(--ink); outline-offset: calc(var(--bar) * -1); }
/* column grids */
.list--2 { --cols: minmax(0, 1fr) minmax(0, 2fr); }
.list--3 { --cols: minmax(0, 2fr) repeat(2, minmax(0, 1fr)); }
.list--4 { --cols: minmax(0, 2fr) repeat(3, minmax(0, 1fr)); }
.list--5 { --cols: minmax(0, 2fr) repeat(4, minmax(0, 1fr)); }
.list--6 { --cols: minmax(0, 2fr) repeat(5, minmax(0, 1fr)); }
.list--7 { --cols: minmax(0, 2fr) repeat(6, minmax(0, 1fr)); }
.list--8 { --cols: minmax(0, 1.6fr) repeat(7, minmax(0, 1fr)); }
.list--people { --cols: minmax(0, 2.4fr) minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.2fr) calc(var(--control) * 3); }
.list--companies { --cols: minmax(0, 2.4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.2fr); }
.list--tasks { --cols: minmax(0, 2.6fr) minmax(0, 1.6fr) minmax(0, 0.8fr) minmax(0, 1.2fr) minmax(0, 0.8fr); }
/* first column of people and companies: initials, name, sub-line */
.entity { display: flex; align-items: center; gap: var(--gap-3); min-width: 0; }
.entity__avatar { width: var(--avatar); height: var(--avatar); border-radius: 50%; background: var(--fill); color: var(--ink); font-size: var(--text-xs); font-weight: 500; display: flex; align-items: center; justify-content: center; flex: none; }
.entity__text { display: flex; flex-direction: column; min-width: 0; }
.entity__name { color: var(--ink); }
a.entity__name { text-decoration: none; }
.entity__sub, .cell-sub { color: var(--ink-2); font-size: var(--text-sm); }
.cell-sub { display: block; }
.list td.row-actions { white-space: nowrap; text-align: right; }
.row-actions .icon-btn { color: var(--ink-3); }

/* ---------- Status: 6 px dot plus text in the same colour; colour only for late and waiting ---------- */
.status { display: inline-flex; align-items: center; gap: var(--gap-2); color: var(--ink-2); white-space: nowrap; }
.status::before { content: ''; width: var(--dot); height: var(--dot); border-radius: 50%; background: currentColor; flex: none; }
.status--warn { color: var(--warn); }
.status--danger { color: var(--danger); }
.text-bad { color: var(--danger); }
.list .status { white-space: normal; }  /* narrow columns: the label wraps instead of overflowing */

/* ---------- Country with a small round flag (js/flags.js) ---------- */
.country { display: inline-flex; align-items: center; gap: var(--gap-2); vertical-align: bottom; }
.flag { width: var(--flag); height: var(--flag); border: 1px solid var(--line); border-radius: 50%; flex-shrink: 0; }
.flag--none { border-color: transparent; }  /* unknown country: keeps the space, shows nothing */

/* ---------- Bars ---------- */
.bar { display: block; height: var(--bar); border-radius: 1px; background: var(--line); }
.bar__fill { display: block; height: 100%; border-radius: 1px; background: var(--ink); }
.bar--chart { height: calc(var(--bar) * 3); border-radius: var(--bar); }
.bar--chart .bar__fill { border-radius: var(--bar); }
.progress { display: flex; align-items: center; gap: var(--gap-2); }
.progress .bar { width: calc(var(--sidebar-w) / 2); }
.progress__value { color: var(--ink-2); font-size: var(--text-xs); }
.meters { display: flex; flex-direction: column; gap: var(--gap-3); }
.meter { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 4fr) minmax(0, 1fr); gap: var(--gap-3); align-items: center; }
.total { display: flex; justify-content: space-between; border-top: 1px solid var(--ink); padding-top: var(--gap-2); font-weight: 500; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(calc(var(--sidebar-w) * 0.8), 100%), 1fr)); gap: var(--gap-4); }
.fact__value { margin-top: 2px; font-size: var(--text-lg); font-weight: 500; }

/* ---------- Project stages ---------- */
.stepper { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(calc(var(--sidebar-w) * 0.6), 1fr)); gap: var(--gap-3); min-width: calc(var(--sidebar-w) * 3.2); }
.stepper--4 { grid-template-columns: repeat(4, minmax(calc(var(--sidebar-w) * 0.55), 1fr)); min-width: calc(var(--sidebar-w) * 2.4); }
.step { display: flex; flex-direction: column; gap: var(--gap-2); }
.step__head { display: flex; gap: var(--gap-2); align-items: baseline; }
.step__no { color: var(--ink-2); font-size: var(--text-xs); }
.step__name { font-weight: 400; }
.step.is-current .step__name { font-weight: 500; }
.step.is-done .step__name { color: var(--ink); }
.step__note { margin-top: calc(var(--gap-1) * -1); color: var(--ink-2); font-size: var(--text-sm); }
.step__link { min-height: var(--control); align-items: center; color: inherit; text-decoration: none; }

/* ---------- Tabs ---------- */
.tabs { position: relative; display: flex; flex-wrap: wrap; gap: var(--gap-5); border-bottom: 1px solid var(--line); }
.tab { margin-bottom: -1px; padding: var(--gap-3) 0; border-bottom: var(--bar) solid transparent; color: var(--ink-2); text-decoration: none; }
.tab.is-active { color: var(--ink); }
.tab.is-active .tab__label { font-weight: 500; }
.tabs:not([data-mark]) .tab.is-active { border-bottom-color: var(--ink); }  /* before tabs.js has placed the underline */
.tabs__indicator { position: absolute; left: 0; bottom: -1px; width: 0; height: var(--bar); background: var(--ink); transform-origin: left; pointer-events: none; transition: transform var(--dur-tab) var(--ease-tab); }
/* the label keeps the width of its bold form, so the tab row never shifts when the weight changes */
.tab__label, .segmented__label { display: inline-flex; flex-direction: column; align-items: center; }
.tab__label::after, .segmented__label::after { content: attr(data-label); content: attr(data-label) / ''; height: 0; overflow: hidden; visibility: hidden; font-weight: 500; pointer-events: none; user-select: none; }
.tab__count { margin-left: calc(var(--gap-1) + 2px); color: var(--ink-2); font-weight: 400; }
.tabbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--gap-2) var(--gap-3); border-bottom: 1px solid var(--line); }
.tabbar .tabs { flex: 1 1 auto; border-bottom: 0; }
.tabbar .search, .tabbar .segmented { align-self: center; }

/* ---------- Segmented control: a choice of 2 to 5 options, buttons or links ---------- */
.segmented { position: relative; isolation: isolate; align-self: flex-start; display: inline-flex; align-items: center; gap: 2px; padding: var(--segment-pad); border-radius: var(--radius); background: var(--fill); }
.segmented__option { height: var(--segment); padding: 0 var(--gap-3); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--ink-2); font-size: var(--text-sm); display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; cursor: pointer; }
.segmented__option[aria-pressed='true'], .segmented__option[aria-current='page'] { color: var(--ink); }
.segmented__option[aria-pressed='true'] .segmented__label, .segmented__option[aria-current='page'] .segmented__label { font-weight: 500; }
.segmented:not([data-mark]) .segmented__option[aria-pressed='true'], .segmented:not([data-mark]) .segmented__option[aria-current='page'] { background: var(--canvas); box-shadow: var(--shadow-segment); }
.segmented__thumb { position: absolute; top: var(--segment-pad); left: 0; z-index: -1; width: 0; height: var(--segment); border-radius: var(--radius-sm); background: var(--canvas); box-shadow: var(--shadow-segment); transform-origin: left; pointer-events: none; transition: transform var(--dur-segment) var(--ease-tab); }
.segmented__option:focus-visible { outline: var(--bar) solid var(--ink); outline-offset: 1px; }

/* ---------- Pagination: count on the left, Previous / Next as text ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3); }
.pager__count { color: var(--ink-2); font-size: var(--text-sm); }
.pager__nav { display: flex; gap: var(--gap-4); }
.pager__link { min-height: var(--control); padding: 0; border: 0; background: transparent; color: var(--ink); cursor: pointer; }
.pager__link:disabled { color: var(--ink-2); cursor: default; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: var(--gap-2); }
.field__label { font-weight: 500; }
.input { width: 100%; min-height: var(--control); padding: 0 var(--gap-3); border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--canvas); }
textarea.input { padding: var(--gap-2) var(--gap-3); min-height: calc(var(--row) * 1.5); resize: vertical; }
.input:focus { outline: 0; border-color: var(--ink); }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-3); }
.check, .task-label { display: flex; align-items: center; gap: var(--gap-3); }
.task__check { appearance: none; width: var(--check-size); height: var(--check-size); margin: 0; border: 1px solid var(--check); border-radius: var(--radius-xs); background: var(--canvas); display: inline-grid; place-content: center; flex: none; cursor: pointer; }
.task__check::before { content: ''; width: calc(var(--check-size) * 0.28); height: calc(var(--check-size) * 0.52); border-right: 1.5px solid var(--canvas); border-bottom: 1.5px solid var(--canvas); transform: translateY(-1px) rotate(45deg) scale(0); transition: transform var(--dur-fast) var(--ease-out); }
.task__check:checked { background: var(--ink); border-color: var(--ink); }
.task__check:checked::before { transform: translateY(-1px) rotate(45deg) scale(1); }
.task__check:focus-visible { outline: var(--bar) solid var(--ink); outline-offset: var(--bar); }
.start { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: var(--gap-6) var(--gap-5); display: flex; flex-direction: column; align-items: center; gap: var(--gap-4); text-align: center; }
.start__title { font-size: var(--text-title); font-weight: 400; line-height: 1.2; }
.start__form { width: min(100%, calc(var(--sidebar-w) * 3)); text-align: left; }

/* ---------- Month calendar ---------- */
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); min-width: calc(var(--sidebar-w) * 3); border-top: 1px solid var(--line); border-left: 1px solid var(--line-soft); }
.calendar__weekday { padding: var(--gap-2); border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.calendar__day { min-height: calc(var(--tap) * 1.75); min-width: 0; padding: var(--gap-1) var(--gap-2); border-right: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: var(--gap-1); }
.calendar__day--outside { color: var(--ink-2); }
.calendar__day.is-today { box-shadow: inset 0 var(--bar) 0 var(--ink); }
.calendar__day.is-today .calendar__date { color: var(--ink); font-weight: 500; }
.calendar__date { font-size: var(--text-sm); }
.calendar__event { display: block; overflow: hidden; text-overflow: ellipsis; font-size: var(--text-xs); }
.calendar__event::before { display: inline-block; margin-right: var(--gap-1); vertical-align: middle; }
.calendar__more { color: var(--ink-2); font-size: var(--text-xs); }

/* ---------- Sign-in ---------- */
.login { min-height: 100vh; display: flex; flex-wrap: wrap; }
.login__brand { flex: 1 1 calc(var(--sidebar-w) * 1.5); padding: calc(var(--gap-6) + var(--gap-3)); background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; gap: var(--gap-6); }
.login__brand .brand__name { color: var(--ink); font-size: var(--text-title); }
.login__claim { max-width: 16em; font-size: var(--text-title); font-weight: 400; letter-spacing: -0.02em; line-height: 1.25; }
.login__place { color: var(--ink-2); font-size: var(--text-sm); }
.login__form { flex: 1 1 calc(var(--sidebar-w) * 1.5); padding: calc(var(--gap-6) + var(--gap-3)); display: flex; flex-direction: column; justify-content: center; }
.login__card { width: 100%; max-width: calc(var(--sidebar-w) * 1.5); margin: 0 auto; display: flex; flex-direction: column; gap: var(--gap-4); }
.login__foot { display: flex; justify-content: space-between; align-items: center; gap: var(--gap-3); font-size: var(--text-sm); }
.login__error { width: 100%; max-width: calc(var(--sidebar-w) * 1.5); margin: var(--gap-4) auto 0; color: var(--danger); font-size: var(--text-sm); }
.login__card.is-shaking { animation: shake var(--dur-slow) var(--ease-out); }

/* ---------- Home: wordmark, command bar, choice cards. Nothing else, centred, with air ---------- */
.home { justify-content: center; align-items: center; gap: var(--gap-5); padding-bottom: calc(var(--gap-6) * 2); }
.home > * { width: 100%; max-width: calc(var(--sidebar-w) * 3); }
.home__brand { margin: 0 0 var(--gap-5); text-align: center; font-weight: 400; }
.home__brand .brand__name { position: relative; display: inline-block; overflow: hidden; color: var(--ink); font-size: calc(var(--text-title) + var(--gap-2)); }
.home__letter { display: inline-block; white-space: pre; }
.home__rule { display: block; width: calc(var(--gap-6) * 1.6); height: 1px; margin: var(--gap-3) auto 0; background: var(--gold); transform-origin: center; }
.home__brand .brand__sub { display: block; margin-top: var(--gap-3); }
/* a faint light runs over the letters every 8 seconds, at once on hover */
.home__brand .brand__name::after { content: ''; position: absolute; inset: 0 -40%; background: linear-gradient(100deg, transparent 40%, var(--shine) 50%, transparent 60%); transform: translateX(-100%); pointer-events: none; animation: shine 8s linear 2.6s infinite; }
.home__brand .brand__name:hover::after { animation: shine-once 1.1s linear; }
@keyframes shine { 0% { transform: translateX(-100%); } 14% { transform: translateX(100%); } 100% { transform: translateX(100%); } }
@keyframes shine-once { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* first visit in a session: letters rise out of a blur one by one while the spacing closes,
   the gold line draws from the middle, ATELIER OS fades in, then search and cards follow */
.home > * { animation: none; }
.home__brand .brand__name { animation: word-close calc(var(--dur-intro) + var(--intro-step) * 10) var(--ease-page) backwards; }
.home__letter { animation: letter-in var(--dur-intro) var(--ease-page) backwards; animation-delay: calc(var(--i, 0) * var(--intro-step)); }
.home__letter:nth-child(2) { --i: 1; } .home__letter:nth-child(3) { --i: 2; } .home__letter:nth-child(4) { --i: 3; }
.home__letter:nth-child(5) { --i: 4; } .home__letter:nth-child(6) { --i: 5; } .home__letter:nth-child(7) { --i: 6; }
.home__letter:nth-child(8) { --i: 7; } .home__letter:nth-child(9) { --i: 8; } .home__letter:nth-child(10) { --i: 9; }
.home__letter:nth-child(11) { --i: 10; }
.home__rule { animation: rule-draw 500ms var(--ease-page) 1050ms backwards; }
.home__brand .brand__sub { animation: fade-in 400ms var(--ease-out) 1450ms backwards; }
.home > .command { animation: follow-in 400ms var(--ease-out) 1650ms backwards; }
.home .choice-card { animation: follow-in 400ms var(--ease-out) calc(1650ms + var(--j, 1) * var(--intro-follow)) backwards; }
.home .choice-card:nth-child(2) { --j: 2; } .home .choice-card:nth-child(3) { --j: 3; } .home .choice-card:nth-child(4) { --j: 4; }
@keyframes letter-in { from { opacity: 0; transform: translateY(12px); filter: blur(8px); } }
@keyframes word-close { from { letter-spacing: 0.42em; } }
@keyframes rule-draw { from { transform: scaleX(0); } }
@keyframes follow-in { from { opacity: 0; transform: translateY(var(--gap-2)); } }
/* later visits in the same session: one short 300 ms variant */
.intro-seen .home__letter, .intro-seen .home__brand .brand__name, .intro-seen .home__rule, .intro-seen .home__brand .brand__sub,
.intro-seen .home .choice-card { animation: none; }
.intro-seen .home > * { animation: follow-in 300ms var(--ease-out) backwards; }
/* while the browser prerenders Home on hover, nothing runs yet */
.intro-paused .home, .intro-paused .home *, .intro-paused .home__brand .brand__name::after { animation-play-state: paused !important; }
.command { height: calc(var(--tap) + var(--gap-3)); padding: 0 var(--gap-4); border: 0; border-radius: var(--radius); background: var(--fill); color: var(--ink-2); display: flex; align-items: center; gap: var(--gap-3); text-align: left; cursor: pointer; }
.command > .icon { color: var(--ink-3); }
.command__text { flex: 1; min-width: 0; }
.command:focus-visible { outline: var(--bar) solid var(--ink); outline-offset: var(--bar); }


/* ---------- Overlays: scrim, slide-in panel, dialog, popover menu, toast ----------
   Built and opened by app.js from data attributes; white surface, hairline, --shadow-pop. */
.scrim { position: fixed; inset: 0; z-index: 30; background: var(--scrim); opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
.scrim.is-open { opacity: 1; transition-duration: var(--dur-panel); }
.panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; width: var(--panel-w); max-width: 100%; background: var(--canvas); border-left: 1px solid var(--line); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; transform: translateX(100%); transition: transform var(--dur-base) var(--ease-out); }
.panel.is-open { transform: none; transition-duration: var(--dur-panel); }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: var(--gap-3); padding: var(--gap-4) var(--gap-5); border-bottom: 1px solid var(--line); }
.panel__title { font-size: var(--text-lg); font-weight: 500; }
.panel__body { flex: 1; overflow-y: auto; padding: var(--gap-5); display: flex; flex-direction: column; gap: var(--gap-4); }
.panel__foot { display: flex; gap: var(--gap-2); padding: var(--gap-4) var(--gap-5); border-top: 1px solid var(--line); }
.panel__foot .btn--primary { flex: 1; }
.dialog { position: fixed; top: 50%; left: 50%; z-index: 31; width: min(var(--panel-w), calc(100% - 2 * var(--gap-5))); padding: var(--gap-5); background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); display: flex; flex-direction: column; gap: var(--gap-2); opacity: 0; transform: translate(-50%, -50%) scale(0.98); transition: opacity var(--dur-dialog) var(--ease-out), transform var(--dur-dialog) var(--ease-out); }
.dialog.is-open { opacity: 1; transform: translate(-50%, -50%); }
.dialog__title { font-size: var(--text-lg); font-weight: 500; }
.dialog__text { color: var(--ink-2); }
.dialog__foot { display: flex; justify-content: flex-end; gap: var(--gap-2); margin-top: var(--gap-4); }
.popover { padding: var(--gap-1) 0; background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); color: var(--ink); font-size: var(--text-sm); opacity: 0; transform: scale(0.97); transition: opacity var(--dur-pop) var(--ease-out), transform var(--dur-pop) var(--ease-out); }
.popover.is-open { opacity: 1; transform: none; }
.popover__option { position: relative; width: 100%; min-height: var(--side-item); padding: 0 var(--gap-3) 0 var(--gap-4); border: 0; background: transparent; color: var(--ink); display: flex; align-items: center; text-align: left; cursor: pointer; outline: 0; }
.popover__option[aria-checked='true'] { font-weight: 500; }
.popover__option[aria-checked='true']::before { content: ''; position: absolute; left: 0; top: var(--gap-2); bottom: var(--gap-2); width: var(--bar); background: var(--ink); }
.popover__option:focus-visible { background: var(--row-hover); }
.toast-stack { position: fixed; right: var(--gap-5); bottom: var(--gap-5); z-index: 40; display: flex; flex-direction: column; align-items: flex-end; gap: var(--gap-2); pointer-events: none; }
.toast { padding: var(--gap-3) var(--gap-4); background: var(--canvas); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-pop); color: var(--ink); font-size: var(--text-sm); opacity: 0; transform: translateY(var(--gap-3)); transition: opacity var(--dur-toast) var(--ease-out), transform var(--dur-toast) var(--ease-out); }
.toast.is-open { opacity: 1; transform: none; }

/* ---------- Small and low screens ---------- */
@media (max-height: 600px) {
  .nav__item { min-height: calc(var(--side-item) - var(--gap-1)); }
}
@media (max-width: 760px) {
  .app { height: auto; flex-wrap: wrap; overflow: visible; }
  .sidebar { flex: 1 1 100%; height: auto; }
  .main { height: auto; overflow: visible; }
  .page { overflow: visible; padding: var(--gap-4); }
  .search { flex: 1 1 100%; order: 3; }
  .kpi__value { font-size: calc(var(--text-figure) * 0.8); }
  .login__brand, .login__form { padding: var(--gap-6) var(--gap-5); }
}

/* ---------- Motion ----------
   Frequent actions (menu, tabs, keyboard) stay instant. Enter and exit use ease-out,
   movement uses transform and opacity only. Hover effects only where a pointer can hover. */

/* page change: the sidebar stays, only the page content fades */
@view-transition { navigation: auto; }
/* the old page fades out and rises 6px, the new one fades in and comes 8px from below */
::view-transition-old(root) { animation: page-out var(--dur-page-out) var(--ease-out) both; }
::view-transition-new(root) { animation: page-in var(--dur-page-in) var(--ease-page) both; }
@keyframes page-out { to { opacity: 0; transform: translateY(calc(var(--page-out-rise) * -1)); } }
@keyframes page-in { from { opacity: 0; transform: translateY(var(--page-in-rise)); } }
/* the sidebar, open or collapsed, does not move at all: the new state shows at once */
::view-transition-group(sidebar), ::view-transition-new(sidebar) { animation: none; }
::view-transition-old(sidebar) { display: none; }
/* the active menu mark glides to its new place; blended so the menu text stays readable on top */
::view-transition-group(nav-active) { animation-duration: var(--dur-nav); animation-timing-function: var(--ease-page); mix-blend-mode: multiply; }
:root[data-sidebar='ink']::view-transition-group(nav-active) { mix-blend-mode: screen; }
::view-transition-old(nav-active), ::view-transition-new(nav-active) { animation-duration: var(--dur-nav); }
/* the page title morphs from the old title to the new one */
::view-transition-group(page-title), ::view-transition-old(page-title), ::view-transition-new(page-title) { animation-duration: var(--dur-nav); animation-timing-function: var(--ease-page); }
.page-title { view-transition-name: page-title; }
/* a customer name morphs from its list row into the title of the customer page (names set by JS, one per customer) */
.entity__name, .record-id__title { view-transition-class: record-name; }
::view-transition-group(*.record-name), ::view-transition-old(*.record-name), ::view-transition-new(*.record-name) { animation-duration: var(--dur-nav); animation-timing-function: var(--ease-page); }
/* to and from the sign-in page the sidebar exists on one side only */
::view-transition-old(sidebar):only-child { display: block; animation: fade-out var(--dur-fast) var(--ease-out) both; }
::view-transition-new(sidebar):only-child { animation: fade-in var(--dur-fast) var(--ease-out) both; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }

/* hover and press */
.btn, .icon-btn, .segmented__option, .lang__option, .tab, .command, .profile-menu__option, .popover__option, .link-button, .pager__link {
  transition: transform var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.btn:active, .icon-btn:active, button.segmented__option:active, .lang__option:active, .command:active { transform: scale(0.97); }
.list tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
@media (hover: hover) {
  .nav__item:hover { color: var(--side-strong); }
  .sidebar__toggle:hover, .profile:hover { background: var(--side-active); color: var(--side-strong); }
  :root.sidebar-collapsed .nav__item:hover .nav__label,
  :root.sidebar-collapsed .profile:hover .profile__name { opacity: 1; }
  :root.sidebar-collapsed .profile[aria-expanded='true']:hover .profile__name { opacity: 0; }
  .profile-menu__option:hover { color: var(--ink); }
  .profile-menu__logout:hover, .popover__option:hover { background: var(--row-hover); }
  .btn:hover { background: var(--row-hover); border-color: var(--check); }
  .btn--primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--canvas)); border-color: transparent; }
  .link-button:hover, .pager__link:not(:disabled):hover { text-decoration: underline; }
  .list tbody tr:hover { background: var(--row-hover); }
  .list tbody tr.is-selected:hover { background: var(--nav-active); }
  .tab:hover, .segmented__option:hover { color: var(--ink); }
  .step__link:hover .step__name { text-decoration: underline; }
  .command:hover { color: var(--ink); }
  .row-actions .icon-btn:hover { color: var(--ink); }
  .row-actions { opacity: 0; transition: opacity var(--dur-fast) var(--ease-out); }
  .list--people tr:hover .row-actions, .list--people tr:focus-within .row-actions, .list--people tr:focus .row-actions, .list--people tr.is-selected .row-actions { opacity: 1; }
}

/* tab content: the old part fades out, the new one fades in with a small rise (js/tabs.js) */
.tab-fade { transition: opacity var(--dur-fade-in) var(--ease-out), transform var(--dur-fade-in) var(--ease-out); }
.tab-fade.is-leaving { opacity: 0; transform: none; transition: opacity var(--dur-fade-out) linear; }
.tab-fade.is-entering { opacity: 0; transform: translateY(var(--gap-1)); transition: none; }

/* sections of a page: once on load, small rise, short stagger */
.page > * { animation: rise-in var(--dur-base) var(--ease-out) backwards; animation-delay: calc(var(--n, 0) * var(--stagger)); }
.page > :nth-child(2) { --n: 1; } .page > :nth-child(3) { --n: 2; } .page > :nth-child(4) { --n: 3; }
.page > :nth-child(5) { --n: 4; } .page > :nth-child(n+6) { --n: 5; }
/* arriving through a page transition: blocks start once the new page has faded in; the head with the morphing title stays */
.vt-in .page > * { animation-delay: calc(var(--dur-page-in) + var(--n, 0) * var(--stagger)); }
.vt-in .page > .page-head, .vt-in .page > .record-head { animation: none; }
@keyframes rise-in { from { opacity: 0; transform: translateY(var(--rise)); } }

/* bars fill once from the left */
.bar__fill { transform-origin: left; animation: fill-in var(--dur-slow) var(--ease-out) var(--dur-fast) backwards; }
@keyframes fill-in { from { transform: scaleX(0); } }

/* sidebar labels come back after the sidebar has opened (see setCollapsed in app.js) */
.is-expanding .brand, .is-expanding .nav__label, .is-expanding .profile__name, .is-expanding .profile__chevron { animation: fade-in var(--dur-base) var(--ease-out) var(--dur-fast) backwards; }

/* sign-in error */
@keyframes shake { 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

/* ---------- Record pages: customer, supplier and project share these classes (js/record.js) ----------
   Header zone (white): back link, identity and actions, KPI row, full-width line.
   Body zone (--sunken): white section cards, two columns from 1100px, one below. */
.page.record { padding: 0; gap: 0; }
.record-head { display: flex; flex-direction: column; gap: var(--gap-4); padding: var(--gap-5) var(--gap-6) 0; background: var(--canvas); border-bottom: 1px solid var(--line); }
.record-head__back { align-self: flex-start; display: inline-flex; align-items: center; gap: var(--gap-1); color: var(--ink-2); font-size: var(--text-sm); text-decoration: none; }
.record-head__back .icon { width: var(--icon-sm); height: var(--icon-sm); }
.record-head__row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--gap-4); }
.record-id { display: flex; align-items: center; gap: var(--gap-4); min-width: 0; }
.record-id__avatar { width: var(--record-avatar); height: var(--record-avatar); border-radius: 50%; background: var(--fill); color: var(--ink); font-size: var(--text-md); font-weight: 500; display: flex; align-items: center; justify-content: center; flex: none; }
.record-id__text { display: flex; flex-direction: column; gap: var(--gap-1); min-width: 0; }
.page-title.record-id__title { font-size: var(--text-record); line-height: 1.15; }
.record-meta { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--gap-1) var(--gap-4); color: var(--ink-2); }
.record-meta__item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.record-meta__item > .icon { width: var(--icon-sm); height: var(--icon-sm); }
.record-meta__item a { color: var(--ink); text-decoration: none; }

/* stage track (project): all stages on one line, done filled, the current one named with its date */
.stage-track { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(var(--stages, 5), minmax(0, 1fr)); max-width: calc(var(--sidebar-w) * 3.4); }
.stage-track__step { position: relative; display: flex; flex-direction: column; min-width: 0; padding: calc(var(--gap-3) + var(--gap-1)) var(--gap-2) 0 0; color: var(--ink-3); font-size: var(--text-sm); }
.stage-track__step::before { content: ''; position: absolute; top: 4px; left: 0; right: 0; height: var(--bar); background: var(--line-strong); }
.stage-track__step::after { content: ''; position: absolute; top: 0; left: 0; box-sizing: border-box; width: 10px; height: 10px; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--canvas); }
.stage-track__step:last-child::before { display: none; }
.stage-track__step.is-done { color: var(--ink-2); }
.stage-track__step.is-done::before, .stage-track__step.is-done::after { background: var(--ink); border-color: var(--ink); }
.stage-track__step.is-current { color: var(--ink); font-weight: 500; }
.stage-track__step.is-current::after { border-color: var(--ink); box-shadow: 0 0 0 3px var(--fill); }
.stage-track__name, .stage-track__since { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-track__since { color: var(--ink-2); font-size: var(--text-xs); font-weight: 400; }

/* KPI row: four equal cells divided by thin lines, no boxes */
.record-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; padding: var(--gap-1) 0 var(--gap-5); }
.record-kpi { min-width: 0; padding: 0 var(--gap-5); border-left: 1px solid var(--line); }
.record-kpi:first-child { padding-left: 0; border-left: 0; }
.record-kpi > * { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-kpi__label { color: var(--ink-2); font-size: var(--text-xs); font-weight: 500; }
.record-kpi__value { margin-top: var(--gap-1); font-size: var(--text-kpi); font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.record-kpi__value--warn { color: var(--warn); }
.record-kpi__value--danger { color: var(--danger); }
.record-kpi__sub { color: var(--ink-2); font-size: var(--text-sm); }
/* tabs (project) sit on the header line */
.record-head > .tabs { border-bottom: 0; margin-bottom: -1px; }
.record-head > .record-kpis:last-child { padding-bottom: var(--gap-5); }

/* body zone: the colour change separates it from the header */
.record-body { flex: 1 0 auto; display: flex; flex-direction: column; gap: var(--card-pad); padding: var(--card-pad) var(--gap-6) var(--gap-6); background: var(--sunken); }
.record-body > .tab-panel { display: flex; flex-direction: column; gap: var(--card-pad); }
.record-body .columns { grid-template-columns: minmax(0, 1fr); gap: var(--card-pad); }  /* tables in cards get the full width */
.record-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: var(--card-pad); align-items: start; }
.record-grid__main, .record-grid__side, .record-stack { display: flex; flex-direction: column; gap: var(--card-pad); min-width: 0; }
/* long pages: a small sticky menu with one link per card */
.record-menu { position: sticky; top: 0; z-index: 2; display: flex; flex-wrap: wrap; gap: var(--gap-1) var(--gap-4); margin: calc(var(--card-pad) * -1) 0 calc(var(--card-pad) * -0.5); padding: var(--gap-3) 0; background: var(--sunken); font-size: var(--text-sm); }
.record-menu[hidden] { display: none; }
.record-menu__link { color: var(--ink-2); text-decoration: none; white-space: nowrap; }
.record-menu__link.is-active { color: var(--ink); font-weight: 500; }

/* section card */
.card { display: flex; flex-direction: column; gap: var(--gap-3); min-width: 0; padding: var(--card-pad); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--canvas); scroll-margin-top: calc(var(--control) + var(--gap-3)); container: card / inline-size; }
.card__head { display: flex; align-items: center; gap: var(--gap-3); min-height: var(--tile); }
.card__title { font-size: var(--text-md); font-weight: 500; white-space: nowrap; }
.card__count { color: var(--ink-2); }
.card__action { margin-left: auto; padding: 0; border: 0; background: none; color: var(--ink-2); font: inherit; font-size: var(--text-sm); text-decoration: none; white-space: nowrap; cursor: pointer; }
.card__empty { color: var(--ink-2); padding: var(--gap-2) 0; }
.card > .list-tools, .card > .filter-tags { margin: 0; }
/* icon tile: card heads, payment states, activity channels */
.icon-tile { width: var(--tile); height: var(--tile); border-radius: var(--radius); background: var(--fill); color: var(--ink); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-tile > .icon { width: var(--icon-sm); height: var(--icon-sm); }
.icon-tile--warn { color: var(--warn); }
.icon-tile--danger { color: var(--danger); }
.icon .icon__solid { fill: currentColor; stroke: none; }
.icon .icon__knock { stroke: var(--canvas); stroke-width: 2; }

/* rows in a card: 52px, fixed columns, never wrap (ellipsis, full text as tooltip) */
.card-list { list-style: none; margin: 0 calc(var(--card-pad) * -1); padding: 0; }
.card-row { position: relative; display: grid; grid-template-columns: var(--cols); align-items: center; column-gap: var(--gap-3); height: var(--card-row); padding: 0 var(--card-pad); border-top: 1px solid var(--line-soft); }
.card-row.is-link { cursor: pointer; }
.card-row :is(a, button):not(.row-link) { position: relative; z-index: 1; }
.card-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-cell--num { text-align: right; font-variant-numeric: tabular-nums; }
.card-cell--muted { color: var(--ink-2); }
.card-cell > .status { display: inline-flex; max-width: 100%; }
.card-entity { display: flex; align-items: center; gap: var(--gap-3); min-width: 0; }
.card-entity__avatar { width: var(--avatar-sm); height: var(--avatar-sm); border-radius: 50%; background: var(--fill); font-size: var(--text-2xs); font-weight: 500; display: flex; align-items: center; justify-content: center; flex: none; }
.card-entity__text { display: flex; flex-direction: column; min-width: 0; line-height: 1.35; }
.card-entity__name, .card-entity__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-entity__name { color: var(--ink); text-decoration: none; }
.card-entity__sub { color: var(--ink-2); font-size: var(--text-sm); }
/* column sets, shared by card type */
.card-list--2 { --cols: minmax(0, 1fr) var(--col-status); }                                           /* name and one status */
.card-list--3 { --cols: minmax(0, 1fr) var(--col-status) var(--col-amount); }                       /* linked records */
.card-list--4 { --cols: minmax(0, 1fr) var(--col-mid) var(--col-status) var(--col-amount); }        /* linked records with stage or date */
.card-list--tasks { --cols: minmax(0, 1fr) var(--col-status) var(--avatar-row); }
.card-list--payments { --cols: var(--tile) minmax(0, 1fr) var(--col-date) var(--col-status) var(--col-amount); }
.card-list--details { --cols: var(--icon-sm) calc(var(--col-date) - var(--gap-1)) minmax(0, 1fr) var(--control-sm); }
.card-list--details .card-row { height: auto; min-height: calc(var(--card-row) - var(--gap-2)); }
.card-list--details .icon { width: var(--icon-sm); height: var(--icon-sm); color: var(--ink-2); }
.card-list--details .card-cell--muted { color: var(--ink-2); }
.card-row__copy { width: var(--control-sm); height: var(--control-sm); color: var(--ink-2); opacity: 0; }
.card-row__copy .icon { width: var(--icon-sm); height: var(--icon-sm); }
.card-row:hover .card-row__copy, .card-row:focus-within .card-row__copy, .card-row__copy.is-copied { opacity: 1; }
.card-row__dir { width: 12px; height: 12px; margin-right: var(--gap-1); color: var(--ink-3); stroke-width: 2; vertical-align: -1px; }

/* payments: a thin split bar paid vs open, both amounts labelled */
.pay-split { display: flex; flex-direction: column; gap: var(--gap-1); }
.pay-split__labels { display: flex; justify-content: space-between; gap: var(--gap-3); color: var(--ink-2); font-size: var(--text-sm); }
.pay-split__labels strong { color: var(--ink); font-weight: 500; }
.pay-split .split-bar { margin: 0; }

/* notes and activity, newest first */
.note-add { display: flex; gap: var(--gap-2); }
.note-add__input { flex: 1; min-width: 0; }
.activity { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.activity__item { display: grid; grid-template-columns: var(--tile) minmax(0, 1fr); gap: var(--gap-3); padding: var(--gap-3) 0; border-top: 1px solid var(--line-soft); }
.activity__meta { color: var(--ink-2); font-size: var(--text-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity__text { overflow-wrap: anywhere; }

/* documents: medium guiding thumbnails with name, type and date */
.doc-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(var(--thumb-md) + var(--gap-6)), 1fr)); gap: var(--gap-4) var(--gap-3); }
.doc-tile { display: flex; flex-direction: column; align-items: flex-start; gap: var(--gap-1); min-width: 0; color: var(--ink); text-decoration: none; }
.doc-tile__name, .doc-tile__meta { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-tile__name { margin-top: var(--gap-1); font-size: var(--text-sm); }
.doc-tile__meta { color: var(--ink-2); font-size: var(--text-xs); }

/* tables kept inside cards (project tabs): rows never wrap */
.card .table-wrap { margin: 0 calc(var(--card-pad) * -1); }
.card .list td { min-height: var(--card-row); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .list .status { white-space: nowrap; }
.card .list tr { padding: 0 var(--card-pad); }
.card .total { margin: 0; }

@media (hover: hover) {
  .record-head__back:hover, .record-meta__item a:hover, .card__action:hover, .record-menu__link:hover { color: var(--ink); }
  .card__action:hover { text-decoration: underline; }
  .card-row:hover { background: var(--row-hover); }
  .doc-tile:hover .doc-tile__name { text-decoration: underline; }
}
/* narrow cards (side column): the fixed columns get narrower, still fixed */
@container card (max-width: 440px) {
  .card-list { --col-status: 112px; --col-amount: 80px; }
}
@media (max-width: 1100px) {
  .record-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .record-head, .record-body { padding-left: var(--gap-4); padding-right: var(--gap-4); }
  .record-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: var(--gap-4); }
  .record-kpi:nth-child(3) { padding-left: 0; border-left: 0; }
  .card-list--4 { --cols: minmax(0, 1fr) var(--col-status) var(--col-amount); }
  .card-list--4 .card-cell:nth-child(2) { display: none; }
  .card-list--payments { --cols: var(--tile) minmax(0, 1fr) var(--col-amount); }
  .card-list--payments .card-cell:nth-child(3), .card-list--payments .card-cell:nth-child(4) { display: none; }
}

/* reduced motion: nothing moves, fades stay */
@media (prefers-reduced-motion: reduce) {
  .home__letter, .home__brand .brand__name, .home__rule, .home__brand .brand__sub, .home .choice-card, .home > .command { animation: none; }
  .home > *, .intro-seen .home > * { animation: fade-in 300ms var(--ease-out) backwards; }
  .home__brand .brand__name::after, .home__brand .brand__name:hover::after { animation: none; }
  ::view-transition-group(nav-active), ::view-transition-group(page-title), ::view-transition-group(*.record-name) { animation: none; }
  .page > * { animation-name: fade-in; }
  .bar__fill { animation: none; }
  .sidebar::before { transition: none; }
  .btn:active, .icon-btn:active, button.segmented__option:active, .lang__option:active, .command:active { transform: none; }
  .login__card.is-shaking { animation: none; }
  .panel { transform: none; opacity: 0; transition: opacity var(--dur-base) var(--ease-out); }
  .panel.is-open { opacity: 1; transition-duration: var(--dur-panel); }
  .dialog, .dialog.is-open { transform: translate(-50%, -50%); }
  .popover, .toast { transform: none; }
  .task__check::before { transition: none; }
}

/* ---------- Guiding thumbnails: a miniature document per object type (js/thumbs.js) ---------- */
.doc-thumb { --t: var(--thumb-md); --tag-bg: var(--ink); position: relative; display: inline-flex; align-items: center; justify-content: center; width: var(--t); height: var(--t); flex: none; border-radius: var(--radius); background: var(--fill); vertical-align: middle; }
.doc-thumb--sm { --t: var(--thumb-sm); border-radius: var(--radius-sm); }
.doc-thumb--lg { --t: var(--thumb-lg); border-radius: var(--radius-lg); }
.doc-thumb--none { background: transparent; }  /* keeps the place in rows without a document */
.doc-thumb__paper { position: relative; width: calc(var(--t) * 0.62); height: calc(var(--t) * 0.78); border: 1px solid var(--line); border-radius: var(--radius-xs); background: var(--canvas); box-shadow: var(--shadow-paper); }
.doc-thumb--sm .doc-thumb__paper { border-radius: var(--radius-tag); }
.doc-thumb--lg .doc-thumb__paper { border-radius: var(--radius-sm); }
.doc-thumb__paper--short { height: calc(var(--t) * 0.5); }
.doc-thumb__paper--behind { position: absolute; top: 50%; left: 50%; transform: translate(calc(-50% + var(--t) * 0.08), calc(-50% - var(--t) * 0.06)); }
.doc-thumb__paper svg, .doc-thumb__art { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.doc-thumb__art { inset: 15%; width: 70%; height: 70%; }
.doc-thumb .sk { fill: var(--skeleton); }
.doc-thumb .sk2 { fill: var(--skeleton-strong); }
.doc-thumb .sk3 { fill: var(--ink-3); }
.doc-thumb .sw1 { fill: var(--skeleton-strong); }
.doc-thumb .sw2 { fill: var(--ink-3); }
.doc-thumb .sw3 { fill: var(--ink-2); }
.doc-thumb .so, .doc-thumb .cell, .doc-thumb .cellh, .doc-thumb .line, .doc-thumb .dim, .doc-thumb .tick { vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; }
.doc-thumb .so { fill: none; stroke: var(--skeleton-strong); stroke-width: 1; }
.doc-thumb .cell { fill: none; stroke: var(--skeleton); stroke-width: 1; }
.doc-thumb .cellh { fill: var(--skeleton); stroke: var(--skeleton-strong); stroke-width: 1; }
.doc-thumb .line { stroke: var(--ink-3); stroke-width: 1.3; }
.doc-thumb .dim { stroke: var(--skeleton-strong); stroke-width: 1; }
.doc-thumb .tick { stroke: var(--ink); stroke-width: 1.8; }
.doc-thumb__tag { position: absolute; top: 12%; left: -10%; z-index: 1; padding: 2px 3px; border-radius: var(--radius-tag); background: var(--tag-bg); color: var(--canvas); font-size: var(--text-tag); font-weight: 600; line-height: 1; letter-spacing: 0.04em; text-transform: uppercase; white-space: nowrap; }
.doc-thumb--md .doc-thumb__tag > span { display: none; }
.doc-thumb--md .doc-thumb__tag { left: -18%; padding: 2px; letter-spacing: 0.02em; }  /* long tags stay inside the tile */
.doc-thumb--md .doc-thumb__tag::before { content: attr(data-short); }
.doc-thumb--sm .doc-thumb__tag { top: 14%; left: 12%; width: 45%; height: 3px; padding: 0; border-radius: 1px; font-size: 0; }
.doc-thumb__mark { position: absolute; right: 6%; bottom: 6%; z-index: 2; width: max(var(--gap-3), calc(var(--t) * 0.26)); height: max(var(--gap-3), calc(var(--t) * 0.26)); border: 1px solid var(--line); border-radius: 50%; background: var(--canvas); color: var(--ink); display: flex; align-items: center; justify-content: center; }
.doc-thumb__mark--paid { border-color: var(--ink); background: var(--ink); color: var(--canvas); }
.doc-thumb__mark svg, .doc-thumb__badge svg { width: 70%; height: 70%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.doc-thumb__dot { position: absolute; top: 8%; right: 8%; z-index: 2; width: max(var(--dot), calc(var(--t) * 0.13)); height: max(var(--dot), calc(var(--t) * 0.13)); border-radius: 50%; box-shadow: 0 0 0 2px var(--fill); }
.doc-thumb__dot--waiting { background: var(--warn); }
.doc-thumb__dot--overdue { background: var(--danger); }
.doc-thumb__count { position: absolute; left: 6%; bottom: 6%; z-index: 2; min-width: calc(var(--gap-3) + 2px); height: calc(var(--gap-3) + 2px); padding: 0 var(--radius-tag); border-radius: var(--radius-tag); background: var(--ink); color: var(--canvas); font-size: var(--text-tag); font-weight: 600; display: flex; align-items: center; justify-content: center; }
.doc-thumb--sm .doc-thumb__count { display: none; }
.doc-thumb__badge { position: absolute; right: 8%; bottom: 8%; z-index: 2; width: var(--thumb-badge); height: var(--thumb-badge); border-radius: var(--radius-badge); background: var(--tag-bg); color: var(--canvas); display: flex; align-items: center; justify-content: center; }
/* a thumbnail and its name in one cell */
.doc-cell { display: flex; align-items: center; gap: var(--gap-3); min-width: 0; }
.doc-cell__text { display: flex; flex-direction: column; min-width: 0; }

/* ---------- Choice cards: what to create, open or import ---------- */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(calc(var(--thumb-lg) * 1.2), 100%), 1fr)); gap: var(--gap-3); }
.choice-card { display: flex; flex-direction: column; gap: var(--gap-1); padding: var(--gap-2) var(--gap-2) var(--gap-3); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--canvas); color: var(--ink); font: inherit; text-align: left; text-decoration: none; cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out); }
.choice-card__art { display: flex; align-items: center; justify-content: center; height: calc(var(--thumb-lg) + var(--gap-4)); margin-bottom: var(--gap-2); border-radius: var(--radius); background: var(--fill); }
.choice-card__art .doc-thumb { background: transparent; transition: transform var(--dur-fast) var(--ease-out); }
.choice-card__label { padding: 0 var(--gap-1); font-weight: 500; }
.choice-card__note { padding: 0 var(--gap-1); color: var(--ink-2); font-size: var(--text-sm); }
.choice-card[aria-pressed='true'] { border-color: var(--ink); }
/* the one place where object types carry a tone: tag and badge on choice cards */
.choice-card .doc-thumb { --tag-bg: var(--type, var(--ink)); }
.choice-card--quote { --type: var(--type-quote); }
.choice-card--order { --type: var(--type-order); }
.choice-card--packing { --type: var(--type-packing); }
.choice-card--project { --type: var(--type-project); }
.choice-card--payment { --type: var(--type-payment); }
.choice-card--customer { --type: var(--type-customer); }
.choice-card--note { --type: var(--type-note); }
.choice-card--product { --type: var(--type-product); }
.choice-card--sample { --type: var(--type-sample); }
.choice-card--expense { --type: var(--type-expense); }

/* ---------- Upload zones: dashed outline with the matching thumbnail ---------- */
.upload { position: relative; display: flex; flex-direction: column; align-items: center; gap: var(--gap-2); padding: var(--gap-5) var(--gap-4); border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); color: var(--ink-2); text-align: center; cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.upload input[type='file'] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.upload__title { color: var(--ink); font-weight: 500; }
.upload__name { font-size: var(--text-sm); }
.upload .doc-thumb { opacity: 0.6; transition: opacity var(--dur-base) var(--ease-out); }
.upload.is-over { border-color: var(--ink); background: var(--row-hover); }
.upload.is-filled { border-style: solid; border-color: var(--line); }
.upload.is-filled .doc-thumb { opacity: 1; }
.upload.is-filled .doc-thumb .sk { fill: var(--skeleton-strong); }
.upload.is-filled .doc-thumb .cell { stroke: var(--skeleton-strong); }
.upload.is-filled .upload__name { color: var(--ink); }
.upload:focus-within { border-color: var(--ink); }

/* ---------- List toolbar: search, filter, sort (js/lists.js) ---------- */
.list-tools { position: relative; display: flex; align-items: center; justify-content: flex-end; gap: var(--gap-1); }
.tabbar .list-tools { align-self: center; }
.list-tools__button { display: inline-flex; align-items: center; gap: calc(var(--gap-1) + 2px); height: var(--control-sm); padding: 0 var(--gap-2); border: 0; border-radius: var(--radius); background: transparent; color: var(--ink-2); font-size: var(--text-md); white-space: nowrap; cursor: pointer; }
.list-tools__button .icon { width: var(--icon-sm); height: var(--icon-sm); }
.list-tools__button.is-active { background: var(--fill); color: var(--ink); }
.list-tools__count { color: var(--ink); font-weight: 500; }
.list-tools__search { display: flex; align-items: center; height: var(--control-sm); padding: 0 var(--gap-3); border-radius: var(--radius); background: var(--fill); }
.list-tools__input { width: calc(var(--sidebar-w) * 0.7); border: 0; outline: 0; background: transparent; color: var(--ink); }
.list-tools__input::placeholder { color: var(--ink-2); }
.list-tools__pop { position: absolute; top: calc(100% + var(--gap-1)); right: 0; z-index: 20; width: calc(var(--sidebar-w) * 1.3); padding: var(--gap-3); border-radius: var(--radius-lg); transform-origin: top right; text-align: left; }
.list-tools__pop--sort { width: calc(var(--sidebar-w) * 0.95); padding: var(--gap-2) 0; }
.list-tools__pop-title { display: block; margin-bottom: var(--gap-2); color: var(--ink); font-size: var(--text-sm); font-weight: 500; }
.list-tools__pop--sort .list-tools__pop-title { padding: 0 var(--gap-4); }
.list-tools__pop-head { display: flex; align-items: center; gap: var(--gap-1); margin: calc(var(--gap-2) * -1) 0 var(--gap-2) calc(var(--gap-2) * -1); }
.list-tools__pop-head .list-tools__pop-title { margin: 0; }
.list-tools__pop-foot { display: flex; justify-content: flex-end; margin-top: var(--gap-3); }
.list-tools__dir { margin-top: var(--gap-1); padding: var(--gap-2) var(--gap-3) 0; border-top: 1px solid var(--line); }
.filter-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap-2); }
.filter-tile { display: flex; flex-direction: column; align-items: flex-start; gap: var(--gap-2); padding: var(--gap-3); border: 1px solid transparent; border-radius: var(--radius); background: var(--fill); color: var(--ink-2); font-size: var(--text-sm); text-align: left; cursor: pointer; }
.filter-tile .icon { width: var(--icon-tile); height: var(--icon-tile); }
.filter-tile.is-chosen { border-color: var(--ink); color: var(--ink); }
.filter-values { display: flex; flex-direction: column; max-height: calc(var(--row) * 4); overflow-y: auto; }
.filter-value { display: flex; align-items: center; gap: var(--gap-3); min-height: var(--side-item); cursor: pointer; }
.filter-value__label { flex: 1; min-width: 0; }
.filter-value__count { color: var(--ink-2); font-size: var(--text-sm); }
.filter-tags { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-2); margin-top: calc(var(--gap-3) * -1); }
.filter-tag { display: inline-flex; align-items: center; gap: var(--gap-1); padding: 2px 2px 2px var(--gap-2); border-radius: var(--radius-sm); background: var(--fill); color: var(--ink); font-size: var(--text-sm); }
.filter-tag__remove { width: calc(var(--gap-4) + var(--gap-1)); height: calc(var(--gap-4) + var(--gap-1)); padding: 0; border: 0; border-radius: var(--radius-xs); background: transparent; color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.filter-tag__remove svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.filter-tags__clear { min-height: 0; color: var(--ink-2); font-size: var(--text-sm); }
.list.is-empty thead { display: none; }
/* empty list: matching thumbnail, one line, one button */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--gap-3); padding: var(--gap-6) var(--gap-4); color: var(--ink-2); text-align: center; }

/* ---------- Quiet tags for several values in one cell ---------- */
.tag-list { display: flex; flex-wrap: wrap; gap: var(--gap-1); }
.tag { display: inline-flex; align-items: center; height: var(--tag-h); padding: 0 calc(var(--gap-1) + 2px); border-radius: var(--radius-sm); background: var(--fill); color: var(--ink-2); font-size: var(--text-sm); white-space: nowrap; }

/* ---------- Mini stage indicator next to a project name ---------- */
.stage-dots { display: inline-flex; gap: 2px; margin-left: var(--gap-2); vertical-align: middle; }
.stage-dots__step { width: var(--gap-2); height: calc(var(--bar) + 1px); border-radius: 1px; background: var(--line); }
.stage-dots__step.is-done { background: var(--ink); }
.stage-dots__step.is-current { background: var(--ink-3); }

/* ---------- Payment split: paid against open on invoices and orders ---------- */
.split-bar { display: block; width: 100%; height: var(--bar); margin-top: var(--gap-1); border-radius: 1px; background: var(--line); overflow: hidden; }
.split-bar__paid { display: block; height: 100%; background: var(--ink); }

@media (hover: hover) {
  .choice-card:hover { border-color: var(--ink); }
  .choice-card:hover .doc-thumb { transform: translateY(-2px); }
  .list-tools__button:hover { color: var(--ink); }
  .filter-tile:hover { color: var(--ink); }
  .filter-tag__remove:hover { color: var(--ink); background: var(--line); }
  .upload:hover { border-color: var(--ink-3); }
}
@media (prefers-reduced-motion: reduce) {
  .choice-card .doc-thumb, .choice-card:hover .doc-thumb { transform: none; }
}

/* ---------- Header with a thumbnail, detected sheets of an upload ---------- */
.page-head__lead { display: flex; align-items: center; gap: var(--gap-4); }
.sheet-list { display: flex; flex-wrap: wrap; gap: var(--gap-3); }
.sheet-item { display: flex; align-items: center; gap: var(--gap-3); padding: var(--gap-2) var(--gap-4) var(--gap-2) var(--gap-2); border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--canvas); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.sheet-item[aria-pressed='true'] { border-color: var(--ink); }
@media (hover: hover) { .sheet-item:hover { border-color: var(--ink-3); } .sheet-item[aria-pressed='true']:hover { border-color: var(--ink); } }

/* ---------- Review page for the thumbnails (thumbs.html) ---------- */
.list--variants { --cols: minmax(0, 1.6fr) var(--thumb-sm) var(--thumb-md) var(--thumb-lg) minmax(0, 1.4fr); }
.list--variants td { padding-top: var(--gap-3); padding-bottom: var(--gap-3); }
.thumb-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--gap-5); }
.thumb-demo { display: flex; flex-direction: column; align-items: center; gap: var(--gap-2); }
.split-demo { display: flex; flex-direction: column; gap: var(--gap-2); width: calc(var(--sidebar-w) * 0.6); }

/* ---------- Agenda: week strip, one day, task rows (js/agenda.js) ---------- */
.segmented--sm .segmented__option { height: var(--segment-sm); padding: 0 var(--gap-2); }
.segmented--sm .segmented__thumb { height: var(--segment-sm); }
.agenda { gap: var(--gap-5); }
.week { display: flex; align-items: center; gap: var(--gap-2); }
.week__days { flex: 1; min-width: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--gap-2); }
.week__day { position: relative; height: var(--day-tile-h); padding: var(--gap-2) var(--gap-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--canvas); color: var(--ink); display: flex; flex-direction: column; justify-content: space-between; text-align: left; font: inherit; cursor: pointer; transition: border-color var(--dur-fast) var(--ease-out); }
.week__head { display: flex; align-items: baseline; justify-content: space-between; }
.week__name { color: var(--ink-2); font-size: var(--text-xs); }
.week__num { font-size: calc(var(--text-lg) + 4px); font-weight: 500; font-variant-numeric: tabular-nums; line-height: 1; }
.week__stripes { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap-1); min-height: var(--stripe-h); }
.week__stripe { width: var(--stripe-w); height: var(--stripe-h); border-radius: 2px; background: var(--stripe); transition: opacity var(--dur-base) var(--ease-out); }
.week__stripe--warn { background: var(--warn); }
.week__stripe--overdue { background: var(--danger); }
.week__more { color: var(--ink-2); font-size: var(--text-xs); line-height: 1; }
.week__day.is-selected { border-color: var(--ink); background: var(--ink); color: var(--canvas); }
.week__day.is-selected .week__name, .week__day.is-selected .week__more { color: var(--stripe-on-ink); }
.week__day.is-selected .week__stripe { background: var(--stripe-on-ink); }
.week__day.is-selected .week__stripe--warn { background: var(--warn-on-ink); }
.week__day.is-selected .week__stripe--overdue { background: var(--danger-on-ink); }
.week__num { position: relative; }
.week__day.is-today:not(.is-selected) .week__num::after { content: ''; position: absolute; left: 50%; bottom: calc(var(--gap-1) * -2); width: var(--dot); height: var(--dot); border-radius: 50%; background: var(--ink); transform: translateX(-50%); }
.week__day:focus-visible { outline: var(--bar) solid var(--ink); outline-offset: var(--bar); }
.week__nav { flex: none; color: var(--ink-2); }
/* the selected day: heading with the open count, then the tasks */
.agenda-day { display: flex; flex-direction: column; gap: var(--gap-2); }
.agenda-day__head { display: flex; align-items: baseline; gap: var(--gap-2); }
.agenda-day__title { font-size: var(--text-md); font-weight: 500; }
.agenda-day__count { color: var(--ink-2); }
.agenda-day__back { min-height: 0; margin-left: var(--gap-2); color: var(--ink-2); font-size: var(--text-sm); }
.agenda-day__list { display: flex; flex-direction: column; gap: 2px; }
.agenda-day__label { padding: var(--gap-2) var(--gap-3) var(--gap-1); color: var(--ink-2); font-size: var(--text-xs); font-weight: 500; }
/* one task: tick, title and project, status, person. The row folds away once it is done */
.task-row { display: grid; grid-template-rows: 1fr; transition: grid-template-rows var(--dur-slow) var(--ease-in-out), opacity var(--dur-base) var(--ease-out); }
.task-row.is-collapsing { grid-template-rows: 0fr; opacity: 0; }
.task-row__inner { min-height: 0; overflow: hidden; }
.task-row__body { position: relative; min-height: var(--task-row); padding: var(--gap-2) var(--gap-3); border-radius: var(--radius); display: grid; grid-template-columns: var(--round-check) minmax(0, 1fr) auto var(--avatar-row); grid-template-areas: "check text status person"; align-items: center; column-gap: var(--gap-3); transition: background-color var(--dur-fast) var(--ease-out); }
.task-check { grid-area: check; position: relative; z-index: 1; width: var(--round-check); height: var(--round-check); padding: 0; border: 1.5px solid var(--stripe); border-radius: 50%; background: var(--canvas); color: var(--canvas); display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out); }
.task-check svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transform: scale(0.6); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out); }
.task-check[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); }
.task-check[aria-pressed='true'] svg { opacity: 1; transform: none; }
.task-row__text { grid-area: text; display: flex; flex-direction: column; min-width: 0; }
.task-row__open { padding: 0; border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; transition: color var(--dur-base) var(--ease-out); }
.task-row__open::after { content: ''; position: absolute; inset: 0; border-radius: var(--radius); }   /* the whole row opens the task */
.task-row__project { color: var(--ink-2); font-size: var(--text-sm); }
.task-row__status { grid-area: status; font-size: var(--text-sm); }
.task-row__avatar { grid-area: person; position: relative; z-index: 1; width: var(--avatar-row); height: var(--avatar-row); border-radius: 50%; background: var(--fill); color: var(--ink); font-size: var(--text-2xs); font-weight: 500; display: flex; align-items: center; justify-content: center; }
.task-row.is-checked .task-row__open { color: var(--ink-2); text-decoration: line-through; }
.task-row__open:focus-visible { outline: 0; }
.task-row__body:has(:focus-visible) { box-shadow: inset 0 0 0 var(--bar) var(--ink); }   /* keyboard only, not after a click */
.agenda__empty { display: flex; flex-direction: column; align-items: center; gap: var(--gap-3); padding: var(--gap-6) var(--gap-4); color: var(--ink-2); }
/* filters fade the list and the stripes over; a new day fades only the list (80 ms out, 160 ms in) */
.agenda .agenda-day__list, .agenda .week__stripes { transition: opacity var(--dur-day-in) var(--ease-out); }
.agenda.is-switching .agenda-day__list, .agenda.is-switching .week__stripes,
.agenda.is-switching-day .agenda-day__list { opacity: 0; transition-duration: var(--dur-fade-out); }
/* on open: week strip, then the day, slightly staggered */
.agenda > .week, .agenda > .agenda-day { animation: rise-in var(--dur-base) var(--ease-out) backwards; }
.agenda > .agenda-day { animation-delay: var(--stagger); }
/* undo after ticking a task off */
.toast--action { display: flex; align-items: center; gap: var(--gap-3); pointer-events: auto; }
.toast__action { min-height: 0; padding: 0; border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 500; text-decoration: underline; cursor: pointer; }
@media (hover: hover) {
  .week__day:hover { border-color: var(--ink-3); }
  .week__day.is-selected:hover { border-color: var(--ink); }
  .task-row__body:hover { background: var(--row-hover); }
  .task-check:hover { border-color: var(--ink-2); }
  .task-check[aria-pressed='true']:hover { border-color: var(--ink); }
}
@media (max-width: 760px) {
  .week__days { overflow-x: auto; grid-template-columns: repeat(7, minmax(calc(var(--day-tile-h) * 0.8), 1fr)); scroll-snap-type: x proximity; }
  .week__day { scroll-snap-align: start; }
  .task-row__body { grid-template-columns: var(--round-check) minmax(0, 1fr) var(--avatar-row); grid-template-areas: "check text person" ". status ."; row-gap: var(--gap-1); }
}
@media (prefers-reduced-motion: reduce) {
  .task-row { transition: opacity var(--dur-base) var(--ease-out); }
  .task-row.is-collapsing { grid-template-rows: 1fr; }
  .agenda > .week, .agenda > .agenda-day { animation-name: fade-in; }
}
