:root {
  --canvas: #FCFBF9;
  --surface: #FFFFFF;
  --surface-sunken: #F4F2EE;
  --surface-subtle: #EFECE6;
  --ink: #0F172A;
  --ink-secondary: #334155;
  --ink-muted: #64748B;
  --border: #E4E1DA;
  --border-strong: #CFCBC1;
  --emerald: #047857;
  --emerald-hover: #065F46;
  --emerald-tint: #ECFDF5;
  --brass: #B45309;
  --brass-tint: #FEF3C7;
  --night: #0F172A;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: var(--emerald-tint);
  color: var(--emerald-hover);
}

a {
  color: var(--emerald);
  text-underline-offset: 3px;
}

.num, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: 64px;
  background: rgba(252, 251, 249, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.015em;
  white-space: nowrap;
}

.brand img {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: block;
}

.brand-tag {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  border-left: 1px solid var(--border-strong);
  padding-left: 10px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
}

.nav-links a {
  text-decoration: none;
  color: var(--ink-secondary);
  font-size: 14px;
  font-weight: 500;
}

.nav-links a:hover { color: var(--ink); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 7px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
  white-space: nowrap;
}

.btn:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--emerald);
  outline-offset: 2px;
}

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

.btn-primary:hover { background: var(--emerald-hover); }

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

.btn-secondary:hover {
  background: var(--surface-sunken);
  border-color: var(--ink-muted);
}

.btn-ghost {
  background: var(--surface-sunken);
  color: var(--ink);
  border-color: var(--border);
}

.btn-ghost:hover { background: var(--surface-subtle); }

/* Hero */
.hero {
  padding: clamp(32px, 5vw, 56px) 0 28px;
}

.privacy-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--emerald-tint);
  color: var(--emerald-hover);
  border: 1px solid rgba(4, 120, 87, 0.22);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 18px;
}

.privacy-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  flex-shrink: 0;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  gap: clamp(20px, 3vw, 40px);
  align-items: end;
}

h1 {
  margin: 0 0 14px;
  font-size: clamp(2.05rem, 3.8vw, 3.05rem);
  font-weight: 650;
  line-height: 1.09;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.hero-lead {
  margin: 0;
  font-size: 16.5px;
  color: var(--ink-secondary);
  max-width: 60ch;
}

.hero-privacy-card {
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 13.5px;
  color: var(--ink-secondary);
}

.hero-privacy-card strong {
  display: block;
  color: var(--ink);
  margin-bottom: 6px;
  font-size: 14px;
}

.hero-privacy-card code {
  display: block;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre;
  color: var(--ink);
  overflow-x: auto;
}

/* Workbench Shell */
.workbench-section {
  padding: 8px 0 56px;
}

.workbench {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 14px 36px -12px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.wb-topbar {
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.scenario-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-btn {
  background: var(--surface);
  color: var(--ink-secondary);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 130ms ease;
}

.tab-btn:hover { color: var(--ink); border-color: var(--ink-muted); }

.tab-btn[aria-selected="true"] {
  background: var(--night);
  color: #FFFFFF;
  border-color: var(--night);
}

.wb-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Upload Dropzone */
.dropzone {
  border-bottom: 1px solid var(--border);
  background: #FAF8F5;
  padding: 12px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: background-color 140ms ease;
}

.dropzone.drag-over {
  background: var(--emerald-tint);
}

.dropzone-info {
  font-size: 13px;
  color: var(--ink-secondary);
}

.dropzone-info strong { color: var(--ink); }

.file-error {
  width: 100%;
  color: #B91C1C;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  display: none;
}

.file-error.visible { display: block; }

/* KPI Strip */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--border);
}

.kpi-card {
  padding: 18px 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card:last-child { border-right: none; }

.kpi-card.highlight-leak {
  background: var(--brass-tint);
}

.kpi-card.highlight-true {
  background: var(--emerald-tint);
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-muted);
}

.kpi-card.highlight-leak .kpi-label { color: #92400E; }
.kpi-card.highlight-true .kpi-label { color: var(--emerald-hover); }

.kpi-value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.35rem, 2.2vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  line-height: 1.15;
}

.kpi-card.highlight-leak .kpi-value { color: #92400E; }
.kpi-card.highlight-true .kpi-value { color: var(--emerald-hover); }

.kpi-sub {
  font-size: 12px;
  color: var(--ink-secondary);
}

/* Main Workbench Body */
.wb-body {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 0.78fr);
}

.wb-main {
  padding: 20px 22px;
  border-right: 1px solid var(--border);
  min-width: 0;
}

.wb-controls {
  padding: 20px;
  background: var(--surface-sunken);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h2, .panel-heading h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  letter-spacing: -0.015em;
}

.panel-note {
  font-size: 12.5px;
  color: var(--ink-muted);
}

/* Chart */
.chart-wrap {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 14px 14px 10px;
  margin-bottom: 18px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-secondary);
  margin-bottom: 8px;
}

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

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.swatch-occ { background: rgba(4, 120, 87, 0.25); border: 2px solid var(--emerald); }
.swatch-snap { background: transparent; border-top: 2px dashed var(--brass); height: 0; width: 16px; }
.swatch-gap { background: rgba(180, 83, 9, 0.16); border: 1px solid rgba(180, 83, 9, 0.45); }

