/* SkyFlame Docs: private document tool + public verify page.
   Follows SkyFlame Group Brand Guidelines v2.0: Raleway, the Charcoal Sapphire palette (near-black #080B10,
   warm white #EEF2F8, sapphire #3260A8 for structure) and Vivid Sky Blue #1E90FF only for interactive states.
   Light theme on purpose: documents are paper, read at a desk or on a phone outdoors. */

@font-face {
  font-family: "Raleway";
  src: url("fonts/raleway.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  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: "Raleway";
  src: url("fonts/raleway-latin-ext.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
  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-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Aptos Narrow Web";
  src: local("Aptos Narrow"), url("fonts/aptos-narrow.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* brand palette */
  --sf-base: #080B10; --sf-dark: #111520; --sf-deep: #1A2840; --sf-mid: #243D6B; --sf-sap: #3260A8;
  --sf-light: #6898CC; --sf-pale: #B8D0E8; --sf-white: #EEF2F8; --sf-off: #F4F6F9; --sf-silver: #8A9DB8;
  --sf-muted: #3D5068; --sf-neon: #1E90FF;

  --bg: var(--sf-white);
  --surface: var(--sf-off);
  --surface-2: color-mix(in srgb, var(--sf-pale) 28%, var(--sf-off));
  --line: color-mix(in srgb, var(--sf-sap) 15%, var(--sf-off));
  --line-strong: color-mix(in srgb, var(--sf-sap) 32%, var(--sf-off));
  --ink: var(--sf-dark);
  --ink-2: var(--sf-muted);
  --ink-3: color-mix(in srgb, var(--sf-muted) 88%, var(--sf-silver));
  --navy: var(--sf-dark);
  --label: var(--sf-sap);
  --accent: var(--sf-sap);
  --accent-hover: var(--sf-neon);
  --accent-soft: color-mix(in srgb, var(--sf-sap) 10%, var(--sf-off));
  --chrome: var(--sf-base);
  --chrome-2: var(--sf-dark);
  --chrome-3: var(--sf-deep);
  --chrome-ink: var(--sf-white);
  --chrome-muted: var(--sf-silver);
  --chrome-label: var(--sf-light);
  --danger: oklch(0.51 0.17 25);
  --danger-hover: oklch(0.45 0.17 25);
  --danger-soft: oklch(0.965 0.018 25);
  --ok: oklch(0.47 0.1 155);
  --ok-soft: oklch(0.962 0.028 155);
  --warn: oklch(0.5 0.1 70);
  --warn-soft: oklch(0.965 0.035 85);
  --c6: var(--sf-mid);

  --r-ctl: 4px;
  --r-box: 8px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --t-xs: 0.75rem; --t-sm: 0.8125rem; --t-md: 0.9375rem; --t-lg: 1.125rem; --t-xl: 1.375rem; --t-2xl: 1.75rem;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out-q: cubic-bezier(0.165, 0.84, 0.44, 1);
  --ease-io: cubic-bezier(0.77, 0, 0.175, 1);
  --slow: 320ms;
  --glide: 260ms;
  --accent-on-dark: oklch(0.72 0.11 258);
  --tab-dark: linear-gradient(90deg, oklch(0.72 0.11 258 / 0.16), transparent 70%) oklch(0.25 0.012 262);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --fast: 140ms;
  --base: 200ms;
  --z-sticky: 10; --z-nav: 20; --z-scrim: 30; --z-drawer: 35; --z-toast: 40;
  --focus: 0 0 0 2px var(--sf-neon);
  --sans: "Raleway", sans-serif;
  --mono: "Courier New", Courier, monospace;
  /* Typed text matches the documents (ACM style). */
  --field: "Aptos Narrow Web", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 var(--t-md)/1.55 var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums;
}
h1, h2, h3 { color: var(--navy); margin: 0; text-wrap: balance; }
h1 { font-size: 2rem; font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; }
h2 { font-size: var(--t-lg); font-weight: 500; line-height: 1.3; }
h3 { font-size: var(--t-md); font-weight: 600; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-ctl); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: lining-nums tabular-nums; }
.muted { color: var(--ink-3); }
.small { font-size: var(--t-sm); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.skip { position: absolute; left: var(--s4); top: -40px; background: var(--surface); padding: var(--s2) var(--s3); z-index: var(--z-toast); }
.skip:focus { top: var(--s3); }

/* ---------- app shell ---------- */
/* Menu mechanics follow Dentiware's rail: one tab slides between items (it moves on the click, before
   the next page arrives), and on phones the same rail is a drawer that slides in from the left. */
.shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); min-height: 100dvh; }
.side {
  background:
    radial-gradient(120% 45% at 0% 0%, rgb(30 144 255 / 0.10), transparent 70%),
    radial-gradient(90% 40% at 100% 100%, rgb(50 96 168 / 0.16), transparent 70%),
    linear-gradient(rgb(50 96 168 / 0.05) 1px, transparent 1px) 0 0 / 100% 60px,
    linear-gradient(90deg, rgb(50 96 168 / 0.05) 1px, transparent 1px) 0 0 / 60px 100%,
    linear-gradient(180deg, var(--sf-dark), var(--sf-base) 55%, var(--sf-deep));
  color: var(--chrome-ink);
  display: flex; flex-direction: column; gap: var(--s5);
  padding: var(--s5) var(--s4) var(--s4);
  position: sticky; top: 0; height: 100dvh;
}
.side-head { display: flex; align-items: center; gap: var(--s2); }
.side .brand { display: block; flex: 1; min-width: 0; padding: var(--s1) var(--s2) 0; border-radius: var(--r-ctl); }
.side .brand img { width: 100%; height: auto; display: block; transition: opacity var(--fast) var(--ease-out); }
.side .brand:hover img { opacity: 0.86; }
.side .close { display: none; }
/* Pinned menus: scroll only when longer than the screen, under the pointer; the bar shows on hover
   and reaching the end does not drag the page along. */
.nav, .split .list, .toc { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.nav:hover, .nav:focus-within, .split .list:hover, .split .list:focus-within, .toc:hover { scrollbar-color: color-mix(in srgb, var(--sf-silver) 60%, transparent) transparent; }
.nav::-webkit-scrollbar, .split .list::-webkit-scrollbar, .toc::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb, .split .list::-webkit-scrollbar-thumb, .toc::-webkit-scrollbar-thumb { background: transparent; border-radius: 3px; }
.nav:hover::-webkit-scrollbar-thumb, .split .list:hover::-webkit-scrollbar-thumb, .toc:hover::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--sf-silver) 60%, transparent); }
.side .new { display: flex; align-items: center; justify-content: center; gap: var(--s2); }
.nav { position: relative; display: flex; flex-direction: column; gap: 2px; min-height: 0; flex: 0 1 auto; }
.nav-label { color: var(--chrome-label); font-size: 10px; font-weight: 500; letter-spacing: 3px; text-transform: uppercase; padding: var(--s4) var(--s3) var(--s1); margin-top: var(--s2); border-top: 1px solid var(--chrome-2); }
.nav a {
  position: relative; z-index: 1;
  display: flex; align-items: center; gap: var(--s3);
  padding: 8px var(--s3);
  color: var(--chrome-muted); text-decoration: none; font-size: var(--t-sm); font-weight: 500;
  border-left: 3px solid transparent; border-radius: 8px;
  transition: background-color var(--fast) var(--ease-out-q), color var(--fast) var(--ease-out-q), transform var(--fast) var(--ease-out-q);
}
.nav a .icon { color: var(--chrome-muted); transition: color var(--fast) var(--ease-out-q); }
.nav a:hover { background: oklch(0.23 0.008 262 / 0.6); color: var(--chrome-ink); }
.nav a:hover .icon { color: var(--chrome-ink); }
.nav a:active { transform: scale(0.98); }
.nav a[aria-current="page"] { color: var(--chrome-ink); font-weight: 600; }
.nav a[aria-current="page"] .icon { color: var(--accent-on-dark); }
.nav[data-indicator="ready"] a[aria-current="page"]:hover { background: none; }
/* Before the script measures (first paint, no JS), the active item draws its own tab. */
.nav:not([data-indicator="ready"]) a[aria-current="page"] { background: var(--tab-dark); border-left-color: var(--accent-on-dark); }
/* A click is on its way: the clicked item looks chosen now, the one it left stops. */
.nav[data-pending] a[aria-current="page"]:not([data-nav-pending]) { color: var(--chrome-muted); font-weight: 500; }
.nav[data-pending] a[aria-current="page"]:not([data-nav-pending]) .icon { color: var(--chrome-muted); }
.nav[data-pending] a[data-nav-pending] { color: var(--chrome-ink); font-weight: 600; background: none; }
.nav[data-pending] a[data-nav-pending] .icon { color: var(--accent-on-dark); }

/* The sliding tab: one element per menu, moved between items. */
.slider { position: absolute; left: 0; top: 0; pointer-events: none; border-radius: var(--r-ctl); opacity: 0; z-index: 0; }
.slider.shown { opacity: 1; }
.slider.glide { transition: transform var(--glide) var(--ease-io), width var(--glide) var(--ease-io), height var(--glide) var(--ease-io), opacity var(--base) var(--ease-out-q); }
/* As in Dentiware: a 3px left border on an 8px-rounded tab curves round the corners like a bracket. */
.nav > .slider { background: var(--tab-dark); border-left: 3px solid var(--accent-on-dark); border-radius: 8px; box-shadow: 0 1px 2px oklch(0 0 0 / 0.3); }

