/* ProjectCostPro V3 — used by every calculator page and the landing directory. */
* { box-sizing: border-box; margin: 0; padding: 0; }

/* Screen-reader-only utility (accessibility for unlabeled controls) */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

:root {
  /* Construction-tech palette — navy/steel primary, orange used sparingly */
  --bg: #fafbfc;
  --card: #ffffff;
  --panel: #ffffff;
  --ink: #0f1419;
  --ink-soft: #334155;
  --ink-muted: #64748b;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-soft: #f1f5f9;
  --line-strong: #cbd5e1;

  /* Navy primary */
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --primary-dark: #1e293b;
  --primary-bg: #eff6ff;
  --primary-soft: #dbeafe;

  /* Charcoal secondary */
  --secondary: #334155;

  /* Steel accents */
  --steel: #64748b;
  --steel-light: #94a3b8;
  --steel-lighter: #cbd5e1;

  /* Safety orange — small accent only */
  --accent: #ea580c;
  --accent-light: #fb923c;
  --accent-bg: #fff7ed;

  /* Status colors */
  --good: #047857;
  --good-bg: #f0fdf4;
  --good-border: #86efac;
  --warn: #b45309;
  --warn-bg: #fefce8;
  --warn-border: #fde68a;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fca5a5;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 4px 6px rgba(15, 23, 42, 0.07), 0 20px 40px rgba(15, 23, 42, 0.10);
  --shadow-xl: 0 8px 16px rgba(15, 23, 42, 0.10), 0 24px 56px rgba(15, 23, 42, 0.15);

  /* Type scale — use these tokens for any new font-size; existing raw px values
     will be migrated over time. Hero/display sizes stay distinct. */
  --text-xxs: 11px;
  --text-xs:  12px;
  --text-sm:  13px;
  --text-base:14px;
  --text-md:  15px;
  --text-lg:  17px;
  --text-xl:  22px;
  --text-display: 32px;
  --text-hero:    36px;
  --text-mega:    40px;

  /* Spacing scale — pair with type scale for consistent vertical rhythm. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* Color aliases — these are intentional duplicates that exist for semantic clarity.
     If you change one of these hex values, also change the canonical one.
       --muted     == --ink-muted == --steel        (mid-grey,   #64748b)
       --secondary == --ink-soft                    (dark-grey,  #334155)
       --steel-light, --steel-lighter — used in a handful of accents (#94a3b8 / #cbd5e1) */
}

/* === Global a11y focus ring ===
   System default focus styles vary across browsers; this gives every interactive
   control a consistent, high-contrast outline when keyboard-focused. Mouse clicks
   do not trigger :focus-visible, so this doesn't add visual noise for pointer users. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 4px;
}
input.field:focus-visible,
select.field:focus-visible {
  /* form fields already have a focus glow via .field input:focus — don't double up. */
  outline: none;
}

/* Subtle blueprint grid background */
html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  background-image:
    linear-gradient(rgba(226, 232, 240, 0.4) 1px, transparent 1px),
    linear-gradient(90deg, rgba(226, 232, 240, 0.4) 1px, transparent 1px);
  background-size: 24px 24px;
}

body { min-height: 100vh; }
a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-light); text-decoration: underline; }

/* Header */
.brand {
  font-weight: 800;
  font-size: 22px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
/* Page head */
.page-head {
  max-width: 1200px;
  margin: 28px auto 8px;
  padding: 0 24px;
}
.breadcrumb { font-size: 13px; color: var(--ink-muted); margin-bottom: 12px; font-weight: 600; }
.breadcrumb a { color: var(--ink-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--primary); }
.page-head h1 {
  font-size: 32px;
  line-height: 1.2;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.page-head .lede { color: var(--ink-soft); margin-top: 8px; font-size: 16px; max-width: 800px; line-height: 1.6; }
.page-hero-photo {
  margin: 18px 0 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,0.04), 0 4px 16px rgba(15,23,42,0.08);
  background: #e2e8f0;
}
.page-hero-photo img {
  display: block;
  width: 100%;
  height: 260px;
  object-fit: cover;
  object-position: center;
}
@media (max-width: 768px) {
  .page-hero-photo img { height: 180px; }
}
@media (max-width: 480px) {
  .page-hero-photo { margin: 14px -8px 0; border-radius: 8px; }
  .page-hero-photo img { height: 150px; }
}

/* Main calculator layout */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px 32px;
}
.calc {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(320px, 1fr) minmax(380px, 1.2fr);
  align-items: start;
}
@media (max-width: 900px) { .calc { grid-template-columns: 1fr; } }
.result-stack {
  display: grid;
  gap: 16px;
  position: sticky;
  top: 16px;
  align-self: start;
}
@media (max-width: 900px) { .result-stack { position: static; } }

