/* Components: header, tabs, fields, answer card, metrics, charts, tables, FAQ, footer, print. */
.site-header{position:sticky;top:0;z-index:100;background:var(--bg);border-bottom:1px solid var(--border-subtle);padding:0 1.5rem}
.nav-inner{max-width:1100px;margin:0 auto;display:flex;align-items:center;flex-wrap:wrap;min-height:3.5rem;gap:0 1rem}
.logo{font-family:var(--font-display);font-weight:500;font-size:1.25rem;color:var(--ink);text-decoration:none;letter-spacing:-.02em}
.logo span{font-weight:700}
.nav-links{display:flex;gap:2px;margin-left:auto;flex-wrap:wrap}
.nav-links a{display:inline-flex;align-items:center;min-height:2.25rem;font-size:.875rem;font-weight:500;color:var(--ink-2);text-decoration:none;padding:5px 12px;border-radius:var(--radius-control)}
.nav-links a:hover{background:var(--surface-2);color:var(--ink)}

/* Tabs: one scrollable row, active tab = heavier weight + 3px underline (not color alone) */
.tabs-wrap{max-width:1100px;margin:0 auto;padding:1.5rem 1.5rem 0}
.tabs{display:flex;flex-wrap:nowrap;gap:.25rem;overflow-x:auto;border-bottom:1px solid var(--border-subtle);scrollbar-width:thin}
.tab-btn{flex:0 0 auto;font-family:var(--font-body);font-size:.875rem;font-weight:500;color:var(--muted);background:none;border:none;border-bottom:3px solid transparent;padding:.5rem 1rem;min-height:2.75rem;cursor:pointer;display:flex;align-items:center;gap:6px;white-space:nowrap}
.tab-btn svg{width:16px;height:16px}
.tab-label-short{display:none}
.tab-btn:hover{color:var(--ink)}
.tab-btn[aria-selected=true]{color:var(--ink);border-bottom-color:var(--ink);font-weight:600}
.tab-btn:focus-visible,.table-scroll:focus-visible{outline-offset:-3px}
.panel-title{font-family:var(--font-display);font-weight:600;font-size:1.5rem;letter-spacing:-.01em;margin-bottom:1rem}

/* Cards */
.input-card,.metric,.chart-card,.table-card,.faq-item{background:var(--bg);border:1px solid var(--border-subtle);border-radius:var(--radius-card)}
.input-card{padding:1.25rem}
.slabel{font-size:.75rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.06em;margin-bottom:.5rem}

/* Fields */
.field{margin-bottom:1rem}.field:last-child{margin-bottom:0}
.field label{display:block;font-size:.875rem;color:var(--ink-2);margin-bottom:.25rem;font-weight:500}
.input-wrap{position:relative}
.input-wrap .prefix,.input-wrap .suffix{position:absolute;top:50%;transform:translateY(-50%);font-size:.875rem;color:var(--muted);pointer-events:none}
.input-wrap .prefix{left:12px}.input-wrap .suffix{right:12px}
input[type=number],select{width:100%;min-height:2.75rem;border:1px solid var(--border-input);border-radius:var(--radius-control);background:var(--surface-2);color:var(--ink);font-family:var(--font-body);font-size:1rem;padding:0 12px;font-variant-numeric:tabular-nums}
.input-wrap.has-prefix input[type=number]{padding-left:26px}
.input-wrap.has-suffix input[type=number]{padding-right:38px}
input[type=number]:focus,select:focus{background:var(--bg)}
input[aria-invalid=true]{border-color:var(--bad);background:var(--bad-bg)}
.field-error{display:flex;gap:6px;align-items:flex-start;font-size:.875rem;color:var(--bad);margin-top:.25rem}
.err-icon{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:1.1em;height:1.1em;margin-top:.15em;border-radius:50%;background:var(--bad);color:var(--bg);font-size:.75rem;font-weight:700;line-height:1}
select{cursor:pointer}
/* align-items:end keeps the inputs level when one label wraps to two lines and its neighbour doesn't */
.field-row{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.75rem;align-items:end}
.field-row{margin-bottom:1rem}.field-row:last-child{margin-bottom:0}
.field-row .field{margin-bottom:0}   /* spacing lives on the row, so bottom-aligned fields have equal margins */
.divider-line{border:none;border-top:1px solid var(--border-subtle);margin:1.25rem 0}
.sub-box{background:var(--surface-2);border-radius:var(--radius-control);padding:1rem;margin-top:1rem}
.sub-box input[type=number]{background:var(--bg)}
.presets{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.375rem}
.preset-btn,.print-btn{font-family:var(--font-body);font-weight:500;background:var(--bg);border:1px solid var(--border-input);color:var(--ink-2);border-radius:var(--radius-control);cursor:pointer}
.preset-btn{font-size:.875rem;padding:.25rem .75rem;min-height:2.25rem}
.preset-btn:hover,.print-btn:hover{background:var(--surface-2)}
/* The one place the primary (filled) button style appears: a selected preset chip. */
.preset-btn[aria-pressed=true]{background:var(--good);border-color:var(--good);color:var(--bg)}
.print-btn{font-size:.875rem;padding:.25rem .875rem;min-height:2.25rem;display:inline-flex;align-items:center;gap:6px;margin-bottom:1rem}