.side .who { margin-top: auto; padding: var(--s3) var(--s2) 0; border-top: 1px solid var(--chrome-2); font-size: var(--t-xs); color: var(--chrome-muted); }
.side .who .email { overflow-wrap: anywhere; display: flex; align-items: center; gap: var(--s2); }
.side .who .avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--chrome-2); color: var(--chrome-ink); font-weight: 600; flex: none; }
.side .who form { margin-top: var(--s2); }
.side .who button {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: var(--s3); width: 100%; box-sizing: border-box;
  color: var(--chrome-muted); font-size: var(--t-sm); padding: 8px var(--s2); border-radius: var(--r-ctl);
  transition: background-color var(--fast) var(--ease-out-q), color var(--fast) var(--ease-out-q), transform var(--fast) var(--ease-out-q);
}
.side .who button:hover { color: var(--chrome-ink); background: var(--chrome-2); }
.side .who button:active { transform: scale(0.98); }
.side .who button:focus-visible { box-shadow: var(--focus); }

.main { min-width: 0; padding: var(--s6) var(--s6) var(--s7); }
.wrap { max-width: 1120px; margin: 0 auto; }
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s4); flex-wrap: wrap;
  position: sticky; top: 0; z-index: var(--z-sticky);
  margin: calc(-1 * var(--s6)) 0 var(--s5); padding: var(--s6) 0 var(--s4);
  background: var(--bg); border-bottom: 1px solid transparent;
  animation: head-stuck linear both; animation-timeline: scroll(); animation-range: 0 24px;
}
@keyframes head-stuck { to { border-bottom-color: var(--line); } }
.crumb + .page-head { margin-top: 0; padding-top: var(--s2); }
.page-head p { color: var(--ink-2); margin-top: var(--s1); }
.crumb { display: inline-flex; align-items: center; gap: var(--s1); color: var(--ink-3); font-size: var(--t-sm); text-decoration: none; margin-bottom: var(--s2); }
.crumb:hover { color: var(--accent); }

/* phones and small tablets: top bar + sliding drawer */
.topbar, .scrim { display: none; }
@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); height: 100dvh; z-index: var(--z-drawer);
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--slow) var(--ease-out-q), visibility 0s linear var(--slow);
    box-shadow: 8px 0 8px color-mix(in srgb, var(--sf-base) 12%, transparent);
  }
  body.nav-open .side { transform: none; visibility: visible; transition: transform var(--slow) var(--ease-out-q), visibility 0s; }
  .side .close { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border: 0; background: none; color: var(--chrome-muted); border-radius: var(--r-ctl); cursor: pointer; }
  .side .close:hover { color: var(--chrome-ink); background: var(--chrome-2); }
  .side .close .icon { width: 20px; height: 20px; }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: var(--z-scrim);
    background: color-mix(in srgb, var(--sf-base) 45%, transparent); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity var(--slow) var(--ease-out-q);
  }
  body.nav-open .scrim { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .topbar {
    display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: var(--s3);
    background: var(--chrome); color: var(--chrome-ink);
    padding: var(--s2) var(--s3); position: sticky; top: 0; z-index: var(--z-nav);
  }
  .topbar .menu-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 0; background: none; color: var(--chrome-ink); border-radius: var(--r-ctl); cursor: pointer; }
  .topbar .menu-btn:hover { background: var(--chrome-2); }
  .topbar .menu-btn .icon { width: 22px; height: 22px; }
  .topbar .logo img { height: 44px; width: auto; display: block; }
  .nav a { padding: 11px var(--s3); font-size: var(--t-md); }
  .main { padding: var(--s5) var(--s4) var(--s7); }
  .page-head { top: 60px; margin-top: calc(-1 * var(--s5)); padding-top: var(--s5); }
  .crumb + .page-head { margin-top: 0; padding-top: var(--s2); }
  h1 { font-size: 1.625rem; }
}

/* ---------- buttons ---------- */
.btn {
  --bg-c: var(--surface); --fg-c: var(--ink); --bd-c: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 38px; padding: 0 var(--s4);
  font: 600 var(--t-sm)/1 var(--sans); white-space: nowrap;
  color: var(--fg-c); background: var(--bg-c); border: 1px solid var(--bd-c); border-radius: var(--r-ctl);
  text-decoration: none; cursor: pointer;
  transition: background-color var(--base) var(--ease-out), border-color var(--base) var(--ease-out), box-shadow var(--slow) var(--ease-out), transform var(--fast) var(--ease-out);
}
/* Hover lights the button with a Vivid Sky Blue glow (the brand's interactive color); the label never changes. */
.btn:hover { --bg-c: var(--surface-2); --bd-c: var(--sf-neon); color: var(--fg-c); text-decoration: none; box-shadow: 0 0 0 1px rgb(30 144 255 / 0.25), 0 0 12px rgb(30 144 255 / 0.25); }
.btn:active { transform: scale(0.98); }
.btn.primary { --bg-c: var(--accent); --fg-c: var(--sf-white); --bd-c: var(--accent); }
.btn.primary:hover { --bg-c: color-mix(in srgb, var(--sf-sap) 82%, var(--sf-neon)); --bd-c: var(--sf-neon); box-shadow: 0 0 0 1px rgb(30 144 255 / 0.45), 0 0 18px rgb(30 144 255 / 0.5), 0 0 36px rgb(30 144 255 / 0.2); }
.btn.dark { --bg-c: var(--chrome); --fg-c: var(--chrome-ink); --bd-c: var(--chrome); }
.btn.dark:hover { --bg-c: var(--chrome-3); --bd-c: var(--sf-neon); }
.side .btn.primary { --bd-c: var(--accent); }
.btn.ghost { --bd-c: transparent; --bg-c: transparent; color: var(--ink-2); }
.btn.ghost:hover { --bg-c: var(--surface-2); --bd-c: transparent; color: var(--ink); box-shadow: none; }
.btn.danger { --bg-c: var(--surface); --fg-c: var(--danger); --bd-c: oklch(0.85 0.06 25); }
.btn.danger:hover { --bg-c: var(--danger-soft); --bd-c: var(--danger); box-shadow: 0 0 12px oklch(0.51 0.17 25 / 0.25); }
.btn.danger.solid { --bg-c: var(--danger); --fg-c: var(--sf-white); --bd-c: var(--danger); }
.btn.danger.solid:hover { --bg-c: var(--danger-hover); --bd-c: var(--danger-hover); }
.btn.sm { min-height: 32px; padding: 0 var(--s3); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.busy { pointer-events: none; opacity: 0.7; }
.actions { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }

/* ---------- panels & tables ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box); }
.panel > header { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.panel > .body, .panel > form > .body { padding: var(--s5); }
.panel + .panel { margin-top: var(--s5); }

.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th { text-align: left; font-weight: 600; color: var(--label); font-size: var(--t-xs); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.table th:first-child { border-top-left-radius: var(--r-box); }
.table th:last-child { border-top-right-radius: var(--r-box); }
.table td { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { position: relative; transition: background-color var(--fast) var(--ease-out); }
.table tbody tr:hover { background: color-mix(in srgb, var(--sf-pale) 14%, var(--sf-off)); }
.table .row-link { color: var(--ink); text-decoration: none; font-weight: 560; }
.table .row-link::after { content: ""; position: absolute; inset: 0; }
.table .row-link:focus-visible { box-shadow: none; }
.table tr:has(.row-link:focus-visible) { box-shadow: inset var(--focus); }
.table .sub { display: block; color: var(--ink-3); font-size: var(--t-xs); margin-top: 2px; }
@media (max-width: 699px) {
  .table.stack thead { display: none; }
  .table.stack tr { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  .table.stack td { border: 0; padding: 0; }
  .table.stack td[data-hide-sm] { display: none; }
}

/* ---------- chips & badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-xs); font-weight: 560; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.chip.sf { background: var(--chrome); color: var(--chrome-ink); }
.chip.c6 { background: color-mix(in srgb, var(--sf-pale) 45%, var(--sf-off)); color: var(--c6); }
.chip.other { background: var(--surface-2); color: var(--ink-2); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: var(--t-xs); font-weight: 580; padding: 3px 8px 3px 6px; border-radius: 999px; white-space: nowrap; }
.badge .icon { width: 14px; height: 14px; }
.badge.draft { background: var(--surface-2); color: var(--ink-2); }
.badge.issued { background: var(--ok-soft); color: var(--ok); }
.badge.superseded { background: var(--warn-soft); color: var(--warn); }
.badge.revoked { background: var(--danger-soft); color: var(--danger); }

/* ---------- forms ---------- */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4) var(--s5); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field.wide { grid-column: span 2; }
@media (max-width: 699px) { .field.wide { grid-column: 1 / -1; } }
.field > label, .field > .label { font-size: var(--t-sm); font-weight: 560; color: var(--ink); }
.field .req { color: var(--danger); margin-left: 2px; }
.hint { font-size: var(--t-xs); color: var(--ink-3); line-height: 1.45; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  width: 100%; font: 400 0.9375rem/1.4 var(--field); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  padding: 9px 11px; min-height: 40px;
  transition: border-color var(--fast) var(--ease-out), box-shadow var(--fast) var(--ease-out);
}
textarea { min-height: 84px; resize: vertical; }
textarea.code { min-height: 150px; }
/* Phones zoom into fields under 16px. */
@media (max-width: 899px) { input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea { font-size: 1rem; } }
/* Dropdowns: the house blue chevron instead of the browser's grey arrow. */
select:not([multiple]) {
  appearance: none; padding-right: 36px; cursor: pointer;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%233260A8'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/%3E%3C/svg%3E") no-repeat right 11px center / 16px 16px;
}
/* Boxes with a suggestion list (a searchable white menu, see base.html): the same blue chevron. */
input.combo:not([type=checkbox]):not([type=radio]):not([type=file]) { padding-right: 36px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 256 256' fill='%233260A8'%3E%3Cpath d='M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z'/%3E%3C/svg%3E") no-repeat right 11px center / 16px 16px; }
.combo-menu .choice { grid-template-columns: minmax(0, 1fr); }
.combo-menu .choice small { white-space: normal; }
.choice.on { background: var(--accent-soft); color: var(--accent); }
.choice.current { font-weight: 600; }
.choice-menu.sel-menu { padding-top: 0; }  /* beats .choice-menu's padding: the search sticks to the very top, nothing scrolls above it */
.sel-menu input.sel-search:not([type=checkbox]):not([type=radio]):not([type=file]) { position: sticky; top: 0; z-index: 1; margin: 0 0 6px; min-height: 36px; border-width: 0 0 1px; border-radius: 0; padding: 8px; background: var(--surface); }
.sel-search:focus { box-shadow: none; border-color: var(--accent); }
.choice-menu.sel-menu.no-search { padding-top: 6px; }
.sel-menu.no-search input.sel-search:not([type=checkbox]):not([type=radio]):not([type=file]) { position: absolute; width: 1px; height: 1px; min-height: 0; margin: 0; padding: 0; border: 0; opacity: 0; }  /* short lists: no box, typing still filters */
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--sf-silver); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
input[type=file] { font: inherit; font-size: var(--t-sm); color: var(--ink-2); }
input[type=file]::file-selector-button {
  font: 560 var(--t-sm) var(--sans); margin-right: var(--s3); padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--surface); color: var(--ink);
}
.check { position: relative; display: flex; gap: var(--s3); align-items: flex-start; font-size: var(--t-sm); cursor: pointer; }
/* Checkbox from Concepto POT (Uiverse.io green-bobcat-29, MIT). The real input stays on top, invisible, so
   keyboard and screen readers still reach it; the stroke draws the box and, when checked, slides into the tick. */