/* Panels */
.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin-bottom: 16px;
  font-weight: 800;
}
.panel > h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--secondary);
  margin: 22px -20px 14px;
  padding: 12px 20px 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: linear-gradient(90deg, #f8fafc 0%, #fff 100%);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid #eef2f7;
}
.panel > h3:first-of-type { margin-top: 18px; }
/* H3 that immediately follows the metric-grid (i.e. "Cost breakdown" in the
   result panel) gets a tighter top margin. Replaces 50 inline style="margin-top:6px"
   attributes across the calc HTMLs. */
.panel .metric-grid + h3 { margin-top: 6px; }
.panel > h3::before {
  content: "";
  width: 4px; height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
  flex: 0 0 auto;
}

/* Form fields */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--secondary); margin-bottom: 5px; font-weight: 600; }
.field input, .field select {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 15px; color: var(--ink); background: white;
  font-family: inherit; transition: all 0.15s;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .row { grid-template-columns: 1fr; } }
.help { font-size: 12px; color: var(--ink-muted); margin-top: 4px; line-height: 1.4; }

/* Result summary card */
.summary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 14px;
  color: white;
  position: relative;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(30, 58, 138, 0.22);
}
.summary::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}
.summary-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  position: relative; z-index: 1;
}
.summary-value {
  font-size: 36px;
  font-weight: 800;
  color: white;
  margin-top: 4px;
  letter-spacing: -0.01em;
  position: relative; z-index: 1;
}
.summary-sub { color: rgba(255, 255, 255, 0.9); font-size: 13px; margin-top: 6px; position: relative; z-index: 1; }

/* Metrics grid */
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
@media (max-width: 640px) { .metric-grid { grid-template-columns: 1fr; } }
.metric {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  transition: all 0.15s;
}
.metric:hover { border-color: var(--line-strong); box-shadow: var(--shadow-sm); }
.metric-label {
  color: var(--ink-muted); font-size: 11px;
  font-weight: 800; text-transform: uppercase; letter-spacing: 0.04em;
}
.metric-value { margin-top: 4px; font-weight: 800; font-size: 17px; font-variant-numeric: tabular-nums; color: var(--ink); }

