:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-soft: #eff6ff;
  --success: #15803d;
  --success-soft: #f0fdf4;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Sticky Top Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.brand-badge {
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

/* Global Unit Switcher */
.unit-toggle {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

.unit-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.unit-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Layout Container */
.container {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3.5rem;
}

.hero {
  margin-bottom: 1.75rem;
}

.hero h1 {
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.2;
  margin: 0 0 0.5rem;
  letter-spacing: -0.025em;
}

.hero p {
  margin: 0;
  color: var(--text-muted);
  max-width: 72ch;
  font-size: 1.02rem;
}

/* Calculator Two-Column Grid */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 820px) {
  .calc-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin-top: 0;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

/* Form Inputs */
.form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

@media (max-width: 520px) {
  .form-row,
  .form-row-2 {
    grid-template-columns: 1fr;
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.9rem;
}

.form-row .field,
.form-row-2 .field {
  margin-bottom: 0;
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="number"],
select {
  width: 100%;
  padding: 0.58rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  font-family: inherit;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.12);
}

.unit-tag {
  position: absolute;
  right: 0.65rem;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  pointer-events: none;
}

/* Result Readouts */
.kpi-box {
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 1.1rem;
  margin-bottom: 1rem;
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--primary);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.15;
  margin: 0.25rem 0;
}

.kpi-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.metric-tile {
  background: var(--surface-alt);
  border-radius: 7px;
  padding: 0.75rem;
}

.metric-tile .m-label {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-tile .m-val {
  font-size: 1.12rem;
  font-weight: 700;
  margin-top: 0.15rem;
}

/* Progress Bar (Threshold Headroom) */
.cliff-meter {
  margin: 1rem 0;
}

.cliff-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.progress-track {
  width: 100%;
  height: 10px;
  background: var(--surface-alt);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.25s ease, background 0.25s ease;
}

.progress-fill.warn {
  background: #d97706;
}

.progress-fill.danger {
  background: #dc2626;
}

/* Status Callouts */
.callout {
  border-radius: 7px;
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  margin-bottom: 1rem;
  border-left: 4px solid var(--primary);
  background: var(--surface-alt);
}

.callout.success {
  background: var(--success-soft);
  border-left-color: var(--success);
  color: #14532d;
}

.callout.warning {
  background: var(--warning-soft);
  border-left-color: var(--warning);
  color: #78350f;
}

.callout.danger {
  background: var(--danger-soft);
  border-left-color: var(--danger);
  color: #7f1d1d;
}

/* Buttons & Affiliate CTAs */
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1rem;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-alt);
  text-decoration: none;
}

.affiliate-box {
  margin-top: 1.1rem;
  padding: 0.95rem 1.05rem;
  border: 1px dashed #93c5fd;
  background: #f8fbff;
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.affiliate-box p {
  margin: 0;
  font-size: 0.86rem;
  color: var(--text);
  max-width: 44ch;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--surface-alt);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tr.highlight-row {
  background: var(--success-soft);
  font-weight: 600;
}

/* Ad Slot & SEO Content Sections */
.ad-slot {
  margin: 2rem 0;
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.seo-section {
  margin-top: 2.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.6rem;
}

.seo-section h2 {
  margin-top: 0;
  font-size: 1.25rem;
}

.seo-section h3 {
  font-size: 1.02rem;
  margin-bottom: 0.35rem;
}

/* Related Tools Directory Grid */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.15s;
}

.tool-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
  text-decoration: none;
}

.tool-card h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: var(--text);
}

.tool-card p {
  margin: 0 0 0.8rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.tool-card .card-link {
  font-size: 0.83rem;
  font-weight: 700;
  color: var(--primary);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 2rem 1.25rem;
  font-size: 0.83rem;
  color: var(--text-muted);
}

.footer-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
}
/* Temporarily hide monetization placeholders until ad tags are live */
.affiliate-box,
.ad-slot {
  display: none !important;
}