.check input { position: absolute; width: 18px; height: 18px; margin: 1px 0 0; opacity: 0; cursor: pointer; }
.tic { width: 18px; height: 18px; margin-top: 1px; flex: none; overflow: visible; }
.tic path {
  fill: none; stroke: var(--ink-3); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 241 9999999; stroke-dashoffset: 0;
  transition: stroke-dasharray .5s ease, stroke-dashoffset .5s ease, stroke .2s ease;
}
.check:hover .tic path { stroke: var(--sf-neon); }
.check input:checked ~ .tic path { stroke: var(--accent); stroke-dasharray: 70.5096664428711 9999999; stroke-dashoffset: -262.2723388671875; }
.check input:focus-visible ~ .tic path { stroke: var(--sf-neon); filter: drop-shadow(0 0 3px rgb(30 144 255 / 0.6)); }
.check strong { font-weight: 560; display: block; }
/* A checkbox beside fields: sits on the same line as their boxes. */
/* How a field prints, shown under it as it is typed. */
.says { margin: 4px 0 0; padding: 8px 11px; font-size: var(--t-sm); line-height: 1.5; color: var(--ink-2); background: var(--accent-soft); border-radius: var(--r-ctl); }
.says-k { font-size: var(--t-xs); font-weight: 600; color: var(--accent); margin-right: 4px; }
/* hidden always hides, whatever display a class gives the element */
[hidden] { display: none !important; }
.validity { display: flex; flex-wrap: wrap; gap: var(--s2); }
.validity select { width: auto; flex: 1 1 150px; }
.check-line { min-height: 40px; display: flex; align-items: center; }
.check-line .check { align-items: center; }
.check > .icon { width: 15px; height: 15px; color: var(--ink-3); flex: none; }
/* Explanations on hover or keyboard focus, so the form stays clean. */
.btn[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 8px); z-index: 30;
  width: max-content; max-width: min(320px, 80vw); padding: 8px 11px; white-space: normal;
  font: 400 var(--t-xs)/1.5 var(--sans); color: var(--chrome-ink); background: var(--chrome);
  border-radius: var(--r-ctl); box-shadow: 0 4px 8px rgb(9 14 24 / 0.18);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 150ms var(--ease-out), transform 150ms var(--ease-out);
}
[data-tip]:hover::after, [data-tip]:focus-within::after { opacity: 1; transform: none; transition-delay: 250ms; }
@media (prefers-reduced-motion: reduce) { [data-tip]::after { transform: none; transition: opacity 1ms; } }
.picklist { border: 1px solid var(--line-strong); border-radius: var(--r-ctl); max-height: 260px; overflow: auto; background: var(--surface); }
.picklist .check { padding: 10px var(--s3); border-bottom: 1px solid var(--line); }
.picklist .check:last-child { border-bottom: 0; }
.picklist .check:hover { background: var(--surface-2); }
.picklist .kind { color: var(--ink-3); font-size: var(--t-xs); display: block; }
.subsection { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--line); display: grid; gap: var(--s2); }
.subsection h3 { margin: 0; font-size: var(--t-md); font-weight: 600; color: var(--ink); }
.subsection[hidden] { display: none; }
.kind-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s2); }
.kind-chips .chip-btn .n { margin-left: 6px; color: var(--ink-3); }
.chip-btn[aria-pressed="true"] { border-style: solid; border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.picklist .check[hidden] { display: none; }
.clause-items { display: grid; gap: var(--s3); margin-top: var(--s3); }
.clause-items[hidden] { display: none; }
.clause-item { border: 1px solid var(--line-strong); border-radius: var(--r-box); background: var(--surface); padding: var(--s3); display: grid; gap: var(--s2); }
.ci-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.ci-head .ci-title { flex: 1 1 220px; min-height: 36px; font-weight: 560; }
.ci-head .ci-kind { width: auto; min-height: 36px; }
.ci-edited { font-size: var(--t-xs); color: var(--warn); }
.ci-edited[hidden], .ci-head .btn[hidden] { display: none; }
.clause-item .ci-body { min-height: 110px; font-size: var(--t-sm); line-height: 1.5; resize: vertical; }
/* extra sections: numbered title, blue sub-title, formatted text, highlighted note */
.extra-list { display: grid; gap: var(--s3); }
.extra-list:empty { display: none; }
.extra-item input.x-sub { color: var(--accent); font-weight: 560; }
.extra-item .x-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.x-tools { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: var(--s2); }  /* clear of the box and its focus ring */
/* formatting buttons: an icon each, what it does in the hover note */
.fmt-btn { all: unset; box-sizing: border-box; position: relative; cursor: pointer; display: grid; place-items: center; width: 32px; height: 32px;
  border: 1px solid var(--line); border-radius: var(--r-ctl); color: var(--ink-2); background: var(--surface); }
.fmt-btn .icon { width: 17px; height: 17px; }
.fmt-btn .fmt-letters { width: auto; height: auto; font: 700 13px/1 var(--sans); letter-spacing: -0.02em; }  /* no list-letters glyph in the icon set */
.fmt-btn:hover, .fmt-btn:focus-visible { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.fmt-btn:active { transform: scale(0.96); }
.extra-item .x-note { background: color-mix(in srgb, #E8D27A 18%, var(--surface)); border-color: #E8D27A; min-height: 56px; resize: vertical; }
.extra-item label.small { font-size: var(--t-xs); color: var(--label); font-weight: 560; }
.paste { margin-top: var(--s3); border: 1px dashed var(--line-strong); border-radius: var(--r-box); padding: var(--s2) var(--s3); }
.paste summary { cursor: pointer; font-weight: 560; padding: var(--s1) 0; }
.paste[open] { display: grid; gap: var(--s2); }
.paste-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.paste-row input:not([type=checkbox]) { flex: 1 1 260px; }
.empty-pick { padding: var(--s4); font-size: var(--t-sm); color: var(--ink-3); }

/* company selector: always obvious which letterhead a draft uses */
.companies { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s3); }
.company-opt { position: relative; display: flex; gap: var(--s3); align-items: center; padding: var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r-box); cursor: pointer; background: var(--surface); transition: border-color var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out); }
.company-opt input { position: absolute; opacity: 0; }
.company-opt .mark { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; font: 650 var(--t-sm) var(--sans); flex: none; }
.company-opt .mark.sf { background: var(--chrome); color: var(--chrome-ink); }
.company-opt .mark.c6 { background: color-mix(in srgb, var(--sf-pale) 45%, var(--sf-off)); color: var(--c6); }
.company-opt strong { display: block; font-weight: 600; }
.company-opt span.muted { font-size: var(--t-xs); }
.company-opt:hover { border-color: var(--sf-silver); }
.company-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.company-opt:has(input:focus-visible) { box-shadow: var(--focus); }

/* ---------- document editor layout ---------- */
.editor { display: grid; grid-template-columns: 188px minmax(0, 1fr); gap: var(--s6); align-items: start; }
.toc { position: sticky; top: calc(var(--head-h, 0px) + var(--s4)); max-height: calc(100dvh - var(--head-h, 0px) - var(--s4) - var(--s6)); display: flex; flex-direction: column; gap: 2px; font-size: var(--t-sm); }
.toc > .slider { background: var(--surface-2); border-left: 3px solid var(--accent); border-radius: 8px; }
.toc a { position: relative; z-index: 1; color: var(--ink-2); text-decoration: none; padding: 6px var(--s3); border-left: 3px solid transparent; border-radius: 8px; transition: color var(--fast) var(--ease-out-q); }
.toc a:hover { background: var(--surface-2); color: var(--ink); }
.toc a.on { color: var(--ink); font-weight: 560; }
.toc[data-indicator="ready"] a:hover { background: none; }
.section { scroll-margin-top: calc(var(--head-h, 0px) + var(--s4)); }
.section + .section { margin-top: var(--s5); }
.section > header p { color: var(--ink-3); font-size: var(--t-sm); margin-top: 2px; }
/* form sections: a light blue title band, so each section is easy to spot while scrolling */
.section > header { background: color-mix(in srgb, var(--sf-sap) 9%, var(--surface)); border-bottom-color: color-mix(in srgb, var(--sf-sap) 22%, var(--surface));
  border-radius: calc(var(--r-box) - 1px) calc(var(--r-box) - 1px) 0 0; }
.section > header h2 { color: var(--accent); }
/* The save bar: a floating pill like the iPhone's Dynamic Island, centred over the form, a gap above the screen's edge. */
.savebar {
  position: sticky; bottom: var(--s4); z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  width: fit-content; max-width: 100%; margin: var(--s5) auto 0; padding: 6px 6px 6px var(--s5);
  color: var(--chrome-ink); border-radius: 999px; background: var(--sf-base);
  border: 1px solid rgb(184 208 232 / 0.10);
  box-shadow: 0 10px 8px -6px rgb(8 11 16 / 0.35);
}
.savebar .state { font-size: var(--t-sm); color: var(--sf-pale); min-width: 9em; white-space: nowrap; }
.savebar .state.dirty { color: oklch(0.82 0.13 80); }
.savebar .state.ok { color: oklch(0.80 0.15 150); font-weight: 600; }
.savebar .state.bad { color: oklch(0.75 0.15 25); font-weight: 600; }
.savebar .actions { flex-wrap: nowrap; gap: 6px; }
.savebar .state:empty { display: none; }  /* only the buttons: the pill hugs them */
.savebar:has(> .state:empty) { padding: 0; margin: 0 var(--s5) var(--s5) auto; background: none; border: 0; box-shadow: none; }  /* just the buttons, at the form's end */
.savebar .btn { border-radius: 999px; }
.savebar .btn:not(.primary) { --bg-c: rgb(238 242 248 / 0.08); --fg-c: var(--chrome-ink); --bd-c: transparent; }
.savebar .btn:not(.primary):hover { --bg-c: rgb(238 242 248 / 0.14); --bd-c: var(--sf-neon); }
.savebar .btn.ghost, .savebar .btn.ghost:hover { color: var(--chrome-ink); }  /* light on the dark bar */
@media (max-width: 640px) { .savebar { width: 100%; padding-left: var(--s4); } .savebar .state { min-width: 0; } }
/* Greeting: Mr./Ms. beside the last name it greets */
.greet { display: grid; grid-template-columns: auto 92px minmax(0, 1fr); gap: var(--s2); align-items: center; }
.greet > .check { padding-right: var(--s2); }
.greet .off { opacity: 0.45; }
@media (max-width: 999px) {
  .editor { grid-template-columns: 1fr; }
  .editor > * { min-width: 0; }  /* wide rows scroll inside their box, never the page */
  /* section jump bar: a sticky strip of chips under the top bar */
  .toc { flex-direction: row; overflow-x: auto; overflow-y: hidden; max-height: none; top: var(--head-h, 0px); z-index: var(--z-sticky);
    margin: 0 calc(-1 * var(--s4)); padding: var(--s2) var(--s4); gap: 6px; background: var(--bg); scrollbar-width: none; }
  .toc::-webkit-scrollbar { display: none; }
  @media (min-width: 700px) and (pointer: fine) { .toc { flex-wrap: wrap; overflow-x: visible; } }
  .toc > .slider { display: none; }
  .toc a { flex: none; white-space: nowrap; border: 1px solid var(--line); border-left-width: 1px; border-radius: 999px; padding: 6px 12px; background: var(--surface); }
  .toc a.on { border-color: var(--sf-neon); color: var(--accent); background: var(--surface); }
  .section { scroll-margin-top: calc(var(--head-h, 0px) + 64px); }
}


/* issue panel: irreversible step reads as deliberate */
.issue { border-color: color-mix(in srgb, var(--sf-sap) 40%, var(--sf-off)); }
.issue .steps { display: grid; gap: var(--s2); margin: var(--s3) 0 var(--s4); padding: 0; list-style: none; font-size: var(--t-sm); color: var(--ink-2); }
.issue .steps li { display: flex; gap: var(--s2); align-items: center; }
.issue .steps .icon { color: var(--accent); }

/* ---------- settings (list + form) ---------- */
.split { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: var(--s5); align-items: start; }
.split .list .item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); text-decoration: none; color: var(--ink); transition: background-color var(--fast) var(--ease-out); }
.split .list .item:last-child { border-bottom: 0; }
.split .list .item:hover { background: var(--surface-2); }
.split .list .item[aria-current="true"] { background: var(--accent-soft); }
.split .list .item .meta { margin-left: auto; color: var(--ink-3); font-size: var(--t-xs); text-align: right; }
.split .list .item strong { font-weight: 560; display: block; font-size: var(--t-sm); }
/* Left menus stay put while the page scrolls; a long one scrolls on its own, under the pointer only. */
.split .list { position: sticky; top: calc(var(--head-h, 0px) + var(--s4)); max-height: calc(100dvh - var(--head-h, 0px) - var(--s4) - var(--s6)); }
.thumb { align-self: flex-start; width: auto; height: auto; max-height: 72px; max-width: 100%; object-fit: contain; margin-top: var(--s2); padding: 6px; border: 1px dashed var(--line-strong); border-radius: var(--r-ctl); background: var(--sf-off); }
@media (max-width: 899px) { .split { grid-template-columns: 1fr; } .split .list { position: static; max-height: none; } }

