@font-face { font-family: "Montserrat"; src: url("/fonts/sans.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Montserrat"; src: url("/fonts/sans-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
:root { --b-midnight: #121A26; --b-midnight-raised: #1B2534; --b-midnight-deep: #070A0F; --b-paper: #F5F1EB; --b-porcelain: #EDE6DC; --b-white: #FFFFFF; --b-bronze: #7F5B36; --b-bronze-deep: #664828; --b-champagne: #D2B093; --b-accent-ink: #6E4D2B; --b-steel: #8FA3BF; --b-silver: #C9D1DC; --b-cool: #EFEAE3; --b-ink: #111A27; --b-muted: #555C67; --b-line: #DDD5C9; --b-line-strong: #878078; --b-dark-muted: #B9C1CC; --b-critical: #A3262E; --b-critical-bg: #FBECEC; --b-warning: #8A5300; --b-warning-bg: #FBF1DF; --b-good: #1F6B45; --b-good-bg: #E6F3EC; --f-sans: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif; --f-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace; }
/* Myelin Desk – core stylesheet. Brand variables (--b-*) are generated from lib/brand.json and prepended.
   Modules add their own files (finance/public/finance.css, marketing/public/marketing.css) after this one. */

/* 1. Tokens ---------------------------------------------------------------------------------- */
:root {
  --bg: var(--b-paper);
  --surface: var(--b-white);
  --surface-2: var(--b-cool);
  --ink: var(--b-ink);
  --muted: var(--b-muted);
  --line: var(--b-line);
  --line-strong: var(--b-line-strong);
  --accent: var(--b-bronze);
  --accent-deep: var(--b-bronze-deep);
  --side: var(--b-midnight);
  --side-raised: var(--b-midnight-raised);
  --side-text: var(--b-silver);
  --focus: var(--b-bronze);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(17, 26, 39, 0.04), 0 4px 16px rgba(17, 26, 39, 0.04);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  /* Chart tones: fixed meaning across the app (see lib/charts.mjs). */
  --t-revenue: #33507A;
  --t-cost: #B98A5E;
  --t-net: var(--b-ink);
  --t-pos: #33507A;
  --t-neg: #B5523B;
  --t-s1: #33507A;
  --t-s2: #B98A5E;
  --t-s3: #6F8F7A;
  --t-s4: #8E7AA6;
  --hm-0: #F1ECE4; --hm-1: #DCE3EE; --hm-2: #B3C3DA; --hm-3: #8099BD; --hm-4: #52709C; --hm-5: #2C4569;
  color-scheme: light;
}

/* 2. Base ------------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--f-sans); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); font-feature-settings: "tnum" 1; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -0.01em; line-height: 1.2; }
h1 { font-size: 1.75rem; font-weight: 400; }
h2 { font-size: 1.0625rem; }
h3 { font-size: 0.9375rem; }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-deep); }
code { font-family: var(--f-mono); font-size: 0.85em; }
:focus-visible { outline: 2px solid var(--focus); 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; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
a, button, summary, label, select { touch-action: manipulation; }

/* 3. Shell: a slim top bar, then one row of tabs inside a section. No sidebar. ----------------------- */
.bar { background: var(--side); color: var(--side-text); position: sticky; top: 0; z-index: 20; }
.bar-in { display: flex; align-items: center; gap: var(--s3); max-width: 1440px; margin: 0 auto; padding: 0 clamp(var(--s4), 3vw, var(--s7)); height: 56px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--b-white); text-decoration: none; font-weight: 500; font-size: 1.0625rem; }
.brand svg { width: 26px; height: 26px; flex: none; }
.brand em { font-style: italic; font-weight: 300; color: var(--b-champagne); }
.brand--ink { color: var(--ink); padding: 0 0 var(--s5); }
.brand--ink em { color: var(--accent); }
.brand:hover { color: var(--b-white); }
.crumb-sep { color: var(--b-steel); }
.crumb { color: var(--b-white); text-decoration: none; font-size: 0.9375rem; }
.crumb:hover { color: var(--b-champagne); }
.bar-gap { flex: 1; }
.jump-btn { text-decoration: none; display: inline-flex; align-items: center; gap: 8px; background: var(--side-raised); color: var(--side-text); border: 0; border-radius: var(--radius-sm); padding: 7px 12px; font-size: 0.875rem; cursor: pointer; }
.jump-btn:hover { color: var(--b-white); }
.jump-btn .i { width: 16px; height: 16px; }
.jump-btn kbd { font-family: var(--f-mono); font-size: 0.6875rem; color: var(--b-steel); border: 1px solid rgba(255, 255, 255, 0.16); border-radius: 4px; padding: 1px 5px; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; color: var(--b-white); font-size: 0.875rem; border-radius: 999px; padding: 3px 4px; }
.usermenu summary::-webkit-details-marker { display: none; }
.avatar { position: relative; display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--b-champagne); color: var(--b-midnight); font-weight: 600; font-size: 0.75rem; }
.usermenu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(17, 26, 39, 0.18); padding: var(--s4); display: grid; gap: var(--s2); }
.usermenu-pop .me-name { font-weight: 500; }
.usermenu-pop .me-role { font-size: 0.8125rem; color: var(--muted); margin-bottom: var(--s2); }
.usermenu-pop a, .usermenu-pop .linklike { color: var(--accent); font-size: 0.875rem; text-align: left; }
.linklike { background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; color: var(--accent); }
.section-tabs { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 10; }
.section-tabs-in { display: flex; gap: var(--s1); max-width: 1440px; margin: 0 auto; padding: 0 clamp(var(--s4), 3vw, var(--s7)); overflow-x: auto; }
.section-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 14px var(--s3); text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 0.9375rem; }
.section-tabs a:hover { color: var(--ink); }
.section-tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }
.subtabs { display: flex; gap: var(--s2); flex-wrap: wrap; }
.subtabs a { padding: 5px 14px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); text-decoration: none; font-size: 0.875rem; }
.subtabs a:hover { color: var(--ink); }
.subtabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--b-white); }
.nav-count { min-width: 20px; text-align: center; font-size: 0.75rem; font-weight: 600; line-height: 20px; padding: 0 7px; border-radius: 999px; background: var(--b-champagne); color: var(--b-midnight); }
.jump { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px)); margin: 12vh auto 0; box-shadow: 0 24px 64px rgba(17, 26, 39, 0.35); }
.jump::backdrop { background: rgba(17, 26, 39, 0.45); }
.jump input { width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: var(--s4); font-size: 1rem; outline: none; border-radius: var(--radius) var(--radius) 0 0; }
.jump ul { list-style: none; margin: 0; padding: var(--s2); max-height: 50vh; overflow-y: auto; }
.jump li a { display: block; padding: 9px var(--s3); border-radius: var(--radius-sm); color: var(--ink); text-decoration: none; font-size: 0.9375rem; }
.jump li a { display: flex; justify-content: space-between; gap: var(--s3); }
.jump li a:hover, .jump li a.is-sel { background: var(--surface-2); }
.jump-h { font-family: var(--f-mono); font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); padding: var(--s3) var(--s3) 4px; }
.jump-note { color: var(--muted); font-size: 0.8125rem; padding: 4px var(--s3) var(--s2); }
.j-sub { color: var(--muted); font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55%; }
.search-form { display: flex; gap: var(--s2); margin-bottom: var(--s4); max-width: 640px; }
.search-form input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.results { list-style: none; margin: 0; padding: 0; }
.results li + li { border-top: 1px solid var(--line); }
.results a { display: flex; justify-content: space-between; gap: var(--s4); padding: 11px 0; text-decoration: none; color: var(--ink); flex-wrap: wrap; }
.results a:hover .r-title { color: var(--accent); text-decoration: underline; }
.r-sub { color: var(--muted); font-size: 0.875rem; }
.search-results .card { margin-top: var(--s4); }
.main { padding: var(--s6) clamp(var(--s4), 3vw, var(--s7)) var(--s7); max-width: 1440px; width: 100%; margin: 0 auto; outline: none; }
.demo-banner { background: var(--b-warning-bg); color: var(--b-warning); text-align: center; font-size: 0.8125rem; font-weight: 500; padding: 6px var(--s4); border-bottom: 1px solid #EBD9B5; }
/* Start page: one card per section */
.home-h { margin: var(--s6) 0 var(--s3); font-size: 1.0625rem; }
.sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--s4); }
.section-card { display: grid; gap: 6px; align-content: start; padding: var(--s5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); transition: border-color 0.15s, transform 0.15s; }
.section-card:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--ink); }
.section-icon { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); color: var(--accent-deep); margin-bottom: var(--s2); }
.section-icon .i { width: 22px; height: 22px; }
.section-name { display: flex; align-items: center; gap: 10px; font-size: 1.125rem; font-weight: 500; }
.section-blurb { color: var(--muted); font-size: 0.875rem; line-height: 1.45; }

