/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:        #1a2744;
  --amber:       #f59e0b;
  --amber-dark:  #d97706;
  --bg:          #f1f5f9;
  --card:        #ffffff;
  --text:        #1e293b;
  --text-muted:  #64748b;
  --border:      #e2e8f0;
  --success:     #059669;
  --success-bg:  #ecfdf5;
  --radius:      8px;
  --shadow:      0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
}

/* ===== Header ===== */
header {
  background: var(--navy);
  color: #fff;
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  gap: 1rem;
}

.logo {
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  letter-spacing: -.02em;
}
.logo span { color: var(--amber); }

nav {
  display: flex;
  gap: 0.1rem;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
nav::-webkit-scrollbar { display: none; }

nav a {
  color: rgba(255,255,255,.75);
  text-decoration: none;
  font-size: .8rem;
  padding: .38rem .65rem;
  border-radius: 4px;
  white-space: nowrap;
  transition: background .15s, color .15s;
}
nav a:hover, nav a.active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

/* ===== Main ===== */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ===== Page Header ===== */
.page-header { margin-bottom: 1.25rem; }
.page-header h1 {
  font-size: clamp(1.4rem, 4vw, 1.9rem);
  color: var(--navy);
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: .35rem;
}
.page-header .subtitle {
  color: var(--text-muted);
  font-size: .9rem;
}
.page-meta {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: .3rem;
}
.hero .page-meta {
  color: rgba(255,255,255,.55);
  margin-top: .5rem;
}

/* ===== Ad Slots ===== */
.ad-slot {
  background: #f8f9fa;
  border: 1px dashed #ccc;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #bbb;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 1.25rem;
}
.ad-leaderboard { height: 90px; min-height: 90px; }
.ad-rectangle { height: 250px; min-height: 250px; max-width: 336px; width: 100%; }
.ad-banner { height: 90px; min-height: 90px; }

/* ===== Calc Card ===== */
.calc-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.calc-card > h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 1.1rem;
  padding-bottom: .6rem;
  border-bottom: 2px solid var(--amber);
  display: inline-block;
}

/* ===== Form ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
}
.form-full { grid-column: 1 / -1; }

label {
  font-size: .83rem;
  font-weight: 600;
  color: var(--text);
}
label .unit {
  font-weight: 400;
  color: var(--text-muted);
}

input[type="number"], select {
  padding: .6rem .75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  color: var(--text);
  background: #fff;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
  -moz-appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px rgba(245,158,11,.15);
}

/* ===== Results ===== */
.results-box {
  background: var(--success-bg);
  border: 1.5px solid #a7f3d0;
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-top: 1.1rem;
}
.results-box.hidden { display: none; }

.results-box h3 {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--success);
  margin-bottom: .65rem;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: .65rem;
}