/* ---------- issued document ---------- */
.doc-hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s5); align-items: start; padding: var(--s5); }
.doc-hero .number { font-size: var(--t-xl); font-weight: 560; color: var(--navy); }
.doc-hero .meta { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; margin-top: var(--s2); color: var(--ink-2); font-size: var(--t-sm); }
.downloads { display: flex; flex-wrap: wrap; gap: var(--s2); }
@media (max-width: 699px) { .doc-hero { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s3) var(--s5); margin: 0; font-size: var(--t-sm); }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.copyable { display: flex; gap: var(--s2); align-items: center; }
.copyable code { font-family: var(--mono); font-size: var(--t-xs); background: var(--surface-2); padding: 4px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: var(--t-sm); }
.timeline li { display: grid; grid-template-columns: 22px 1fr auto; gap: var(--s3); align-items: start; padding: var(--s2) 0; }
.timeline .icon { color: var(--ink-3); margin-top: 2px; }
.timeline time { color: var(--ink-3); font-size: var(--t-xs); white-space: nowrap; }
.two-col > .panel { margin-top: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: var(--s5); align-items: start; margin-top: var(--s5); }
@media (max-width: 899px) { .two-col { grid-template-columns: 1fr; } }
/* the activity log as tall as the panel beside it, scrolling inside, so a long log never pushes the page down */
.two-col > .panel.activity { align-self: stretch; display: flex; flex-direction: column; }
.panel.activity > .body { flex: 1 1 0; min-height: 0; overflow-y: auto; contain: size; }
@media (max-width: 899px) { .panel.activity > .body { contain: none; flex: none; max-height: 320px; } }

