/*!
 * kit.css: the look of every app the kit builds.
 * Themes are token sets. Pick one with data-preset on <html>; data-theme="dark" flips it.
 */

/* ---------- Theme presets ---------- */
:root, [data-preset="workshop"] {
  --bg: #F5EFE2; --bg-2: #EFE6D2; --surface: #FAF6EC; --surface-2: #F1E9D8;
  --ink: #1A1714; --ink-soft: #5A5148; --line: #D9CCAF; --edge: #1A1714;
  --accent: #E8703A; --accent-ink: #1A1714; --secondary: #2B5F8A; --muted: #C9B994;
  --good: #2F7D4F; --good-bg: #E3EFD9; --bad: #C13F2E; --bad-bg: #F7DCD3; --highlight: #F5C24B;
  --border-w: 1.5px; --shadow: 3px 3px 0 var(--edge); --shadow-hover: 4px 4px 0 var(--edge); --shadow-press: 1px 1px 0 var(--edge);
  --r-sm: 4px; --r-md: 8px; --r-lg: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display-weight: 900; --display-track: -0.03em;
}
[data-preset="clean"] {
  --bg: #F6F7F9; --bg-2: #EEF0F4; --surface: #FFFFFF; --surface-2: #F3F5F8;
  --ink: #111827; --ink-soft: #5B6474; --line: #E3E6EC; --edge: #E3E6EC;
  --accent: #2563EB; --accent-ink: #FFFFFF; --secondary: #0F9F8F; --muted: #CBD2DC;
  --good: #15803D; --good-bg: #DCFCE7; --bad: #B91C1C; --bad-bg: #FEE2E2; --highlight: #FDE68A;
  --border-w: 1px; --shadow: 0 1px 2px rgba(17,24,39,.06), 0 4px 14px rgba(17,24,39,.06);
  --shadow-hover: 0 2px 4px rgba(17,24,39,.08), 0 8px 22px rgba(17,24,39,.08); --shadow-press: 0 1px 2px rgba(17,24,39,.08);
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --display-weight: 800; --display-track: -0.025em;
}
[data-preset="forest"] {
  --bg: #F2F4EE; --bg-2: #E7EBDF; --surface: #FBFCF8; --surface-2: #EEF1E7;
  --ink: #18201A; --ink-soft: #55604F; --line: #CED6C3; --edge: #18201A;
  --accent: #2F7D4F; --accent-ink: #FFFFFF; --secondary: #B7791F; --muted: #BCC7AE;
  --good: #2F7D4F; --good-bg: #DDEBD8; --bad: #B4432F; --bad-bg: #F4DDD5; --highlight: #E9C46A;
  --border-w: 1.5px; --shadow: 3px 3px 0 var(--edge); --shadow-hover: 4px 4px 0 var(--edge); --shadow-press: 1px 1px 0 var(--edge);
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px;
}
[data-preset="ocean"] {
  --bg: #EFF5F8; --bg-2: #E2EDF2; --surface: #FBFDFE; --surface-2: #EAF2F6;
  --ink: #0F1E2A; --ink-soft: #4C6070; --line: #CADBE4; --edge: #CADBE4;
  --accent: #0E7490; --accent-ink: #FFFFFF; --secondary: #E07A5F; --muted: #B7CBD6;
  --good: #0F766E; --good-bg: #D5F0EC; --bad: #C2410C; --bad-bg: #FBE3D6; --highlight: #FCD34D;
  --border-w: 1px; --shadow: 0 1px 2px rgba(15,30,42,.06), 0 6px 18px rgba(15,30,42,.07);
  --shadow-hover: 0 2px 4px rgba(15,30,42,.08), 0 10px 26px rgba(15,30,42,.1); --shadow-press: 0 1px 2px rgba(15,30,42,.08);
  --r-sm: 10px; --r-md: 14px; --r-lg: 20px; --display-weight: 800; --display-track: -0.025em;
}
[data-preset="mono"] {
  --bg: #F4F4F2; --bg-2: #EAEAE6; --surface: #FFFFFF; --surface-2: #F1F1EE;
  --ink: #141414; --ink-soft: #5E5E5A; --line: #DADAD5; --edge: #141414;
  --accent: #141414; --accent-ink: #FFFFFF; --secondary: #7A7A74; --muted: #CFCFC9;
  --good: #1F7A4C; --good-bg: #DDEEE3; --bad: #B3261E; --bad-bg: #F6DEDB; --highlight: #FFE45C;
  --border-w: 1.5px; --shadow: 3px 3px 0 var(--edge); --shadow-hover: 4px 4px 0 var(--edge); --shadow-press: 1px 1px 0 var(--edge);
  --r-sm: 2px; --r-md: 4px; --r-lg: 6px;
}

