/* Customs Docs AI: five looks a person can pick (Account page), built from the same named tokens.
   Each theme only changes token values; every component below uses the tokens.
   Colours and contrast from the design research of 14 Nov 2026 (body text >= 4.5:1, input borders
   and focus rings >= 3:1, WCAG 2.2). Fonts are system fonts: nothing is loaded from the internet. */

/* ================================================================ themes */
:root, [data-theme] {                   /* base tokens = Harbour (calm and minimal, the default); other themes override */
  --bg: #fafafa; --panel: #ffffff; --raised: #ffffff; --ink: #171717; --muted: #525252; --line: #e5e5e5;
  --border: #8d8d8d; --brand: #4f46e5; --brand-ink: #ffffff; --brand-soft: #eef0ff; --focus: #4f46e5;
  --nav-bg: #ffffff; --nav-ink: #404040; --nav-active: #eef0ff; --nav-active-ink: #3730a3;
  --ok: #146c43; --ok-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fff4d6; --err: #b42318; --err-bg: #fdecea;
  --info-bg: #eef2ff; --amber-row: #fff8e5; --head-bg: #fafafa; --zebra: transparent; --hover: #f5f5f5;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --radius: 8px; --radius-sm: 6px; --shadow: none; --pop-shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.08);
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  --fs: 14px; --side-w: 232px; --border-w: 1px; --grid-lines: 0; --link-deco: none;
}
[data-theme="ledger"] {                  /* dense and precise, for power users */
  --bg: #f4f4f4; --panel: #ffffff; --raised: #ffffff; --ink: #161616; --muted: #525252; --line: #e0e0e0;
  --border: #8d8d8d; --brand: #0f62fe; --brand-ink: #ffffff; --brand-soft: #edf5ff; --focus: #0f62fe;
  --nav-bg: #161616; --nav-ink: #c6c6c6; --nav-active: #393939; --nav-active-ink: #ffffff;
  --info-bg: #edf5ff; --head-bg: #e8e8e8; --zebra: #f8f8f8; --hover: #e8e8e8;
  --radius: 2px; --radius-sm: 2px; --shadow: none; --pop-shadow: 0 2px 6px rgba(0,0,0,.2);
  --fs: 13px; --grid-lines: 1;
}
[data-theme="sandstone"] {               /* warm and friendly */
  --bg: #faf7f2; --panel: #ffffff; --raised: #ffffff; --ink: #2b2723; --muted: #6b6259; --line: #e7e0d6;
  --border: #8f857a; --brand: #b4461b; --brand-ink: #ffffff; --brand-soft: #fbece4; --focus: #b4461b;
  --nav-bg: #f3ede4; --nav-ink: #4a433c; --nav-active: #ffffff; --nav-active-ink: #8a3412;
  --info-bg: #f6efe6; --amber-row: #fff6e0; --head-bg: #fbf8f3; --hover: #fbf6ef;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 3px rgba(60,40,20,.08); --pop-shadow: 0 10px 30px rgba(60,40,20,.15);
  --fs: 15px; --side-w: 244px;
}
[data-theme="beacon"] {                  /* high contrast, large text */
  --bg: #ffffff; --panel: #ffffff; --raised: #ffffff; --ink: #0b0b0b; --muted: #3d3d3d; --line: #595959;
  --border: #595959; --brand: #0b4fb3; --brand-ink: #ffffff; --brand-soft: #e6eefa; --focus: #ffbf47;
  --nav-bg: #0b0b0b; --nav-ink: #ffffff; --nav-active: #ffbf47; --nav-active-ink: #0b0b0b;
  --ok: #0b5f34; --ok-bg: #dff3e6; --warn: #6b4500; --warn-bg: #fff1c7; --err: #a30f0f; --err-bg: #fde4e4;
  --info-bg: #e6eefa; --amber-row: #fff1c7; --head-bg: #f0f0f0; --hover: #f0f0f0;
  --radius: 4px; --radius-sm: 4px; --shadow: none; --fs: 16px; --border-w: 2px; --link-deco: underline;
}
[data-theme="midnight"] {                /* dark and modern (dark in both modes) */
  --bg: #0b0d12; --panel: #141821; --raised: #1c2130; --ink: #e6e8ee; --muted: #9aa1b2; --line: #2a3040;
  --border: #5a6278; --brand: #8b9cff; --brand-ink: #0b0d12; --brand-soft: #1f2540; --focus: #8b9cff;
  --nav-bg: #0f1218; --nav-ink: #aab1c2; --nav-active: #1f2540; --nav-active-ink: #e6e8ee;
  --ok: #6fcf97; --ok-bg: #15301f; --warn: #f2c14e; --warn-bg: #352a10; --err: #ff8a8a; --err-bg: #3a1a1e;
  --info-bg: #1a2033; --amber-row: #2a2412; --head-bg: #171b25; --zebra: transparent; --hover: #1a1f2b;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --radius: 8px; --radius-sm: 6px; --shadow: inset 0 1px 0 rgba(255,255,255,.04); --pop-shadow: 0 12px 40px rgba(0,0,0,.5);
  color-scheme: dark;
}

