/* Underpin Business Toolkit. Brand: navy #1E2A35, gold #C5A880, light grey #DDE1E6, charcoal #444B52, Montserrat. */
@font-face { font-family: 'Montserrat'; font-weight: 400; font-display: swap; src: url('/fonts/montserrat-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 500; font-display: swap; src: url('/fonts/montserrat-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 600; font-display: swap; src: url('/fonts/montserrat-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 700; font-display: swap; src: url('/fonts/montserrat-latin-700-normal.woff2') format('woff2'); }
@font-face { font-family: 'Montserrat'; font-weight: 800; font-display: swap; src: url('/fonts/montserrat-latin-800-normal.woff2') format('woff2'); }

:root {
  --navy: #1E2A35; --navy-2: #2A3A48; --gold: #C5A880; --gold-d: #8A6A3B; --gold-bg: #F7F4EF;
  --grey: #DDE1E6; --grey-l: #F3F5F7; --char: #444B52; --muted: #5F6873; --white: #fff;
  --pos: #2F7D4F; --pos-bg: #EAF5EE; --neg: #B3542C; --neg-bg: #FBF0EA; --amber: #8F5E12; --amber-bg: #FDF5E6;
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --r: 10px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html, body { margin: 0; }
body { font-family: var(--font); color: var(--char); background: var(--grey-l); font-size: 14px; line-height: 1.4;
  min-height: 100vh; min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
a { color: var(--gold-d); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.ico { width: 20px; height: 20px; display: block; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------------------------------------------------------------- top bar */
.tb { position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff;
  padding: calc(var(--sat) + 4px) calc(var(--sar) + 6px) 4px calc(var(--sal) + 6px);
  display: flex; align-items: center; gap: 2px; min-height: calc(44px + var(--sat)); }
.tb h1 { flex: 1; min-width: 0; margin: 0; font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb .num { color: var(--gold); font-weight: 700; margin-right: 6px; font-size: 12px; }
.icon-btn { background: none; border: 0; color: inherit; width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; flex: none; text-decoration: none; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.tb .icon-btn { color: #dfe5ea; }
.tb .back { color: var(--gold); }

/* ---------------------------------------------------------------- calculator layout */
#app { max-width: 980px; margin: 0 auto; padding: 8px calc(var(--sar) + 10px) calc(var(--sab) + 10px) calc(var(--sal) + 10px); }
.results { background: var(--white); border-radius: var(--r); padding: 10px 12px; box-shadow: 0 1px 2px rgba(30,42,53,.08); }
.inputs { padding: 4px 2px 0; }

.hero { text-align: center; padding: 0 0 4px; }
.hero-lab { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.hero-val { font-size: 34px; line-height: 1.12; font-weight: 800; color: var(--navy); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.hero.pos .hero-val { color: var(--pos); } .hero.neg .hero-val { color: var(--neg); }
.hero-sub { font-size: 12.5px; color: var(--muted); font-weight: 500; min-height: 0; }

.stats { display: grid; gap: 6px; margin: 4px 0 2px; }
.stats.n2 { grid-template-columns: 1fr 1fr; } .stats.n3 { grid-template-columns: repeat(3, 1fr); } .stats.n4 { grid-template-columns: 1fr 1fr; }
.stat { background: var(--grey-l); border-radius: 8px; padding: 5px 8px; text-align: center; min-width: 0; }
.stat span { display: block; font-size: 10.5px; color: var(--muted); font-weight: 600; line-height: 1.2; }
.stat b { display: block; font-size: 15px; color: var(--navy); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat.pos b { color: var(--pos); } .stat.neg b { color: var(--neg); }

table.cmp { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.cmp th, .cmp td { padding: 3px 4px; text-align: right; white-space: nowrap; }
.cmp thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--grey); }
.cmp tbody th { text-align: left; font-weight: 500; color: var(--char); padding-left: 0; }
.cmp tbody tr + tr > * { border-top: 1px solid #eef0f2; }
.cmp tr.strong > * { font-weight: 700; color: var(--navy); }
.cmp td.pos { color: var(--pos); } .cmp td.neg { color: var(--neg); }
.cmp.ref thead th:first-child { text-align: left; }
.cmp.ref tr.hl > * { background: var(--gold-bg); font-weight: 700; color: var(--navy); }

.bars { margin-top: 6px; }
.bars-t { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin-bottom: 2px; }
.bar { display: grid; grid-template-columns: 76px 1fr auto; align-items: center; gap: 8px; font-size: 12.5px; height: 19px; }
.bl { color: var(--char); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt { height: 8px; background: var(--grey-l); border-radius: 4px; overflow: hidden; }
.bt i { display: block; height: 100%; background: var(--gold); border-radius: 4px; }
.bt i.neg { background: var(--neg); } .bt i.mut { background: #9aa4ae; }
.bv { font-weight: 600; color: var(--navy); font-variant-numeric: tabular-nums; min-width: 64px; text-align: right; }

.stk-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--grey-l); margin: 3px 0 4px; }
.stk-bar i, .stk-leg i { display: block; height: 100%; }
.c0 { background: var(--gold); } .c1 { background: var(--navy); } .c2 { background: #8C9AA7; } .c3 { background: #D9C3A1; }
.stk-leg { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; }
.stk-leg span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.stk-leg i { width: 9px; height: 9px; border-radius: 2px; }
.stk-leg b { color: var(--navy); font-variant-numeric: tabular-nums; }
.cols svg { width: 100%; height: auto; display: block; }
.cols rect.col { fill: var(--gold); } .cols rect.now { fill: #9aa4ae; } .cols rect.neg { fill: var(--neg); }
.cols .axis { stroke: var(--grey); }
.cols text { font: 600 9px var(--font); fill: var(--char); text-anchor: middle; }
.cols text.cl { fill: var(--muted); font-weight: 500; }

.warn { background: var(--amber-bg); color: var(--amber); font-size: 12px; font-weight: 600; border-radius: 6px; padding: 4px 8px; margin: 4px 0; }
.tip { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.35; }

/* ---------------------------------------------------------------- inputs */
.grp { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--gold-d); font-weight: 700; margin: 6px 0 0; }
.row { padding: 2px 0 0; }
.row .top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.lab { font-size: 13px; font-weight: 500; color: var(--char); line-height: 1.3; }
.lab small { color: var(--muted); font-weight: 400; font-size: 11px; }
.val { background: none; border: 0; padding: 0; font-size: 15px; font-weight: 700; color: var(--navy); cursor: text; line-height: 1.3;
  border-bottom: 1px dashed #a9b2bb; font-variant-numeric: tabular-nums; }
.val-edit { width: 120px; font: 700 16px var(--font); color: var(--navy); text-align: right; border: 1px solid var(--gold); border-radius: 6px; padding: 2px 6px; }

input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; margin: 0; display: block; touch-action: pan-y; --p: 50%; }
input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--gold) 0 var(--p), var(--grey) var(--p) 100%); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; border-radius: 50%; background: var(--white); border: 2px solid var(--navy); margin-top: -9px; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--grey); }
input[type=range]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--gold); }
input[type=range]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: var(--white); border: 2px solid var(--navy); }

.toggle { display: flex; align-items: center; justify-content: space-between; padding: 5px 0 1px; }
.seg { display: inline-flex; background: var(--grey); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: none; padding: 4px 14px; border-radius: 6px; font-weight: 600; font-size: 13px; cursor: pointer; color: var(--muted); min-height: 30px; }
.seg button[aria-pressed=true] { background: var(--white); color: var(--navy); box-shadow: 0 1px 2px rgba(0,0,0,.12); }

details.adv { margin-top: 6px; border-top: 1px solid var(--grey); }
details.adv summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--gold-d); padding: 7px 0 2px; list-style: none; }
details.adv summary::-webkit-details-marker { display: none; }
details.adv summary::before { content: '+ '; }
details.adv[open] summary::before { content: '- '; }
.note { font-size: 11.5px; color: var(--muted); margin: 6px 0 0; line-height: 1.35; }

/* ---------------------------------------------------------------- info sheet, toast */
dialog.sheet { border: 0; border-radius: 14px; padding: 14px 16px calc(14px + var(--sab)); max-width: 560px; width: calc(100% - 20px); max-height: 85dvh; color: var(--char); }
dialog.sheet::backdrop { background: rgba(30,42,53,.55); }
.sheet-hd { display: flex; align-items: center; justify-content: space-between; }
.sheet h2 { font-size: 16px; color: var(--navy); margin: 0; }
.sheet .q { font-weight: 600; color: var(--navy); margin: 4px 0 8px; }
.sheet ul { padding-left: 18px; margin: 0 0 10px; } .sheet li { margin-bottom: 6px; font-size: 13.5px; }
.sheet .small { font-size: 12.5px; color: var(--muted); }
.sheet .priv { background: var(--gold-bg); padding: 8px 10px; border-radius: 8px; color: var(--char); }
.sheet .priv p { margin: 0 0 6px; } .sheet .priv p:last-child { margin: 0; }
.clear-btn { background: none; border: 1px solid var(--gold-d); color: var(--gold-d); border-radius: 16px; padding: 5px 14px; font-size: 12.5px; font-weight: 600; cursor: pointer; margin-top: 6px; min-height: 32px; }
.priv-ft { background: var(--white); border-radius: var(--r); padding: 10px 14px; color: var(--char); }
#toast { position: fixed; left: 50%; bottom: calc(18px + var(--sab)); transform: translate(-50%, 30px); opacity: 0; transition: opacity .2s, transform .2s;
  background: var(--navy); color: #fff; padding: 8px 14px; border-radius: 20px; font-size: 13px; font-weight: 600; pointer-events: none; max-width: 90vw; z-index: 30; }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- dashboard */
.dash-hd { background: var(--navy); color: #fff; padding: calc(var(--sat) + 14px) calc(var(--sar) + 16px) 16px calc(var(--sal) + 16px); }
.dash-hd .in { max-width: 980px; margin: 0 auto; }
.dash-hd img { height: 26px; width: auto; display: block; }
.dash-hd .ttl { font-size: 18px; font-weight: 800; letter-spacing: .02em; margin: 10px 0 2px; color: #fff; }
.dash-hd .ttl span { color: var(--gold); }
.dash-hd p { margin: 0; font-size: 12.5px; color: #c9d1d8; }
.dash { max-width: 980px; margin: 0 auto; padding: 4px calc(var(--sar) + 12px) calc(var(--sab) + 18px) calc(var(--sal) + 12px); }
.cat h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--gold-d); font-weight: 700; margin: 16px 2px 6px; }
.cards { display: grid; gap: 8px; grid-template-columns: 1fr; }
.card { display: grid; grid-template-columns: 38px 1fr; gap: 10px; align-items: center; background: var(--white); border-radius: var(--r); padding: 10px 12px;
  text-decoration: none; color: var(--char); box-shadow: 0 1px 2px rgba(30,42,53,.08); border: 1px solid transparent; }
.card:hover { border-color: var(--gold); }
.card .ci { width: 38px; height: 38px; border-radius: 9px; background: var(--gold-bg); color: var(--gold-d); display: grid; place-items: center; }
.card b { display: block; color: var(--navy); font-size: 14px; font-weight: 700; }
.card span { display: block; font-size: 12px; color: var(--muted); line-height: 1.3; margin-top: 1px; }
.card.used .ci { background: var(--navy); color: var(--gold); }
.dash-ft { font-size: 12px; color: var(--muted); text-align: center; margin-top: 22px; line-height: 1.6; }
.dash-ft a { color: var(--gold-d); font-weight: 600; }
#install { font-size: 12px; color: #c9d1d8; margin-top: 8px; }
.link-btn { background: none; border: 1px solid rgba(197,168,128,.6); color: var(--gold); border-radius: 16px; padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; }

/* ---------------------------------------------------------------- larger screens */
@media (min-width: 560px) { .cards { grid-template-columns: 1fr 1fr; } }
@media (min-width: 820px) {
  .cards { grid-template-columns: repeat(3, 1fr); }
  #app { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; padding-top: 20px; }
  .results { order: 2; position: sticky; top: 64px; padding: 16px 18px; }
  .inputs { order: 1; background: var(--white); border-radius: var(--r); padding: 8px 16px 14px; box-shadow: 0 1px 2px rgba(30,42,53,.08); }
  .hero-val { font-size: 40px; }
}
/* Short phones (375 × 667 class): tighten slightly so tools still fit. */
@media (max-height: 700px) and (max-width: 560px) {
  .tb { min-height: calc(40px + var(--sat)); padding-top: calc(var(--sat) + 2px); padding-bottom: 2px; }
  #app { padding-top: 6px; }
  .results { padding: 6px 10px; }
  .hero-val { font-size: 28px; }
  .hero-lab { font-size: 10.5px; }
  .row { padding-top: 0; }
  input[type=range] { height: 22px; }
  .cmp { font-size: 12px; }
  .cmp th, .cmp td { padding: 1px 4px; }
  .stat { padding: 3px 6px; }
  .note { margin-top: 4px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