/* Dark: one set of surfaces, each preset keeps its accent. */
[data-theme="dark"] {
  --bg: #171513; --bg-2: #1E1B18; --surface: #22201C; --surface-2: #2A2723;
  --ink: #F3EEE4; --ink-soft: #ABA298; --line: #3A3631; --edge: #0B0A09; --muted: #4A443D;
  --good: #6BC08B; --good-bg: #1F3326; --bad: #F08A76; --bad-bg: #3A221D; --highlight: #F5C24B;
  --shadow: 3px 3px 0 #000; --shadow-hover: 4px 4px 0 #000; --shadow-press: 1px 1px 0 #000;
}
[data-theme="dark"][data-preset="clean"], [data-theme="dark"][data-preset="ocean"] {
  --bg: #0F1419; --bg-2: #141B22; --surface: #18212A; --surface-2: #1F2A35; --line: #2A3643; --edge: #2A3643; --muted: #34414F;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 6px 18px rgba(0,0,0,.3); --shadow-hover: 0 2px 4px rgba(0,0,0,.4), 0 10px 26px rgba(0,0,0,.35); --shadow-press: 0 1px 2px rgba(0,0,0,.4);
}
[data-theme="dark"][data-preset="ocean"] { --accent: #22A3C3; --accent-ink: #06141A; }
[data-theme="dark"][data-preset="clean"] { --accent: #5B8DEF; --accent-ink: #0A1020; }
[data-theme="dark"][data-preset="forest"] { --accent: #4FA872; --accent-ink: #0C1A11; }
[data-theme="dark"][data-preset="mono"] { --accent: #F3EEE4; --accent-ink: #141414; }

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 16px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  min-height: 100dvh; overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--secondary); }
h1, h2, h3 { margin: 0; letter-spacing: var(--display-track); line-height: 1.12; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid var(--highlight); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--r-sm);
  border: var(--border-w) solid var(--edge); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 15px; cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow); transition: box-shadow .15s ease, transform .15s ease, background-color .15s ease;
}
.btn:hover { box-shadow: var(--shadow-hover); transform: translate(-1px, -1px); }
.btn:active { box-shadow: var(--shadow-press); transform: translate(2px, 2px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--edge); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; transform: none; }
.btn-ghost:active { transform: none; box-shadow: none; }
.btn-lg { min-height: 54px; padding: 0 26px; font-size: 17px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; }
.icon-btn {
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; border-radius: var(--r-sm); cursor: pointer; color: var(--ink-soft);
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
.side { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.brand-mark {
  width: 36px; height: 36px; border-radius: var(--r-md); flex: none;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
  border: var(--border-w) solid var(--edge); box-shadow: var(--shadow-press);
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-tabs { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; gap: 4px;
  padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px; border: 0; background: transparent; border-radius: var(--r-md);
  color: var(--ink-soft); font-size: 11.5px; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: color .2s ease, background-color .2s ease;
}
.tab svg.i { width: 22px; height: 22px; }
.tab[aria-current="page"] { color: var(--ink); background: color-mix(in srgb, var(--accent) 18%, transparent); }
.tab[aria-current="page"] svg.i { color: var(--accent); stroke-width: 2.1; }
main.view { padding: 18px 16px 110px; max-width: 1240px; width: 100%; margin: 0 auto; min-width: 0; }
.screen-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 18px; }
.screen-head h1 { font-size: clamp(26px, 6vw, 38px); font-weight: var(--display-weight); }
.screen-head p { margin: 6px 0 0; color: var(--ink-soft); max-width: 60ch; }
.screen { animation: enter .45s cubic-bezier(.22,1,.36,1) backwards; }
@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (min-width: 768px) {
  main.view { padding: 26px 28px 60px; }
  .tabbar { display: none; }
  .top-tabs { display: flex; gap: 4px; }
  .top-tabs .tab { flex-direction: row; gap: 8px; font-size: 14px; padding: 8px 12px; max-width: none; white-space: nowrap; }
}
@media (min-width: 1100px) {
  .shell { grid-template-columns: 248px minmax(0, 1fr); }
  .topbar { display: none; }
  .side {
    display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100dvh;
    padding: 22px 16px; border-right: 1px solid var(--line); background: var(--bg-2);
  }
  .side .brand { flex: none; margin-bottom: 18px; padding: 0 6px; }
  .side .brand-mark { width: 42px; height: 42px; }
  .side nav { display: flex; flex-direction: column; gap: 4px; }
  .side .tab { flex-direction: row; justify-content: flex-start; gap: 12px; max-width: none; font-size: 15px; padding: 11px 12px; }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; }
  .side-foot .btn { justify-content: flex-start; font-weight: 600; color: var(--ink-soft); }
  main.view { padding: 34px 40px 60px; }
}

/* ---------- Cards, banner, KPIs ---------- */
.card {
  background: var(--surface); border: var(--border-w) solid var(--edge); border-radius: var(--r-lg);
  box-shadow: var(--shadow); padding: 20px; min-width: 0;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }

.banner {
  display: flex; gap: 16px; align-items: flex-start; padding: 20px 22px;
  border-radius: var(--r-lg); border: var(--border-w) solid var(--edge); box-shadow: var(--shadow);
  transition: background-color .5s ease, color .5s ease;
}
.banner .badge {
  width: 46px; height: 46px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: var(--border-w) solid var(--edge);
}
.banner .badge svg.i { width: 24px; height: 24px; stroke-width: 2.2; }
.banner h2 { font-size: clamp(20px, 4.4vw, 28px); font-weight: var(--display-weight); }
.banner p { margin: 6px 0 0; font-size: 15.5px; }
.banner.good { background: var(--good-bg); } .banner.good .badge { color: var(--good); }
.banner.bad { background: var(--bad-bg); } .banner.bad .badge { color: var(--bad); }
.banner.pulse { animation: pulse .6s ease; }
@keyframes pulse { 40% { transform: scale(1.012); } }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px; display: flex; flex-direction: column; gap: 4px; container-type: inline-size; }
.kpi .k-label { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
/* Sized to the tile, so a long number like $1,125,667 stays on one line in a narrow tile. */
.kpi .k-value { font-size: clamp(18px, 15cqi, 30px); font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; overflow-wrap: anywhere; }
.kpi .k-note { font-size: 12.5px; color: var(--ink-soft); }
.kpi.good .k-value { color: var(--good); } .kpi.bad .k-value { color: var(--bad); }
@media (min-width: 1300px) { .kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ---------- Calculator layout ---------- */
.calc { display: grid; gap: 18px; grid-template-columns: minmax(0, 1fr); }
.calc-results { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.calc-inputs { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.calc-inputs > *, .calc-results > * { flex: none; }
.calc-inputs > h2 { font-size: 20px; font-weight: 800; margin-top: 10px; }
@media (min-width: 1000px) {
  .calc { grid-template-columns: minmax(330px, 380px) minmax(0, 1fr); align-items: start; gap: 26px; }
  .calc-inputs { order: -1; position: sticky; top: 20px; max-height: calc(100dvh - 40px); overflow-y: auto; padding: 4px 8px 12px 4px; scrollbar-width: thin; }
  .calc-inputs > h2 { margin-top: 0; }
}
/* Phone: a live result pill follows you while you edit numbers. */
.live-pill {
  position: fixed; left: 50%; top: calc(66px + env(safe-area-inset-top)); z-index: 25;
  transform: translate(-50%, -140%); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 999px;
  font-weight: 700; font-size: 14px; border: var(--border-w) solid var(--edge); box-shadow: var(--shadow);
  transition: transform .35s cubic-bezier(.22,1,.36,1), opacity .25s ease; white-space: nowrap; max-width: calc(100vw - 32px);
}
.live-pill.show { transform: translate(-50%, 0); opacity: 1; }
.live-pill.good { background: var(--good-bg); } .live-pill.bad { background: var(--bad-bg); }
.live-pill svg.i { width: 18px; height: 18px; }
.live-pill.good svg.i { color: var(--good); } .live-pill.bad svg.i { color: var(--bad); }
@media (min-width: 1000px) { .live-pill { display: none; } }

/* Input groups */
.group { padding: 0; overflow: hidden; }
.group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 16px 18px; font-weight: 800; font-size: 16px;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary .g-note { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--ink-soft); }
.group > summary .chev { transition: transform .25s ease; color: var(--ink-soft); }
.group[open] > summary .chev { transform: rotate(180deg); }
.group .g-body { padding: 2px 18px 18px; display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-top { display: flex; align-items: center; gap: 6px; }
.field-top label { font-size: 14.5px; font-weight: 600; flex: 1; }
.help-btn { width: 28px; height: 28px; }
.help-btn svg.i { width: 17px; height: 17px; }
.help { font-size: 13.5px; color: var(--ink-soft); margin: -2px 0 0; display: none; }
.field.show-help .help { display: block; }
.field-row { display: flex; align-items: center; gap: 12px; }
.numbox {
  display: flex; align-items: center; flex: none; width: 132px; height: 44px; padding: 0 10px;
  background: var(--bg); border: var(--border-w) solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s ease;
}
.numbox:focus-within { border-color: var(--accent); outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.numbox input { width: 100%; min-width: 0; border: 0; background: transparent; outline: 0; font-weight: 700; font-size: 16px; text-align: right; font-variant-numeric: tabular-nums; padding: 0; }
.numbox .affix { color: var(--ink-soft); font-weight: 600; font-size: 15px; }
.numbox .affix.pre { margin-right: 2px; } .numbox .affix.post { margin-left: 2px; }
.stepper { display: flex; gap: 6px; }
.stepper .icon-btn { border: var(--border-w) solid var(--line); width: 44px; height: 44px; background: var(--surface); }

/* Range slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none; flex: 1; min-width: 0; height: 28px; background: transparent; cursor: pointer;
  --fill: 50%;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--line) var(--fill));
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--line); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--edge); box-shadow: 0 1px 3px rgba(0,0,0,.25);
  transition: transform .15s ease;
}
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--edge); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }

/* ---------- Charts ---------- */
.chart-card { padding: 18px 16px 12px; }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; padding: 0 4px; }
.chart-head h3 { font-size: 17px; font-weight: 800; }
.chart-box { position: relative; height: clamp(250px, 46vw, 400px); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 4px 2px; font-size: 13px; color: var(--ink-soft); }
.legend button { display: inline-flex; align-items: center; gap: 7px; border: 0; background: transparent; padding: 4px 2px; cursor: pointer; color: inherit; font-size: 13px; }
.legend button[aria-pressed="false"] { opacity: .45; text-decoration: line-through; }
.legend .sw { width: 14px; height: 10px; border-radius: 3px; flex: none; }

/* ---------- Tables ---------- */
.table-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  min-height: 36px; padding: 0 14px; border-radius: 999px; border: var(--border-w) solid var(--line);
  background: var(--surface); font-weight: 600; font-size: 14px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.table-wrap {
  overflow: auto; max-height: calc(100dvh - 230px); border-radius: var(--r-lg);
  border: var(--border-w) solid var(--edge); background: var(--surface); box-shadow: var(--shadow);
  -webkit-overflow-scrolling: touch;
}
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 14.5px; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 11px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
table.data th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); font-size: 12.5px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .05em; }
table.data th:first-child, table.data td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--surface); font-weight: 700; }
table.data th:first-child { z-index: 3; background: var(--surface-2); }
table.data tr:hover td { background: var(--surface-2); }
table.data td.em { font-weight: 800; }
table.data td.neg { color: var(--bad); }
table.data .tag { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; vertical-align: 1px; }
table.data .tag.on { background: color-mix(in srgb, var(--accent) 22%, transparent); }
table.data .tag.off { background: color-mix(in srgb, var(--secondary) 18%, transparent); }
table.data tr.divider td { border-top: 2px solid var(--accent); }