/* Segmented control */
.segmented {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: #f1f5f9;
  margin-bottom: 10px;
}
.segmented label { cursor: pointer; position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segment-body {
  display: block; text-align: center;
  padding: 9px 10px;
  border-radius: 8px;
  /* slate-600, gives ~5.7:1 contrast vs the slate-100 segmented background (passes WCAG AA) */
  color: #475569;
  font-size: 13px; font-weight: 700;
  border: 1px solid transparent;
  transition: all 0.15s;
}
.segmented input:checked + .segment-body {
  color: var(--primary);
  background: white;
  border-color: rgba(30, 58, 138, 0.2);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

/* Lead/bid-check */
.lead-box {
  border: 1px solid rgba(59, 130, 246, 0.3);
  background: linear-gradient(135deg, #eff6ff 0%, #f8fbff 100%);
  border-radius: 12px;
  padding: 18px;
}
.lead-box h3 { margin-top: 0; color: var(--primary); text-transform: uppercase; font-size: 13px; font-weight: 800; letter-spacing: 0.04em; }
.source-list { display: grid; gap: 10px; font-size: 13px; color: var(--ink-soft); line-height: 1.6; }
.source-list strong { color: var(--secondary); }
.source-list a { color: var(--primary); font-weight: 600; text-decoration: underline; }

/* Pills */
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; background: #fff; color: var(--ink-muted); font-size: 12px; font-weight: 700; }
.pill.good { border-color: var(--good-border); background: var(--good-bg); color: var(--good); }
.pill.warn { border-color: var(--warn-border); background: var(--warn-bg); color: var(--warn); }
.pill.error { border-color: var(--danger-border); background: var(--danger-bg); color: var(--danger); }
.mini-copy { font-size: 13px; color: var(--ink-soft); margin: -8px 0 14px; line-height: 1.5; }

/* Preset grid */
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
@media (max-width: 900px) { .preset-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .preset-grid { grid-template-columns: 1fr; } }
.preset-btn {
  text-align: left;
  border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; background: #fff;
  cursor: pointer; font-family: inherit; color: var(--ink);
  transition: all 0.15s;
}
.preset-btn:hover { border-color: var(--primary); background: var(--primary-bg); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.preset-btn strong { display: block; font-size: 13px; font-weight: 700; }
.preset-btn span { display: block; color: var(--ink-muted); font-size: 12px; margin-top: 2px; }

/* Tables */
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
th, td { padding: 9px 6px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); }
thead tr { background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); border-bottom: 2px solid var(--line); }
th { color: var(--ink-muted); font-size: 11px; text-transform: uppercase; font-weight: 800; letter-spacing: 0.04em; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: #f8fafc; }
td.qty, th.qty { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
td.range, th.range { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.unit-note { display: block; font-size: 11px; color: var(--ink-muted); font-weight: 400; margin-top: 2px; }
.cat-divider td { background: #f1f5f9; font-weight: 800; font-size: 11px; text-transform: uppercase; color: var(--secondary); padding: 8px 6px; letter-spacing: 0.04em; }
.total td { border-top: 2px solid var(--secondary); border-bottom: none; padding: 12px 6px; font-size: 15px; font-weight: 800; background: #f8fafc; }
.footnote { font-size: 12px; color: var(--ink-soft); margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); line-height: 1.5; }
.footnote strong { color: var(--secondary); }

/* Donut chart */
.chart-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: center; }
@media (max-width: 540px) { .chart-wrap { grid-template-columns: 1fr; } }
.donut { width: 148px; height: 148px; border-radius: 50%; background: conic-gradient(var(--primary) 0 100%); position: relative; margin: 0 auto; }
.donut::after { content: ""; position: absolute; inset: 36px; background: #fff; border-radius: 50%; }
.donut-label { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; text-align: center; width: 80px; line-height: 1.15; }
.donut-label strong { display: block; font-size: 17px; font-weight: 800; color: var(--ink); }
.donut-label small { display: block; font-size: 11px; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; margin-top: 2px; }
.legend { display: grid; gap: 10px; }
.legend-row { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn {
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 700;
  color: var(--secondary);
  transition: all 0.15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-bg); }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff; border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.22);
}
.btn-primary:hover { color: #fff; box-shadow: 0 4px 12px rgba(30, 58, 138, 0.32); }
.copy-status { font-size: 12px; color: var(--good); min-height: 14px; margin-top: 6px; font-weight: 600; }

/* Advanced toggle */
.toggle-advanced {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px;
  background: #f8fafc;
  border: 1px dashed var(--line-strong);
  border-radius: 8px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--secondary);
  margin: 18px 0 0; user-select: none; width: 100%; font-family: inherit;
}
.toggle-advanced:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-bg); }
.toggle-advanced .chevron { transition: transform .2s; }
.toggle-advanced[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.advanced-options {
  display: none; padding: 14px 14px 0; margin: 0 0 4px;
  border: 1px solid var(--line); border-top: 0;
  border-radius: 0 0 10px 10px; background: #fbfdff;
}
.advanced-options.open { display: block; }

/* Long-form content sections */
.content { max-width: 1200px; margin: 32px auto 0; padding: 0 24px; display: grid; gap: 24px; }
.content-card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.content-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 12px; color: var(--ink); letter-spacing: -0.01em; }
.content-card h3 { font-size: 16px; font-weight: 800; margin: 18px 0 8px; color: var(--secondary); }
.content-card p, .content-card li { font-size: 15px; color: var(--ink-soft); margin-bottom: 8px; line-height: 1.65; }
.content-card ul, .content-card ol { padding-left: 22px; margin: 6px 0 12px; }
.content-card table { margin: 12px 0; }
.content-card td, .content-card th { font-size: 14px; }
.content-card strong { color: var(--secondary); }
.content-card em { color: var(--ink); }

/* FAQ */
.faq details {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; margin-bottom: 8px;
  background: #fff; transition: all 0.15s;
}
.faq details[open] { border-color: var(--primary-soft); background: #fbfdff; box-shadow: var(--shadow-sm); }
.faq summary {
  cursor: pointer; font-weight: 700; font-size: 15px;
  color: var(--ink); list-style: none;
  padding-right: 24px; position: relative;
  transition: color 0.15s;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 0; top: 0; font-weight: 800; color: var(--primary); font-size: 20px; transition: transform 0.15s; }
.faq details[open] summary { color: var(--primary); }
.faq details[open] summary::after { content: "\2212"; }
.faq details p { margin-top: 10px; color: var(--ink-soft); line-height: 1.65; font-size: 14px; }

.section-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fbfdff; margin-top: 14px; }
.section-card h4 { margin: 0 0 6px; font-size: 13px; color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 800; }

/* ───────────────────────────────────────────────────────────
   LANDING PAGE — calculator directory
   Cards are compact (directory entries, not feature cards).
   Hover stays in blue/navy/steel — never orange/red.
   ─────────────────────────────────────────────────────────── */
.calc-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  max-width: 1200px;
  margin: 0 auto;
}
.calc-list a {
  display: block;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  position: relative;
}
.calc-list a:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  text-decoration: none;
}
/* Dim non-hovered siblings slightly when one card is being hovered */
.calc-list:hover a:not(:hover) { opacity: 0.55; }