/* 4. Page parts ------------------------------------------------------------------------------ */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s5); }
.eyebrow { font-family: var(--f-mono); font-size: 0.6875rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--s2); }
.lead { color: var(--muted); margin-top: var(--s2); max-width: 70ch; }
.page-actions, .card-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s5); box-shadow: var(--shadow); min-width: 0; }
.card + .card, .grid + .card, .card + .grid, .kpis + .card, .kpis + .grid, .grid + .grid, .tabs + .card, .filters + .kpis, .filters + .card, .filters + .grid, .note + .card { margin-top: var(--s4); }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s3); margin-bottom: var(--s4); }
.card-sub { color: var(--muted); font-size: 0.8125rem; margin-top: 2px; }
h3.sub { margin: var(--s5) 0 var(--s3); }
.grid { display: grid; gap: var(--s4); }
.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--main-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.grid > .card + .card { margin-top: 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s4); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4) var(--s5); box-shadow: var(--shadow); min-width: 0; }
.kpi-label { font-size: 0.8125rem; color: var(--muted); }
.kpi-value { font-size: clamp(1.25rem, 0.9rem + 0.6vw, 1.625rem); font-weight: 400; letter-spacing: -0.02em; margin-top: 2px; overflow-wrap: anywhere; }
.kpi-delta { font-size: 0.8125rem; font-weight: 500; margin-top: 2px; }
.kpi-delta--good { color: var(--b-good); }
.kpi-delta--bad { color: var(--b-critical); }
.kpi-delta--neutral { color: var(--muted); }
.kpi-hint { font-size: 0.75rem; color: var(--muted); margin-top: 2px; }
.kpi--accent { background: var(--side); border-color: var(--side); }
.kpi--accent .kpi-label, .kpi--accent .kpi-hint { color: var(--b-silver); }
.kpi--accent .kpi-value { color: var(--b-white); }
.kpi--accent .kpi-delta--good { color: #8FD1AE; } .kpi--accent .kpi-delta--bad { color: #F2A7A7; } .kpi--accent .kpi-delta--neutral { color: var(--b-silver); }
.kpi .spark { display: block; width: 100%; height: 28px; margin-top: var(--s2); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { text-align: start; padding: 9px var(--s3); border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: 0.75rem; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; border-bottom-color: var(--line-strong); white-space: nowrap; }
tbody tr:hover { background: #FBF9F6; }
.num { text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; border-top: 1px solid var(--line-strong); border-bottom: 0; }
td .sub-line { display: block; color: var(--muted); font-size: 0.8125rem; }
.neg { color: var(--b-critical); }

/* Badges, notes, flash */
.badge { display: inline-block; font-size: 0.75rem; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.badge--good { color: var(--b-good); background: var(--b-good-bg); }
.badge--warning { color: var(--b-warning); background: var(--b-warning-bg); }
.badge--critical { color: var(--b-critical); background: var(--b-critical-bg); }
.badge--info { color: #2C4569; background: #E4EAF3; }
.badge--neutral { color: var(--muted); background: var(--surface-2); border-color: var(--line); }
.flash { background: var(--b-good-bg); color: var(--b-good); border: 1px solid #CFE6D9; border-radius: var(--radius-sm); padding: var(--s3) var(--s4); margin-bottom: var(--s4); font-size: 0.9375rem; }
.flash--error { background: var(--b-critical-bg); color: var(--b-critical); border-color: #F2CFCF; }
.flash p + p { margin-top: var(--s2); }
.secret code { font-size: 1.125rem; letter-spacing: 0.04em; background: var(--surface); padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); color: var(--ink); user-select: all; }
.note { border-radius: var(--radius-sm); padding: var(--s3) var(--s4); font-size: 0.875rem; }
.note--info { background: #EEF2F7; color: #2C4569; }
.note--warning { background: var(--b-warning-bg); color: var(--b-warning); }
.note--critical { background: var(--b-critical-bg); color: var(--b-critical); }
.empty, .empty-state p { color: var(--muted); font-size: 0.9375rem; }
.empty-state { padding: var(--s6) var(--s4); text-align: center; display: grid; gap: var(--s3); justify-items: center; }
.dl { display: grid; gap: var(--s3); margin: 0; }
.dl div { display: grid; grid-template-columns: 110px 1fr; gap: var(--s3); font-size: 0.875rem; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* Tabs */
.tabs { display: flex; gap: var(--s1); border-bottom: 1px solid var(--line); margin-bottom: var(--s4); overflow-x: auto; }
.tabs a { padding: var(--s2) var(--s3); text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 0.9375rem; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 500; }

/* 5. Forms ----------------------------------------------------------------------------------- */
.form { display: grid; gap: var(--s4); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); }
.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.field--wide { grid-column: 1 / -1; }
.field label { font-size: 0.8125rem; font-weight: 500; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); padding: 9px 12px; min-height: 42px; }
.field textarea { resize: vertical; line-height: 1.55; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink); }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555C67' stroke-width='1.6'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-size: 16px; background-position: right 12px center; padding-right: 36px; }
.field select option { background: var(--surface); color: var(--ink); }
.field--check label { display: flex; gap: var(--s2); align-items: center; font-weight: 400; font-size: 0.9375rem; }
.field--check input { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.field--error input { border-color: var(--b-critical); }
.hint { font-size: 0.75rem; color: var(--muted); }
.field-error { font-size: 0.8125rem; color: var(--b-critical); }
.form-actions { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }
.form.inline { display: flex; gap: var(--s2); align-items: flex-end; flex-wrap: wrap; }
.filters { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; margin-bottom: var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3) var(--s4); }
.filters .field { min-width: 150px; flex: 0 1 200px; }
.filters .field input, .filters .field select { min-height: 38px; padding-block: 7px; }
.js .filters[data-autosubmit] .filters-actions { display: none; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-weight: 500; font-size: 0.9375rem; text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color 120ms ease, border-color 120ms ease; }
.btn--primary { background: var(--side); color: var(--b-white); }
.btn--primary:hover { background: #1F2B3D; color: var(--b-white); }
.btn--secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--secondary:hover { border-color: var(--ink); color: var(--ink); }
.btn--ghost { background: transparent; color: var(--accent); padding-inline: var(--s2); }
.btn--danger { background: var(--surface); color: var(--b-critical); border-color: #E3B8B8; }
.btn--danger:hover { background: var(--b-critical-bg); color: var(--b-critical); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.row-menu summary { cursor: pointer; color: var(--accent); font-size: 0.875rem; list-style: none; }
.row-menu summary::-webkit-details-marker { display: none; }
.row-menu-body { display: grid; gap: var(--s3); padding: var(--s3) 0; min-width: 240px; }

/* 6. Charts ---------------------------------------------------------------------------------- */
.chart { margin: 0; display: grid; gap: var(--s3); min-width: 0; }
.chart figcaption { display: grid; gap: 2px; }
.chart-title { font-weight: 500; font-size: 1rem; }
.chart-sub, .chart-note { font-size: 0.8125rem; color: var(--muted); }
.chart-scroll { overflow-x: auto; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-svg--narrow { display: none; }
@media (max-width: 700px) { .chart-svg--wide { display: none; } .chart-svg--narrow { display: block; } }
.chart-svg .tick line { stroke: var(--line); stroke-width: 1; }
.chart-svg .tick line.zero { stroke: var(--line-strong); }
.chart-svg text { font-family: var(--f-sans); font-size: 11px; fill: var(--muted); }
.chart-svg .mark { stroke: var(--surface); stroke-width: 1; }
.chart-svg .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-svg .dot { stroke: var(--surface); stroke-width: 1.5; }
.chart-svg .hit { fill: transparent; cursor: crosshair; }
.chart-svg .hit:hover { fill: rgba(17, 26, 39, 0.04); }
.mark.tone-revenue, .dot.tone-revenue, .swatch.tone-revenue, .bl-bar.tone-revenue { fill: var(--t-revenue); background: var(--t-revenue); }
.mark.tone-cost, .dot.tone-cost, .swatch.tone-cost, .bl-bar.tone-cost { fill: var(--t-cost); background: var(--t-cost); }
.mark.tone-net, .dot.tone-net, .swatch.tone-net { fill: var(--t-net); background: var(--t-net); }
.mark.tone-pos, .bl-bar.tone-pos, .swatch.tone-pos { fill: var(--t-pos); background: var(--t-pos); }
.mark.tone-neg, .bl-bar.tone-neg, .swatch.tone-neg { fill: var(--t-neg); background: var(--t-neg); }
.mark.tone-s1, .dot.tone-s1, .swatch.tone-s1, .bl-bar.tone-s1 { fill: var(--t-s1); background: var(--t-s1); }
.mark.tone-s2, .dot.tone-s2, .swatch.tone-s2, .bl-bar.tone-s2 { fill: var(--t-s2); background: var(--t-s2); }
.mark.tone-s3, .dot.tone-s3, .swatch.tone-s3, .bl-bar.tone-s3 { fill: var(--t-s3); background: var(--t-s3); }
.mark.tone-s4, .dot.tone-s4, .swatch.tone-s4, .bl-bar.tone-s4 { fill: var(--t-s4); background: var(--t-s4); }
.line.tone-revenue { stroke: var(--t-revenue); } .line.tone-cost { stroke: var(--t-cost); } .line.tone-net { stroke: var(--t-net); }
.line.tone-s1 { stroke: var(--t-s1); } .line.tone-s2 { stroke: var(--t-s2); } .line.tone-s3 { stroke: var(--t-s3); } .line.tone-s4 { stroke: var(--t-s4); }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: 0.8125rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch--line { height: 2px; width: 14px; border-radius: 1px; }
.spark .line { fill: none; stroke-width: 1.5; }
.chart-table summary { cursor: pointer; font-size: 0.8125rem; color: var(--accent); width: fit-content; }
.chart-table table { margin-top: var(--s2); font-size: 0.8125rem; }
/* Bar list */
.barlist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.bl-text { display: flex; justify-content: space-between; gap: var(--s3); font-size: 0.875rem; margin-bottom: 4px; }
.bl-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.bl-sub { display: block; color: var(--muted); font-size: 0.75rem; }
.bl-value { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.bl-share { color: var(--muted); font-weight: 400; margin-left: var(--s2); }
.bl-track { position: relative; height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bl-track--signed::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line-strong); }
.bl-bar { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 4px; }
.bl-row { cursor: default; }
/* Heatmap */
.heatmap { display: grid; gap: 3px; min-width: 520px; }
.hm-row { display: grid; grid-template-columns: 44px repeat(var(--cols), minmax(0, 1fr)); gap: 3px; align-items: center; }
.hm-head span { font-size: 0.6875rem; color: var(--muted); text-align: center; }
.hm-label { font-size: 0.75rem; color: var(--muted); }
.hm-cell { display: block; height: 22px; border-radius: 3px; }
.hm-0 { background: var(--hm-0); } .hm-1 { background: var(--hm-1); } .hm-2 { background: var(--hm-2); } .hm-3 { background: var(--hm-3); } .hm-4 { background: var(--hm-4); } .hm-5 { background: var(--hm-5); }
.hm-scale { display: flex; align-items: center; gap: 4px; font-size: 0.75rem; color: var(--muted); }
.hm-scale .hm-cell { width: 18px; height: 10px; }
/* Tooltip */
.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--side); color: var(--b-white); font-size: 0.8125rem; line-height: 1.45; padding: 8px 10px; border-radius: 8px; white-space: pre-line; max-width: 280px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18); }

/* 7. Bare pages (sign-in) --------------------------------------------------------------------- */
.bare { background: var(--b-midnight); }
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: var(--s5) var(--s4); }
.bare-card { width: min(420px, 100%); background: var(--surface); border-radius: 16px; padding: var(--s6); display: grid; gap: var(--s4); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3); }
.bare-card h1 { font-size: 1.5rem; }
.bare-card .form-actions .btn { width: 100%; min-height: 48px; }
.bare-card input { min-height: 48px; }
.bare-card .flash p { margin: 0; }

/* 8. Responsive ------------------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .grid--3, .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--main-side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .bar-in { gap: var(--s2); }
  .jump-btn span, .jump-btn kbd, .usermenu-name { display: none; }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .main { padding: var(--s5) var(--s4) var(--s7); }
  h1 { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print {
  .bar, .section-tabs, .subtabs, .filters, .page-actions, .card-actions, .chart-table, .demo-banner { display: none !important; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}

/* 9. Navigation icons, counters, authenticator steps ------------------------------------------------- */
.steps-list { margin: 0 0 var(--s4); padding-left: 1.25rem; display: grid; gap: var(--s3); }
.steps-list .secret { margin-top: var(--s2); }
.bare-card .muted { margin-top: calc(-1 * var(--s3)); font-size: 0.9375rem; }

/* Icons used inside content (buttons, labels): one line high by default */
.i { width: 1.1em; height: 1.1em; vertical-align: -0.18em; flex: none; }

/* Long values (emails, links) wrap instead of widening the page; wide boards scroll inside themselves. */
.main, .main > *, .grid > * { min-width: 0; }
.dl dd { min-width: 0; overflow-wrap: anywhere; }

/* Phones: inputs never outgrow their cell (date pickers are wide by default); filters sit two per row. */
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; }
@media (max-width: 600px) {
  .filters { gap: var(--s3) var(--s2); padding: var(--s3); }
  .filters .field { flex: 1 1 calc(50% - var(--s2)); min-width: 0; }
  .filters .field input, .filters .field select { font-size: 0.875rem; padding-inline: 10px; }
}
@media (max-width: 600px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
  .kpi { padding: var(--s3); }
  .kpi-value { font-size: 1.125rem; }
  .kpi-delta, .kpi-hint { font-size: 0.75rem; }
}
.small { font-size: 0.75rem; }
/* "Amounts in AED | USD" switch at the top of every page (display only). */
.toprow { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.topbar { display: flex; justify-content: flex-end; margin: 0 0 0 auto; }
.cur-switch { display: inline-flex; align-items: center; gap: var(--s2); font-size: 0.8125rem; color: var(--muted); margin: 0; flex-wrap: wrap; }
.cur-options { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px; background: var(--surface); }
.cur-options button { border: 0; background: transparent; color: var(--ink); font: inherit; font-weight: 500; padding: 4px 12px; border-radius: 999px; cursor: pointer; min-height: 28px; }
.cur-options button.is-on { background: var(--side); color: var(--b-white); }
.cur-options button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cur-rate { font-size: 0.75rem; }
@media (max-width: 720px) { .topbar { justify-content: flex-start; margin: 0; } .cur-rate { display: none; } }
.avatar-dot { position: absolute; top: -2px; right: -2px; width: 11px; height: 11px; border-radius: 50%; background: #B5523B; border: 2px solid var(--side); }
.usermenu-pop a { display: flex; align-items: center; gap: 8px; }
.dl + form { margin-top: var(--s4); }
.mail-preview { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s4); background: #fff; margin: var(--s4) 0; }
@media (max-width: 600px) { .dl div { grid-template-columns: 1fr; gap: 2px; } }

/* 10. Tables (step 5b) -------------------------------------------------------------------------------------
   Desktop: the header row stays in view under the page bars. Phone: every row is a card (each cell carries its
   column name in data-label), the first cell is the card's title, and the totals row stays at the bottom of the screen. */
@media (min-width: 701px) {
  .table-wrap { overflow-x: visible; }
  thead th { position: sticky; top: 108px; z-index: 3; background: var(--surface); box-shadow: 0 1px 0 var(--line-strong); }
  td, th { overflow-wrap: anywhere; }
  td.num, th.num { overflow-wrap: normal; }
}
@media (max-width: 700px) {
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tfoot, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap tbody tr { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s3) var(--s4); margin-bottom: var(--s3); background: var(--surface); }
  .table-wrap tbody tr:hover { background: var(--surface); }
  .table-wrap td { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); border: 0; padding: 5px 0; text-align: end; }
  .table-wrap td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: start; color: var(--muted); font-size: 0.8125rem; }
  .table-wrap td > .cell { min-width: 0; overflow-wrap: anywhere; text-align: end; }
  .table-wrap td.num, .table-wrap td .num { white-space: normal; }
  .table-wrap td[data-primary] { display: block; text-align: start; font-weight: 500; font-size: 1rem; padding: 0 0 var(--s2); margin-bottom: var(--s2); border-bottom: 1px solid var(--line); }
  .table-wrap td[data-primary]::before { display: none; }
  .table-wrap td[data-primary] > .cell { text-align: start; }
  .table-wrap td:not([data-primary]):has(> .cell:empty), .table-wrap td:not([data-primary]):has(> .cell > .muted:only-child) { display: none; }
  .table-wrap td > .cell > .sub-line { text-align: end; }
  .table--sticky-foot tfoot { position: sticky; bottom: var(--s3); z-index: 4; }
  .table-wrap tfoot { margin-top: var(--s3); }
  .table-wrap tfoot tr { background: var(--side); color: var(--b-white); border-radius: var(--radius-sm); padding: var(--s3) var(--s4); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25); }
  .table-wrap tfoot td { border: 0; font-weight: 500; }
  .table-wrap tfoot td::before { color: var(--b-silver); }
  .table-wrap tfoot td:has(> .cell:empty) { display: none; }
  .table-wrap tfoot td[data-primary] { border-bottom-color: rgba(255, 255, 255, 0.2); }
  .table-wrap tfoot a { color: inherit; }
  .table-wrap tfoot .neg { color: #F2A7A7; }
}
@media (max-width: 700px) {
  .table-wrap tr { display: flex; flex-direction: column; }
  .table-wrap td[data-primary] { order: -1; }
  .table-wrap tfoot td { font-size: 0.875rem; padding: 2px 0; }
  .table-wrap tfoot td[data-primary] { font-size: 0.875rem; padding-bottom: var(--s2); }
}

/* Show / Hide button on password fields (public/password-toggle.js) */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-inline-end: 76px; }
.pw-toggle { position: absolute; inset-block: 0; inset-inline-end: 0; min-width: 72px; min-height: 44px; padding: 0 var(--s3); background: transparent; border: 0; border-start-end-radius: var(--radius-sm); border-end-end-radius: var(--radius-sm); color: var(--accent-text, var(--ink)); font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; text-decoration: underline; }
.pw-toggle:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

/* Wide matrices (many columns, e.g. profit and loss by month): tighter cells so they fit; the table component adds table--dense */
.table--dense table { font-size: 0.8125rem; }
.table--dense th, .table--dense td { padding: 7px var(--s2); }
@media (max-width: 700px) { .badge { white-space: normal; } }

.table--dense td:first-child, .table--dense th:first-child { white-space: nowrap; overflow-wrap: normal; }
.table--dense td.num, .table--dense th.num { white-space: nowrap; }
@media (min-width: 701px) {
  .table--dense table { font-size: 0.78rem; }
  .table--dense th, .table--dense td { padding: 7px 5px; }
  .table--dense thead th { letter-spacing: 0.03em; }
  .card:has(.table--dense) { padding-inline: var(--s3); }
}

/* 11. Phone shell (step 5c) -------------------------------------------------------------------------------
   Everything you tap is at least 44 px; tab rows wrap instead of scrolling sideways; nothing needs a sideways swipe. */
@media (max-width: 700px) {
  .bar .brand, .jump-btn, .usermenu summary { min-height: 44px; min-width: 44px; }
  .jump-btn { justify-content: center; }
  .usermenu summary { justify-content: center; }
  .usermenu-pop a, .usermenu-pop .linklike, .usermenu-pop button { display: flex; align-items: center; min-height: 44px; width: 100%; }
  .section-tabs { position: static; }
  .section-tabs-in { flex-wrap: wrap; overflow: visible; gap: 0; }
  .section-tabs a, .tabs a, .subtabs a { display: inline-flex; align-items: center; min-height: 44px; }
  .section-tabs a { padding-block: 0; }
  .tabs { flex-wrap: wrap; overflow: visible; }
  .subtabs a { padding-block: 0; }
  .btn, .field input, .field select, .field textarea, .filters .field input, .filters .field select, .search-form input { min-height: 44px; }
  .field--check input { min-height: 0; }
  .cur-switch button, .cur-options button, .cur-options label, .cur-options a { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
  summary, .linklike, .row-menu summary { min-height: 44px; display: flex; align-items: center; }
  .heatmap { min-width: 0; }
  .hm-row { grid-template-columns: 36px repeat(var(--cols), minmax(0, 1fr)); gap: 2px; }
  .hm-head span { font-size: 0.625rem; }
  .chart-scroll { overflow-x: visible; }
}
@media (max-width: 700px) {
  .crumb a, .card-actions a, .card-actions .btn { display: inline-flex; align-items: center; min-height: 44px; }
  .fin-chip, .fin-chips button, .mk-chip { min-height: 44px; display: inline-flex; align-items: center; }
  .row-menu summary { min-width: 44px; justify-content: center; }
  .crm-move .field select, .crm-move .field input, .crm-move input[type="date"], .form input, .form select, .todo-add input, .todo-add button, .todo-add .btn { min-height: 44px; }
  .mk-review-body h2 a, .mk-review-body h3 a, .claim-main h2 a, .claim-main h3 a, .claim-main a { display: inline-flex; align-items: center; min-height: 44px; }
}

/* The hidden attribute always wins over any display rule above. */
[hidden] { display: none !important; }
@media (max-width: 700px) {
  a.crumb { display: inline-flex; align-items: center; min-height: 44px; }
  .card-actions a, .card-actions .btn { min-width: 44px; justify-content: center; }
  .form input, .form select, .form textarea { min-height: 44px; }
}

/* Overview dashboard */
.tasks { list-style: none; margin: 0; padding: 0; display: grid; }
.task { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.9375rem; }
.task:last-child { border-bottom: 0; }
.task a { color: var(--ink); text-decoration: none; }
.task a:hover { color: var(--accent); text-decoration: underline; }
.task-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.task--critical .task-dot { background: var(--b-critical); }
.task--warning .task-dot { background: #C98A1B; }
.task--info .task-dot { background: var(--t-revenue); }
.task--good .task-dot { background: var(--b-good); }
.task-due { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }
.home-body { margin-top: var(--s4); display: grid; gap: var(--s4); }
.home-body > .grid + .grid, .home-body > .kpis + .grid { margin-top: 0; }
.mk-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.mk-stats strong { display: block; font-size: 1.75rem; line-height: 1.1; font-weight: 600; }
.mk-stats span { display: block; font-size: 0.8125rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Today, to-do and notifications */
.today-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: var(--s4); margin-top: var(--s5); align-items: start; }
.today-grid--page { margin-top: 0; }
@media (max-width: 1000px) { .today-grid { grid-template-columns: minmax(0, 1fr); } }
.today-list, .todos, .note-list { list-style: none; margin: 0; padding: 0; }
.today-item, .note-row { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.note-row { grid-template-columns: minmax(0, 1fr) auto; }
.today-item:last-child, .note-row:last-child { border-bottom: 0; }
.ti-title { font-weight: 500; }
.ti-why { color: var(--muted); font-size: 0.875rem; margin-top: 2px; }
.ti-act { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.today-item--critical .task-dot { background: var(--b-critical); }
.today-item--warning .task-dot { background: #C98A1B; }
.today-item--info .task-dot { background: var(--t-revenue); }
.fyi { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 999px; padding: 3px 10px; white-space: nowrap; }
.today-item.is-fyi .ti-title { color: var(--muted); }
@media (max-width: 600px) { .today-item { grid-template-columns: 10px minmax(0, 1fr); } .today-item .ti-act { grid-column: 2; justify-content: flex-start; } .note-row { grid-template-columns: minmax(0, 1fr); } .note-row .ti-act { justify-content: flex-start; } }
.note-row.is-unread .ti-title::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 8px; }
.todo-add { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s3); }
.todo-add input[name=title] { flex: 1 1 160px; min-width: 0; }
.todo-add input { padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); }
.todo { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto 28px; gap: var(--s2); align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.todo:last-child { border-bottom: 0; }
.todo.is-late .todo-due { color: var(--b-critical); }
.todo-due { font-size: 0.8125rem; color: var(--muted); white-space: nowrap; }
.check { width: 22px; height: 22px; border: 2px solid var(--line-strong); border-radius: 6px; background: var(--surface); cursor: pointer; padding: 0; }
.check:hover { border-color: var(--accent); background: var(--surface-2); }
.todo-x { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1.25rem; line-height: 1; min-width: 28px; min-height: 28px; }
.prefs { display: grid; gap: var(--s2); margin-bottom: var(--s3); }
.pref { display: flex; gap: var(--s2); align-items: flex-start; font-size: 0.9375rem; }

/* Enquiries module styles (appended to /desk.css). Uses core tokens only. */
.chip { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2, #F3F1EB); border: 1px solid var(--line); color: var(--ink); white-space: nowrap; }
.crm-overdue { color: var(--b-critical); font-weight: 600; }
.crm-today { color: var(--ink); font-weight: 600; }
.crm-stack { display: grid; gap: var(--s4); align-content: start; min-width: 0; }
.crm-stack > .card { margin-top: 0; }
.crm-message { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1rem; line-height: 1.6; margin-bottom: var(--s3); }
.crm-draft { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2, #F3F1EB); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s3); margin: var(--s2) 0; }
.crm-notes, .crm-timeline, .crm-closed { list-style: none; padding: 0; margin: var(--s3) 0 0; display: grid; gap: var(--s3); }
.crm-notes li { border-left: 3px solid var(--line-strong); padding-left: var(--s3); overflow-wrap: anywhere; white-space: pre-wrap; }
.crm-note-meta { font-size: 0.8125rem; color: var(--muted); }
.crm-timeline li { display: flex; gap: var(--s3); align-items: flex-start; }
.crm-timeline .i { flex: none; width: 18px; height: 18px; margin-top: 2px; color: var(--muted); }
.crm-closed li { display: flex; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.crm-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(260px, 1fr); gap: var(--s4); overflow-x: auto; align-items: start; margin-bottom: var(--s4); padding-bottom: var(--s2); }
.crm-col { background: var(--surface-2, #F3F1EB); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s3); display: grid; gap: var(--s3); align-content: start; min-width: 0; }
.crm-col h2 { font-size: 1rem; display: flex; justify-content: space-between; align-items: baseline; }
.crm-count { font-size: 0.8125rem; color: var(--muted); font-weight: 500; }
.crm-col-sum { font-size: 0.8125rem; color: var(--muted); margin-top: 2px; }
.crm-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s3); min-width: 0; }
.crm-card-name { font-weight: 600; overflow-wrap: anywhere; }
.crm-card-co { color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.crm-card-meta { display: flex; justify-content: space-between; gap: var(--s2); font-size: 0.8125rem; margin-top: var(--s1); flex-wrap: wrap; }
.crm-move { display: flex; gap: var(--s2); align-items: flex-end; margin-top: var(--s2); flex-wrap: wrap; }
.crm-move .field { margin: 0; flex: 1 1 110px; min-width: 0; }
.crm-move .field label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.crm-move input[type="date"] { min-height: 36px; max-width: 100%; }
.crm-move select { min-height: 36px; padding-block: 6px; }
.crm-group--late { border-left: 3px solid var(--b-critical); }
.crm-group--today { border-left: 3px solid var(--accent); }
.card-actions .form { margin: 0; }
/* On a phone the stages stack one under the other: nothing scrolls sideways. */
@media (max-width: 700px) { .crm-board { grid-auto-flow: row; grid-auto-columns: minmax(0, 1fr); overflow-x: visible; } }
.crm-board { width: 100%; max-width: 100%; position: relative; } /* hidden labels stay inside the scrolling board */
@media (max-width: 700px) { .crm-move input[type="date"], .crm-move select, .crm-move .btn { min-height: 44px; } }
/* On a phone the page is one column in this order: what it says, what to do about it (status, owner, follow-up), replying, notes, then the
   rest (AI, replies sent, research, activity, where it came from) and Privacy last. The two desktop columns are flattened for that. */
@media (max-width: 700px) {
  .grid--main-side { display: flex; flex-direction: column; align-items: stretch; gap: var(--s4); }
  .grid--main-side > .crm-stack { display: contents; }
  .grid--main-side .crm-stack > * { order: 5; margin-top: 0; }
  .grid--main-side .crm-stack > .crm-o1 { order: 1; }
  .grid--main-side .crm-stack > .crm-o2 { order: 2; }
  .grid--main-side .crm-stack > .crm-o3 { order: 3; }
  .grid--main-side .crm-stack > .crm-o4 { order: 4; }
  .grid--main-side .crm-stack > .crm-o9 { order: 9; }
}

/* Finance module: small additions on top of desk.css */
.fin-insights { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fin-insights li { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: start; line-height: 1.45; }
.fin-insights .badge { margin-top: 2px; }
.fin-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.page-actions .fin-quick { margin-bottom: 0; }
.fin-stack { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line, #e3e0d8); }
.fin-indent { display: inline-block; padding-left: 14px; color: var(--muted, #5b6472); }
.fin-notes { white-space: pre-wrap; overflow-wrap: anywhere; }
.fin-files { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 6px; }
.fin-period { margin: 0 0 12px; font-size: 0.875rem; }
.fin-foot { margin-top: 16px; font-size: 0.8125rem; max-width: 70ch; }
.aed-preview { margin: 4px 0 12px; font-weight: 600; min-height: 1.4em; }
.aed-preview:empty { min-height: 0; margin: 0; }
.tabs { overflow-x: auto; }
.table-wrap td, .table-wrap th { vertical-align: top; }
.flash ul { margin: 0; padding-left: 18px; }
.field input[type="file"] { max-width: 100%; }

/* Quick add */
.fin-qa-row { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; align-items: end; }
.fin-qa-row > .field { grid-column: span 4; }
.fin-qa-row > .field:nth-child(1) { grid-column: span 3; }
.fin-qa-row > .field:nth-child(2) { grid-column: span 2; }
.fin-qa-row > .field:nth-child(3) { grid-column: span 3; }
.fin-qa-row > .field:nth-child(4) { grid-column: span 4; }
.fin-qa-row > .field:nth-child(5) { grid-column: span 5; }
.fin-qa-row > .field:nth-child(6) { grid-column: span 4; }
.fin-qa-row > .field:nth-child(7) { grid-column: span 3; }
.fin-qa-row select { text-overflow: ellipsis; }
.fin-qa-row .field--wide { grid-column: 1 / -1; }
.fin-seg { display: inline-flex; border: 1px solid var(--line-strong, #cfcabd); border-radius: 999px; padding: 3px; gap: 2px; width: fit-content; margin: 0; }
.fin-seg-opt { position: relative; cursor: pointer; }
.fin-seg-opt input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.fin-seg-opt span { display: block; padding: 6px 18px; border-radius: 999px; font-size: 0.875rem; font-weight: 500; }
.fin-seg-opt input:checked + span { background: var(--side, #1b2433); color: #fff; }
.fin-seg-opt input:focus-visible + span { outline: 2px solid var(--accent, #8a6a3b); outline-offset: 2px; }
.fin-more { border-top: 1px solid var(--line, #e3e0d8); padding-top: 12px; }
.fin-more > summary { cursor: pointer; color: var(--accent, #8a6a3b); font-size: 0.9rem; font-weight: 500; }
.fin-more > summary .muted { font-weight: 400; font-size: 0.8125rem; margin-left: 6px; }
.fin-more-fields { margin-top: 12px; }
.fin-chips { display: none; flex-wrap: wrap; gap: 6px; }
.js .fin-chips { display: flex; }
.fin-chip, .fin-tag { display: inline-block; font-size: 0.75rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2, #f3f1ea); border: 1px solid var(--line, #e3e0d8); color: inherit; text-decoration: none; cursor: pointer; font-family: inherit; }
.fin-chip:hover, .fin-tag:hover { border-color: var(--accent, #8a6a3b); }
.fin-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* Lists */
.fin-new { font-weight: 600; }
tr:has(.fin-new) { background: var(--b-good-bg, #e9f5ee); }
.fin-marks { display: inline-flex; gap: 8px; margin-left: 8px; vertical-align: middle; }
.fin-mark { display: inline-flex; align-items: center; gap: 3px; font-size: 0.75rem; color: var(--muted, #5b6472); }
.fin-mark svg, .fin-mark .i { width: 14px; height: 14px; }
.fin-mark--warn { color: var(--b-warning, #8a5a00); }
.fin-thread { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.fin-thread li { border-left: 2px solid var(--line-strong, #cfcabd); padding-left: 12px; }
.fin-thread-meta { font-size: 0.8125rem; margin-bottom: 2px; }
.fin-means { margin: 12px 0 0; font-size: 0.8125rem; color: var(--muted, #5b6472); background: var(--surface-2, #f6f4ee); padding: 8px 12px; border-radius: 6px; }
.fin-files li form { display: inline; }
.fin-qa .card-sub { margin-bottom: 8px; }
@media (max-width: 900px) { .fin-qa-row { grid-template-columns: repeat(6, minmax(0, 1fr)); } .fin-qa-row > .field { grid-column: span 3 !important; } .fin-qa-row > .field:nth-child(5) { grid-column: 1 / -1 !important; } }
@media (max-width: 560px) { .fin-qa-row > .field { grid-column: 1 / -1 !important; } .fin-qa-row > .field:nth-child(1) { grid-column: span 4 !important; } .fin-qa-row > .field:nth-child(2) { grid-column: span 2 !important; } }

/* Add an entry disclosure on the Entries page */
.fin-add { margin-bottom: 16px; }
.fin-add > summary { cursor: pointer; display: inline-block; padding: 9px 16px; border: 1px solid var(--line-strong, #cfcabd); border-radius: 8px; font-weight: 500; }
.fin-add[open] > summary { margin-bottom: 12px; }

/* Budget chart and table */
.fin-bud .barlist { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 14px; }
.fin-bud .bl-track + .bl-track { margin-top: 3px; }
.fin-bud .bl-label { white-space: normal; }
@media (min-width: 701px) { .fin-budget-table table { min-width: 520px; } }
.fin-budget-table td.num, .fin-budget-table th.num { white-space: nowrap; }
.fin-tech { margin-top: 12px; }
.fin-swap { color: var(--accent); font-size: 0.8125rem; margin-top: 2px; text-align: left; }
/* Expense claims */
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s4); }
.claim-card { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(240px, 1fr); gap: var(--s5); margin-bottom: var(--s4); }
@media (max-width: 800px) { .claim-card { grid-template-columns: minmax(0, 1fr); } }
.claim-person { color: var(--muted); font-size: 0.875rem; }
.claim-amount { font-size: 1.0625rem; margin: 4px 0 var(--s3); }
.claim-files { list-style: none; margin: var(--s3) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s3); align-items: flex-end; }
.claim-files img { display: block; max-width: 160px; max-height: 120px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.claim-actions details { border-top: 1px solid var(--line); padding: var(--s3) 0; }
.claim-actions summary { cursor: pointer; font-weight: 500; }
.claim-act { display: grid; gap: var(--s3); margin-top: var(--s3); }

/* Claim form: quick to fill in one-handed right after paying (amount first, camera, the Send button always in reach) */
.claim-form .claim-first .field:first-child input { font-size: 1.5rem; font-weight: 500; min-height: 56px; }
.claim-form input[type="file"] { padding: 6px; }
.claim-form input[type="file"]::file-selector-button { font: inherit; font-weight: 500; min-height: 44px; margin-right: var(--s3); padding: 0 var(--s4); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); cursor: pointer; }
.claim-form .claim-proof { display: grid; gap: var(--s3); }
@media (max-width: 700px) {
  .claim-form input, .claim-form select, .claim-form textarea { font-size: 1.0625rem; }
  .claim-form input[type="file"] { min-height: 56px; }
  .claim-form input[type="file"]::file-selector-button { min-height: 44px; }
  .claim-form .form-actions { position: sticky; bottom: 0; z-index: 3; background: var(--surface); padding: var(--s3) 0; margin-top: var(--s4); border-top: 1px solid var(--line); display: flex; gap: var(--s3); }
  .claim-form .form-actions .btn--primary { flex: 1; min-height: 52px; }
}

/* Myelin Desk – Marketing module. Appended to desk.css; reuses its tokens. */

/* Board */
.mk-board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: var(--s4); margin-top: var(--s4); align-items: start; }
.mk-col { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); min-width: 0; }
.mk-col h2 { font-size: 0.9375rem; display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--s3); }
.mk-count-pill { font-size: 0.75rem; font-weight: 500; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
.mk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.mk-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s3); display: grid; gap: 4px; min-width: 0; }
.mk-item a { font-weight: 500; text-decoration: none; color: var(--ink); overflow-wrap: anywhere; }
.mk-item a:hover { color: var(--accent); }
.mk-item-meta { font-size: 0.75rem; display: flex; flex-wrap: wrap; gap: 4px; }
.mk-queue { border-left: 3px solid var(--accent); }

/* Editor */
.mk-editor { margin-top: 0; }
.mk-main, .mk-side { display: grid; gap: var(--s4); min-width: 0; align-content: start; }
.mk-main > .form { display: grid; gap: var(--s4); }
.mk-main .card + .card, .mk-side .card + .card { margin-top: 0; }
.mk-fieldset { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--s3) var(--s4); display: flex; flex-wrap: wrap; gap: var(--s2) var(--s5); align-items: center; }
.mk-fieldset legend { font-size: 0.8125rem; font-weight: 500; padding: 0 var(--s2); }
.mk-fieldset .hint { flex-basis: 100%; }
.mk-variant { display: grid; gap: var(--s4); }
.mk-variant .card-head { margin-bottom: 0; }
.mk-count { font-variant-numeric: tabular-nums; font-size: 0.8125rem; color: var(--muted); }
.mk-count.neg { color: var(--b-critical); font-weight: 600; }
.mk-ai-row { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); border-top: 1px dashed var(--line); padding-top: var(--s3); }
.mk-save-bar { position: sticky; bottom: var(--s3); z-index: 2; padding: var(--s3) var(--s4); }
.mk-actions-stack { display: grid; gap: var(--s4); margin-top: var(--s3); }
.mk-stack { display: grid; gap: var(--s2); justify-items: start; }
.mk-stack .field { width: 100%; }
.mk-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.mk-text-box { white-space: pre-wrap; }
.mk-issues, .mk-insights { margin: var(--s3) 0 0; padding-left: var(--s5); display: grid; gap: var(--s3); font-size: 0.9375rem; }
.mk-history { list-style: none; margin: var(--s4) 0 0; padding: 0; display: grid; gap: var(--s3); font-size: 0.875rem; }
.mk-history li { border-left: 2px solid var(--line); padding-left: var(--s3); overflow-wrap: anywhere; }
.mk-details summary { cursor: pointer; color: var(--accent); font-size: 0.875rem; margin: var(--s3) 0; }
.mk-details ol { padding-left: var(--s5); display: grid; gap: var(--s2); font-size: 0.875rem; }
.mk-details + .form { margin-top: var(--s3); }

/* Checks */
.mk-checks { display: grid; gap: var(--s3); }
.mk-check-title { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }
.mk-check--critical { color: var(--b-critical); } .mk-check--warning { color: var(--b-warning); } .mk-check--neutral { color: var(--muted); }
.mk-check-group ul { margin: 0; padding-left: var(--s4); font-size: 0.875rem; display: grid; gap: 4px; }

/* Neutral platform preview (deliberately not a copy of either platform's layout) */
.mk-preview { border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); padding: var(--s4); display: grid; gap: var(--s3); max-width: 520px; }
.mk-preview header { display: flex; gap: var(--s3); align-items: center; font-size: 0.875rem; }
.mk-preview-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--side); color: var(--b-champagne); display: grid; place-items: center; font-weight: 500; flex: none; }
.mk-preview-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 0.9375rem; line-height: 1.55; max-height: 22em; overflow: auto; }
.mk-preview-img { width: 100%; height: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); display: block; }
.mk-preview-tags { color: var(--accent); font-size: 0.875rem; overflow-wrap: anywhere; }
.mk-preview-tags:empty { display: none; }

/* Calendar */
.mk-cal-head, .mk-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.mk-cal-head span { font-size: 0.75rem; color: var(--muted); text-align: center; padding-bottom: 4px; }
.mk-day { border: 1px solid var(--line); border-radius: var(--radius-sm); min-height: 96px; padding: 6px; display: grid; gap: 4px; align-content: start; min-width: 0; background: var(--surface); }
.mk-day.is-out { background: var(--surface-2); opacity: 0.7; }
.mk-day.is-today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.mk-day-n { font-size: 0.75rem; color: var(--muted); }
.mk-day-w { display: none; }
.mk-chip { display: block; font-size: 0.75rem; line-height: 1.3; padding: 3px 6px; border-radius: 6px; text-decoration: none; color: var(--ink); background: var(--surface-2); border-left: 3px solid var(--line-strong); overflow-wrap: anywhere; }
.mk-chip span { font-weight: 600; font-variant-numeric: tabular-nums; }
.mk-chip small { display: block; color: var(--muted); }
.mk-chip--good { background: var(--b-good-bg); border-left-color: var(--b-good); }
.mk-chip--warning { background: var(--b-warning-bg); border-left-color: var(--b-warning); }

/* Media */
.mk-media-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s4); }
.mk-media { display: grid; gap: var(--s2); align-content: start; min-width: 0; overflow-wrap: anywhere; font-size: 0.875rem; }
.mk-media img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); display: block; }

@media (max-width: 860px) {
  .mk-cal-head { display: none; }
  .mk-cal-grid { grid-template-columns: minmax(0, 1fr); }
  .mk-day.is-empty { display: none; }
  .mk-day { min-height: 0; }
  .mk-day-w { display: inline; }
  .mk-save-bar { position: static; }
}

/* ---- Autopilot, Ideas, Review ------------------------------------------------------------ */
.inline-form { display: inline-flex; margin: 0; }
.page-actions .inline-form .btn { white-space: nowrap; }
.plain-list { margin: 0; padding-left: 1.1em; display: grid; gap: var(--s2); }
.mk-steps { margin: 0 0 var(--s3); padding-left: 1.2em; display: grid; gap: var(--s3); line-height: 1.55; }
.mk-steps li::marker { color: var(--accent); font-weight: 600; }
.mk-warn { color: var(--b-warning); font-weight: 500; }
.mk-plan-row { margin-bottom: var(--s3); }
.mk-plan-row .field { margin: 0; }
.mk-plan-row .field--check { flex-basis: 100%; }
.mk-days { display: flex; flex-wrap: wrap; gap: 6px; }
.mk-day-pick { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); border-radius: 999px; padding: 6px 12px; font-size: 0.875rem; cursor: pointer; background: var(--surface); }
.mk-day-pick:has(input:checked) { background: var(--surface-2); border-color: var(--accent); }
.mk-day-pick input { margin: 0; }
.mk-facts summary { cursor: pointer; font-size: 0.8125rem; color: var(--muted); }
.mk-facts p { white-space: pre-wrap; margin: 6px 0 0; font-size: 0.875rem; }
.mk-consent { margin-top: var(--s2); display: flex; gap: var(--s2); align-items: end; flex-wrap: wrap; }
.mk-consent .field { margin: 0; min-width: 180px; }
.mk-review-item { display: grid; grid-template-columns: minmax(160px, 280px) minmax(0, 1fr); gap: var(--s5); margin-bottom: var(--s4); }
.mk-review-media { min-width: 0; }
.mk-review-img { width: 100%; height: auto; display: block; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface-2); }
.mk-review-img.is-story { max-width: 220px; }
.mk-review-body { min-width: 0; display: grid; gap: var(--s3); align-content: start; }
.mk-review-body h2 { margin: 0; font-size: 1.125rem; }
.mk-review-meta { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.mk-review-text { border-left: 3px solid var(--line-strong); padding-left: var(--s3); }
.mk-review-text .eyebrow { margin: 0 0 4px; }
.mk-review-checks { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; font-size: 0.875rem; }
.mk-review-actions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: end; }
.mk-review-actions .mk-stack { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: end; margin: 0; }
.mk-review-actions .field { margin: 0; min-width: 220px; }
@media (max-width: 720px) {
  .mk-review-item { grid-template-columns: minmax(0, 1fr); }
  .mk-review-img { max-width: 320px; }
  .mk-review-actions .field { min-width: 0; width: 100%; }
}
.mk-suggest { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.mk-suggest li { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); border-bottom: 1px solid var(--line); padding: var(--s2) 0; }
.mk-suggest li > div { min-width: 0; overflow-wrap: anywhere; }
.mk-changes summary { cursor: pointer; color: var(--accent); font-size: 0.875rem; font-weight: 500; }
.mk-changes .mk-stack { margin-top: var(--s2); }
.mk-banner { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.mk-how summary { cursor: pointer; font-weight: 500; font-size: 1rem; }
.mk-how[open] summary { margin-bottom: var(--s3); }
.mk-legend { margin-top: var(--s3); }
.mk-noimg { border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); aspect-ratio: 4 / 5; display: grid; place-items: center; color: var(--muted); font-size: 0.875rem; text-align: center; padding: var(--s3); }
.mk-outcome { margin: 0; font-size: 0.875rem; color: var(--ink); background: var(--surface-2); border-radius: var(--radius-sm); padding: var(--s2) var(--s3); }
.mk-story-preview { display: block; margin: var(--s3) auto 0; border-radius: 18px; border: 6px solid var(--side); }
[data-kind-only][hidden] { display: none; }