/* ---------- feedback ---------- */
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-ctl); font-size: var(--t-sm); margin-bottom: var(--s4); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--accent-soft); color: var(--navy); }
.toast {
  position: fixed; right: var(--s5); bottom: var(--s5); z-index: var(--z-toast);
  display: flex; align-items: center; gap: var(--s2);
  background: var(--chrome); color: var(--chrome-ink); padding: 10px var(--s4); border-radius: var(--r-ctl);
  font-size: var(--t-sm); box-shadow: 0 6px 8px color-mix(in srgb, var(--sf-base) 16%, transparent);
  animation: toast-in var(--base) var(--ease-out);
}
.toast .icon { color: oklch(0.8 0.12 155); }
.toast.out { animation: toast-out 160ms var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
@media (max-width: 699px) { .toast { left: var(--s4); right: var(--s4); bottom: var(--s4); } }

.empty { text-align: left; padding: var(--s7) var(--s6); }
.empty h2 { margin-bottom: var(--s2); }
.empty ol { color: var(--ink-2); padding-left: 1.2em; margin: var(--s3) 0 var(--s5); display: grid; gap: var(--s1); font-size: var(--t-sm); }

.toolbar { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; margin-bottom: var(--s4); }
.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search .icon { position: absolute; z-index: 2; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
/* :not() lifts this above the generic text-field rule so the padding clears the icon. */
.search input[type=search]:not([type=checkbox]) { position: relative; z-index: 1; padding-left: 36px; background: var(--surface); }
/* Light ring from Concepto POT's search bar (Uiverse.io curvy-earwig-22, MIT), in sapphire and sky blue.
   Not a loop: it rests still, turns a little on hover and makes the long turn on focus. */
.search .aro, .search .brillo { position: absolute; z-index: 0; overflow: hidden; pointer-events: none; border-radius: calc(var(--r-ctl) + 2px); }
.search .aro { inset: -1.5px; }
.search .brillo { inset: -8px; filter: blur(12px); opacity: .4; }
.search .aro::before, .search .brillo::before {
  content: ""; position: absolute; top: 50%; left: 50%; width: 560px; height: 560px; background-repeat: no-repeat;
  transform: translate(-50%, -50%) rotate(70deg); transition: transform 2s var(--ease-out-q);
  background-image: conic-gradient(transparent, var(--sf-sap) 6%, transparent 17%, transparent 50%, var(--sf-neon) 61%, transparent 72%);
}
.search:hover .aro::before, .search:hover .brillo::before { transform: translate(-50%, -50%) rotate(250deg); }
.search:focus-within .aro::before, .search:focus-within .brillo::before { transform: translate(-50%, -50%) rotate(430deg); transition-duration: 4s; }
.search input[type=search]:focus { box-shadow: none; border-color: transparent; }
.filters { position: relative; display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 8px; }
.filters > .slider { background: var(--surface); box-shadow: 0 1px 2px color-mix(in srgb, var(--sf-dark) 10%, transparent); }
.filters button { all: unset; cursor: pointer; font-size: var(--t-sm); padding: 6px 11px; border-radius: var(--r-ctl); color: var(--ink-2); transition: background-color var(--fast) var(--ease-out), color var(--fast) var(--ease-out); }
.filters button:hover { color: var(--ink); }
.filters button { position: relative; z-index: 1; }
.filters button[aria-pressed="true"] { color: var(--ink); font-weight: 560; }
.filters:not([data-indicator="ready"]) button[aria-pressed="true"] { background: var(--surface); box-shadow: 0 1px 2px color-mix(in srgb, var(--sf-dark) 8%, transparent); }
.filters button:focus-visible { box-shadow: var(--focus); }
/* company / type dropdowns, at the right of the toolbar; the menu grows from its top-right corner */
.dd-group { display: flex; gap: var(--s2); margin-left: auto; }
.dd { position: relative; }
.dd-btn { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 var(--s3); font-size: var(--t-sm); color: var(--ink-2); background: var(--surface-2); border-radius: 8px; transition: color var(--fast) var(--ease-out), box-shadow var(--fast) var(--ease-out); }
.dd-btn:hover { color: var(--ink); box-shadow: 0 0 12px color-mix(in srgb, var(--sf-neon) 22%, transparent); }
.dd-btn:focus-visible { box-shadow: var(--focus); }
.dd-btn .icon { color: var(--accent); }
.dd-btn .icon { width: 14px; height: 14px; transition: transform var(--fast) var(--ease-out); }
.dd[data-open="1"] .dd-btn .icon { transform: rotate(180deg); }
.dd.on .dd-value { color: var(--ink); font-weight: 560; }
.dd-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: var(--z-toast); min-width: 200px; max-height: min(360px, 60vh); overflow-y: auto; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-box); box-shadow: 0 6px 8px color-mix(in srgb, var(--sf-dark) 14%, transparent);
  transform-origin: top right; opacity: 0; visibility: hidden; transform: translateX(8px) scale(0.96);
  transition: opacity 160ms var(--ease-out), transform 200ms cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 200ms; }
.dd[data-open="1"] .dd-menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.dd-menu li { cursor: pointer; padding: 7px 10px; border-radius: var(--r-ctl); font-size: var(--t-sm); white-space: nowrap; color: var(--ink-2); outline: none; }
.dd-menu li:hover, .dd-menu li:focus { background: var(--surface-2); color: var(--ink); }
.dd-menu li[aria-selected="true"] { color: var(--ink); font-weight: 560; box-shadow: inset 3px 0 0 var(--sf-neon); }
.dd-menu li .muted { font-size: var(--t-xs); margin-left: 6px; }
@media (prefers-reduced-motion: reduce) { .dd-menu { transform: none !important; } }
@media (max-width: 640px) { .dd-group { margin-left: 0; } }

/* ---------- login ---------- */
.auth { min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth .brandside { background: var(--chrome); color: var(--chrome-ink); padding: var(--s7); display: flex; flex-direction: column; justify-content: space-between; }
.auth .brandside img { width: clamp(280px, 32vw, 560px); height: auto; }
.auth .brandside p { color: var(--chrome-muted); max-width: 34ch; font-size: var(--t-md); }
.auth .signin { display: grid; place-items: center; padding: var(--s6) var(--s5); }
.auth .signin > div { width: min(100%, 340px); }
.auth h1 { margin-bottom: var(--s2); }
.auth .lede { color: var(--ink-2); margin-bottom: var(--s5); }
.gbtn { width: 100%; min-height: 44px; }
@media (max-width: 799px) {
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth .brandside { padding: var(--s5); }
  .auth .brandside p { display: none; }
  .auth .brandside img { width: min(240px, 70vw); }
}

/* ---------- public verify page ---------- */
.verify { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; padding: var(--s6) var(--s4); }
.verify .card { width: min(100%, 520px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box); overflow: hidden; }
.verify .status { display: flex; gap: var(--s4); align-items: center; padding: var(--s5); }
.verify .status .seal { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.verify .status .seal .icon { width: 28px; height: 28px; }
.verify .status.valid { background: var(--ok-soft); }
.verify .status.valid .seal { background: var(--ok); color: var(--sf-white); }
.verify .status.bad { background: var(--danger-soft); }
.verify .status.bad .seal { background: var(--danger); color: var(--sf-white); }
.verify .status.warn { background: var(--warn-soft); }
.verify .status.warn .seal { background: var(--warn); color: var(--sf-white); }
.verify .status h1 { font-size: var(--t-xl); color: var(--ink); }
.verify .status p { color: var(--ink-2); font-size: var(--t-sm); margin-top: 2px; }
.verify .block { padding: var(--s5); border-top: 1px solid var(--line); }
.verify .block h2 { font-size: var(--t-md); margin-bottom: var(--s3); }
.drop { display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center; padding: var(--s5); border: 1.5px dashed var(--line-strong); border-radius: var(--r-box); cursor: pointer; color: var(--ink-2); font-size: var(--t-sm); transition: border-color var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop .icon { width: 26px; height: 26px; color: var(--accent); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop:has(input:focus-visible) { box-shadow: var(--focus); }
.result { display: none; margin-top: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r-ctl); font-size: var(--t-sm); font-weight: 560; align-items: center; gap: var(--s2); }
.result.ok { display: flex; background: var(--ok-soft); color: var(--ok); }
.result.no { display: flex; background: var(--danger-soft); color: var(--danger); }
.verify footer { width: min(100%, 520px); margin-top: var(--s4); font-size: var(--t-xs); color: var(--ink-3); display: flex; gap: var(--s2); align-items: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .btn:active { transform: none; }
}
@media print { .side, .topbar, .savebar, .toast { display: none !important; } .shell { display: block; } }

/* ---------- clients: card index (after Dentiware's patient cardex) ---------- */
.cardex-tools { display: flex; flex-direction: column; gap: var(--s3); margin-bottom: var(--s4); }
.cardex-tools .search { flex: none; width: 100%; }
.rail { display: flex; flex-wrap: wrap; gap: 4px; }
.rail button {
  all: unset; box-sizing: border-box; min-width: 26px; height: 28px; padding: 0 7px; text-align: center; line-height: 28px;
  border-radius: var(--r-ctl); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); cursor: pointer;
  transition: background-color var(--fast) var(--ease-out-q), color var(--fast) var(--ease-out-q), box-shadow var(--base) var(--ease-out-q), transform var(--fast) var(--ease-out-q);
}
.rail button:hover:not(:disabled) { background: var(--accent-soft); color: var(--accent); box-shadow: 0 0 12px rgb(30 144 255 / 0.35); }
.rail button:active:not(:disabled) { transform: scale(0.9); }
.rail button[aria-pressed="true"] { background: var(--accent); color: var(--sf-white); box-shadow: 0 0 14px rgb(30 144 255 / 0.45); }
.rail button:disabled { color: color-mix(in srgb, var(--ink-3) 35%, transparent); cursor: default; }
.rail button:focus-visible { box-shadow: var(--focus); }
/* clip, not hidden: a hidden box is a scroll container and the letter headers could not stick to the page. */
.cardex { overflow: clip; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box); }
/* A chosen letter folds the other groups shut, so the list visibly shortens instead of being swapped. */
.fold { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 450ms cubic-bezier(0.65, 0, 0.35, 1), opacity 300ms ease-out; }
.fold > div { min-height: 0; overflow: clip; }
.fold[data-folded="true"] { grid-template-rows: 0fr; opacity: 0; }
.cardex .letter {
  position: sticky; top: var(--head-h, 0px); z-index: 1; padding: 4px var(--s4);
  font-size: var(--t-xs); font-weight: 600; color: var(--label);
  background: color-mix(in srgb, var(--surface-2) 88%, transparent); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line);
}
.cardex ul { list-style: none; margin: 0; padding: 6px; }
.cardex li a {
  display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); border-radius: 8px; color: var(--ink); text-decoration: none;
  transition: transform var(--fast) var(--ease-out-q), box-shadow var(--fast) var(--ease-out-q), background-color var(--fast) var(--ease-out-q);
}
.cardex li a:hover, .cardex li a:focus-visible {
  transform: translateY(-1px); background: var(--bg); color: var(--ink); text-decoration: none;
  box-shadow: 0 0 0 1px var(--line), 0 2px 6px color-mix(in srgb, var(--sf-dark) 8%, transparent);
}
.cardex .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.cardex .who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.cardex .who strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cardex .who span, .cardex .count { font-size: var(--t-xs); color: var(--ink-3); }
.cardex .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cardex .count { font-variant-numeric: lining-nums tabular-nums; white-space: nowrap; }
.cardex li a > .icon { color: var(--ink-3); }