.calc-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.calculator-icon {
  width: 24px; height: 24px;
  flex: 0 0 24px;
  color: var(--steel);
  transition: color 0.15s;
}
.calculator-icon svg { width: 100%; height: 100%; display: block; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.calc-list a:hover .calculator-icon { color: var(--primary); }

.calc-list strong,
.calc-card-top strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.calc-list a:hover strong { color: var(--primary); }

.calc-card-summary,
.calc-list span {
  display: block;
  color: var(--ink-muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Search */
.calc-search { margin: 12px 0 16px; }
.calc-search input {
  width: 100%; padding: 12px 16px;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px; outline: none;
  background: #fff;
  transition: all 0.15s;
}
.calc-search input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12); }

.calc-section { margin-top: 28px; }
.calc-section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 0 0 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
}
.calc-section h2::before {
  content: "";
  width: 4px; height: 18px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
}
.calc-section.is-empty { display: none; }

/* Footer */
/* Responsive */
@media (max-width: 768px) {
  .page-head h1 { font-size: 26px; }
  .page-head .lede { font-size: 15px; }
  .summary-value { font-size: 30px; }
  .content-card { padding: 22px; }
  .content-card h2 { font-size: 20px; }
}

/* Print */
@media print {
  body { background: white; background-image: none; }
  .panel, .content-card { box-shadow: none; page-break-inside: avoid; }
  .actions { display: none; }
}

/* === Sliders (auto-enhanced from data-slider) ============================
   Layout (full panel width):
     row 1: label (LEFT)  |  big live value + small number input (RIGHT)
     row 2: full-width slider
     row 3: min tick (LEFT)  |  max tick (RIGHT)

   Always spans the whole .row container so sliders never get squeezed
   into a half-width grid cell.
*/
.slider-field {
  display: block !important;
  width: 100%;
  margin-bottom: 14px;
  grid-column: 1 / -1 !important;     /* always span the whole .row */
  contain: layout;                    /* isolate layout effects from neighbors */
}
/* CLS fix: reserve the slider widget's full height on the parent BEFORE JS
   enhancement runs, so when enhanceSliders() rewrites the DOM there is no
   visible jump. ~110px = label (24) + value+input row (40) + slider track (24)
   + tick row (18) + small buffer. Applies to both pre- and post-enhancement
   states because the input keeps its data-slider attribute throughout. */
.field:has(input[data-slider]),
.field.slider-field {
  min-height: 110px;
}
/* The slider track must always reach panel edges */
.slider-field .slider-zone,
.slider-field .slider-range {
  width: 100% !important;
  max-width: none !important;
  box-sizing: border-box;
}
.slider-field > label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.02em;
  margin-bottom: 0;
  font-weight: 600;
}
.slider-field .slider-zone {
  display: block;
  margin-top: 4px;
}
.slider-field .slider-zone .slider-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
/* The head reads as "Label   ............   20 ft  [_20_]"
   Label is part of the parent .slider-field, so we move it up via JS into the head. */