/* dark versions: chosen "Dark", or "Follow my device" on a device set to dark */
[data-mode="dark"]:is([data-theme="harbour"], [data-theme="ledger"], [data-theme="sandstone"], [data-theme="beacon"]) { color-scheme: dark; }
[data-theme="harbour"][data-mode="dark"] {
  --bg: #0a0a0a; --panel: #171717; --raised: #1f1f1f; --ink: #ededed; --muted: #a1a1a1; --line: #2e2e2e; --border: #6b6b6b;
  --brand: #818cf8; --brand-ink: #0a0a0a; --brand-soft: #1e1b4b; --focus: #818cf8;
  --nav-bg: #111111; --nav-ink: #c4c4c4; --nav-active: #1e1b4b; --nav-active-ink: #e0e7ff; --head-bg: #141414; --hover: #1c1c1c;
}
[data-theme="ledger"][data-mode="dark"] {
  --bg: #161616; --panel: #262626; --raised: #2e2e2e; --ink: #f4f4f4; --muted: #c6c6c6; --line: #393939; --border: #8d8d8d;
  --brand: #78a9ff; --brand-ink: #161616; --brand-soft: #1c2b47; --focus: #78a9ff;
  --nav-bg: #0d0d0d; --head-bg: #333333; --zebra: #2a2a2a; --hover: #353535;
}
[data-theme="sandstone"][data-mode="dark"] {
  --bg: #1c1916; --panel: #26221e; --raised: #2e2925; --ink: #f2ede6; --muted: #b8aea2; --line: #3a342e; --border: #7d736a;
  --brand: #f08a5d; --brand-ink: #1c1916; --brand-soft: #3a2519; --focus: #f08a5d;
  --nav-bg: #211d1a; --nav-ink: #d6cdc2; --nav-active: #3a2519; --nav-active-ink: #fde3d4; --head-bg: #221e1b; --hover: #2c2723;
  --info-bg: #2c2620; --amber-row: #2f2812;
}
[data-theme="beacon"][data-mode="dark"] {
  --bg: #000000; --panel: #000000; --raised: #111111; --ink: #ffffff; --muted: #d0d0d0; --line: #a0a0a0; --border: #a0a0a0;
  --brand: #8cc8ff; --brand-ink: #000000; --brand-soft: #0d2238; --nav-bg: #000000; --head-bg: #111111; --hover: #1a1a1a;
  --info-bg: #0d2238; --amber-row: #2f2500;
}
[data-mode="dark"]:not([data-theme="midnight"]) {
  --ok: #6fcf97; --ok-bg: #15301f; --warn: #f2c14e; --warn-bg: #352a10; --err: #ff8a8a; --err-bg: #3a1a1e;
  --amber-row: #2f2812; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --pop-shadow: 0 12px 40px rgba(0,0,0,.5);
}
@media (prefers-color-scheme: dark) {
  [data-mode="auto"]:is([data-theme="harbour"], [data-theme="ledger"], [data-theme="sandstone"], [data-theme="beacon"]) { color-scheme: dark; }
  [data-theme="harbour"][data-mode="auto"] {
    --bg: #0a0a0a; --panel: #171717; --raised: #1f1f1f; --ink: #ededed; --muted: #a1a1a1; --line: #2e2e2e; --border: #6b6b6b;
    --brand: #818cf8; --brand-ink: #0a0a0a; --brand-soft: #1e1b4b; --focus: #818cf8;
    --nav-bg: #111111; --nav-ink: #c4c4c4; --nav-active: #1e1b4b; --nav-active-ink: #e0e7ff; --head-bg: #141414; --hover: #1c1c1c;
  }
  [data-theme="ledger"][data-mode="auto"] {
    --bg: #161616; --panel: #262626; --raised: #2e2e2e; --ink: #f4f4f4; --muted: #c6c6c6; --line: #393939; --border: #8d8d8d;
    --brand: #78a9ff; --brand-ink: #161616; --brand-soft: #1c2b47; --focus: #78a9ff;
    --nav-bg: #0d0d0d; --head-bg: #333333; --zebra: #2a2a2a; --hover: #353535;
  }
  [data-theme="sandstone"][data-mode="auto"] {
    --bg: #1c1916; --panel: #26221e; --raised: #2e2925; --ink: #f2ede6; --muted: #b8aea2; --line: #3a342e; --border: #7d736a;
    --brand: #f08a5d; --brand-ink: #1c1916; --brand-soft: #3a2519; --focus: #f08a5d;
    --nav-bg: #211d1a; --nav-ink: #d6cdc2; --nav-active: #3a2519; --nav-active-ink: #fde3d4; --head-bg: #221e1b; --hover: #2c2723;
    --info-bg: #2c2620; --amber-row: #2f2812;
  }
  [data-theme="beacon"][data-mode="auto"] {
    --bg: #000000; --panel: #000000; --raised: #111111; --ink: #ffffff; --muted: #d0d0d0; --line: #a0a0a0; --border: #a0a0a0;
    --brand: #8cc8ff; --brand-ink: #000000; --brand-soft: #0d2238; --nav-bg: #000000; --head-bg: #111111; --hover: #1a1a1a;
    --info-bg: #0d2238; --amber-row: #2f2500;
  }
  [data-mode="auto"]:not([data-theme="midnight"]) {
    --ok: #6fcf97; --ok-bg: #15301f; --warn: #f2c14e; --warn-bg: #352a10; --err: #ff8a8a; --err-bg: #3a1a1e;
    --amber-row: #2f2812; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --pop-shadow: 0 12px 40px rgba(0,0,0,.5);
  }
}