/* Answer card: the one number the person came for */
.answer{border-radius:var(--radius-card);padding:1.25rem 1.5rem;margin-bottom:1rem;border:1px solid var(--border-subtle);background:var(--good-bg);color:var(--ink)}
.answer--info{background:var(--info-bg)}.answer--bad{background:var(--bad-bg)}
.answer-num{display:block;font-family:var(--font-display);font-weight:700;font-size:clamp(2.25rem,6vw,3.5rem);line-height:1.05;margin:.1em 0;color:var(--good);font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.answer--info .answer-num{color:var(--info)}.answer--bad .answer-num{color:var(--bad)}
.answer-detail{color:var(--ink-2);font-size:.875rem;margin-top:.5rem}

/* Metrics */
.metrics{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.5rem;margin-bottom:1.25rem}
.metrics-4{grid-template-columns:repeat(auto-fit,minmax(9rem,1fr))}
.metric{padding:.875rem 1rem}
.metric .mlabel{font-size:.75rem;color:var(--muted);margin-bottom:.25rem;font-weight:600;text-transform:uppercase;letter-spacing:.04em}
.metric .mval{font-size:1.5rem;font-weight:600;color:var(--ink);line-height:1.15;font-variant-numeric:tabular-nums}
.metric .msub{font-size:.75rem;color:var(--muted);margin-top:.125rem}
.metric .mtag{font-weight:600}
.metric.good .mval,.metric.good .mtag{color:var(--good)}.metric.warn .mval,.metric.warn .mtag{color:var(--bad)}

/* Charts */
.chart-card{padding:1.1rem;margin-bottom:.875rem}
.chart-card .chart-title{font-size:.875rem;font-weight:600;color:var(--ink-2);margin-bottom:.75rem}
.chart-wrap{position:relative;width:100%}
.legend-row{display:flex;flex-wrap:wrap;gap:.25rem 1rem;margin-bottom:.625rem;font-size:.75rem;color:var(--muted);list-style:none}
.legend-row li{display:flex;align-items:center;gap:6px}
.leg-dot{width:10px;height:10px;border-radius:2px;flex-shrink:0}
.leg-line{width:20px;height:0;border-top:3px solid;flex-shrink:0}
.leg-line.dashed{border-top-style:dashed}.leg-line.dotted{border-top-style:dotted}

/* Tables */
.table-card{position:relative;overflow:hidden;margin-bottom:.875rem}
.table-card.has-more::after{content:"";position:absolute;top:0;right:0;bottom:0;width:1.75rem;background:linear-gradient(to left,var(--scroll-shade),transparent);pointer-events:none}
.table-scroll{overflow:auto}
.table-scroll.tall{max-height:380px}
.table-card table{width:100%;border-collapse:collapse;font-size:.875rem;font-variant-numeric:tabular-nums}
.table-card caption{text-align:left;font-size:.875rem;font-weight:600;color:var(--ink-2);padding:.875rem 12px .5rem}
.table-card th{text-align:left;font-size:.75rem;font-weight:600;color:var(--muted);text-transform:uppercase;letter-spacing:.04em;padding:.5rem 12px;background:var(--surface-2);border-bottom:1px solid var(--border-subtle);white-space:nowrap}
.table-card tbody th{font-weight:500;text-transform:none;letter-spacing:0;font-size:.875rem;color:var(--ink);background:none}
.table-card td{padding:.5rem 12px;color:var(--ink)}
.table-card tbody tr:nth-child(even){background:var(--surface-2)}
.table-card tbody tr.best th{box-shadow:inset 4px 0 0 var(--good)}
.badge{display:inline-block;font-size:.75rem;background:var(--good-bg);color:var(--good);padding:1px 8px;border-radius:20px;margin-left:6px;font-weight:600}
.badge--info{background:var(--info-bg);color:var(--info)}

/* About / FAQ */
.faq-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:1rem}
.faq-item{padding:1.25rem}
.faq-item h3{font-size:1rem;font-weight:600;color:var(--ink);margin-bottom:.5rem}
.faq-item p{font-size:.875rem;color:var(--ink-2);line-height:1.65}
.about-grid{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:1rem;margin-bottom:2rem}
.about-card{background:var(--surface-2);border-radius:var(--radius-card);padding:1.25rem}
.about-card .icon{font-size:1.5rem;margin-bottom:.5rem}
.about-card h3{font-size:1rem;font-weight:600;margin-bottom:.35rem}
.about-card p{font-size:.875rem;color:var(--ink-2);line-height:1.6}
.fine-print{font-size:.875rem;color:var(--muted);max-width:38rem}