.slider-field .slider-head .slider-head-label {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.slider-field > input[type="number"] {
  width: 70px;
  padding: 6px 8px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}
.slider-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
  margin-left: auto;       /* push value to the right; input sits after */
}
.slider-field .slider-head > input[type="number"] {
  width: 60px !important;
  padding: 5px 8px;
  margin-left: 8px;
  font-size: 14px;
  font-weight: 700;
  text-align: right;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  box-sizing: border-box;
}
.slider-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  display: block;
  height: 8px;
  background: transparent;
  outline: none;
  margin: 6px 0;
  cursor: pointer;
  padding: 0;
  border: 0;
}
/* === Webkit: gradient lives on the track pseudo (the input's own bg is hidden under it) === */
.slider-range::-webkit-slider-runnable-track {
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--primary) 0%,
    var(--primary) var(--p, 0%),
    #E2E8F0 var(--p, 0%),
    #E2E8F0 100%);
}
/* === Firefox: native progress fill === */
.slider-range::-moz-range-track {
  height: 8px; border-radius: 999px; background: #E2E8F0;
}
.slider-range::-moz-range-progress {
  height: 8px; border-radius: 999px; background: var(--primary);
}
.slider-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.30);
  margin-top: -8px;
  transition: background 0.15s, transform 0.1s;
}
.slider-range::-webkit-slider-thumb:hover {
  background: var(--primary-light);
  transform: scale(1.08);
}
.slider-range::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 3px solid #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.30);
}
.slider-range::-moz-range-thumb:hover { background: var(--primary-light); }
.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 4px;
}
.slider-ticks .slider-min { text-align: left; }
.slider-ticks .slider-max { text-align: right; }

/* === Live-compute box ==================================================== */
.live-box {
  background: var(--primary-bg);
  border: 1px solid var(--primary-soft);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 4px 0 10px;
}
.live-box .live-label {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.live-box .live-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

/* === Cost-breakdown horizontal bars ======================================
   Stacked layout per row:
     row-head:  category name (left)  +  $ amount (right)
     track:     full-width bar
*/
.cost-bars {
  display: grid;
  gap: 14px;
  margin: 12px 0 8px;
}
.cost-bars-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}
.cost-bars-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  text-transform: capitalize;
}
.cost-bars-mid {
  text-align: right;
  line-height: 1.1;
}
.cost-bars-mid strong {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.cost-bars-mid small {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.bar-row {
  display: block;
}
.bar-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  gap: 10px;
}
.bar-label {
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bar-track {
  display: block;
  width: 100%;
  height: 12px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 1px 2px rgba(15,23,42,0.10) inset;
}
.bar-value {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* === Pill icons (badges) ================================================= */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill-icon { flex: 0 0 auto; }
.pill.good   { color: var(--good); background: var(--good-bg); border-color: var(--good-border); }
.pill.warn   { color: var(--warn); background: var(--warn-bg); border-color: var(--warn-border); }
.pill.error  { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }

/* === Metric card icons =================================================== */
.metric { position: relative; }
.metric-icon {
  display: block;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

  .bar-label { font-size: 13px; }
}

/* === Related calculators grid =========================================== */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.related-card {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
}
.related-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
  text-decoration: none;
}
.related-card strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 4px;
}
.related-card span {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.4;
}

/* === Sources used / Last updated / Tax credit note ====================== */
.sources-group { font-size: 13px; color: var(--ink-soft); margin: 4px 0; line-height: 1.5; }
.sources-group strong { color: var(--ink); margin-right: 4px; }
.sources-group a { color: var(--primary); }
.source-internal { color: var(--ink-muted); font-style: italic; }

.last-updated {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.last-updated svg { vertical-align: middle; }

.tax-credit-note {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.45;
  margin: 10px 0;
}

/* === Site header / brand === */
.site-header {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.site-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: inherit;
}
.brand:hover { text-decoration: none; color: inherit; }
.brand-icon {
  width: 34px; height: 34px;
  border-radius: 7px;
  display: block;
  flex: 0 0 auto;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.brand-tag {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin-top: 2px;
}
.site-nav { margin-left: auto; display: flex; gap: 22px; align-items: center; }
.site-nav a {
  font-size: 14px;
  font-weight: 600;
  color: var(--steel);
  text-decoration: none;
  letter-spacing: -0.005em;
  transition: color 0.15s;
}
.site-nav a:hover { color: var(--ink); text-decoration: none; }
@media (max-width: 640px) {
  .site-header-inner { padding: 10px 16px; gap: 12px; }
  .brand-tag { display: none; }
  .site-nav { gap: 14px; }
  .site-nav a { font-size: 13px; }
}

/* === Site footer === */
.site-footer {
  background: var(--panel);
  border-top: 1px solid var(--line);
  margin-top: 56px;
  color: var(--steel);
}
.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px 24px 24px;
  display: grid;
  gap: 28px;
  grid-template-columns: 1.4fr 1fr 1.2fr;
}
@media (max-width: 760px) {
  .site-footer-inner { grid-template-columns: 1fr; gap: 22px; }
}
.site-footer-brand .brand { margin-bottom: 10px; }
.site-footer-brand p {
  font-size: 13px;
  line-height: 1.55;
  color: var(--steel);
  margin: 0;
  max-width: 320px;
}
.site-footer-links { display: flex; flex-direction: column; gap: 8px; }
.site-footer-links h3,
.site-footer-links h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 4px;
}
.site-footer-links a {
  font-size: 14px;
  color: var(--steel);
  text-decoration: none;
  font-weight: 600;
}
.site-footer-links a:hover { color: var(--ink); text-decoration: underline; }
.site-footer-disclaimer {
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}
.site-footer-disclaimer h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 6px;
}
.site-footer-bar {
  border-top: 1px solid var(--line);
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  max-width: 1200px;
  margin: 0 auto;
}
@media (max-width: 540px) {
  .site-footer-bar { flex-direction: column; gap: 6px; padding: 14px 16px; }
}