.chart-svg {
  width: 100%;
  height: 230px;
  display: block;
}

.chart-tooltip {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--surface-sunken);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--ink-secondary);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
}

/* Breakdown Grid */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.breakdown-box {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 13px 15px;
  background: var(--canvas);
}

.breakdown-box h4 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
}

.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}

.kv-row:last-child { border-bottom: none; padding-top: 6px; font-weight: 650; color: var(--ink); }
.kv-row span:first-child { color: var(--ink-secondary); }
.kv-row .amt { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.kv-row .amt-leak { color: var(--brass); }
.kv-row .amt-good { color: var(--emerald-hover); }

/* Controls Form */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.field label span {
  font-weight: 500;
  color: var(--ink-muted);
}

.field input[type="number"], .field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
}

.field select { font-family: var(--font-sans); }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
}

.toggle-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--emerald);
  cursor: pointer;
}

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

/* Ledger Table */
.ledger-details {
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  background: var(--surface);
}

.ledger-details summary {
  padding: 11px 15px;
  background: var(--surface-sunken);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.table-scroll {
  overflow-x: auto;
  max-height: 360px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-sunken);
  border-bottom: 1px solid var(--border-strong);
  padding: 8px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--ink-secondary);
  white-space: nowrap;
}

thead th.r, tbody td.r { text-align: right; }

tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr:hover { background: var(--canvas); }
tbody tr.peak-row { background: var(--emerald-tint); }
tbody tr.cutoff-row { background: var(--brass-tint); }

/* Client Breakdown Table for Multi-Client */
.multi-client-wrap {
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
  display: none;
}

.multi-client-wrap.visible { display: block; }

/* Sections below workbench */
.section {
  padding: 44px 0;
  border-top: 1px solid var(--border);
}

.section h2 {
  margin: 0 0 10px;
  font-size: clamp(1.5rem, 2.5vw, 2.05rem);
  font-weight: 620;
  letter-spacing: -0.025em;
}

.section-lead {
  margin: 0 0 26px;
  color: var(--ink-secondary);
  max-width: 66ch;
}

.how-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.how-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.step-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--emerald-hover);
  background: var(--emerald-tint);
  padding: 3px 9px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.how-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 650;
}

.how-card p {
  margin: 0;
  font-size: 14px;
  color: var(--ink-secondary);
}

/* Pricing */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.price-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.price-card.featured {
  border-color: var(--emerald);
  box-shadow: 0 10px 28px -12px rgba(4, 120, 87, 0.18);
}

.price-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
}

.price-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.price-tag {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 700;
  color: var(--ink);
}

.price-desc {
  margin: 0 0 16px;
  color: var(--ink-secondary);
  font-size: 14px;
}

.price-list {
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
  color: var(--ink-secondary);
}

.price-list li {
  padding-left: 20px;
  position: relative;
}

.price-list li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--emerald);
  font-weight: 700;
}

.price-cta-wrap {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* Footer */
.site-footer {
  background: var(--night);
  color: #CBD5E1;
  padding: 36px 0;
  font-size: 13.5px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.site-footer a {
  color: #A7F3D0;
  text-decoration: none;
}

.site-footer a:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 960px) {
  .hero-grid, .wb-body { grid-template-columns: 1fr; }
  .wb-main { border-right: none; border-bottom: 1px solid var(--border); }
  .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-card:nth-child(2) { border-right: none; }
  .kpi-card:nth-child(1), .kpi-card:nth-child(2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 720px) {
  .nav-links, .brand-tag { display: none; }
  .how-grid, .pricing-grid, .breakdown-grid { grid-template-columns: 1fr; }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi-card { border-right: none; border-bottom: 1px solid var(--border); }
  .kpi-card:last-child { border-bottom: none; }
}

/* Clean Print / PDF Statement */
@media print {
  body { background: #FFFFFF; font-size: 11px; }
  .site-header, .hero, .wb-topbar, .dropzone, .wb-controls, .section, .site-footer { display: none !important; }
  .workbench { border: none; box-shadow: none; }
  .wb-body { grid-template-columns: 1fr; }
  .wb-main { border: none; padding: 0; }
  .table-scroll { max-height: none; overflow: visible; }
  .ledger-details { break-inside: avoid; }
}