/* names the Pulse grid (pulse_grid.js) reads, mapped to the theme; the logo word on dark menu bars */
:root, [data-theme] { --surface: var(--panel); --text: var(--ink); --p-acc: var(--brand); --logo-word: var(--brand); }
[data-theme="ledger"] { --logo-word: #78a9ff; }
[data-theme="beacon"] { --logo-word: #ffbf47; }
body .hfilter { border-color: var(--line); box-shadow: var(--pop-shadow); }
body .pg-tools button { border-color: var(--border); min-height: 0; font-weight: 500; }
body .pg-tools button:hover { background: var(--hover); filter: none; }

/* rows in tables: a personal setting, separate from the look */
:root { --cell-y: 7px; --cell-x: 10px; }
[data-density="compact"] { --cell-y: 3px; --cell-x: 7px; }
[data-density="comfortable"] { --cell-y: 11px; --cell-x: 12px; }
[data-theme="ledger"]:not([data-density="comfortable"]) { --cell-y: 4px; --cell-x: 8px; }

/* ================================================================ foundation */
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: var(--fs)/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: var(--link-deco); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
[data-theme="beacon"] :focus-visible { outline: 3px solid var(--focus); box-shadow: 0 0 0 5px #0b0b0b; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 300; background: var(--panel); padding: 8px 12px; border-radius: var(--radius-sm); }
.skip:focus { left: 8px; }
.ic { width: 18px; height: 18px; flex: 0 0 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
h1 { font-size: 1.55em; line-height: 1.25; margin: 4px 0 12px; letter-spacing: -.01em; }
h2 { font-size: 1.15em; margin: 18px 0 10px; } h3 { font-size: 1em; margin: 14px 0 6px; }
.panel h2:first-child, .panel h3:first-child { margin-top: 0; }

/* ================================================================ app frame: side menu + content */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 14px 10px;
        background: var(--nav-bg); color: var(--nav-ink); border-right: var(--border-w) solid var(--line); overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 9px; padding: 4px 8px 10px; color: inherit; text-decoration: none; font-weight: 600; font-size: 15px; }
.brand b { color: var(--logo-word); font-weight: 700; }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--brand); color: var(--brand-ink); font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.env { align-self: flex-start; margin: 0 8px 4px; font-size: 11px; padding: 1px 6px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); text-transform: uppercase; font-weight: 600; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a, .side-foot a, .signout { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--nav-ink); text-decoration: none; font-size: 14px; }
.side nav a:hover, .side-foot a:hover, .signout:hover { background: var(--nav-active); color: var(--nav-active-ink); text-decoration: none; }
.side nav a[aria-current="page"], .side-foot a[aria-current="page"] { background: var(--nav-active); color: var(--nav-active-ink); font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 10px; border-top: 1px solid var(--line); }
.side-foot select { font-size: 13px; padding: 5px 8px; margin-bottom: 4px; }
.tenant { padding: 4px 10px 6px; font-size: 12px; color: var(--nav-ink); opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
button.link.signout { width: 100%; justify-content: flex-start; background: none; border: 0; cursor: pointer; font: inherit; font-size: 14px; font-weight: 400; color: var(--nav-ink); min-height: 0; }
.content { min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 1360px; margin: 0 auto; padding: 22px 28px; flex: 1; }
main.narrow { max-width: 460px; padding-top: 40px; }
.foot { max-width: 1360px; width: 100%; margin: 0 auto; padding: 8px 28px 22px; color: var(--muted); font-size: 12px; }
.plain-top { display: flex; align-items: center; gap: 12px; padding: 14px 22px; }
body.plain main.narrow .panel, body.plain main.narrow > form { box-shadow: var(--pop-shadow); }

/* the menu can be collapsed to icons (remembered in a cookie, so the page opens the way it was left) */
.shell { transition: grid-template-columns .18s ease; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.side-top .brand { min-width: 0; }
button.side-toggle { background: none; border: 0; color: var(--nav-ink); padding: 6px; min-height: 0; border-radius: var(--radius-sm); flex: 0 0 auto; opacity: .75; }
button.side-toggle:hover { background: var(--nav-active); color: var(--nav-active-ink); opacity: 1; filter: none; }
[data-side="collapsed"]:not([data-theme="ledger"]):not([data-theme="beacon"]) { --side-w: 64px; }
[data-side="collapsed"]:not([data-theme="ledger"]):not([data-theme="beacon"]) .side { padding: 14px 8px; }
[data-side="collapsed"]:not([data-theme="ledger"]):not([data-theme="beacon"]) .side-top { flex-direction: column; gap: 8px; }
[data-side="collapsed"]:not([data-theme="ledger"]):not([data-theme="beacon"]) .brand { padding: 4px 0; }
[data-side="collapsed"]:not([data-theme="ledger"]):not([data-theme="beacon"]) .side-toggle .ic { transform: scaleX(-1); }
[data-side="collapsed"]:not([data-theme="ledger"]):not([data-theme="beacon"]) :is(.brand span:last-child, .side nav a span, .side-foot a span, .signout span, .tenant, .env, .side-foot form:not(:last-child)) { display: none; }
[data-side="collapsed"]:not([data-theme="ledger"]):not([data-theme="beacon"]) :is(.side nav a, .side-foot a, button.link.signout) { justify-content: center; padding: 9px 0; }
[data-theme="ledger"] .side-toggle, [data-theme="beacon"] .side-toggle { display: none; }
[data-theme="ledger"] .side-top, [data-theme="beacon"] .side-top { display: contents; }

/* usage and balance, small, in the top corner of every page */
.topstrip { display: flex; justify-content: flex-end; padding: 10px 28px 0; font-size: 12px; line-height: 1.4; }
.topstrip a { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; align-items: center; padding: 4px 12px; color: var(--muted); text-decoration: none;
              background: var(--panel); border: 1px solid var(--line); border-radius: 999px; }
.topstrip a:hover { border-color: var(--border); text-decoration: none; }
.ts-item { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ts-item + .ts-item { padding-left: 14px; border-left: 1px solid var(--line); }
.ts-k { font-weight: 600; color: var(--ink); margin-right: 3px; }
.ts-item.warn, .ts-item.warn .ts-k { color: var(--warn); }
[data-theme="ledger"] .topstrip { padding: 8px 18px 0; }
[data-theme="ledger"] .topstrip a, [data-theme="beacon"] .topstrip a { border-radius: var(--radius-sm); }
[data-theme="beacon"] .topstrip { font-size: 14px; }
.topstrip + main { padding-top: 10px; }

/* top-bar layout: Ledger (power users) and Beacon (high contrast) */
[data-theme="ledger"] .shell, [data-theme="beacon"] .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
[data-theme="ledger"] .side, [data-theme="beacon"] .side { position: sticky; z-index: 50; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 6px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
[data-theme="ledger"] .side nav, [data-theme="beacon"] .side nav { flex-direction: row; flex-wrap: wrap; }
[data-theme="ledger"] .brand, [data-theme="beacon"] .brand { padding: 4px 10px 4px 0; }
[data-theme="ledger"] .side nav a, [data-theme="ledger"] .side-foot a, [data-theme="ledger"] .signout { padding: 6px 10px; font-size: 13px; }
[data-theme="ledger"] .side-foot, [data-theme="beacon"] .side-foot { margin: 0 0 0 auto; flex-direction: row; align-items: center; border: 0; padding: 0; }
[data-theme="ledger"] .side-foot select, [data-theme="beacon"] .side-foot select { width: auto; margin: 0; }
[data-theme="ledger"] .env, [data-theme="beacon"] .env { margin: 0 8px 0 0; align-self: center; }
[data-theme="beacon"] .side nav a { text-decoration: underline; text-underline-offset: 4px; }
[data-theme="ledger"] main { padding: 14px 18px; max-width: none; } [data-theme="ledger"] .foot { max-width: none; padding: 6px 18px 14px; }

/* phones and narrow windows: the side menu becomes a scrolling bar at the top */
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { position: sticky; z-index: 50; height: auto; flex-direction: row; align-items: center; gap: 4px; padding: 6px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { flex-direction: row; flex-wrap: nowrap; }
  .side nav a span, .side-foot span, .tenant, .side-foot form:first-child { display: none; }
  .side nav a, .side-foot a, .signout { padding: 8px; }
  .side-foot { margin: 0 0 0 auto; flex-direction: row; border: 0; padding: 0; }
  .brand span:last-child { display: none; }
  .side-toggle { display: none; } .side-top { display: contents; }
  .topstrip { padding: 8px 16px 0; justify-content: flex-start; } .topstrip a { border-radius: var(--radius); }
  main { padding: 16px; } .foot { padding: 8px 16px 18px; }
}

/* ================================================================ page header */
.page-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-end; justify-content: space-between; margin: 0 0 16px; }
.page-head h1 { margin: 0; }
.page-head .sub, p.sub { margin: 4px 0 0; color: var(--muted); }
.bar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 4px 0 12px; }
.bar h1, .bar h2 { margin: 0; flex: 1 1 auto; }
.bar h1 .badge { vertical-align: middle; font-size: 12px; font-weight: 600; }

/* ================================================================ surfaces */
.panel { background: var(--panel); border: var(--border-w) solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
[data-theme="ledger"] .panel { padding: 12px 14px; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid > .panel { margin-bottom: 0; }
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--panel); border: var(--border-w) solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tile .n { font-size: 1.6em; font-weight: 650; letter-spacing: -.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.tile .l { color: var(--muted); font-size: 13px; margin-top: 2px; }
.tile .l a { color: inherit; } .tile .l a:hover { color: var(--brand); }
[data-theme="sandstone"] .tile { border-top: 3px solid var(--brand); }
[data-theme="midnight"] .tile { background: linear-gradient(180deg, var(--raised), var(--panel)); }

/* ================================================================ forms and buttons */
label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea { width: 100%; padding: 8px 10px; border: var(--border-w) solid var(--border); border-radius: var(--radius-sm); background: var(--panel); color: var(--ink); font: inherit; transition: border-color .12s, box-shadow .12s; }
input:hover, select:hover, textarea:hover { border-color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px var(--brand-soft); }
[data-theme="beacon"] input:focus, [data-theme="beacon"] select:focus, [data-theme="beacon"] textarea:focus { box-shadow: 0 0 0 3px var(--focus); border-color: var(--ink); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--brand); }
input[type=file] { padding: 5px; border-style: dashed; }
textarea { min-height: 84px; }
fieldset { border: 0; padding: 0; margin: 0; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.label-row label { margin-bottom: 4px; }
legend { font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 4px; padding: 0; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; border-radius: var(--radius-sm); border: var(--border-w) solid var(--brand); background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600; font-size: 14px; line-height: 1.2; cursor: pointer; text-decoration: none; transition: filter .12s, background .12s; min-height: 36px; }
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:active, .btn:active { filter: brightness(.95); }
button.secondary, .btn.secondary { background: var(--panel); color: var(--ink); border-color: var(--border); }
button.secondary:hover, .btn.secondary:hover { background: var(--hover); filter: none; }
button.danger { background: var(--err); border-color: var(--err); color: #fff; }
button.link { background: none; border: none; color: var(--brand); padding: 0; min-height: 0; font-weight: 500; }
button[disabled] { opacity: .45; cursor: not-allowed; filter: none; }
[data-theme="ledger"] button:not(.link):not(.chip):not(.pick-btn):not(.mf-pick), [data-theme="ledger"] .btn { min-height: 32px; padding: 6px 12px; font-size: 13px; }
[data-theme="sandstone"] button:not(.link):not(.chip):not(.pick-btn):not(.mf-pick):not(.signout), [data-theme="sandstone"] .btn { border-radius: 999px; padding-left: 18px; padding-right: 18px; }
[data-theme="beacon"] button:not(.link):not(.chip):not(.pick-btn):not(.mf-pick), [data-theme="beacon"] .btn { min-height: 44px; box-shadow: 0 2px 0 #0b0b0b; }
form.inline { display: inline; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 170px; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.seg legend { width: 100%; }
.seg label { margin: 0; display: inline-flex; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { padding: 6px 12px; border: var(--border-w) solid var(--border); border-radius: var(--radius-sm); color: var(--ink); cursor: pointer; font-size: 13px; background: var(--panel); }
.seg input:checked + span { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.seg input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ================================================================ messages and badges */
.flash { display: flex; gap: 8px; align-items: baseline; padding: 10px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; border: 1px solid transparent; }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.flash.error { background: var(--err-bg); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); }
.flash.info { background: var(--info-bg); color: var(--ink); border-color: var(--line); }
.flash.ok::before { content: "✓"; font-weight: 700; } .flash.error::before { content: "!"; font-weight: 800; }
.flash.trial { padding: 6px 12px; font-size: 13px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--info-bg); color: var(--ink); white-space: nowrap; line-height: 1.6; }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.err { background: var(--err-bg); color: var(--err); }
[data-theme="ledger"] .badge, [data-theme="beacon"] .badge { border-radius: var(--radius-sm); }
[data-theme="beacon"] .badge { border: 1px solid currentColor; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.q { padding: 8px 12px; border-left: 3px solid var(--warn); background: var(--warn-bg); margin: 6px 0; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.codes { font-family: var(--mono); font-size: .95em; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.05em; margin-bottom: 4px; }

/* ================================================================ tables */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; background: var(--panel); font-variant-numeric: tabular-nums; }
th, td { border-bottom: 1px solid var(--line); padding: var(--cell-y) var(--cell-x); text-align: left; vertical-align: top; font-size: 14px; }
th { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; background: var(--head-bg); }
tbody tr:hover td, table tr:hover > td { background: var(--hover); }
table tr:nth-child(even) > td { background-color: var(--zebra); }
[data-theme="ledger"] th, [data-theme="ledger"] td { border: 1px solid var(--line); font-size: 13px; }
[data-theme="beacon"] th { color: var(--ink); text-transform: none; font-size: 14px; letter-spacing: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.amber > td { background: var(--amber-row); }
tr.approved td:first-child { box-shadow: inset 3px 0 var(--ok); }
.legend span { display: inline-block; width: 10px; height: 10px; margin: 0 4px 0 12px; }
.chat .you { text-align: right; } .chat .msg { display: inline-block; padding: 9px 13px; border-radius: var(--radius); margin: 4px 0; max-width: 80%; white-space: pre-wrap; text-align: left; }
.chat .you .msg { background: var(--brand-soft); } .chat .help .msg { background: var(--panel); border: 1px solid var(--line); }
.recovery { columns: 2; font-family: var(--mono); font-size: 16px; }
details summary { cursor: pointer; }
details.panel > summary { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::before { content: "▸"; color: var(--muted); transition: transform .15s; }
details.panel[open] > summary::before { transform: rotate(90deg); }
details.panel[open] > summary { margin-bottom: 10px; }
@media (max-width: 640px) { th, td { font-size: 13px; padding: 5px 6px; } }

/* ================================================================ shipment page: documents, grid, slicer, picker */
.inline-form { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form input[type=file] { width: auto; max-width: 240px; }
.inline-form select { width: auto; }
label.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; color: var(--ink); font-weight: 400; }
.docgroups { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin-bottom: 12px; }
.docgroup { background: var(--panel); border: var(--border-w) solid var(--line); border-radius: var(--radius); padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow); }
.dg-head { font-weight: 600; margin-bottom: 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.doc { padding: 5px 0; border-top: 1px solid var(--line); }
.doc:first-of-type { border-top: 0; }
.doc .badge { font-size: 11px; padding: 0 6px; }
details.compact { padding: 8px 14px; }
details.compact summary { font-size: 13px; color: var(--muted); }
.slicer { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.chip { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font-size: 12px; font-weight: 500; cursor: pointer; min-height: 0; }
.chip:hover { background: var(--hover); filter: none; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.chip.on .muted { color: inherit; opacity: .8; }
.grid-wrap { max-height: 70vh; overflow: auto; border: var(--border-w) solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.pg { font-size: 13px; }
table.pg th { background: var(--head-bg); position: sticky; top: 0; z-index: 2; }
table.pg td { padding: var(--cell-y) var(--cell-x); }
table.pg td.r, table.pg th.r { text-align: right; }
table.pg td.pick { cursor: pointer; color: var(--brand); }
table.pg tr.amber td { background: var(--amber-row); }
table.pg tr.approved td:first-child { box-shadow: inset 3px 0 var(--ok); }
table.pg tr.foot td { font-weight: 600; border-top: 2px solid var(--line); background: var(--head-bg); }
.pg-tools .sub { color: var(--muted); }
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 12px; backdrop-filter: blur(2px); }
.modal[hidden] { display: none; }
.modal-box { background: var(--panel); color: var(--ink); border-radius: var(--radius); width: min(900px, 100%); max-height: 84vh; display: flex; flex-direction: column; padding: 14px 16px; box-shadow: var(--pop-shadow); border: 1px solid var(--line); }
.picker-list { overflow: auto; margin-top: 8px; }
#picker-table tr.pk { cursor: pointer; }
#picker-table tr.pk:hover td, #picker-table tr.pk:focus td { background: var(--brand-soft); }
#picker-table tr.sel td { background: var(--ok-bg); font-weight: 600; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--err); color: #fff; padding: 10px 14px; border-radius: var(--radius); z-index: 200; max-width: 420px; box-shadow: var(--pop-shadow); }
.toast[hidden] { display: none; }
.formgrid { display: grid; gap: 6px 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.formgrid label { margin: 4px 0 2px; font-size: 12px; }
.formgrid input, .formgrid select { padding: 5px 8px; font-size: 13px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
table.pg td.codes, table.pg td[data-c="inv"], table.pg td[data-c="duty"] { white-space: nowrap; }
.pick-btn { border: 1px solid var(--border); background: var(--panel); border-radius: 4px; padding: 0 5px; margin-left: 4px; cursor: pointer; line-height: 1.2; color: var(--brand); min-height: 0; font-weight: 400; }
.pick-btn::after { content: "▾"; }

/* ================================================================ dashboard */
.dash-grid { display: grid; gap: 16px; grid-template-columns: 2fr 1fr; margin-bottom: 16px; }
.dash-grid .panel { margin: 0; min-width: 0; }
.dash-grid h2 { margin-top: 0; }
.chart { height: 280px; width: 100%; }
.chart.tall { height: 340px; }
.small-tiles .tile { padding: 10px 14px; }
.small-tiles .n { font-size: 1.3em; }
.filters { padding: 10px 14px; }
@media (max-width: 960px) { .dash-grid { grid-template-columns: 1fr; } }

/* ================================================================ mapping a document by hand */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.map-pages { display: flex; flex-direction: column; gap: 12px; max-height: calc(100vh - 170px); overflow: auto; padding-right: 4px; }
.map-page { position: relative; width: 100%; background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.map-page img { display: block; width: 100%; height: 100%; user-select: none; }
.map-over { position: absolute; inset: 0; }
.picking .map-over { cursor: crosshair; }
.mw { position: absolute; border-radius: 2px; }
.picking .mw:hover { background: rgba(42, 120, 214, .18); outline: 1px solid var(--series-1); cursor: pointer; }
.map-drag { position: absolute; border: 2px dashed var(--series-1); background: rgba(42, 120, 214, .08); pointer-events: none; }
.map-box { position: absolute; border: 2px solid var(--series-1); background: rgba(42, 120, 214, .10); border-radius: 3px; pointer-events: none; }
.map-box.col { border-color: var(--series-3); background: rgba(27, 175, 122, .08); }
.map-box.old { border-style: dashed; opacity: .7; }
.map-box span { position: absolute; top: -16px; left: -2px; font-size: 10px; line-height: 14px; padding: 0 4px; border-radius: 3px; background: #171717; color: #fff; white-space: nowrap; }
.map-pno { position: absolute; right: 6px; bottom: 4px; background: #fff; color: #525252; padding: 0 6px; border-radius: 4px; }
.map-panel { position: sticky; top: 8px; max-height: calc(100vh - 170px); overflow: auto; }
.map-steps { margin: 0 0 8px 18px; padding: 0; }
.mf { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto; gap: 6px; align-items: center; padding: 3px 4px; border-radius: var(--radius-sm); }
.mf.on { background: var(--warn-bg); outline: 1px solid var(--warn); }
.mf-pick { text-align: left; background: none; border: 0; color: var(--brand); padding: 2px 0; cursor: pointer; font: inherit; font-size: 13px; min-height: 0; justify-content: flex-start; font-weight: 500; }
.mf-val { width: 100%; font-size: 13px; padding: 3px 6px; }
@media (max-width: 960px) { .map-layout { grid-template-columns: 1fr; } .map-panel, .map-pages { position: static; max-height: none; } }

/* ================================================================ the look picker (Account page) */
.theme-cards { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); margin-bottom: 14px; }
.theme-card { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 10px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--ink); cursor: pointer; font-weight: 400; transition: border-color .12s, transform .12s; }
.theme-card:hover { transform: translateY(-2px); }
.theme-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.theme-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.theme-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.tc-preview { display: grid; grid-template-columns: 30% 1fr; height: 112px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); }
[data-theme="ledger"] .tc-preview, [data-theme="beacon"] .tc-preview { grid-template-columns: 1fr; grid-template-rows: 16px 1fr; }
.tc-side { display: flex; flex-direction: column; gap: 4px; padding: 8px 6px; background: var(--nav-bg); }
[data-theme="ledger"] .tc-side, [data-theme="beacon"] .tc-side { flex-direction: row; padding: 4px 6px; }
.tc-side i { display: block; height: 6px; border-radius: 3px; background: var(--nav-ink); opacity: .35; }
[data-theme="ledger"] .tc-side i, [data-theme="beacon"] .tc-side i { width: 18%; height: 7px; }
.tc-side i.on { background: var(--brand); opacity: 1; }
.tc-body { display: flex; flex-direction: column; gap: 5px; padding: 8px; background: var(--bg); }
.tc-title { width: 55%; height: 7px; border-radius: 3px; background: var(--ink); }
.tc-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.tc-tiles i { height: 16px; border-radius: calc(var(--radius-sm) / 2); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
[data-theme="sandstone"] .tc-tiles i { border-top: 2px solid var(--brand); }
.tc-rows { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: calc(var(--radius-sm) / 2); padding: 3px; }
.tc-rows i { height: 4px; background: var(--line); border-radius: 2px; }
.tc-rows i.amber { background: var(--warn); opacity: .5; }
.tc-btn { align-self: flex-end; width: 34px; height: 9px; border-radius: var(--radius-sm); background: var(--brand); }
.tc-name { font-weight: 650; display: flex; align-items: center; gap: 6px; }
.tc-desc { font-size: 12.5px; color: var(--muted); line-height: 1.4; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media print { .side, .foot, .skip { display: none; } .shell { display: block; } }

/* access grid (Company page) */
table.access select { width: auto; min-width: 110px; padding: 4px 8px; font-size: 13px; }
table.access td { vertical-align: middle; }
table.access td.actions { white-space: nowrap; }
table.access td.actions form + form { margin-left: 10px; }
.input-btn { display: flex; gap: 6px; align-items: center; }
.input-btn input { flex: 1 1 auto; min-width: 0; }
.input-btn button { white-space: nowrap; min-height: 0; padding: 5px 10px; font-size: 12px; }
input:disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; background: var(--hover); }

/* billing: choose the term; admin: receipts to check */
.term-cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 10px; }
.term-card { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 12px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); cursor: pointer; font-weight: 400; }
.term-card:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.term-card:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.term-card input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tc-head { font-weight: 650; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tc-price { font-size: 1.35em; font-weight: 700; font-variant-numeric: tabular-nums; }
.proof { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px 14px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.proof:first-of-type { border-top: 0; }
.proof .inline-form input { width: 200px; }
@media (max-width: 960px) { .proof { grid-template-columns: 1fr; } }
.side nav .count { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: var(--panel); font-size: 11px; font-weight: 700; text-align: center; }
table.subs td { vertical-align: middle; }
table.subs td.actions { white-space: nowrap; }
table.subs .inline-form input { width: 210px; }

/* Confirm button on an amber line in the grid */
.link-btn { border: 0; background: none; padding: 0; color: var(--brand); font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }
.link-btn:disabled { opacity: .5; cursor: wait; }