/* === Page shell (for home, about, sources, legal) ====================== */
.page-shell { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }
.page-shell .page-head { margin-bottom: 24px; padding: 0; }
.page-shell .page-section { margin-bottom: 36px; max-width: 820px; }
.page-shell .page-section h2 { font-size: 22px; font-weight: 700; margin: 0 0 12px; letter-spacing: -0.01em; color: var(--ink); }
.page-shell .page-section h3 { font-size: 16px; font-weight: 700; margin: 16px 0 6px; color: var(--ink); }
.page-shell .page-section p { color: var(--steel); line-height: 1.65; margin: 0 0 12px; max-width: 720px; }
.page-shell .page-section p code { font-family: ui-monospace, monospace; font-size: 13px; padding: 1px 6px; background: var(--bg); border-radius: 4px; border: 1px solid var(--line); color: var(--primary); }
ul.plain-list { list-style: none; padding: 0; margin: 0 0 12px; }
ul.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--line-soft); color: var(--steel); line-height: 1.55; }
ul.plain-list li:last-child { border-bottom: 0; }
ul.plain-list strong { color: var(--ink); }

/* Hero */
.page-hero { padding: 36px 0 28px; border-bottom: 1px solid var(--line); margin-bottom: 36px; }
.page-hero-inner {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 44px;
  align-items: center;
}
.page-hero-inner h1 { font-size: 40px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; margin: 0 0 14px; color: var(--ink); }
@media (max-width: 640px) { .page-hero-inner h1 { font-size: 28px; } .page-hero-inner h1 br { display: none; } }
.page-hero-lede { font-size: 17px; color: var(--steel); line-height: 1.6; max-width: 680px; margin: 0 0 22px; }
.page-hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.page-hero-photo-home {
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(15,23,42,0.06), 0 12px 32px rgba(15,23,42,0.12);
  background: var(--line-soft);
  aspect-ratio: 16 / 10;
}
.page-hero-photo-home img { display: block; width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 900px) {
  .page-hero-inner { grid-template-columns: 1fr; gap: 24px; }
  .page-hero-photo-home { aspect-ratio: 16 / 9; }
}

.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.section-link { font-size: 13px; font-weight: 600; color: var(--primary); text-decoration: none; }
.section-link:hover { text-decoration: underline; }

