:root {
  --navy: #0B2A4A;
  --orange: #F59E0B;
  --charcoal: #1F2937;
  --bg: #F8FAFC;
  --surface: #ffffff;
  --border: #E5E7EB;
  --muted: #64748B;
  --success: #16A34A;
  --error: #DC2626;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

[data-theme="dark"] {
  --bg: #101820;
  --surface: #182230;
  --charcoal: #F8FAFC;
  --border: #334155;
  --muted: #CBD5E1;
  --navy: #93C5FD;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.24);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--charcoal);
  line-height: 1.6;
}
a { color: inherit; }
img { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.skip-link:focus {
  position: fixed;
  z-index: 20;
  top: 1rem;
  left: 1rem;
  padding: .75rem 1rem;
  background: var(--orange);
  color: #111827;
}
.container { width: min(1120px, calc(100% - 32px)); margin-inline: auto; }
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.header-inner {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.logo, .footer-brand {
  display: inline-flex;
  align-items: center;
  gap: .65rem;
  color: var(--navy);
  font-weight: 800;
  text-decoration: none;
}
.primary-nav {
  display: none;
  position: absolute;
  inset: 72px 16px auto 16px;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}
.primary-nav.is-open { display: grid; gap: .65rem; }
.primary-nav a, .theme-toggle {
  min-height: 44px;
  padding: .65rem .8rem;
  border-radius: 6px;
  border: 0;
  background: transparent;
  color: var(--charcoal);
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.primary-nav a:hover, .theme-toggle:hover { background: var(--bg); }
.nav-toggle {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-content: center;
  gap: 5px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.nav-toggle span:not(.sr-only) { width: 22px; height: 2px; background: var(--charcoal); display: block; }
.hero {
  padding: clamp(3rem, 8vw, 6rem) 0 2rem;
  background: linear-gradient(180deg, rgba(11,42,74,.08), transparent);
}
.hero-grid { display: grid; gap: 1.5rem; align-items: center; }
.hero h1, .tool-hero h1, .text-page h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.75rem);
  line-height: 1.02;
  letter-spacing: 0;
  color: var(--navy);
}
.hero p, .tool-hero p { font-size: 1.1rem; max-width: 760px; }
.eyebrow {
  color: var(--orange);
  font-weight: 800;
  text-transform: uppercase;
  font-size: .78rem;
  letter-spacing: .08em;
}
.hero-actions { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1.5rem; }
.share-panel {
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
  padding: .65rem .8rem .65rem 1rem;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  box-shadow: 0 10px 28px rgba(15, 23, 42, .07);
  backdrop-filter: blur(14px);
}
.share-panel > span:first-child {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .14em;
  line-height: 1;
}
.share-actions {
  display: flex;
  align-items: center;
  gap: .55rem;
}
.share-button {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--border) 78%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 34%, transparent);
  color: var(--navy);
  line-height: 0;
  opacity: .78;
  cursor: pointer;
  transition: transform .18s ease, opacity .18s ease, background-color .18s ease, border-color .18s ease;
}
.share-button svg {
  width: 23px;
  height: 23px;
  display: block;
  fill: currentColor;
}
.share-button:hover {
  opacity: 1;
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--orange) 38%, transparent);
  background: color-mix(in srgb, var(--orange) 14%, transparent);
}
.share-status {
  min-width: 0;
  color: var(--success);
  font-size: .86rem;
  font-weight: 750;
  line-height: 1;
}
.button, .calc-actions button, .row-actions button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--charcoal);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button.primary, .calc-actions button.primary { background: var(--orange); border-color: var(--orange); color: #111827; }
.button.secondary { border-color: var(--navy); color: var(--navy); }
.hero-panel, .calculator-card, .category-card, .tool-card, .disclaimer-box, .result-card, .text-page section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-panel { padding: 1.25rem; }
.hero-panel span { display: block; color: var(--orange); font-size: 3rem; font-weight: 900; line-height: 1; }
.section { padding: 3rem 0; }
.section-heading {
  display: grid;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.25rem;
}
h2, h3 { color: var(--navy); line-height: 1.2; letter-spacing: 0; }
h2 { font-size: clamp(1.45rem, 3vw, 2rem); }
.search-label { font-weight: 700; }
.tool-search-form { display: grid; gap: .45rem; }
.search-control {
  display: grid;
  gap: .6rem;
}
.search-input, .field input, .field select, .field textarea {
  width: 100%;
  min-height: 46px;
  padding: .7rem .75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--charcoal);
}
.search-button { width: 100%; }
.tool-grid, .category-grid, .result-grid, .related-grid, .info-grid {
  display: grid;
  gap: 1rem;
}
.tool-card {
  display: grid;
  gap: .45rem;
  padding: 1rem;
  min-height: 170px;
  text-decoration: none;
}
.tool-card span {
  color: var(--orange);
  font-size: .78rem;
  font-weight: 800;
}
.tool-card strong { color: var(--navy); font-size: 1.05rem; }
.tool-card p, .category-card p, .hero-panel p, .section-heading p { color: var(--muted); margin: 0; }
.category-card { padding: 1rem; box-shadow: none; }
.category-card div { display: flex; flex-wrap: wrap; gap: .5rem; }
.category-card a, .related-grid a, .prev-next a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  text-decoration: none;
  background: var(--bg);
}
.band { background: var(--surface); border-block: 1px solid var(--border); }
.ad-placeholder {
  min-height: 90px;
  display: grid;
  place-items: center;
  margin: 1.25rem 0;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  background: color-mix(in srgb, var(--surface) 72%, var(--bg));
  font-size: .9rem;
}
.ad-unit {
  display: block;
  min-height: 120px;
  padding: .75rem;
}
.ad-label {
  display: block;
  margin-bottom: .5rem;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
}
.ad-unit .adsbygoogle {
  display: block;
  width: 100%;
  min-height: 90px;
}
.page-shell { padding: 1rem 0 3rem; }
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  align-items: center;
  margin: 1rem 0 2rem;
  color: var(--muted);
  font-size: .92rem;
}
.breadcrumb a { color: var(--navy); }
.tool-hero { max-width: 860px; }
.calculator-card { padding: 1rem; }
.calc-form { display: grid; gap: 1rem; }
.field-grid { display: grid; gap: 1rem; }
.field label { display: block; margin-bottom: .35rem; font-weight: 750; }
.field small { display: block; margin-top: .25rem; color: var(--muted); }
.field-error { display: block; min-height: 1.2em; color: var(--error); font-size: .9rem; }
.form-error { color: var(--error); font-weight: 700; }
.calc-actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.result-section[hidden] { display: none; }
.result-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-top: 1rem; }
.result-card { padding: 1rem; box-shadow: none; }
.result-card span { display: block; color: var(--muted); font-size: .86rem; }
.result-card strong { display: block; color: var(--navy); font-size: 1.35rem; overflow-wrap: anywhere; }
.breakdown {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  white-space: pre-line;
}
.recent-note { color: var(--muted); font-size: .92rem; }
.content-stack { display: grid; gap: 1.25rem; margin-top: 1.5rem; }
.content-stack section, .text-page section { padding: 1rem; }
.check-list { padding-left: 1.2rem; }
.faq-list { display: grid; gap: .75rem; }
details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
}
summary { cursor: pointer; font-weight: 750; color: var(--navy); }
.prev-next { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 1rem; }
.repeat-table { display: grid; gap: .75rem; }
.repeat-row {
  display: grid;
  gap: .65rem;
  padding: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.estimate-sheet {
  margin-top: 1rem;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; }
th, td { border: 1px solid var(--border); padding: .55rem; text-align: left; }
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 2rem 0 1rem;
}
.footer-grid { display: grid; gap: 1rem; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: .75rem; }
.copyright { margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.empty-state { padding: 1rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }

@media (min-width: 760px) {
  .primary-nav {
    display: flex;
    position: static;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    align-items: center;
  }
  .nav-toggle { display: none; }
  .hero-grid { grid-template-columns: minmax(0, 1.5fr) minmax(280px, .65fr); }
  .section-heading { grid-template-columns: 1fr minmax(280px, 360px); }
  .search-control { grid-template-columns: minmax(0, 1fr) auto; }
  .search-button { width: auto; }
  .tool-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .category-grid, .info-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 520px) {
  .share-panel {
    width: 100%;
    justify-content: space-between;
    border-radius: var(--radius);
  }
  .share-status { min-width: 0; }
}

@media (min-width: 1024px) {
  .category-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .info-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media print {
  .site-header, .site-footer, .breadcrumb, .ad-placeholder, .calc-actions, .related-grid, .prev-next { display: none !important; }
  body { background: #fff; color: #000; }
  .container { width: 100%; }
  .calculator-card, .result-card, .content-stack section { box-shadow: none; border-color: #999; }
}
