/* =============================================================================
   CommissionSlip design system
   Direction: "paper & ink" — calm, precise, record-keeping. Warm paper surfaces,
   near-black ink, hairline rules, tabular figures. Brand violet is an accent only
   (focus, selection, brand mark, charts), never a wash.
   No external fonts or libraries; CSP-safe (no inline styles).
   ============================================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  /* Surfaces */
  --paper: #FAF9F6;          /* app & page background */
  --surface: #FFFFFF;        /* panels, inputs */
  --sunken: #F3F1EC;         /* hover rows, wells, code */
  --line: #E7E3DA;           /* hairline borders */
  --line-strong: #D6D0C3;    /* input borders, emphasis rules */

  /* Ink */
  --ink: #16141D;            /* primary text, primary buttons */
  --ink-2: #4B4757;          /* secondary text */
  --ink-3: #6F6A7B;          /* tertiary / labels (AA on paper) */
  --ink-4: #9C97A6;          /* placeholders, disabled */

  /* Brand */
  --brand: #865DFF;          /* logo violet: brand mark, chart, selection */
  --accent: #5A3CD6;         /* links & focus (AA contrast on white) */
  --accent-soft: rgba(110, 75, 242, .12);
  --midnight: #19142E;

  /* Status (text / tint / border) */
  --ok: #1E6E47;    --ok-bg: #ECF5EF;    --ok-line: #CFE5D7;
  --warn: #8A5300;  --warn-bg: #FBF2E1;  --warn-line: #EFDDB6;
  --bad: #AE2A1F;   --bad-bg: #FBECEA;   --bad-line: #F1CCC7;
  --info: #2B58AE;  --info-bg: #ECF1FA;  --info-line: #CFDBF1;
  --neutral: #5C5868; --neutral-bg: #F1EFEA;

  /* Back-compat aliases used by older rules/partials */
  --violet: var(--brand); --violet-ink: var(--accent); --mist: #F3F0FB; --white: #FFFFFF;
  --border: var(--line); --border-strong: var(--line-strong); --text: var(--ink);
  --muted: var(--ink-3); --subtle: var(--ink-4); --bg: var(--paper);
  --success: var(--ok); --success-bg: var(--ok-bg); --danger: var(--bad); --danger-bg: var(--bad-bg);
  --warning: var(--warn); --warning-bg: var(--warn-bg);

  /* Type */
  --sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Charter", "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;

  /* Shape & depth */
  --r-xs: 5px; --r-sm: 7px; --r: 10px; --r-lg: 14px;
  --radius: var(--r); --radius-sm: var(--r-sm);
  --shadow-xs: 0 1px 0 rgba(22, 20, 29, .04);
  --shadow-sm: 0 1px 2px rgba(22, 20, 29, .06), 0 0 0 1px rgba(22, 20, 29, .02);
  --shadow-pop: 0 16px 40px -12px rgba(22, 20, 29, .22), 0 4px 10px -4px rgba(22, 20, 29, .10);
  --shadow: var(--shadow-xs); --shadow-lg: var(--shadow-pop);

  /* Motion */
  --ease: cubic-bezier(.2, .7, .2, 1);       /* decelerate: entrances, hovers */
  --ease-io: cubic-bezier(.45, 0, .2, 1);    /* move/resize */
  --t1: 120ms; --t2: 180ms; --t3: 260ms;

  /* Layout */
  --sidebar: 240px;
  --topbar: 52px;
  --content-max: 1240px;
  color-scheme: light;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0; font-family: var(--sans); font-size: 14.5px; line-height: 1.55; color: var(--ink);
  background: var(--paper); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