/* Popular grid (home page) */
.popular-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.popular-card { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; text-decoration: none; color: inherit; transition: all 0.15s; }
.popular-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.popular-card .pop-icon { flex: 0 0 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; background: rgba(30,58,138,0.08); color: var(--primary); border-radius: 8px; }
.popular-card .pop-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; display: block; }
.popular-card:hover .pop-icon { background: rgba(30,58,138,0.14); }
.popular-card .pop-text { flex: 1 1 auto; min-width: 0; }
.popular-card .pop-text strong { display: block; font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 3px; }
.popular-card .pop-text span { display: block; font-size: 12px; color: var(--muted); line-height: 1.4; }

/* Category grid */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.cat-card { display: flex; gap: 14px; align-items: flex-start; padding: 18px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: inherit; transition: all 0.15s; }
.cat-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.cat-card .cat-icon { flex: 0 0 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; background: rgba(30,58,138,0.08); color: var(--primary); border-radius: 10px; }
.cat-card .cat-icon svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; display: block; }
.cat-card:hover .cat-icon { background: rgba(30,58,138,0.14); }
.cat-card .cat-text { flex: 1 1 auto; min-width: 0; }
.cat-card .cat-text strong { display: block; font-size: 15px; font-weight: 700; color: var(--ink); margin-bottom: 4px; }
.cat-card .cat-text span { display: block; font-size: 13px; color: var(--muted); line-height: 1.45; }

/* "How it works" 4-step grid */
.how-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.how-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; position: relative; }
.how-num { position: absolute; top: 14px; right: 16px; font-family: ui-monospace, monospace; font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.how-card h3 { font-size: 15px; font-weight: 700; margin: 0 0 8px; color: var(--ink); }
.how-card p { font-size: 13px; color: var(--steel); line-height: 1.55; margin: 0; }

/* Trust + sources cards */
.trust-list { padding-left: 0; list-style: none; display: grid; gap: 8px; }
.trust-list li { padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 14px; color: var(--steel); }
.trust-list strong { color: var(--ink); margin-right: 6px; }
.trust-note { font-size: 13px; color: var(--muted); margin-top: 12px; }
.trust-note a { color: var(--primary); }

.source-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px 22px; margin-bottom: 12px; }
.source-card h3 { font-size: 16px; font-weight: 700; margin: 0 0 6px; color: var(--ink); }
.source-card p { font-size: 14px; color: var(--steel); margin: 0; line-height: 1.6; }
.source-card code { font-family: ui-monospace, monospace; font-size: 12px; background: var(--bg); padding: 1px 5px; border-radius: 3px; border: 1px solid var(--line); }

/* CTA strip */
.cta-section { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 32px; text-align: center; margin-top: 12px; }
.cta-section h2 { margin: 0 0 8px; font-size: 22px; font-weight: 700; color: var(--ink); }
.cta-section p { color: var(--steel); margin: 0 0 14px; font-size: 15px; }
.cta-row { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* Contact form */
.contact-form { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 22px; }
.contact-form .field textarea { width: 100%; padding: 11px 13px; border: 1px solid var(--line); border-radius: 7px; font-size: 14px; font-family: inherit; color: var(--ink); background: var(--panel); resize: vertical; }

/* CLS fix: reserve vertical space for JS-populated calc-page blocks so the
   render of <Render.renderSourcesUsed>, <Render.renderLastUpdated>, and the
   appended <section id="related-calcs"> doesn't push neighbors after first
   paint. Sized to roughly match typical populated heights — overshooting by
   a few px is fine; undershooting causes the original CLS. */
#sources-used { min-height: 220px; contain: layout; }
#last-updated { min-height: 24px; }
#tax-credit-note { min-height: 0; }
#related-calcs  { min-height: 220px; contain: layout; }

/* === Calculator directory page — spacing between category groups ======== */
.calc-category {
  max-width: 1200px;
  margin: 48px auto 0;          /* generous breathing room between groups */
  padding: 0 24px;
  position: relative;
}
.calc-category:first-of-type { margin-top: 28px; }
.calc-category h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.calc-category h2::before {
  content: "";
  display: inline-block;
  width: 4px; height: 22px;
  background: var(--primary);
  border-radius: 2px;
}
/* Indent the calculator grid under each heading so it feels grouped */
.calc-category .calc-list {
  margin-left: 16px;
  padding-left: 0;
}
@media (max-width: 640px) {
  .calc-category { margin: 36px auto 0; padding: 0 16px; }
  .calc-category .calc-list { margin-left: 8px; }
  .calc-category h2 { font-size: 20px; }
}