/* ---------- client file ---------- */
.narrow { max-width: 760px; }
.client-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s5); align-items: start; margin-bottom: var(--s5); }
.client-grid .panel + .panel { margin-top: 0; }
.client-docs > header .search { flex: 0 1 300px; }
.note-add { display: flex; flex-direction: column; align-items: flex-end; gap: var(--s2); margin-bottom: var(--s4); }
.notes { list-style: none; margin: 0; padding: 0; }
.notes li { position: relative; padding: var(--s3) 40px var(--s3) 0; border-top: 1px solid var(--line); }
.notes .when { font-size: var(--t-xs); color: var(--ink-3); }
.notes p { font-size: var(--t-sm); white-space: pre-line; margin-top: 2px; }
.notes form { position: absolute; right: 0; top: var(--s3); }
.icon-btn { all: unset; cursor: pointer; display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-ctl); color: var(--ink-3); transition: color var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out); }
.icon-btn:hover { color: var(--danger); background: var(--danger-soft); }
.icon-btn:focus-visible { box-shadow: var(--focus); }
.icon-btn.edit:hover { color: var(--sf-neon); background: var(--surface-2); }
.list-actions { white-space: nowrap; text-align: right; width: 1%; position: relative; z-index: 1; }  /* above the whole-row link */
.list-actions > * { display: inline-grid; vertical-align: middle; }
.danger-zone { display: flex; justify-content: flex-end; margin-top: var(--s4); }
@media (max-width: 899px) {
  .client-grid { grid-template-columns: 1fr; }
  .cardex .letter { top: calc(60px + var(--head-h, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  .tic path, .fold, .search .aro::before, .search .brillo::before { transition: none; }
}

/* ---------- scan a CIS ---------- */
.scan-form { display: inline-flex; margin: 0; }
.scan-form label:focus-within { box-shadow: var(--focus); }
.scan-text { margin: calc(-1 * var(--s2)) 0 var(--s4); font-size: var(--t-sm); }
.scan-text summary { cursor: pointer; color: var(--accent); width: fit-content; }
.scan-text pre { max-height: 280px; overflow: auto; margin: var(--s2) 0 0; padding: var(--s3); white-space: pre-wrap; font: 400 var(--t-sm)/1.5 var(--field); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); }

/* ---------- company numbering ---------- */
.numbering { display: flex; flex-direction: column; gap: var(--s4); padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r-box); background: var(--bg); }
.num-guide { font-size: var(--t-sm); color: var(--ink-2); }
.num-guide ol { margin: var(--s2) 0; padding-left: 1.3em; display: grid; gap: 2px; }
.num-guide strong { color: var(--ink); font-weight: 600; }
.num-parts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s3); }
.num-preview { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s1) var(--s4); align-items: baseline; padding: var(--s3) var(--s4); border-radius: var(--r-ctl); background: var(--accent-soft); font-size: var(--t-sm); color: var(--ink-2); }
.num-preview strong { font-size: var(--t-lg); color: var(--ink); overflow-wrap: anywhere; }
.num-custom summary { cursor: pointer; color: var(--accent); font-size: var(--t-sm); width: fit-content; }
.num-custom input { margin-top: var(--s2); }
.num-custom .hint { display: block; margin-top: var(--s1); }
.seq-table-wrap { border: 1px solid var(--line); border-radius: var(--r-box); overflow-x: auto; margin-top: var(--s2); }
.seq-table th, .seq-table td { padding: var(--s2) var(--s3); }
.seq-table .mono { white-space: nowrap; font-size: var(--t-xs); }
.seq-table td { vertical-align: middle; }
.seq-table .seq-in { width: 84px; min-height: 34px; padding: 5px 9px; }
.seq-table [data-next] { color: var(--accent); font-weight: 600; white-space: nowrap; }
@media (max-width: 699px) { .num-parts { grid-template-columns: 1fr 1fr; } }

/* ---------- fill from a file; new-client panel ---------- */
.scanbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); margin-bottom: var(--s4); }
.scanbar .hint { flex: 1 1 260px; margin: 0; }
.scanbar label:focus-within { box-shadow: var(--focus); }
.scan-msg { flex: 1 0 100%; margin: 0; padding: var(--s2) var(--s3); border-radius: var(--r-ctl); font-size: var(--t-sm); }
.scan-msg.ok { background: var(--accent-soft); color: var(--navy); }
.scan-msg.bad { background: var(--danger-soft); color: var(--danger); }
/* A field just filled from a file glows once, so you can see what changed. */
.filled { animation: filled 1.6s var(--ease-out-q); }
@keyframes filled { from { box-shadow: 0 0 0 2px var(--sf-neon), 0 0 14px rgb(30 144 255 / 0.45); } to { box-shadow: 0 0 0 0 transparent; } }
.drawer {
  position: fixed; inset: 0 0 0 auto; width: min(480px, 100vw); height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; border-left: 1px solid var(--line); background: var(--surface); color: var(--ink);
  box-shadow: -8px 0 8px color-mix(in srgb, var(--sf-base) 12%, transparent);
  transform: translateX(100%);
  transition: transform var(--slow) var(--ease-out-q), overlay var(--slow) allow-discrete, display var(--slow) allow-discrete;
}
.drawer[open] { transform: none; }
@starting-style { .drawer[open] { transform: translateX(100%); } }
.drawer::backdrop { background: color-mix(in srgb, var(--sf-base) 0%, transparent); transition: background var(--slow) var(--ease-out-q), overlay var(--slow) allow-discrete, display var(--slow) allow-discrete; }
.drawer[open]::backdrop { background: color-mix(in srgb, var(--sf-base) 40%, transparent); }
@starting-style { .drawer[open]::backdrop { background: color-mix(in srgb, var(--sf-base) 0%, transparent); } }
.drawer > form { display: flex; flex-direction: column; height: 100%; }
.drawer > .sd { display: flex; flex-direction: column; height: 100%; }
/* the Characteristics window: wide, its table in plain rows and columns */
.spec-dialog { width: min(940px, 100vw); }
.sd-tools { display: flex; flex-wrap: wrap; gap: var(--s2); padding: var(--s2); margin: calc(var(--s2) * -1) calc(var(--s2) * -1) var(--s2); }
.sd-table { border-collapse: collapse; width: 100%; margin-top: var(--s3); }
.sd-table th, .sd-table td { padding: 3px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sd-table th.tools-h, .sd-table td.row-tools { width: 84px; min-width: 84px; text-align: center; white-space: nowrap; }
.sd-table td.row-tools .icon-btn { display: inline-flex; vertical-align: middle; }
.sd-table th input { font-weight: 600; color: var(--label); background: var(--surface-2); }
.sd-table input { width: 100%; min-width: 90px; min-height: 36px; font-size: var(--t-sm); }
.sd-table td:nth-child(2) input { min-width: 180px; }
.sd-row-actions { margin-top: var(--s3); display: flex; flex-wrap: wrap; gap: var(--s2); }
.sd-row-actions [hidden] { display: none; }
/* the specification's tables, one tab each; the picked one is edited below */
.sd-tabs { display: flex; flex-wrap: wrap; gap: var(--s1); margin-top: var(--s3); }
.sd-tab { min-height: 32px; padding: 0 var(--s3); font: 500 var(--t-sm)/1 var(--sans); color: var(--ink-2); background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-ctl); cursor: pointer; }
.sd-tab[aria-selected=true] { color: var(--sf-white); background: var(--accent); border-color: var(--accent); }
.sd-tab.add { background: none; border-style: dashed; color: var(--accent); }
.sd-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s3); margin-top: var(--s3); }
.sd-table th { position: relative; }
.sd-table th .col-x { position: absolute; top: 4px; right: 2px; width: 22px; height: 22px; min-height: 0; padding: 0; opacity: .6; }
.sd-table th .col-x:hover { opacity: 1; }
.sd-tools [hidden] { display: none; }
.spec-btn { justify-self: start; font-size: var(--t-xs); color: var(--accent); }
.spec-btn.has { font-weight: 600; }
.drawer header { display: flex; align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: var(--s5); }
.drawer footer { display: flex; justify-content: flex-end; gap: var(--s2); padding: var(--s3) var(--s5); border-top: 1px solid var(--line); }
.icon-btn.plain:hover { color: var(--ink); background: var(--surface-2); }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer::backdrop { transition: none; } .filled { animation: none; } }