/* ---------- Scenarios ---------- */
.scn-save { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.scn-save input {
  flex: 1 1 220px; min-height: 46px; padding: 0 14px; border-radius: var(--r-sm);
  border: var(--border-w) solid var(--line); background: var(--bg); font-size: 16px;
}
.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty svg.i { width: 36px; height: 36px; color: var(--muted); margin-bottom: 10px; }
.empty h3 { color: var(--ink); font-size: 18px; margin-bottom: 6px; }
.compare th { vertical-align: bottom; }
.compare td:first-child { white-space: normal; min-width: 130px; max-width: 170px; }
.compare th .scn-actions { display: flex; gap: 2px; justify-content: flex-end; margin-top: 4px; }
.compare th .scn-name { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: 14px; }
.compare td.better { color: var(--good); } .compare td.worse { color: var(--bad); }
.compare tr.section td { background: var(--bg-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); text-align: left; }

/* ---------- Intake wizard ---------- */
.intake {
  position: fixed; inset: 0; z-index: 100; background: var(--bg); overflow-y: auto;
  display: flex; flex-direction: column;
}
.intake-top { display: flex; align-items: center; gap: 12px; padding: 14px 16px; padding-top: max(14px, env(safe-area-inset-top)); max-width: 720px; width: 100%; margin: 0 auto; }
.progress { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .5s cubic-bezier(.22,1,.36,1); }
.intake-body { flex: 1; display: flex; flex-direction: column; justify-content: center; max-width: 640px; width: 100%; margin: 0 auto; padding: 20px 20px 40px; }
.step { animation: stepIn .5s cubic-bezier(.22,1,.36,1) both; }
.step.back { animation-name: stepBack; }
@keyframes stepIn { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: none; } }
@keyframes stepBack { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: none; } }
.step h1 { font-size: clamp(30px, 7.5vw, 48px); font-weight: var(--display-weight); margin: 10px 0 14px; }
.step h2 { font-size: clamp(24px, 5.6vw, 34px); font-weight: var(--display-weight); margin: 8px 0 10px; }
.step p.lead { font-size: 18px; color: var(--ink-soft); margin: 0 0 26px; max-width: 46ch; }
.step .help { display: block; font-size: 15px; margin: 0 0 22px; }
.big-input { display: flex; align-items: center; gap: 4px; border-bottom: 3px solid var(--edge); padding: 6px 2px; margin: 18px 0 18px; max-width: 420px; }
.big-input:focus-within { border-color: var(--accent); }
.big-input input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: clamp(34px, 9vw, 52px); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; padding: 0; }
.big-input .affix { font-size: clamp(26px, 7vw, 40px); font-weight: 700; color: var(--ink-soft); }
.step input[type="range"] { width: 100%; max-width: 420px; display: block; margin-bottom: 30px; }
.step-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.step-actions .hint { font-size: 13px; color: var(--ink-soft); }
.choice-grid { display: grid; gap: 12px; margin: 20px 0 28px; }
@media (min-width: 560px) { .choice-grid { grid-template-columns: 1fr 1fr; } }
.choice {
  text-align: left; padding: 18px; border-radius: var(--r-lg); cursor: pointer;
  border: var(--border-w) solid var(--edge); background: var(--surface); box-shadow: var(--shadow);
  transition: box-shadow .15s ease, transform .15s ease;
}
.choice:hover { box-shadow: var(--shadow-hover); transform: translate(-1px, -1px); }
.choice strong { display: block; font-size: 17px; margin-bottom: 4px; }
.choice span { color: var(--ink-soft); font-size: 14.5px; }
.crunch { text-align: center; }
.crunch .dots { display: inline-flex; gap: 8px; margin: 22px 0; }
.crunch .dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); animation: bounce 1s infinite ease-in-out; }
.crunch .dots i:nth-child(2) { animation-delay: .15s; } .crunch .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(.6); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }

/* ---------- Toast + dialogs ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 200;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--r-md); font-weight: 600; font-size: 14.5px;
  transition: opacity .25s ease, transform .3s cubic-bezier(.22,1,.36,1); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 768px) { .toast { bottom: 28px; } }
.menu {
  position: absolute; right: 12px; top: 56px; z-index: 40; min-width: 220px; padding: 6px;
  background: var(--surface); border: var(--border-w) solid var(--edge); border-radius: var(--r-md); box-shadow: var(--shadow-hover);
  display: none; flex-direction: column;
}
.menu.open { display: flex; animation: enter .25s cubic-bezier(.22,1,.36,1) both; }
.menu button { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: transparent; border-radius: var(--r-sm); text-align: left; cursor: pointer; font-weight: 600; font-size: 15px; }
.menu button:hover { background: var(--surface-2); }

/* ---------- Lists ---------- */
.head-actions { display: flex; align-items: center; gap: 4px; }
.head-actions label.icon-btn { position: relative; }
.add-wide { display: none; margin-left: 6px; }
@media (min-width: 768px) { .add-wide { display: inline-flex; } }
.list-tools { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 0; min-width: 0; }
.search svg.i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--ink-soft); pointer-events: none; }
.search input, select.sort {
  width: 100%; min-height: 46px; border-radius: var(--r-sm); border: var(--border-w) solid var(--line);
  background: var(--surface); font-size: 16px; padding: 0 14px;
}
.search input { padding-left: 44px; }
select.sort { width: auto; flex: 0 1 200px; min-width: 0; max-width: 42%; cursor: pointer; }
.list-tools { flex-wrap: nowrap; }
.list-chips { margin-bottom: 16px; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; scrollbar-width: none; }
.list-chips::-webkit-scrollbar { display: none; }
.list-chips .chip { flex: none; }
.chip-n { opacity: .6; font-weight: 500; margin-left: 2px; }
.cards { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.rec { display: flex; flex-direction: column; gap: 6px; cursor: pointer; padding: 16px 18px; transition: box-shadow .15s ease, transform .15s ease; animation: enter .4s cubic-bezier(.22,1,.36,1) backwards; }
.rec:hover { box-shadow: var(--shadow-hover); transform: translate(-1px, -1px); }
.c-top { display: flex; align-items: flex-start; gap: 10px; }
.c-title { font-size: 17px; font-weight: 800; flex: 1; min-width: 0; overflow-wrap: anywhere; letter-spacing: -0.015em; }
.c-tag { flex: none; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.c-sub { color: var(--ink-soft); font-size: 14.5px; margin-top: -2px; }
.c-amount { font-size: 22px; font-weight: 800; letter-spacing: -0.02em; }
.c-meta { font-size: 14px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
a.c-meta { color: var(--secondary); }
a.c-meta:hover { text-decoration: underline; }
.c-k { font-weight: 600; color: var(--ink); }
.c-date { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.c-date svg.i { width: 15px; height: 15px; }
.c-date.warn { color: var(--bad); font-weight: 700; }
.fab {
  position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 26;
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: var(--border-w) solid var(--edge); box-shadow: var(--shadow);
}
.fab svg.i { width: 26px; height: 26px; stroke-width: 2.2; }
@media (min-width: 768px) { .fab { display: none; } }

/* Add / edit sheet: slides up on phones, a centered dialog on desktop */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 100%; max-height: 92dvh;
  background: var(--surface); color: var(--ink); border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.25); animation: sheetUp .35s cubic-bezier(.22,1,.36,1);
}
dialog.sheet::backdrop { background: rgba(20, 16, 12, .45); backdrop-filter: blur(2px); }
dialog.sheet form { display: flex; flex-direction: column; max-height: 92dvh; }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 768px) {
  dialog.sheet { margin: auto; max-width: 560px; border-radius: var(--r-lg); border: var(--border-w) solid var(--edge); box-shadow: var(--shadow-hover); }
}
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 8px; }
.sheet-head h2 { flex: 1; font-size: 22px; font-weight: 800; }
.sheet-body { padding: 8px 20px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.sheet-foot { display: flex; gap: 10px; align-items: center; padding: 14px 20px; padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); flex-wrap: wrap; }
.ff { display: flex; flex-direction: column; gap: 6px; }
.ff label { font-size: 14px; font-weight: 600; }
.ff input:not([type=checkbox]), .ff select, .ff textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: var(--r-sm);
  border: var(--border-w) solid var(--line); background: var(--bg); font-size: 16px;
}
.ff textarea { resize: vertical; line-height: 1.45; }
.ff input:focus, .ff select:focus, .ff textarea:focus { outline: 3px solid color-mix(in srgb, var(--accent) 30%, transparent); border-color: var(--accent); }
.ff-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ff-row input { flex: 1; }
.ff-check { flex-direction: row; align-items: center; gap: 10px; }
.ff-check input { width: 22px; height: 22px; accent-color: var(--accent); }
.ff-ro { padding: 10px 0; font-weight: 700; }
.ff-bad input, .ff-bad select, .ff-bad textarea { border-color: var(--bad) !important; }
.btn.danger { color: var(--bad); }
ol.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 10px; }
ol.steps .btn { margin-top: 6px; }

/* ---------- Dashboards ---------- */
.dash-grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); margin-top: 16px; }
@media (min-width: 1000px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash-grid .wide { grid-column: 1 / -1; } }
.mini { padding: 18px; }
.mini .card-title { font-size: 17px; font-weight: 800; }
.mini-body { overflow-x: auto; }
.mini-table th, .mini-table td { padding: 9px 8px; }
.mini-table td:first-child { white-space: normal; overflow-wrap: anywhere; }
.mini-table th:first-child, .mini-table td:first-child { position: static; background: transparent; }
.mini-table tr:last-child td { border-bottom: 0; }

/* ---------- Print ---------- */
.print-only { display: none; }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; }
  .side, .topbar, .tabbar, .live-pill, .no-print, .toast, .menu { display: none !important; }
  .shell { display: block; }
  main.view { padding: 0; max-width: none; }
  .card, .banner, .table-wrap { box-shadow: none !important; break-inside: avoid; }
  .calc { display: block; }
  .calc-inputs { display: none; }
  .print-only { display: block; }
  .table-wrap { max-height: none; overflow: visible; }
  .screen { animation: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