/* Footer (on the band) */
.site-footer{background:var(--band);color:var(--band-muted);padding:1.5rem;text-align:center;font-size:.875rem;margin-top:1.5rem}
.site-footer a{display:inline-block;padding:.25rem .15rem;color:var(--band-ink);text-decoration:underline}

@media(max-width:700px){
  .faq-grid,.about-grid{grid-template-columns:minmax(0,1fr)}
}
@media(max-width:760px){
  .site-header{padding:0 1rem}
  .tabs-wrap{padding:1rem 1rem 0}
  .nav-links a{min-height:2.75rem;padding:5px 10px}
  .preset-btn,.print-btn{min-height:2.75rem}
  .content-section{padding:2rem 1rem}
  input[type=number],select{min-height:3rem}

  /* Calculator navigation: a bottom tab bar. All five calculators stay visible and thumb-reachable
     however far you scroll. Same tablist as on desktop (roles, arrow keys, hash), restyled. */
  .tabs-wrap{position:fixed;left:0;right:0;bottom:0;z-index:150;max-width:none;margin:0;padding:0 0 env(safe-area-inset-bottom);background:var(--bg);border-top:1px solid var(--border-subtle);transition:transform .2s}
  .tabs{gap:0;border-bottom:0}
  .tab-btn{flex:1 0 auto;flex-direction:column;justify-content:center;align-items:center;gap:.125rem;min-width:2.75rem;min-height:3.5rem;padding:.375rem;border-bottom:0;font-size:.75rem;line-height:1.2;text-align:center}
  .tab-btn svg{width:22px;height:22px}
  .tab-btn[aria-selected=true]{box-shadow:inset 0 3px 0 var(--ink);font-weight:500}   /* same weight: labels must not change width */
  .tab-label-short{display:inline}
  .tab-label-full{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
  .tab-btn:focus-visible{outline-offset:-4px}
  body{padding-bottom:calc(3.5rem + env(safe-area-inset-bottom))}
  html{scroll-padding-bottom:4.5rem}
  .typing .tabs-wrap:not(:focus-within){transform:translateY(100%)}
  .nav-links a[href="#calculators"]{display:none}   /* the bottom bar is always on screen */

  /* Tables: tighter cells, wrapping headers, and the row label pinned while the rest scrolls */
  .table-card th,.table-card td{padding:.5rem .5rem}
  .table-card th{white-space:normal}
  .table-card thead th:first-child,.table-card tbody th{position:sticky;left:0;z-index:1}
  .table-card thead th:first-child{background:var(--surface-2);z-index:2}
  .table-card tbody th{background:var(--bg)}
  .table-card tbody tr:nth-child(even) th{background:var(--surface-2)}
}
@media(min-width:761px){
  .preset-btn,.print-btn{min-height:2.25rem}
}
/* Print: the active calculator only, answer first, black on white */
@media print{
  @page{margin:14mm}
  body{background:#fff;color:#000;font-size:11pt}
  .site-header,.skip-link,.band,.tabs-wrap,.print-btn,.presets,.content-section,.site-footer{display:none!important}
  .panels{padding:0;max-width:none}
  .panels::before{content:"PayoffNerd \2014  payoffnerd.com";display:block;font-weight:600;font-size:10pt;margin-bottom:8pt}
  .panel-title{color:#000;font-size:18pt;margin-bottom:8pt}
  .layout{grid-template-columns:minmax(0,1fr);row-gap:0}
  .results{display:contents}
  .answer{order:-1}
  .inputs{margin-bottom:12pt}
  .answer,.metric,.input-card,.chart-card,.table-card,.sub-box{background:#fff!important;border:1px solid #000;color:#000;break-inside:avoid}
  .answer-num,.answer-detail,.metric .mval,.metric .mtag,.metric .msub,.mlabel,.slabel,.field label,.chart-card .chart-title,.legend-row,.table-card caption,.prefix,.suffix{color:#000!important}
  .answer-num{font-size:30pt}
  input[type=number],select{background:#fff!important;border:1px solid #000;color:#000}
  .table-scroll{overflow:visible!important;max-height:none!important}
  .table-card tbody tr:nth-child(even){background:none}
  .table-card th{background:none;color:#000;border-bottom:1px solid #000}
  .table-card tbody tr.best th{box-shadow:none}
  tr{break-inside:avoid}
  .badge{background:none;color:#000;border:1px solid #000}
  .leg-dot,.leg-line{-webkit-print-color-adjust:exact;print-color-adjust:exact}
}
