:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --accent-border: #bfdbfe;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-subtle: #1e293b;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #1f2937;
  --border-strong: #334155;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --accent-border: rgba(59, 130, 246, 0.35);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.mono {
  font-family: var(--font-mono);
}

.tabular {
  font-variant-numeric: tabular-nums;
}

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

a:hover {
  text-decoration: underline;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
}

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

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, #2563eb, #0891b2);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 13.5px;
  font-weight: 500;
}

.nav-links a {
  color: var(--text-secondary);
}

.nav-links a:hover {
  color: var(--text);
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-subtle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-subtle:hover {
  border-color: var(--border-strong);
  color: var(--text);
  text-decoration: none;
}

.kofi-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ff5e5b;
  display: inline-block;
}

/* Main Container */
.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 36px 24px 72px;
}

/* Hero */
.hero {
  margin-bottom: 28px;
}

.hero-eyebrow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.pill-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 3.2vw, 36px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  font-weight: 700;
}

.hero-lead {
  margin: 0;
  max-width: 740px;
  color: var(--text-secondary);
  font-size: 16px;
}

/* 3 Clean Stat Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 26px 0 32px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--text);
  line-height: 1.2;
}

.kpi-unit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
}

.kpi-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Section Cards */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 26px 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.section-title {
  margin: 0 0 5px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

.section-desc {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  max-width: 680px;
}

/* Clean Minimal Controls */
.controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.segmented {
  display: inline-flex;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.segmented button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.segmented button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  font-weight: 600;
}

/* Inline Advanced Options Disclosure */
.advanced-disclosure {
  margin-top: 10px;
}

.advanced-disclosure summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.advanced-disclosure summary::-webkit-details-marker {
  display: none;
}

.advanced-disclosure summary:hover {
  color: var(--text);
}

.advanced-panel {
  margin-top: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
}

.check-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.check-toggle input {
  accent-color: var(--accent);
  cursor: pointer;
}

/* Plot Containers */
.plot-wrap {
  width: 100%;
  min-height: 460px;
}

.plot-wrap-bar {
  width: 100%;
  min-height: 440px;
}

.chart-footnote {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.legend-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot-solid {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

.dot-hollow {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: var(--surface);
  display: inline-block;
}

.line-pareto {
  width: 16px;
  height: 0;
  border-top: 2px solid var(--text);
  display: inline-block;
}

.line-pareto-dashed {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--text-muted);
  display: inline-block;
}

/* Takeaway Callout */
.takeaway-strip {
  margin-top: 18px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  font-size: 14px;
  color: var(--text);
}

.takeaway-strip strong {
  color: var(--accent);
}

/* Interactive Quota Planner */
.planner-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 24px;
  align-items: start;
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.preset-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.preset-btn:hover,
.preset-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.slider-row {
  margin-bottom: 14px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13.5px;
  margin-bottom: 5px;
}

.slider-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.planner-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}

.planner-results {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
}

.planner-results h3 {
  margin: 0 0 14px;
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.planner-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.planner-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.planner-stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.planner-stat-val {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.planner-breakdown {
  font-size: 13px;
  color: var(--text-secondary);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.planner-breakdown ul {
  margin: 8px 0 0;
  padding-left: 18px;
}

.planner-breakdown li {
  margin-bottom: 4px;
}

/* Collapsible Deep-Dive Drawers */
.drawer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.drawer > summary {
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.drawer > summary::-webkit-details-marker {
  display: none;
}

.drawer > summary:hover {
  background: var(--surface-subtle);
}

.drawer-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

.drawer-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.drawer-chevron {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  white-space: nowrap;
}

.drawer[open] .drawer-chevron::after {
  content: "Hide";
}

.drawer:not([open]) .drawer-chevron::after {
  content: "Expand";
}

.drawer-body {
  padding: 4px 24px 24px;
  border-top: 1px solid var(--border);
}

/* Data Table inside Drawer */
.table-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 14px;
}

.search-input {
  padding: 7px 11px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  min-width: 220px;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

table.data-table th,
table.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

table.data-table thead th {
  background: var(--surface-subtle);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  cursor: pointer;
  user-select: none;
}

table.data-table thead th:hover {
  color: var(--text);
}

table.data-table tbody tr:hover {
  background: var(--surface-subtle);
}

table.data-table tbody tr:last-child td {
  border-bottom: none;
}

.num-col {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
}

.badge-measured {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent);
}

.badge-scaled {
  background: var(--surface-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.badge-pareto {
  background: rgba(22, 163, 74, 0.14);
  color: #15803d;
  margin-left: 6px;
}

[data-theme="dark"] .badge-pareto {
  color: #4ade80;
}

.model-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 7px;
  vertical-align: middle;
}

/* Methodology Grid inside Drawer */
.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.method-block {
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface-subtle);
}

.method-block h3 {
  margin: 0 0 8px;
  font-size: 14.5px;
  font-weight: 700;
}

.method-block p,
.method-block li {
  font-size: 13px;
  color: var(--text-secondary);
}

.method-block ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.formula {
  display: block;
  margin: 10px 0;
  padding: 9px 11px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  overflow-x: auto;
}

/* Subtle Ko-fi Support Strip */
.support-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 22px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  margin: 28px 0 24px;
}

.support-copy {
  max-width: 680px;
}

.support-copy strong {
  display: block;
  font-size: 14.5px;
  margin-bottom: 2px;
}

.support-copy span {
  font-size: 13.5px;
  color: var(--text-secondary);
}

.btn-kofi {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s;
}

.btn-kofi:hover {
  border-color: #ff5e5b;
  background: color-mix(in srgb, #ff5e5b 10%, var(--surface));
  text-decoration: none;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

@media (max-width: 900px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .planner-grid,
  .method-grid {
    grid-template-columns: 1fr;
  }
  .nav-links {
    display: none;
  }
}

@media (max-width: 600px) {
  .container {
    padding: 20px 14px 48px;
  }
  .section-card {
    padding: 18px 16px;
  }
}

/* Blog & Article Styles */
.blog-list {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}

.post-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  box-shadow: var(--shadow-sm);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}

.post-card:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.post-card h2 {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--text);
}

.post-card p {
  margin: 0 0 12px;
  font-size: 14.5px;
  color: var(--text-secondary);
}

.post-readmore {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--accent);
}

.article-wrap {
  max-width: 780px;
  margin: 0 auto;
}

.breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.article-header h1 {
  margin: 0 0 12px;
  font-size: clamp(26px, 3.4vw, 36px);
  line-height: 1.18;
  letter-spacing: -0.025em;
}

.article-body {
  font-size: 16px;
  line-height: 1.72;
  color: var(--text);
}

.article-body h2 {
  margin: 34px 0 12px;
  font-size: 22px;
  letter-spacing: -0.015em;
}

.article-body h3 {
  margin: 24px 0 8px;
  font-size: 17px;
}

.article-body p {
  margin: 0 0 16px;
}

.tldr-box {
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  margin: 22px 0 28px;
}

.tldr-box h2 {
  margin: 0 0 8px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.tldr-box ul {
  margin: 0;
  padding-left: 20px;
  font-size: 14.5px;
}

.tldr-box li {
  margin-bottom: 5px;
}

.article-chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin: 26px 0;
  box-shadow: var(--shadow-sm);
}

.article-chart-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 4px;
}

.article-chart-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 12px;
}

.faq-list {
  display: grid;
  gap: 12px;
  margin: 18px 0 28px;
}

.faq-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
}

.faq-item h3 {
  margin: 0 0 6px;
  font-size: 15.5px;
}

.faq-item p {
  margin: 0;
  font-size: 14.5px;
  color: var(--text-secondary);
}

.tldr-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 12px;
}

.tldr-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

.tldr-stat-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.tldr-stat-num {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}

.tldr-stat-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

@media (max-width: 640px) {
  .tldr-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