.result-item {
  background: #fff;
  border-radius: 6px;
  padding: .7rem .75rem;
  text-align: center;
  box-shadow: var(--shadow);
}
.result-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1.1;
}
.result-label {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

.result-note {
  margin-top: .7rem;
  font-size: .78rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ===== Disclaimer ===== */
.disclaimer {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: .65rem 1rem;
  font-size: .78rem;
  color: #92400e;
  margin-top: .85rem;
  line-height: 1.55;
}

/* ===== Related Calculators ===== */
.related {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem 1.5rem;
  margin-bottom: 1.25rem;
}
.related h3 {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  margin-bottom: .6rem;
}
.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
}
.related-links a {
  background: var(--bg);
  border: 1.5px solid var(--border);
  color: var(--navy);
  text-decoration: none;
  padding: .35rem .8rem;
  border-radius: 20px;
  font-size: .82rem;
  font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
}
.related-links a:hover {
  background: var(--amber);
  border-color: var(--amber);
  color: #fff;
}

/* ===== FAQ ===== */
.faq {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.faq h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .9rem;
}
details.faq-item {
  border-bottom: 1px solid var(--border);
}
details.faq-item:last-child { border-bottom: none; }

details.faq-item summary {
  font-weight: 600;
  font-size: .875rem;
  color: var(--text);
  cursor: pointer;
  padding: .8rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  list-style: none;
  user-select: none;
}
details.faq-item summary::-webkit-details-marker { display: none; }
details.faq-item summary::after {
  content: '+';
  font-size: 1.2rem;
  color: var(--amber);
  flex-shrink: 0;
  transition: transform .2s;
}
details[open].faq-item summary::after { content: '−'; }

.faq-a {
  font-size: .85rem;
  color: var(--text-muted);
  padding-bottom: .85rem;
  line-height: 1.7;
}

/* ===== Homepage Grid ===== */
.hero {
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  padding: 2rem 1.75rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.hero::after {
  content: '';
  position: absolute;
  right: -40px; bottom: -40px;
  width: 220px; height: 220px;
  background: rgba(245,158,11,.12);
  border-radius: 50%;
}
.hero h1 {
  font-size: clamp(1.5rem, 5vw, 2.2rem);
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: .6rem;
}
.hero h1 span { color: var(--amber); }
.hero p {
  font-size: .9rem;
  color: rgba(255,255,255,.75);
  max-width: 520px;
  line-height: 1.65;
}

.section-label {
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

.calc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.calc-tile {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.1rem;
  text-decoration: none;
  color: var(--text);
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s, transform .1s;
  display: flex;
  align-items: flex-start;
  gap: .85rem;
}
.calc-tile:hover {
  border-color: var(--amber);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.calc-tile-icon {
  font-size: 1.9rem;
  flex-shrink: 0;
  width: 2.2rem;
  text-align: center;
  line-height: 1;
}
.calc-tile-body h2 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .2rem;
}
.calc-tile-body p {
  font-size: .78rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.badge {
  display: inline-block;
  background: var(--amber);
  color: #fff;
  font-size: .6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .1rem .38rem;
  border-radius: 3px;
  margin-top: .3rem;
}
.badge.badge-green { background: var(--success); }

/* ===== Info Box ===== */
.info-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.info-box h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .5rem;
}

/* ===== Table ===== */
.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
  margin-top: .5rem;
}
.breakdown-table th, .breakdown-table td {
  padding: .55rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.breakdown-table th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  font-weight: 600;
}
.breakdown-table tr:last-child td { border-bottom: none; font-weight: 700; color: var(--navy); }
.breakdown-table td:last-child { text-align: right; }

/* ===== Footer ===== */
footer {
  background: var(--navy);
  color: rgba(255,255,255,.65);
  padding: 2rem 1rem 1.5rem;
  text-align: center;
  font-size: .78rem;
  margin-top: 1rem;
}
footer a { color: var(--amber); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: .25rem 1rem;
  margin-bottom: .75rem;
}
footer p + p { margin-top: .4rem; }

/* ===== Builder's Advice / Pro Tip ===== */
.pro-tip {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  position: relative;
  overflow: hidden;
}
.pro-tip::after {
  content: '🔨';
  position: absolute;
  right: 1.25rem; top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  opacity: .12;
  pointer-events: none;
}
.pro-tip h3 {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--amber);
  margin-bottom: .65rem;
}
.pro-tip p {
  font-size: .875rem;
  color: rgba(255,255,255,.82);
  line-height: 1.78;
}
.pro-tip p + p { margin-top: .6rem; }
.pro-tip strong { color: #fff; }

/* ===== Guide / Expert Content ===== */
.guide {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.guide > h2 {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 1rem;
  padding-bottom: .55rem;
  border-bottom: 2px solid var(--amber);
  display: inline-block;
}
.guide h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--navy);
  margin: 1.1rem 0 .35rem;
}
.guide p {
  font-size: .875rem;
  color: var(--text-muted);
  line-height: 1.78;
  margin-top: .35rem;
}
.guide strong { color: var(--text); }

/* ===== Print ===== */
@media print {
  header, footer, .ad-slot, .related, nav { display: none !important; }
  main { max-width: 100%; padding: 0; }
  .calc-card { box-shadow: none; border: 1px solid #ddd; page-break-inside: avoid; }
  .results-box { border: 2px solid #059669; }
  .page-header h1 { color: #000; }
}

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .header-inner { flex-direction: column; height: auto; padding: .6rem 0; gap: .4rem; }
  nav { width: 100%; }
  main { padding: 1rem .75rem 2.5rem; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .calc-grid { grid-template-columns: 1fr; }
  .hero { padding: 1.5rem 1.25rem; }
}
@media (max-width: 380px) {
  .form-grid { grid-template-columns: 1fr; }
}
