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

:root {
  --color-bg: #faf9f7;
  --color-surface: #ffffff;
  --color-text: #1e1e1e;
  --color-text-muted: #5c5c5c;
  --color-border: #e0dcd5;
  --color-accent: #2a5c4a;
  --color-accent-hover: #1e4537;
  --color-highlight: #f0f7f4;
  --color-warning: #b45309;
  --color-danger: #b91c1c;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  --max-width: 1024px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.site-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0 1rem;
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--color-text);
  font-weight: 600;
  font-size: 1.05rem;
}

.logo svg {
  color: var(--color-accent);
}

.site-nav {
  display: flex;
  gap: 1.5rem;
}

.site-nav a {
  text-decoration: none;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  font-weight: 500;
  transition: color 0.15s;
}

.site-nav a:hover {
  color: var(--color-accent);
}

/* Hero */
.hero {
  background: var(--color-highlight);
  padding: 2.5rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--color-border);
}

.hero-content {
  max-width: 640px;
  margin: 0 auto;
}

.hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

.hero-sub {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Main layout */
main {
  flex: 1;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem 3rem;
  width: 100%;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: var(--font-sans);
  white-space: nowrap;
}

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

.btn-secondary:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-outline {
  background: transparent;
  border-color: var(--color-border);
  color: var(--color-text-muted);
}

.btn-outline:hover {
  border-color: var(--color-danger);
  color: var(--color-danger);
}

/* Worksheet */
.worksheet {
  margin-top: 2rem;
}

.worksheet-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.worksheet-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.worksheet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Tabs */
.scenario-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.6rem 1.2rem;
  font-size: 0.95rem;
  font-weight: 600;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--color-text-muted);
  transition: color 0.15s, border-color 0.15s;
  font-family: var(--font-sans);
}

.tab:hover {
  color: var(--color-text);
}

.tab.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

/* Scenario panels */
.scenario-panel {
  display: none;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.scenario-panel.active {
  display: block;
}

.scenario-inputs {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
  min-width: 160px;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.input-group .hint {
  font-size: 0.78rem;
  color: var(--color-text-muted);
}

.calc-input {
  padding: 0.55rem 0.75rem;
  font-size: 0.95rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  transition: border-color 0.15s;
  width: 100%;
}

.calc-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(42, 92, 74, 0.1);
}

.input-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.checkbox-row {
  align-items: center;
}

.checkbox-group {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent);
}

.checkbox-group label {
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
}

/* Result card */
.scenario-result {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.result-card {
  background: var(--color-highlight);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.4rem 0;
  font-size: 0.95rem;
}

.result-label {
  color: var(--color-text-muted);
  font-weight: 500;
}

.result-value {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.result-total {
  border-top: 1px solid var(--color-border);
  margin-top: 0.4rem;
  padding-top: 0.5rem;
  font-size: 1.1rem;
}

.result-total .result-value {
  color: var(--color-accent);
}

/* Comparison section */
.comparison {
  margin-top: 2rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.comparison h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.comparison-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.comparison-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  min-width: 500px;
}

.comparison-table th,
.comparison-table td {
  padding: 0.6rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--color-border);
}

.comparison-table th:first-child,
.comparison-table td:first-child {
  text-align: left;
  font-weight: 600;
}

.comparison-table th {
  background: var(--color-highlight);
  font-weight: 700;
  color: var(--color-accent);
}

.highlight-row td {
  font-weight: 700;
}

.total-row td {
  color: var(--color-accent);
  font-size: 0.95rem;
}

/* Assumptions */
.assumptions {
  margin-top: 2.5rem;
}

.assumptions h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

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

.assumption-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.assumption-card h3 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: var(--color-accent);
}

.assumption-card p {
  font-size: 0.88rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

/* Supporting content */
.supporting-content {
  margin-top: 2.5rem;
}

.supporting-content h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.content-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.content-col h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--color-text);
}

.content-col p {
  font-size: 0.92rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  margin-bottom: 0.75rem;
}

.mistakes-list {
  list-style: none;
  padding: 0;
}

.mistakes-list li {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--color-border);
  line-height: 1.5;
}

.mistakes-list li:last-child {
  border-bottom: none;
}

.mistakes-list strong {
  color: var(--color-warning);
}

/* Footer */
.site-footer {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: 1.5rem 1rem;
  margin-top: 2rem;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  text-align: center;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

.footer-disclaimer {
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.footer-nav {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.footer-nav a {
  color: var(--color-text-muted);
  text-decoration: none;
}

.footer-nav a:hover {
  color: var(--color-accent);
}

.footer-meta {
  font-size: 0.8rem;
}

.footer-meta a {
  color: var(--color-accent);
  text-decoration: none;
}

/* Responsive */
@media (max-width: 700px) {
  .hero h1 {
    font-size: 1.4rem;
  }

  .content-columns {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .worksheet-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .input-row {
    flex-direction: column;
  }

  .scenario-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tab {
    white-space: nowrap;
    padding: 0.5rem 0.9rem;
    font-size: 0.88rem;
  }

  .worksheet-actions {
    width: 100%;
    justify-content: flex-start;
  }
}

@media print {
  .site-header,
  .site-footer,
  .worksheet-actions,
  .scenario-tabs,
  .btn,
  .assumptions,
  .supporting-content,
  .hero {
    display: none !important;
  }

  .scenario-panel {
    display: block !important;
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ccc;
    margin-bottom: 1rem;
  }

  .comparison {
    display: block !important;
    box-shadow: none;
    border: 1px solid #ccc;
  }

  #comparison-section[hidden] {
    display: block !important;
  }

  body {
    background: #fff;
    font-size: 12px;
  }
}



/* Factory-injected deployment helpers. The AI owns the site design above this block. */
.ad-unit {
  width: min(100%, 720px);
  min-height: 120px;
  margin: 24px auto;
  display: block;
}

.legal-page {
  width: min(900px, calc(100% - 32px));
  margin: 40px auto;
}

.factory-fallback-nav {
  width: min(900px, calc(100% - 32px));
  margin: 24px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.95rem;
}

.factory-fallback-nav a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}