img { height: auto; }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 620; letter-spacing: -.012em; line-height: 1.25; color: var(--ink); }
h1 { font-size: 1.5rem; letter-spacing: -.02em; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
h4 { font-size: .875rem; }
p { margin: 0 0 1em; }
strong { font-weight: 620; }
small { font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
code, .mono { font-family: var(--mono); font-size: .88em; font-variant-ligatures: none; }
code { background: var(--sunken); padding: .12em .38em; border-radius: 4px; border: 1px solid var(--line); }
pre { background: #1B1923; color: #ECEAF2; padding: 16px 18px; border-radius: var(--r); overflow-x: auto;
      font-size: .8rem; line-height: 1.6; margin: 0 0 1.2em; }
pre code { background: none; border: 0; padding: 0; color: inherit; }
::selection { background: rgba(134, 93, 255, .22); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* Utilities */
.muted { color: var(--ink-3); } .subtle { color: var(--ink-4); } .small { font-size: .86em; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.mt-0 { margin-top: 0 !important; } .mb-0 { margin-bottom: 0 !important; }
.mt { margin-top: 20px; } .mb { margin-bottom: 20px; } .mt-sm { margin-top: 8px; }
.max-640 { max-width: 640px; } .max-860 { max-width: 860px; } .w-auto { width: auto; }
.inline-form { display: inline; } .btn-block { width: 100%; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.stack > * + * { margin-top: 16px; }
.list-plain { list-style: none; padding: 0; margin: 0; }
.list-plain li { padding: 11px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }
.pill-list { display: flex; flex-wrap: wrap; gap: 6px; }
.hp-field { position: absolute; left: -10000px; }

/* ---------- 3. Buttons ---------- */
.btn {
  --btn-h: 34px;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: var(--btn-h); padding: 0 14px; border-radius: var(--r-sm); border: 1px solid transparent;
  font: inherit; font-size: .875rem; font-weight: 560; line-height: 1; white-space: nowrap; cursor: pointer;
  text-decoration: none !important; user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t1) var(--ease), border-color var(--t1) var(--ease),
              color var(--t1) var(--ease), box-shadow var(--t1) var(--ease), transform var(--t1) var(--ease);
}
.btn:active:not([disabled]) { transform: translateY(1px) scale(.985); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary, .btn-dark {
  background: var(--ink); color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .08) inset, 0 1px 2px rgba(22, 20, 29, .18);
}
.btn-primary:hover, .btn-dark:hover { background: #2B2836; }
.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { border-color: #C3BCAD; background: #FDFCFA; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); }
.btn-danger { background: var(--surface); color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: var(--bad-bg); border-color: #E7B3AC; }
.btn-sm { --btn-h: 28px; padding: 0 10px; font-size: .8125rem; border-radius: 6px; }
.btn-lg { --btn-h: 42px; padding: 0 20px; font-size: .9375rem; }
.btn[disabled], .btn.is-loading { opacity: .6; cursor: default; }
.btn.is-loading { color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-color: rgba(255, 255, 255, .9) rgba(255, 255, 255, .9) transparent transparent;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after, .btn-danger.is-loading::after { border-color: var(--ink-3) var(--ink-3) transparent transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }

/* ---------- 4. Forms ---------- */
.field { margin-bottom: 18px; }
.field > label, .label { display: block; font-weight: 560; font-size: .8125rem; color: var(--ink); margin-bottom: 6px; }
.field .help { color: var(--ink-3); font-size: .78rem; margin-top: 6px; line-height: 1.45; }
.field .error, .errorlist { color: var(--bad); font-size: .78rem; margin: 6px 0 0; padding: 0; list-style: none; }
.errorlist li::before { content: "↳ "; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=date],
input[type=search], input[type=tel], input:not([type]), select, textarea {
  width: 100%; height: 36px; padding: 0 11px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  font: inherit; font-size: .875rem; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs);
  transition: border-color var(--t1) var(--ease), box-shadow var(--t1) var(--ease), background-color var(--t1) var(--ease);
  appearance: none; -webkit-appearance: none;
}
textarea { height: auto; min-height: 88px; padding: 9px 11px; line-height: 1.5; resize: vertical; }
input[type=number] { font-variant-numeric: tabular-nums; }
input[type=date] { padding-right: 8px; }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
select {
  padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236F6A7B' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input:hover, select:hover, textarea:hover { border-color: #C6BFB1; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { background: var(--sunken); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--bad); }
.field.has-error input:focus { box-shadow: 0 0 0 3px rgba(174, 42, 31, .12); }
input[type=checkbox], input[type=radio] {
  width: 16px; height: 16px; margin: 0; accent-color: var(--ink); cursor: pointer; flex: none;
}
.field.checkbox, .checkbox { display: flex; gap: 10px; align-items: flex-start; }
.checkbox input { margin-top: 2px; }
.checkbox label { font-weight: 500; margin: 0; font-size: .875rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.non-field-errors {
  background: var(--bad-bg); color: var(--bad); border: 1px solid var(--bad-line); padding: 10px 12px;
  border-radius: var(--r-sm); margin-bottom: 18px; font-size: .84rem;
}
fieldset { border: 0; padding: 0; margin: 0; }

/* ---------- 5. Panels (cards) ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-xs); min-width: 0;
}
.card-body { padding: 18px 20px; }
.card-header {
  padding: 13px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 50px;
}
.card-header h2, .card-header h3 { margin: 0; font-size: .9375rem; font-weight: 600; letter-spacing: -.005em; }
.card-header .small, .card-header .muted { font-size: .8rem; }
.card > .card-header + .card-header { border-top: 1px solid var(--line); }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid > .card + .card { margin-top: 0; }

/* Key/value lists */
.kv { display: grid; grid-template-columns: minmax(130px, 36%) 1fr; gap: 0; margin: 0; font-size: .875rem; }
.kv dt, .kv dd { padding: 8px 0; border-bottom: 1px solid var(--sunken); }
.kv dt { color: var(--ink-3); padding-right: 16px; }
.kv dd { margin: 0; word-break: break-word; color: var(--ink); }
.kv dt:last-of-type, .kv dd:last-of-type { border-bottom: 0; }

/* ---------- 6. Metrics ----------
   Stat tiles inside a .grid render as one segmented strip, not a pile of cards. */
.stat { padding: 16px 18px 15px; }
.stat-label { color: var(--ink-3); font-size: .78rem; font-weight: 500; letter-spacing: 0; text-transform: none; }
.stat-value {
  font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; margin-top: 6px; line-height: 1.15;
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.stat-sub { color: var(--ink-3); font-size: .76rem; margin-top: 5px; }
.stat-sub a { color: inherit; text-decoration: underline; text-decoration-color: var(--line-strong); }
.grid:has(> .stat) {
  gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-xs); overflow: hidden;
}
.grid:has(> .stat) > .stat { border: 0; border-radius: 0; box-shadow: none; position: relative; }
.grid:has(> .stat) > .stat + .stat::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 1px; background: var(--line);
}
.grid-4:has(> .stat) > .stat:nth-child(4n+1)::before, .grid-3:has(> .stat) > .stat:nth-child(3n+1)::before,
.grid-2:has(> .stat) > .stat:nth-child(2n+1)::before { display: none; }
.grid-4:has(> .stat) > .stat:nth-child(n+5), .grid-3:has(> .stat) > .stat:nth-child(n+4),
.grid-2:has(> .stat) > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
.grid:has(> .stat) + .grid:has(> .stat) { margin-top: 12px; }

/* ---------- 7. Status badges ----------
   Quiet: a coloured dot + label. Colour carries meaning, not decoration. */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: .75rem; font-weight: 550; line-height: 1; white-space: nowrap; vertical-align: middle;
  background: var(--neutral-bg); color: var(--neutral); border: 1px solid transparent;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; flex: none; }
.badge-success { background: var(--ok-bg); color: var(--ok); }
.badge-warning { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--bad-bg); color: var(--bad); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge-violet { background: #F2EEFE; color: var(--accent); }
.badge-violet::before { display: none; }
.test-tag {
  display: inline-flex; align-items: center; height: 18px; font-size: .64rem; font-weight: 650; letter-spacing: .06em;
  color: var(--warn); background: var(--warn-bg); border: 1px solid var(--warn-line); padding: 0 5px;
  border-radius: 4px; vertical-align: middle; text-transform: uppercase;
}

/* ---------- 8. Inline notices (alerts) ---------- */
.alert, .notice, .review-banner {
  position: relative; padding: 11px 14px 11px 40px; border-radius: var(--r-sm); margin-bottom: 16px;
  font-size: .86rem; line-height: 1.5; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
}
.alert::before, .notice::before, .review-banner::before {
  content: ""; position: absolute; left: 14px; top: 13px; width: 16px; height: 16px; border-radius: 50%;
  background: currentColor; opacity: .9;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm.9 12H7.1V7h1.8v5zM8 5.6a1.1 1.1 0 1 1 0-2.2 1.1 1.1 0 0 1 0 2.2z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0zm.9 12H7.1V7h1.8v5zM8 5.6a1.1 1.1 0 1 1 0-2.2 1.1 1.1 0 0 1 0 2.2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.notice { background: #F7F5FD; border-color: #E5DEFA; color: #3E2E8F; }
.alert-success { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.alert-error, .alert-danger { background: var(--bad-bg); border-color: var(--bad-line); color: var(--bad); }
.alert-warning, .review-banner { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.alert strong, .notice strong { color: inherit; }
.alert a, .notice a { color: inherit; text-decoration: underline; }

/* ---------- 9. Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .84rem; }
.table th {
  text-align: left; font-size: .75rem; font-weight: 550; color: var(--ink-3); text-transform: none; letter-spacing: 0;
  padding: 9px 16px; border-bottom: 1px solid var(--line); background: #FCFBF9; white-space: nowrap;
}
.table td { padding: 11px 16px; border-bottom: 1px solid #EFECE5; vertical-align: middle; color: var(--ink-2); white-space: nowrap; }
.table td.wrap, .table td .wrap, .prose .table td { white-space: normal; min-width: 140px; overflow-wrap: anywhere; }
.table tbody tr { transition: background-color var(--t1) var(--ease); }
.table tbody tr:hover { background: #FBFAF7; }
.table tr:last-child td { border-bottom: 0; }
.table th.num, .table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.num { color: var(--ink); }
.table .primary, .table td a.primary { font-weight: 560; color: var(--ink); }
.table td a.primary:hover { color: var(--accent); }
.table .mono, .table td.mono a { white-space: nowrap; }
.table .subtle.small, .table .muted.small { margin-top: 2px; }
.table input[type=checkbox] { vertical-align: middle; }
.table.totals td { padding: 8px 16px; }

/* Empty states: a blank slip, drawn in CSS */
.empty { text-align: center; padding: 44px 24px 40px; color: var(--ink-3); }
.empty::before {
  content: ""; display: block; width: 44px; height: 54px; margin: 0 auto 16px; border-radius: 5px;
  background:
    linear-gradient(var(--line-strong), var(--line-strong)) 9px 15px / 26px 2px no-repeat,
    linear-gradient(var(--line), var(--line)) 9px 23px / 20px 2px no-repeat,
    linear-gradient(var(--line), var(--line)) 9px 31px / 24px 2px no-repeat,
    linear-gradient(var(--line), var(--line)) 9px 39px / 14px 2px no-repeat,
    var(--surface);
  border: 1px solid var(--line-strong); box-shadow: 3px 3px 0 var(--sunken);
}
.empty h3 { color: var(--ink); margin-bottom: 4px; font-size: .9375rem; }
.empty p { max-width: 420px; margin-left: auto; margin-right: auto; font-size: .86rem; }
.empty .btn { margin-top: 14px; }
td .empty { padding: 28px 12px; }

/* ---------- 10. Toolbar, tabs, pagination ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.toolbar .field { margin: 0; }
.toolbar input, .toolbar select { width: auto; min-width: 160px; }
.tabs {
  display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  position: relative; padding: 9px 12px 10px; color: var(--ink-3); font-weight: 550; font-size: .84rem;
  white-space: nowrap; text-decoration: none; transition: color var(--t1) var(--ease);
}
.tabs a:hover { color: var(--ink); }
.tabs a::after {
  content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; border-radius: 2px;
  background: var(--ink); transform: scaleX(0); transition: transform var(--t2) var(--ease);
}
.tabs a.active { color: var(--ink); }
.tabs a.active::after { transform: scaleX(1); }
.pagination {
  display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 10px 16px;
  border-top: 1px solid var(--line); font-size: .8rem; color: var(--ink-3);
}

/* ---------- 11. Copy field, codes, secrets ---------- */
.copy {
  display: flex; align-items: stretch; height: 36px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  overflow: hidden; background: var(--surface); max-width: 100%; box-shadow: var(--shadow-xs);
}
.copy input { border: 0; border-radius: 0; height: 100%; font-family: var(--mono); font-size: .8rem; min-width: 0; background: transparent; box-shadow: none; }
.copy input:focus { box-shadow: none; }
.copy button {
  border: 0; border-left: 1px solid var(--line); background: var(--sunken); color: var(--ink); font: inherit;
  font-weight: 560; font-size: .78rem; padding: 0 14px; cursor: pointer; min-width: 74px;
  transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease);
}
.copy button:hover { background: #ECE9E2; }
.copy button.copied { background: var(--ok-bg); color: var(--ok); }
.code-chip {
  display: inline-block; font-family: var(--mono); font-weight: 600; font-size: .9rem; letter-spacing: .06em;
  color: var(--ink); background: var(--surface); padding: 4px 10px; border-radius: var(--r-xs);
  border: 1px dashed var(--line-strong);
}
.secret-box { background: #1B1923; color: #ECEAF2; border-radius: var(--r); padding: 18px 20px; }
.secret-box h3 { color: #fff; }
.secret-box .label { color: #B9B4C6; }
.secret-box .copy { border-color: #3A3648; background: #24212E; }
.secret-box .copy input { color: #fff; }
.secret-box .copy button { background: #2E2A3A; color: #fff; border-left-color: #3A3648; }

/* ---------- 12. App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; height: 100dvh; display: flex; flex-direction: column;
  padding: 14px 10px 10px; border-right: 1px solid var(--line); background: #F7F5F1; view-transition-name: sidebar;
}
.sidebar .brand { display: flex; align-items: center; height: 36px; padding: 0 10px; margin-bottom: 6px; }
.sidebar .brand img { height: 26px; width: auto; }
.portal-label {
  display: inline-flex; margin: 2px 10px 12px; font-size: .7rem; font-weight: 600; letter-spacing: .04em;
  color: var(--ink-3); text-transform: uppercase;
}
.sidebar-action { margin: 0 4px 14px; }
.sidebar-action .btn { width: 100%; justify-content: flex-start; }
.nav { flex: 1; overflow-y: auto; margin: 0 -4px; padding: 0 4px; scrollbar-width: thin; }
.nav-heading {
  display: block; padding: 14px 10px 5px; font-size: .7rem; font-weight: 600; color: var(--ink-4);
  letter-spacing: .02em;
}
.nav a {
  display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 10px; margin-bottom: 1px;
  border-radius: var(--r-sm); color: var(--ink-2); font-weight: 520; font-size: .84rem; text-decoration: none;
  border: 1px solid transparent; transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease);
}
.nav a:hover { background: rgba(22, 20, 29, .045); color: var(--ink); }
.nav a.active {
  background: var(--surface); color: var(--ink); border-color: var(--line); box-shadow: var(--shadow-sm); font-weight: 580;
}
.nav svg { width: 16px; height: 16px; flex: none; color: var(--ink-3); transition: color var(--t1) var(--ease); }
.nav a.active svg { color: var(--brand); }
.nav .count { margin-left: auto; font-size: .7rem; font-weight: 600; color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* Account menu at the foot of the sidebar */
.account { position: relative; border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.account-trigger {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 0; border-radius: var(--r-sm);
  background: none; font: inherit; color: var(--ink); cursor: pointer; text-align: left;
  transition: background-color var(--t1) var(--ease);
}
.account-trigger:hover, .account.open .account-trigger { background: rgba(22, 20, 29, .05); }
.account-trigger .who { min-width: 0; flex: 1; line-height: 1.25; }
.account-trigger .who strong { display: block; font-size: .82rem; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-trigger .who span { display: block; font-size: .72rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-trigger .chev { width: 14px; height: 14px; color: var(--ink-3); transition: transform var(--t2) var(--ease); }
.account.open .chev { transform: rotate(180deg); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 620; font-size: .75rem; flex: none;
}

/* Generic menu (dropdown) */
.menu {
  position: absolute; z-index: 60; min-width: 220px; padding: 5px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-pop);
  opacity: 0; visibility: hidden; transform: translateY(4px) scale(.98); transform-origin: bottom left;
  transition: opacity var(--t1) var(--ease), transform var(--t2) var(--ease), visibility 0s linear var(--t2);
}
.account .menu { left: 0; right: 0; bottom: calc(100% + 6px); }
.open > .menu { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
.menu a, .menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border: 0; background: none;
  border-radius: 6px; font: inherit; font-size: .84rem; color: var(--ink-2); text-decoration: none; cursor: pointer; text-align: left;
}
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible { background: var(--sunken); color: var(--ink); outline: none; }
.menu svg { width: 15px; height: 15px; color: var(--ink-3); }
.menu hr { margin: 5px 4px; }
.menu .menu-label { padding: 6px 10px 4px; font-size: .72rem; color: var(--ink-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 0 28px; border-bottom: 1px solid transparent;
  background: rgba(250, 249, 246, .82); -webkit-backdrop-filter: saturate(1.4) blur(10px); backdrop-filter: saturate(1.4) blur(10px);
  transition: border-color var(--t2) var(--ease);
}
.topbar.scrolled { border-bottom-color: var(--line); }
.topbar .left, .topbar .right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.org-name { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .badge { height: 20px; font-size: .7rem; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: var(--r-sm); color: var(--ink-2); border: 0; background: none; cursor: pointer;
  transition: background-color var(--t1) var(--ease), color var(--t1) var(--ease);
}
.icon-btn:hover { background: rgba(22, 20, 29, .06); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }
.dot {
  position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  background: var(--brand); color: #fff; font-size: .62rem; font-weight: 700; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 0 0 2px var(--paper);
}
.user-chip { display: none; }
.content { width: 100%; max-width: var(--content-max); padding: 24px 32px 64px; view-transition-name: content; }
.menu-toggle { display: none; }
.scrim { display: none; }
.env-banner {
  background: repeating-linear-gradient(135deg, #FBF2E1 0 10px, #F8ECD2 10px 20px); color: var(--warn);
  text-align: center; font-size: .72rem; font-weight: 600; padding: 4px 8px; letter-spacing: .01em;
  border-bottom: 1px solid var(--warn-line);
}

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 24px; margin: 4px 0 20px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; flex: 1 1 360px; }
.page-head h1 { margin: 0; font-size: 1.375rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head p { margin: 5px 0 0; color: var(--ink-3); font-size: .875rem; max-width: 70ch; }
.breadcrumb { font-size: .8rem; color: var(--ink-3); margin-bottom: 6px; }
.breadcrumb a { color: var(--ink-3); }
.breadcrumb a::before { content: "← "; }
.breadcrumb a:hover { color: var(--ink); text-decoration: none; }

/* Live indicator */
.live-note {
  display: inline-flex; align-items: center; gap: 7px; margin: 0 0 4px; font-size: .72rem; color: var(--ink-4);
  font-variant-numeric: tabular-nums;
}
.live-dot { position: relative; width: 6px; height: 6px; border-radius: 50%; background: #2F9E6A; }
.live-dot::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 1px solid #2F9E6A; opacity: 0;
  animation: pulse 2.4s var(--ease) infinite;
}
.live-note.paused .live-dot { background: #C99A2E; }
.live-note.paused .live-dot::after { animation: none; }

/* ---------- 13. Charts ---------- */
.chart { width: 100%; height: 250px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .axis text { fill: var(--ink-4); font-size: 10.5px; font-family: var(--sans); font-variant-numeric: tabular-nums; }
.chart .grid-line { stroke: #EFECE5; }
.chart-legend { display: flex; gap: 16px; font-size: .76rem; color: var(--ink-3); margin-bottom: 10px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend span::before { content: ""; width: 14px; height: 2px; border-radius: 2px; background: var(--swatch); }
.chart-legend .sw-violet { --swatch: #865DFF; }
.chart-legend .sw-midnight { --swatch: #16141D; }
.chart-tip {
  position: absolute; pointer-events: none; background: #1B1923; color: #fff; font-size: .74rem; line-height: 1.5;
  padding: 7px 10px; border-radius: 7px; white-space: nowrap; transform: translate(-50%, -110%); display: none;
  z-index: 5; box-shadow: var(--shadow-pop); font-variant-numeric: tabular-nums;
}
.chart-tip strong { display: block; font-weight: 600; margin-bottom: 2px; color: #CFCBD9; font-size: .7rem; }

/* Skeletons */
.skeleton { position: relative; overflow: hidden; background: var(--sunken); border-radius: var(--r-sm); }
.skeleton::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent);
  animation: shimmer 1.3s var(--ease-io) infinite;
}
.chart.skeleton { border-radius: var(--r-sm); }

/* ---------- 14. Toasts (flash messages) ---------- */
.toasts {
  position: fixed; z-index: 90; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px;
  width: min(380px, calc(100vw - 28px)); pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px;
  background: #1B1923; color: #F3F1F7; border-radius: var(--r); box-shadow: var(--shadow-pop);
  font-size: .84rem; line-height: 1.45; animation: toast-in var(--t3) var(--ease) both;
}
.toast::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: #9C97A6; }
.toast-success::before { background: #3FBF83; }
.toast-error::before, .toast-danger::before { background: #F06A5B; }
.toast-warning::before { background: #E7B04A; }
.toast-info::before { background: #8EA9F0; }
.toast .toast-msg { flex: 1; }
.toast .toast-close {
  flex: none; width: 22px; height: 22px; margin: -2px -2px 0 0; border: 0; background: none; color: #9C97A6;
  border-radius: 5px; cursor: pointer; font-size: 16px; line-height: 1;
}
.toast .toast-close:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.toast.leaving { animation: toast-out var(--t2) var(--ease-io) forwards; }

/* ---------- 15. Modal (confirm dialogs) ---------- */
.modal {
  border: 0; padding: 0; background: transparent; max-width: min(440px, calc(100vw - 32px)); width: 100%;
  overflow: visible; color: var(--ink);
}
.modal::backdrop { background: rgba(22, 20, 29, 0); transition: background-color var(--t2) var(--ease); }
.modal[open]::backdrop { background: rgba(22, 20, 29, .32); }
.modal-panel {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); border: 1px solid var(--line);
  padding: 20px 20px 16px; animation: modal-in var(--t2) var(--ease) both;
}
.modal-panel h2 { font-size: 1rem; margin: 0 0 6px; }
.modal-panel p { color: var(--ink-2); font-size: .875rem; margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.modal.closing .modal-panel { animation: modal-out var(--t1) var(--ease-io) forwards; }

/* ---------- 16. Auth ---------- */
.auth {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: flex-start; justify-content: center;
  padding: 9vh 16px 48px;
  background:
    linear-gradient(var(--paper), rgba(250, 249, 246, 0) 120px),
    repeating-linear-gradient(0deg, rgba(22, 20, 29, .022) 0 1px, transparent 1px 32px),
    var(--paper);
}
.auth-card { width: 100%; max-width: 420px; animation: rise var(--t3) var(--ease) both; }
.auth-card.wide { max-width: 680px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 26px; }
.auth-logo img { height: 32px; width: auto; }
.auth-card > .card { box-shadow: var(--shadow-sm), 0 24px 48px -28px rgba(22, 20, 29, .25); border-radius: var(--r-lg); }
.auth-card .card-body { padding: 28px 28px 24px; }
.auth-card h1 { font-size: 1.25rem; margin-bottom: 20px; }
.auth-card h1:has(+ p) { margin-bottom: 6px; }
.auth-card h1 + p.muted { margin-bottom: 22px; font-size: .875rem; }
.auth-card h3 { font-size: .8rem; color: var(--ink-3); font-weight: 600; margin: 22px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.auth-card form > h3:first-of-type, .auth-card .non-field-errors + h3 { border-top: 0; padding-top: 0; margin-top: 4px; }
.auth-foot { text-align: center; margin-top: 18px; font-size: .84rem; color: var(--ink-3); }
.portal-choices { display: grid; gap: 10px; }
.portal-choice {
  display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line);
  border-radius: var(--r); color: var(--ink); background: var(--surface); text-decoration: none !important;
  transition: border-color var(--t1) var(--ease), box-shadow var(--t1) var(--ease), transform var(--t1) var(--ease);
}
.portal-choice:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.portal-choice:active { transform: scale(.99); }
.portal-choice strong { display: block; font-size: .9rem; }
.portal-choice .muted { font-size: .8rem; display: block; margin-top: 1px; }
.portal-choice > span:first-child, .portal-choice .avatar {
  width: 34px; height: 34px; border-radius: 9px; background: var(--sunken); color: var(--ink); border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 650; flex: none;
}
.portal-choice::after { content: "→"; margin-left: auto; color: var(--ink-4); transition: transform var(--t1) var(--ease), color var(--t1) var(--ease); }
.portal-choice:hover::after { transform: translateX(3px); color: var(--ink); }
.qr { display: flex; justify-content: center; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }

/* ---------- 17. Public site ---------- */
.container { max-width: 1120px; margin: 0 auto; padding: 0 28px; }
.site-header {
  position: sticky; top: 0; z-index: 40; background: rgba(250, 249, 246, .86);
  -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid transparent; transition: border-color var(--t2) var(--ease); view-transition-name: site-header;
}
.site-header.scrolled { border-bottom-color: var(--line); }
.site-header .container { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 20px; }
.site-header .logo img { height: 28px; width: auto; display: block; }
.site-nav { display: flex; gap: 4px; align-items: center; }
.site-nav a {
  padding: 6px 11px; border-radius: 6px; color: var(--ink-2); font-weight: 520; font-size: .875rem; text-decoration: none;
  transition: color var(--t1) var(--ease), background-color var(--t1) var(--ease);
}
.site-nav a:hover { color: var(--ink); background: rgba(22, 20, 29, .045); }
.site-nav a.active { color: var(--ink); }
.site-actions { display: flex; gap: 6px; align-items: center; }
.site-menu-toggle { display: none; }
.site-mobile-nav { display: none; }

body.public { font-size: 15px; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; color: var(--ink-3); font-weight: 560; font-size: .78rem;
  letter-spacing: .02em; margin-bottom: 14px; text-transform: none;
}
.eyebrow::before { content: ""; width: 14px; height: 1px; background: currentColor; }
.display, .hero h1, .section-head h2, .cta-band h2, .public-title {
  font-family: var(--serif); font-weight: 500; letter-spacing: -.015em;
}
.hero { padding: 72px 0 64px; border-bottom: 1px solid var(--line); }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr); gap: 64px; align-items: center; }
.hero h1 { font-size: clamp(2.1rem, 4.2vw, 3.1rem); line-height: 1.08; margin-bottom: 18px; max-width: 15ch; }
.lead { font-size: 1.0625rem; line-height: 1.6; color: var(--ink-2); max-width: 520px; }
.hero .small.muted { font-size: .8rem; }
.section { padding: 72px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-alt { background: #F5F3EE; }
.section-head { max-width: 620px; margin-bottom: 40px; }
.section-head h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); line-height: 1.15; margin-bottom: 10px; }
.section-head p { color: var(--ink-2); font-size: 1rem; }
.prose h1, .public-title { font-size: clamp(1.8rem, 3.4vw, 2.4rem); line-height: 1.12; }

/* Feature list: ruled rows rather than a grid of identical cards */
.feature-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 56px; border-top: 1px solid var(--line); }
.feature-list .feature, .grid-3 > .feature {
  padding: 22px 0; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; box-shadow: none; background: none;
  display: grid; grid-template-columns: 28px 1fr; column-gap: 14px;
}
.feature .ficon { grid-row: span 2; width: 28px; height: 28px; color: var(--ink); display: flex; align-items: flex-start; padding-top: 1px; }
.feature .ficon svg { width: 20px; height: 20px; color: var(--brand); }
.feature h3 { font-size: .9375rem; margin: 0 0 4px; font-family: var(--sans); font-weight: 600; }
.feature p { color: var(--ink-2); font-size: .875rem; margin: 0; line-height: 1.55; }
.grid-3:has(> .feature) { gap: 0 48px; border-top: 1px solid var(--line); }

/* Numbered steps */
.steps { counter-reset: step; display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 44px 1fr; gap: 0 14px; align-items: start; padding: 18px 0; border-bottom: 1px solid var(--line); }
.step:first-child { padding-top: 0; }
.step:last-child { border-bottom: 0; }
.step::before {
  counter-increment: step; content: counter(step, decimal-leading-zero); font-family: var(--mono); font-size: .8rem;
  color: var(--ink-3); padding-top: 3px;
}
.step h3 { font-size: .9375rem; margin-bottom: 4px; }
.step p { color: var(--ink-2); margin: 0; font-size: .875rem; }

/* The commission slip: the product's signature object */
.slip-preview, .slip {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 22px 22px 26px;
  font-size: .84rem; box-shadow: 0 1px 0 var(--line), 0 18px 40px -24px rgba(22, 20, 29, .35);
  transform: rotate(-.6deg);
}
.slip-preview::after {
  content: ""; position: absolute; left: -1px; right: -1px; bottom: -7px; height: 8px;
  background: radial-gradient(circle at 5px 0, transparent 4px, var(--surface) 4.5px) -1px 0 / 10px 8px repeat-x;
  filter: drop-shadow(0 1px 0 var(--line));
}
.slip-preview .slip-top {
  display: flex; justify-content: space-between; align-items: center; padding-bottom: 12px; margin-bottom: 10px;
  border-bottom: 1px dashed var(--line-strong);
}
.slip-preview .slip-top strong { font-family: var(--mono); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; }
.slip-preview .row { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; color: var(--ink-3); }
.slip-preview .row strong { color: var(--ink); font-weight: 560; font-variant-numeric: tabular-nums; text-align: right; }
.slip-preview .total { border-top: 1px solid var(--ink); margin-top: 10px; padding-top: 12px; color: var(--ink); }
.slip-preview .total strong { font-size: 1.15rem; font-weight: 650; }
.slip-preview .total span { font-weight: 600; }

.price { font-family: var(--serif); font-size: 2.6rem; font-weight: 500; letter-spacing: -.02em; line-height: 1.1; margin: 6px 0 10px; }
.price small { font-family: var(--sans); font-size: .875rem; color: var(--ink-3); font-weight: 500; letter-spacing: 0; }
.checklist { list-style: none; padding: 0; margin: 16px 0; }
.checklist li { padding: 6px 0 6px 24px; position: relative; color: var(--ink-2); font-size: .9rem; }
.checklist li::before {
  content: ""; position: absolute; left: 2px; top: 12px; width: 10px; height: 5px; border-left: 1.6px solid var(--ink);
  border-bottom: 1.6px solid var(--ink); transform: rotate(-45deg);
}
.cta-band {
  display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 36px 0 4px; border-top: 1px solid var(--ink); border-radius: 0; background: none; color: var(--ink);
}
.cta-band h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); margin: 0 0 6px; color: var(--ink); }
.cta-band p { color: var(--ink-2); margin: 0; }

.site-footer { border-top: 1px solid var(--line); padding: 48px 0 40px; margin-top: 24px; font-size: .84rem; color: var(--ink-3); background: var(--paper); }
.site-footer a { color: var(--ink-2); }
.site-footer a:hover { color: var(--ink); }
.site-footer .cols { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr; gap: 32px; }
.site-footer h4 { color: var(--ink); font-size: .78rem; font-weight: 600; margin-bottom: 12px; }
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 0 0 8px; }
.footer-logo { height: 24px; width: auto; }
.footer-about { margin-top: 12px; max-width: 300px; line-height: 1.55; }

/* Long-form text */
.prose { max-width: 720px; }
.prose > p, .prose li { color: var(--ink-2); font-size: .95rem; line-height: 1.7; }
.prose h2 { margin-top: 2.2em; font-size: 1.15rem; }
.prose h3 { margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin-bottom: .35em; }
.prose li::marker { color: var(--ink-4); }
.prose .muted { font-size: .84rem; }
.doc-nav { position: sticky; top: 90px; font-size: .84rem; }
.doc-nav a { display: block; padding: 5px 0 5px 12px; color: var(--ink-3); border-left: 1px solid var(--line); }
.doc-nav a:hover { color: var(--ink); border-left-color: var(--ink); text-decoration: none; }
.doc-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 56px; }

/* Messages / support threads */
.message { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r); margin-bottom: 10px; background: var(--surface); }
.message.staff { background: #F7F5FD; border-color: #E5DEFA; }
.message .meta { font-size: .76rem; color: var(--ink-3); margin-bottom: 6px; }
.message p { white-space: pre-wrap; margin: 0; color: var(--ink-2); }

/* Getting-started checklist (collapsible) */
details.card > summary { list-style: none; cursor: pointer; user-select: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card:not([open]) > summary { border-bottom-color: transparent; }
details.card > summary .setup-meta > svg, details.card .chev { width: 14px; height: 14px; color: var(--ink-3); transition: transform var(--t2) var(--ease); }
details.card[open] > summary .setup-meta > svg, details.card[open] .chev { transform: rotate(180deg); }
details.card > summary:hover h2 { color: var(--accent); }
@supports (interpolate-size: allow-keywords) {
  details.card { interpolate-size: allow-keywords; }
  details.card::details-content { block-size: 0; overflow: hidden;
    transition: block-size var(--t3) var(--ease), content-visibility var(--t3) allow-discrete; }
  details.card[open]::details-content { block-size: auto; }
}
.setup-meta { display: inline-flex; align-items: center; gap: 12px; }
.setup-segs { display: inline-flex; gap: 3px; }
.setup-segs span { width: 14px; height: 4px; border-radius: 2px; background: var(--line); }
.setup-segs span.on { background: var(--ink); }
.setup-steps li.done .setup-help { display: none; }
.setup-steps li.done { padding: 8px 0; }
.setup-card .card-header h2::after { content: none; }
.setup-progress { height: 3px; background: var(--sunken); border-radius: 3px; overflow: hidden; width: 120px; }
.setup-progress > span { display: block; height: 100%; background: var(--ink); border-radius: 3px; transform-origin: left; }
.setup-steps { list-style: none; margin: 0 0 16px; padding: 0; display: grid; gap: 0; }
.setup-steps li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid #F0EDE6; }
.setup-steps li:last-child { border-bottom: 0; }
.setup-steps li strong { font-weight: 580; font-size: .875rem; }
.setup-steps li.done strong { color: var(--ink-3); }
.setup-steps .badge { margin-left: 6px; height: 20px; }
.setup-tick {
  flex: 0 0 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-weight: 600;
  font-size: .72rem; border: 1px solid var(--line-strong); color: var(--ink-2); background: var(--surface);
  font-variant-numeric: tabular-nums; margin-top: 1px;
}
.setup-steps li.done .setup-tick { background: var(--ink); border-color: var(--ink); color: #fff; }

/* Visit (referral landing) page */
.visit-card { max-width: 560px; margin: 0 auto; }

/* ---------- 18. Animations ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes pulse { 0% { opacity: .7; transform: scale(.6); } 70%, 100% { opacity: 0; transform: scale(1.6); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(12px); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes modal-out { to { opacity: 0; transform: scale(.98); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes content-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Cross-page transitions (browsers that support cross-document View Transitions) */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; }
::view-transition-old(content) { animation: fade-out 90ms var(--ease-io) both; }
::view-transition-new(content) { animation: content-in var(--t2) var(--ease) both; }
::view-transition-group(sidebar), ::view-transition-group(site-header) { animation: none; }

/* Live content swap */
.content.refreshed > * { animation: fade-in var(--t2) var(--ease) both; }

/* ---------- 19. Responsive ---------- */
@media (max-width: 1180px) {
  .content { padding: 22px 24px 56px; }
}
/* Metric strips and grids respond to the space the content actually has, not the window. */
.content { container-type: inline-size; container-name: content; }
@container content (max-width: 720px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4:has(> .stat) > .stat:nth-child(2n+1)::before { display: none; }
  .grid-4:has(> .stat) > .stat:nth-child(2n)::before { display: block; }
  .grid-4:has(> .stat) > .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@container content (max-width: 880px) {
  .grid-2:not(:has(> .stat)) { grid-template-columns: 1fr; }
  .grid-3:not(:has(> .stat)) { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .site-nav, .site-actions .btn-ghost { display: none; }
  .site-menu-toggle { display: inline-flex; }
  .site-mobile-nav {
    display: block; position: fixed; inset: 62px 0 auto 0; z-index: 39; background: var(--paper);
    border-bottom: 1px solid var(--line); padding: 8px 20px 20px; box-shadow: var(--shadow-pop);
    opacity: 0; visibility: hidden; transform: translateY(-6px);
    transition: opacity var(--t2) var(--ease), transform var(--t2) var(--ease), visibility 0s linear var(--t2);
  }
  body.site-nav-open .site-mobile-nav { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
  .site-mobile-nav a { display: block; padding: 12px 4px; border-bottom: 1px solid var(--line); color: var(--ink); font-weight: 520; }
  .site-mobile-nav .btn-row { margin-top: 14px; }
  .site-mobile-nav .btn { flex: 1; }
  .hero-grid { grid-template-columns: 1fr; gap: 44px; }
  .hero .slip-preview { max-width: 420px; }
  .doc-layout { grid-template-columns: 1fr; gap: 20px; }
  .doc-nav { position: static; display: flex; flex-wrap: wrap; gap: 4px 14px; }
  .doc-nav a { border-left: 0; padding: 2px 0; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 70; width: min(290px, 86vw); transform: translateX(-100%);
    transition: transform var(--t3) var(--ease); box-shadow: none; background: var(--paper);
  }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-pop); }
  .scrim {
    display: block; position: fixed; inset: 0; z-index: 65; background: rgba(22, 20, 29, .3); opacity: 0; visibility: hidden;
    transition: opacity var(--t3) var(--ease), visibility 0s linear var(--t3);
  }
  body.nav-open .scrim { opacity: 1; visibility: visible; transition-delay: 0s; }
  body.nav-open { overflow: hidden; }
  .menu-toggle { display: inline-flex; margin-left: -6px; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-3:has(> .stat), .grid-2:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 0; font-size: .78rem; }
  .kv dd { padding-top: 2px; }
  .page-head { align-items: flex-start; }
  .page-head .btn-row, .page-head > .btn, .page-head > form { width: 100%; }
  .toolbar > * { flex: 1 1 140px; }
  .toolbar input, .toolbar select { min-width: 0; width: 100%; }
  .feature-list, .grid-3:has(> .feature) { grid-template-columns: 1fr; }
  .site-footer .cols { grid-template-columns: 1fr 1fr; }
  .site-footer .cols > div:first-child { grid-column: 1 / -1; }
  .section { padding: 52px 0; }
  .hero { padding: 44px 0 48px; }
  .toasts { top: auto; bottom: 12px; right: 12px; left: 12px; width: auto; }
  .card-body { padding: 16px; }
  .card-header { padding: 12px 16px; }
  .table th, .table td { padding-left: 12px; padding-right: 12px; }
}
@media (max-width: 520px) {
  body { font-size: 14px; }
  .container { padding: 0 18px; }
  .grid-4, .grid-3:has(> .stat), .grid-2:has(> .stat) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 13px 14px; }
  .stat-value { font-size: 1.2rem; }
  .page-head h1 { font-size: 1.2rem; }
  .btn-lg { --btn-h: 44px; }
  .hero h1 { font-size: 2rem; }
  .auth { padding-top: 6vh; }
  .auth-card .card-body { padding: 22px 18px 18px; }
  .cta-band .btn { width: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; height: 42px; }
}
@media (hover: none) {
  .table tbody tr:hover { background: none; }
}

/* ---------- 20. Reduced motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
    transition-duration: .01ms !important; scroll-behavior: auto !important; }
  @view-transition { navigation: none; }
}
@media print {
  .sidebar, .topbar, .site-header, .site-footer, .btn, .toolbar, .toasts, .env-banner, .live-note { display: none !important; }
  .app { display: block; } .content { padding: 0; max-width: none; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

.portal-choice > span:first-child svg { width: 17px; height: 17px; color: var(--ink-2); }

/* ---------- 21. Public page compositions ---------- */
.hero-actions { margin-top: 28px; gap: 10px; }
.hero-actions .btn-ghost svg { transition: transform var(--t1) var(--ease); }
.hero-actions .btn-ghost:hover svg { transform: translateX(3px); }
.hero-meta { margin: 20px 0 0; font-size: .8rem; color: var(--ink-3); max-width: 460px; line-height: 1.6; }
.hero-visual { position: relative; display: flex; justify-content: center; padding: 8px 0 16px; }
.hero-visual::before {
  content: ""; position: absolute; inset: 6% 2% 0 10%; border-radius: var(--r-lg);
  background: repeating-linear-gradient(0deg, rgba(22, 20, 29, .05) 0 1px, transparent 1px 28px);
  mask-image: radial-gradient(ellipse at center, #000 40%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 40%, transparent 75%);
}
.hero-visual .slip-preview { width: 100%; max-width: 380px; }
.slip-foot { margin: 14px 0 0; font-size: .72rem; color: var(--ink-4); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 72px; align-items: center; }
.split h2.display { font-size: clamp(1.6rem, 2.6vw, 2.1rem); line-height: 1.15; margin-bottom: 14px; }
.split .lead { margin-bottom: 18px; }
.ledger {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 6px 20px 16px;
  box-shadow: var(--shadow-sm); font-size: .84rem;
}
.ledger-head { display: flex; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--line);
  font-size: .72rem; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }
.ledger-head .mono { text-transform: none; letter-spacing: 0; }
.ledger-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; padding: 11px 0; border-bottom: 1px dashed var(--line); color: var(--ink-2); }
.ledger-row .when { color: var(--ink-4); font-variant-numeric: tabular-nums; font-size: .78rem; padding-top: 1px; }
.ledger-row strong { font-variant-numeric: tabular-nums; font-weight: 560; color: var(--ink); }
.ledger-row strong.neg { color: var(--bad); }
.ledger-row.total { border-bottom: 0; border-top: 1px solid var(--ink); margin-top: -1px; color: var(--ink); font-weight: 600; }
.ledger-row.total strong { font-size: 1.05rem; font-weight: 650; }
ol.steps { list-style: none; margin: 0; padding: 0; }
.steps-compact .step { padding: 16px 0; }
.steps-compact .step:first-child { padding-top: 0; }
@media (max-width: 960px) { .split { grid-template-columns: 1fr; gap: 40px; } }
.section:has(> .container > .cta-band) { border-top: 0; padding-top: 24px; }
.page-intro { padding: 64px 0 40px; border-bottom: 1px solid var(--line); }
.page-intro .public-title { max-width: 18ch; margin-bottom: 14px; }
.page-intro .lead { margin-bottom: 0; }
.page-intro + .section { border-top: 0; }
.split-top { align-items: start; }
.label-heading { font-size: .78rem; font-weight: 600; color: var(--ink-3); margin: 6px 0 16px; }
.feature-groups { display: grid; gap: 56px; }
.feature-group { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px 56px; }
.feature-group h2 { font-family: var(--serif); font-weight: 500; font-size: 1.35rem; letter-spacing: -.01em; }
.feature-defs { margin: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 40px; border-top: 1px solid var(--line); }
.feature-defs dt { font-weight: 600; font-size: .9375rem; padding-top: 18px; }
.feature-defs dd { margin: 4px 0 0; padding-bottom: 18px; border-bottom: 1px solid var(--line); color: var(--ink-2); font-size: .875rem; line-height: 1.6; }
.feature-defs { grid-auto-flow: row dense; }
.feature-defs dt:nth-of-type(odd) { grid-column: 1; } .feature-defs dd:nth-of-type(odd) { grid-column: 1; }
.feature-defs dt:nth-of-type(even) { grid-column: 2; } .feature-defs dd:nth-of-type(even) { grid-column: 2; }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0; border-top: 1px solid var(--ink); }
.timeline li { padding: 18px 20px 0 0; position: relative; }
.timeline li::before { content: ""; position: absolute; top: -4px; left: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--paper); border: 1.5px solid var(--ink); }
.timeline-n { font-family: var(--mono); font-size: .78rem; color: var(--ink-3); }
.timeline h3 { font-size: .9375rem; margin: 8px 0 6px; }
.timeline p { color: var(--ink-2); font-size: .86rem; line-height: 1.6; margin: 0; }
.price-table { display: grid; grid-template-columns: 1.3fr 1fr; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden; max-width: 860px; }
.price-col { padding: 28px 30px; }
.price-col + .price-col { border-left: 1px solid var(--line); background: #FCFBF9; }
.price-name { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .9375rem; }
.price-col .btn { margin: 18px 0 4px; }
.faq { margin: 48px 0 0; max-width: 860px; display: grid; grid-template-columns: 240px 1fr; border-top: 1px solid var(--line); }
.faq dt, .faq dd { padding: 16px 0; border-bottom: 1px solid var(--line); margin: 0; }
.faq dt { font-weight: 600; font-size: .9rem; padding-right: 24px; }
.faq dd { color: var(--ink-2); font-size: .9rem; }
.form-card { padding: 24px; }
@media (max-width: 960px) {
  .feature-group { grid-template-columns: 1fr; gap: 16px; }
  .timeline { grid-template-columns: 1fr; border-top: 0; border-left: 1px solid var(--ink); padding-left: 22px; }
  .timeline li { padding: 0 0 26px; }
  .timeline li::before { top: 4px; left: -26px; }
}
@media (max-width: 640px) {
  .feature-defs { grid-template-columns: 1fr; }
  .feature-defs dt:nth-of-type(n), .feature-defs dd:nth-of-type(n) { grid-column: 1; }
  .price-table { grid-template-columns: 1fr; }
  .price-col + .price-col { border-left: 0; border-top: 1px solid var(--line); }
  .faq { grid-template-columns: 1fr; }
  .faq dt { border-bottom: 0; padding-bottom: 2px; }
  .faq dd { padding-top: 0; }
  .page-intro { padding: 40px 0 28px; }
}
/* Compact filter bar (dashboards, analytics, lists) */
.filterbar { gap: 8px 10px; padding: 0 0 16px; margin-bottom: 18px; border-bottom: 1px solid var(--line); align-items: flex-end; }
.filterbar .field > label { font-size: .7rem; font-weight: 550; color: var(--ink-3); margin-bottom: 4px; }
.filterbar input, .filterbar select { height: 30px; font-size: .8125rem; min-width: 0; width: auto; padding-left: 9px; }
.filterbar select { padding-right: 28px; background-position: right 10px center; max-width: 220px; }
.filterbar input[type=date] { width: 138px; }
.filterbar .btn { height: 30px; }
@media (max-width: 860px) {
  .filterbar > .field { flex: 1 1 140px; }
  .filterbar input[type=date], .filterbar select { width: 100%; max-width: none; }
}
.filterbar input[type=search] { width: 260px; }
@media (max-width: 860px) { .filterbar input[type=search] { width: 100%; } }
/* Commission slip detail: the record looks like the slip it represents */
.slip-sheet { border-radius: 4px; position: relative; margin-bottom: 10px; }
.slip-sheet::after {
  content: ""; position: absolute; left: -1px; right: -1px; bottom: -8px; height: 8px;
  background: radial-gradient(circle at 5px 0, transparent 4px, var(--surface) 4.5px) -1px 0 / 10px 8px repeat-x;
  filter: drop-shadow(0 1px 0 var(--line));
}
.slip-sheet .card-header { border-bottom-style: dashed; }
.slip-sheet .kv dt, .slip-sheet .kv dd { border-bottom-style: dashed; border-bottom-color: var(--line); }
input.w-auto, select.w-auto { width: auto; }
.batch-actions input { min-width: 220px; }
.table th, .table td { padding-left: 14px; padding-right: 14px; }
.table th:first-child, .table td:first-child { padding-left: 18px; }
.table th:last-child, .table td:last-child { padding-right: 18px; }
.filterbar > .btn { flex: 0 0 auto; }
/* Sidebar column background runs the full page height (the sidebar itself is sticky) */
@media (min-width: 861px) {
  .app { background: linear-gradient(90deg, #F7F5F1 0 calc(var(--sidebar) - 1px), var(--line) calc(var(--sidebar) - 1px) var(--sidebar), transparent var(--sidebar)); }
  .sidebar { border-right: 0; background: transparent; }
}
/* Filters placed inside a page header use the compact style too */
.page-head form .field { margin: 0; }
.page-head form .field > label { font-size: .7rem; font-weight: 550; color: var(--ink-3); margin-bottom: 4px; }
.page-head form input, .page-head form select { height: 30px; font-size: .8125rem; width: auto; }
.page-head form input[type=date] { width: 138px; }
.page-head form .btn { height: 30px; padding: 0 10px; font-size: .8125rem; }
.page-head form.btn-row { align-items: flex-end; }
.table .copy { min-width: 250px; }
.stat .copy { min-width: 0; }