/* ---------- drag and drop ---------- */
[data-dropzone] { border-radius: var(--r-box); transition: background-color var(--fast) var(--ease-out), box-shadow var(--fast) var(--ease-out); }
.drag-over { background: var(--accent-soft); box-shadow: 0 0 0 2px var(--sf-neon), 0 0 16px rgb(30 144 255 / 0.35); }
.drop-cue { position: fixed; inset: var(--s3); z-index: var(--z-toast); pointer-events: none; display: grid; place-items: center;
  border: 2px dashed var(--sf-neon); border-radius: var(--r-box); background: color-mix(in srgb, var(--sf-neon) 8%, transparent);
  color: var(--accent); font-size: var(--t-lg); font-weight: 600; animation: cue-in 140ms var(--ease-out); }
.drop-cue[hidden] { display: none; }
@keyframes cue-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .drop-cue { animation: none; } }
.scanbar[data-dropzone] { padding: var(--s2); margin-left: calc(-1 * var(--s2)); margin-right: calc(-1 * var(--s2)); }

/* ---------- row editors: product lines, terms, payment lines ---------- */
/* chevrons for boxes that scroll sideways */
.hs-wrap { position: relative; }
.hs-btn { all: unset; position: absolute; top: 50%; z-index: 2; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer;
  transform: translateY(-50%); border-radius: 50%; background: var(--surface); color: var(--accent); border: 1px solid var(--line-strong);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--sf-dark) 18%, transparent);
  transition: box-shadow var(--fast) var(--ease-out), transform var(--fast) var(--ease-out); }
.hs-btn.left { left: -10px; }
.hs-btn.right { right: -10px; }
.hs-btn.left .icon { transform: rotate(180deg); }
.hs-btn .icon { width: 16px; height: 16px; }
.hs-btn:hover { box-shadow: 0 0 12px rgb(30 144 255 / 0.35); }
.hs-btn:active { transform: translateY(-50%) scale(0.94); }
.hs-btn:focus-visible { box-shadow: var(--focus); }
.hs-btn[hidden] { display: none; }
.lines-wrap { container: lines / inline-size; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--surface); }
.lines { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.lines th { text-align: left; font-weight: 600; font-size: var(--t-xs); color: var(--label); padding: var(--s2) var(--s2); border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.lines td { padding: 6px var(--s2); border-bottom: 1px solid var(--line); vertical-align: top; }
.lines tfoot th, .lines tfoot td { border: 0; padding: var(--s2); font-size: var(--t-sm); color: var(--ink); }
.lines tfoot th { text-align: right; }
.lines td.prod { min-width: 230px; width: 100%; }
.lines .stack { display: grid; gap: 4px; }  /* stacked boxes inside a cell; the cell itself stays a table cell */
/* products found in past documents; spec tables shown small */
.found { display: grid; gap: var(--s3); }
.found-item { padding: var(--s3) var(--s4); display: grid; gap: var(--s2); }
.found-item p { margin: 0; }
.found-item .check .hint, .found-item .check .kind { display: block; margin: 2px 0 0; }
.found-specs summary { cursor: pointer; font-size: var(--t-sm); color: var(--accent); font-weight: 560; }
.table-wrap { overflow-x: auto; margin-top: var(--s2); }
table.mini { border-collapse: collapse; font-size: var(--t-xs); width: 100%; }
table.mini th, table.mini td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; }
table.mini th { background: var(--surface-2); color: var(--label); font-weight: 600; }
.lines .stack input.hs { display: none; }  /* only when the invoice includes HS codes */
/* HS code inside the product's box, left of the catalog button */
.lines .stack .prod-top input.hs { position: absolute; right: 42px; top: 50%; transform: translateY(-50%); width: 86px; min-height: 28px; height: 28px;
  padding: 0 22px 0 6px; font-size: var(--t-xs); border: 0; border-left: 1px solid var(--line); border-radius: 0; background-color: transparent; background-position: right 4px center; background-size: 13px 13px; box-shadow: none; }
.lines.hs-on .prod-top > input:first-child:not([type=checkbox]):not([type=radio]):not([type=file]) { padding-right: 134px; }
.lines .amt .was { display: block; font-size: var(--t-xs); color: var(--ink-3, var(--label)); font-weight: 400; }
.lines .was.contract { color: var(--accent); font-weight: 600; }
/* discount: the % or /unit choice inside the box, on the right */
.lines .disc { position: relative; }
.lines .stack .disc input.qty2 { width: 100%; padding-left: 8px; padding-right: 50px; }
.lines .stack .disc select { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 48px; min-height: 0; border: 0; border-left: 1px solid var(--line); border-radius: 0 var(--r-input, 6px) var(--r-input, 6px) 0;
  padding: 0 14px 0 6px; background-color: transparent; background-position: right 2px center; background-size: 11px 11px; font-size: var(--t-xs); box-shadow: none; }
.lines .amt .was, #lines-total .was { display: block; white-space: normal; }
.lines .was .nb { white-space: nowrap; }
.line-tools { display: flex; gap: 2px; }
.line-tools .grip { cursor: grab; touch-action: none; }
.lines tr.dragging { opacity: 0.45; }
.via-list { display: grid; gap: var(--s2); }
.via-row { display: grid; grid-template-columns: 1fr auto; gap: var(--s2); align-items: center; }
.lines.hs-on .stack input.hs { display: block; }
.lines td:nth-child(2) { width: 150px; min-width: 150px; }  /* 9-digit quantities: 100,000,000 */
.lines td:nth-child(3) { width: 86px; min-width: 86px; }
.lines td:nth-child(4) { width: 104px; min-width: 104px; }
@media (min-width: 900px) {  /* the optional boxes are quieter (phones keep 16px so they don't zoom) */
  .lines .stack input.qty2, .lines .stack input.details { font-size: var(--t-xs); min-height: 32px; padding-top: 4px; padding-bottom: 4px; }
}
/* catalog button inside the description box */
.prod-top { position: relative; }
.prod-top > input:first-child:not([type=checkbox]):not([type=radio]):not([type=file]) { width: 100%; padding-right: 44px; }
.cat-pick { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: var(--r-ctl); color: var(--ink-3); transition: color var(--fast) var(--ease-out), background-color var(--fast) var(--ease-out); }
.cat-pick:hover { color: var(--accent); background: var(--surface-2); }
.cat-pick:focus-within { box-shadow: var(--focus); }
.cat-pick.on { color: var(--accent); background: var(--accent-soft); }
.cat-pick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }  /* the native picker, tapped through the icon */
.lines .amt { white-space: nowrap; padding-top: 14px; font-variant-numeric: lining-nums tabular-nums; }
.lines #lines-total { font-weight: 600; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s2); }
.term-rows, .pay-rows { display: grid; gap: var(--s2); }
/* Term sections: the headings in the accent colour, each section's pills in its own colour */
.t-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px var(--s3); padding-top: var(--s4); }
.t-group-title { font-size: var(--t-md); font-weight: 600; color: var(--accent); }
.t-group:first-child { padding-top: 0; }
.t-group .t-chips { display: contents; }
/* a section: its title in the term names' column, its terms menu in the values' column */
.t-group { display: grid; grid-template-columns: minmax(200px, 0.34fr) minmax(0, 1fr) 30px 30px 30px; gap: var(--s2); align-items: center; }
.t-addbtn { all: unset; box-sizing: border-box; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  min-height: 32px; padding: 4px 10px; font-size: var(--t-xs); color: var(--ink-2); border: 1px dashed var(--line-strong); border-radius: var(--r-ctl); }
.t-addbtn:hover, .t-addbtn:focus-visible { border-style: solid; border-color: var(--accent); color: var(--accent); }
.t-addbtn .icon { width: 14px; height: 14px; color: var(--accent); }
.choice.fit-yes { color: oklch(0.48 0.13 150); }
.choice.fit-maybe { color: oklch(0.55 0.01 255); }
.choice.fit-no { color: oklch(0.52 0.16 25); }
.term-row { display: grid; grid-template-columns: minmax(200px, 0.34fr) minmax(0, 1fr) auto auto auto; gap: var(--s2); align-items: center; }
.t-value-wrap { position: relative; }
.t-value-wrap .t-value:not([type=checkbox]):not([type=radio]) { padding-right: 40px; }  /* beats the general input padding so text stops before the arrow */
.t-value-wrap .t-pick { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); color: var(--accent); }
.term-row .icon-btn, .pay-row .icon-btn { width: 30px; height: 30px; }
/* a set term's name: plain text, not a box */
.term-row input.t-label.fixed { border-color: transparent; background: transparent; box-shadow: none; padding-left: 2px; font-weight: 400; color: var(--ink); cursor: default; }
.term-row .icon-btn:not(.t-pick):hover { color: var(--ink); background: var(--surface-2); }
.term-row .icon-btn:last-child:hover, .pay-row .icon-btn:last-child:hover { color: var(--danger); background: var(--danger-soft); }
.pay-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto auto; gap: var(--s2); align-items: center; }
.pay-row .check { align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { all: unset; cursor: pointer; font-size: var(--t-xs); padding: 4px 10px; border-radius: 999px; border: 1px dashed var(--line-strong); color: var(--ink-2); transition: border-color var(--fast) var(--ease-out), color var(--fast) var(--ease-out), box-shadow var(--base) var(--ease-out); }
.chip-btn::before { content: "+ "; }
.chip-btn:hover { border-color: var(--sf-neon); color: var(--accent); box-shadow: 0 0 10px rgb(30 144 255 / 0.25); }
.chip-btn:focus-visible { box-shadow: var(--focus); }
.choice-menu { position: fixed; z-index: var(--z-toast); max-height: min(360px, 60vh); overflow-y: auto; overscroll-behavior: contain; padding: 6px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-box); box-shadow: 0 6px 8px color-mix(in srgb, var(--sf-dark) 14%, transparent); }
.choice-group { font-size: var(--t-xs); font-weight: 600; color: var(--label); padding: 8px 8px 4px; }
.choice { all: unset; box-sizing: border-box; cursor: pointer; display: grid; gap: 2px; width: 100%; padding: 7px 8px; border-radius: var(--r-ctl); font-size: var(--t-sm); color: var(--ink); }
.choice small { color: var(--ink-3); font-size: var(--t-xs); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.choice:hover, .choice:focus-visible { background: var(--accent-soft); color: var(--accent); }
.choice.multi { position: relative; padding-left: 30px; }
.choice.multi::before { content: ""; position: absolute; left: 9px; top: 50%; width: 13px; height: 13px; transform: translateY(-50%);
  border: 1.5px solid var(--line-strong); border-radius: 3px; background: var(--surface); }
.choice.multi[aria-checked="true"]::before { background: var(--accent); border-color: var(--accent);
  box-shadow: inset 0 0 0 2px var(--surface); }
.choice.other { color: var(--ink-3); font-style: italic; border-top: 1px solid var(--line); border-radius: 0; margin-top: 4px; }
.pay-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s2); padding: var(--s2) var(--s3) var(--s3); }
.split-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn.plain::before { content: none; }
.split-row { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); color: var(--ink-2); }
.split-row input { width: 90px !important; }
.split-out { margin: 0; font-size: var(--t-sm); color: var(--ink); font-weight: 560; }
.pay-split .btn { justify-self: start; }
.choice-empty { margin: 0; padding: var(--s3); font-size: var(--t-sm); color: var(--ink-3); }
@media (max-width: 699px) {
  /* term rows: label and controls on top, the value full width below */
  .term-row { grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; }
  .t-group { grid-template-columns: minmax(0, 1fr); }  /* phones: the menu under the title */
  .term-row > .t-value-wrap { grid-column: 1 / -1; grid-row: 2; }
  .term-row + .term-row { padding-top: var(--s2); border-top: 1px solid var(--line); }
  /* payment lines: description full width, then amount, Received and remove */
  .pay-row { grid-template-columns: minmax(0, 1fr) auto auto; }
  .pay-row > .p-desc { grid-column: 1 / -1; }
  .pay-row + .pay-row { padding-top: var(--s2); border-top: 1px solid var(--line); }
}
@container lines (max-width: 720px) {
  /* product lines as stacked cards: product, then quantity / unit / price, then amount */
  .lines thead { display: none; }
  .lines, .lines tbody, .lines tfoot { display: block; }
  .lines tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px var(--s2); padding: var(--s3); border-bottom: 1px solid var(--line); }
  .lines tbody td { display: block; padding: 0; border: 0; width: auto !important; min-width: 0 !important; }
  .lines tbody td.prod { grid-column: 1 / -1; min-width: 0; width: auto; }
  .lines tbody td input { width: 100% !important; }
  .lines tbody td:nth-child(2) { grid-column: 1 / 3; grid-row: 2; }  /* Qty | 2nd qty */
  .lines tbody td:nth-child(2) .stack { grid-template-columns: 1fr 1fr; }
  .lines tbody td:nth-child(3) { grid-column: 1; grid-row: 3; }      /* Unit | Price */
  .lines tbody td:nth-child(4) { grid-column: 2; grid-row: 3; }
  .lines tbody td.amt { grid-column: 1 / 3; grid-row: 4; padding: 2px 0 0; font-weight: 600; }
  .lines tbody td:last-child { grid-column: 3; grid-row: 2; align-self: center; }
  .lines tfoot tr { display: flex; justify-content: space-between; padding: var(--s3); }
  .lines tfoot td:empty { display: none; }
}

/* Products and Terms: the headings of the two biggest blocks of the form */
.label.big { font-size: var(--t-lg); font-weight: 700; color: var(--ink); }

/* "Create FCO" and the other next documents of a deal */
.next-docs { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.next-docs form { display: contents; }

/* Wording: a clause's standard text, edited for this document only */
.wording-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.wording textarea { font-size: var(--t-sm); line-height: 1.5; }
.wording textarea.own { border-color: var(--accent); background: var(--accent-soft); }
.t-value.locked { cursor: pointer; }
/* Procedures: ours apart from those received or written elsewhere */
.picklist .pick-group { padding: 6px var(--s3); background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: var(--t-xs); font-weight: 600; color: var(--ink-2); }
.picklist .pick-none { margin: 0; padding: 10px var(--s3); font-size: var(--t-sm); color: var(--ink-3); }
.picklist .origin { display: inline-block; margin: 0 0 0 8px; padding: 1px 8px; border-radius: 999px; font-size: var(--t-xs); }
.origin-standard { background: var(--accent-soft); color: var(--accent); }
.origin-edited { background: var(--ok-soft); color: var(--ok); }
.origin-custom { background: var(--warn-soft); color: var(--warn); }

.field > .scan-msg { flex: none; }
/* Procedures coloured by how they fit the deal, as the documents are in the terms menu */
.picklist .check.fit-yes > span { color: oklch(0.48 0.13 150); }
.picklist .check.fit-maybe > span { color: oklch(0.55 0.01 255); }
.picklist .check.fit-no > span { color: oklch(0.52 0.16 25); }
.fit-key { display: block; margin-top: 2px; }
.fit-key .fit-yes { color: oklch(0.48 0.13 150); } .fit-key .fit-maybe { color: oklch(0.55 0.01 255); } .fit-key .fit-no { color: oklch(0.52 0.16 25); }
/* Included clauses: one line each, Edit opens the title, type and text */
.ci-included { margin-top: var(--s2); }
.clause-item .ci-name { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.clause-item .ci-name strong { font-weight: 560; overflow-wrap: anywhere; }
.clause-item .ci-preview { font-size: var(--t-xs); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clause-item .ci-meta { display: flex; gap: var(--s2); align-items: center; margin: var(--s2) 0; flex-wrap: wrap; }
.clause-item .ci-meta .ci-title { flex: 1 1 260px; width: auto; min-height: 36px; }
.clause-item .ci-meta .ci-kind { flex: 0 0 auto; width: auto; min-height: 36px; }
.clause-item .ci-head .ci-edited { white-space: nowrap; }
.ci-editor { display: grid; grid-template-rows: 0fr; opacity: 0;
  transition: grid-template-rows 320ms cubic-bezier(0.22, 1, 0.36, 1), opacity 200ms ease-out; }
.ci-editor > div { min-height: 0; overflow: hidden; padding: 0 3px 3px; margin: 0 -3px; }  /* room for the focus ring */
.clause-item.open .ci-editor { grid-template-rows: 1fr; opacity: 1; }
@media (prefers-reduced-motion: reduce) { .ci-editor { transition: none; } }
/* Annexes: the included-list cards of the clauses, the picklist coloured like the procedures */
#list-annex .check.fit-yes > span { color: oklch(0.48 0.13 150); }
#list-annex .check.fit-maybe > span { color: oklch(0.55 0.01 255); }
#list-annex .check.fit-no > span { color: oklch(0.52 0.16 25); }
#items-annex .ci-editor > div > * + * { margin-top: var(--s2); }
#items-annex .clause-item.not-printed strong { color: var(--ink-3); }

/* product photos under the products: thumbnails in the shape they print (4:3), each with move and remove */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--s3); margin: var(--s2) 0; }
.photo-grid[hidden] { display: none; }
.photo { position: relative; margin: 0; aspect-ratio: 4 / 3; border: 1px solid var(--line); border-radius: var(--r-ctl); overflow: hidden; background: var(--surface-2); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-bar { position: absolute; top: var(--s1); right: var(--s1); display: flex; gap: 2px; }
.photo-bar .icon-btn { background: var(--surface); border-radius: var(--r-ctl); }
.photos-field > label.btn { justify-self: start; align-self: start; width: auto; }
/* a specification table's picture, and its heading rows */
.sd-pic { display: flex; align-items: flex-start; gap: var(--s2); }
.sd-pic[hidden] { display: none; }
.sd-pic img { max-width: 220px; max-height: 140px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: #fff; }
.sd-pic-field > label.btn { justify-self: start; align-self: start; width: auto; }
.sd-table .head-btn { font: 700 12px/1 var(--sans); color: var(--ink-3); }
.sd-table .head-btn[aria-pressed=true] { color: var(--sf-white); background: var(--accent); border-radius: var(--r-ctl); }
#specdialog .sd-table tr.head-row input { font-weight: 700; color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.fmt-btn .fmt-blue { display: inline-flex; color: #3260A8; }  /* Highlight: the house blue it prints in */
.hint.warn { color: oklch(0.5 0.15 45); }
