/*
  DripBack BI Dashboard — Editorial-Data Aesthetic
  =================================================
  Why editorial? The founder-terminal (W167) is dense, monospaced, green-on-black —
  optimised for real-time monitoring. This dashboard is for *thinking*, not watching.
  Serif body + generous white-space + narrative copy between charts signals
  "annual-report credibility" to enterprise buyers who see it during demos.
  Chart.js canvases sit inside article-like sections so data and interpretation
  live side-by-side — a pattern proven by The Pudding, FT Visual, and Economist.

  Palette:
    --ink    deep charcoal (not pure black — easier on print)
    --paper  warm off-white
    --accent DripBack electric-blue (#1A6BFF — enterprise, not start-up)
    --pos    teal-green for positive delta
    --neg    brick-red for negative delta
    --rule   thin 1px rule, old-newspaper tradition
*/

:root {
  /* e11-licht: Dark-Flip (Timo 31.07) — warme Paper-Familie wird
     warme Dark-Familie, Akzente für Dark-Kontrast angehoben. */
  --ink:     #F2F0EB;
  --ink2:    #C9C6BE;
  --ink3:    #8F8C84;
  --paper:   #0D0C0A;
  --paper2:  #16140F;
  --paper3:  #201D16;
  --accent:  #4C8DFF;
  --accent2: #85AFFF;
  --pos:     #34D399;
  --neg:     #F87171;
  --warn:    #FBBF24;
  --rule:    #3A362C;
  --serif:   "Georgia", "Times New Roman", serif;
  --sans:    "Inter", "Helvetica Neue", Arial, sans-serif;
  --mono:    "JetBrains Mono", "Courier New", monospace;
  --pad:     20px;
  --col:     720px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

/* ── Masthead ──────────────────────────────────────────────────────────────── */

#masthead {
  border-bottom: 3px solid var(--ink);
  padding: 18px var(--pad) 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mast-brand {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink);
}

.mast-brand span {
  color: var(--accent);
}

.mast-meta {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink3);
  text-align: right;
  line-height: 1.4;
}

.mast-meta strong {
  color: var(--ink2);
}

/* ── Kicker line (issue date / tagline) ───────────────────────────────────── */

#kicker {
  border-bottom: 1px solid var(--rule);
  padding: 7px var(--pad);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink3);
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  background: var(--paper2);
}

#kicker .sep { color: var(--rule); }

/* ── Page layout ──────────────────────────────────────────────────────────── */

#page {
  max-width: 1140px;
  margin: 0 auto;
  padding: 36px var(--pad) 60px;
}

/* ── Feature headline (lead story) ───────────────────────────────────────── */

.feature-headline {
  border-bottom: 1px solid var(--rule);
  padding-bottom: 20px;
  margin-bottom: 32px;
}

.feature-headline h1 {
  font-family: var(--serif);
  font-size: 2.4rem;
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin-bottom: 10px;
}

.feature-headline .lede {
  font-family: var(--sans);
  font-size: 1.05rem;
  color: var(--ink2);
  max-width: 680px;
  line-height: 1.55;
}

/* ── Section headers ──────────────────────────────────────────────────────── */

.section-rule {
  border: none;
  border-top: 2px solid var(--ink);
  margin: 40px 0 8px;
}

.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 20px;
}

.section-header h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--ink);
}

.section-header .section-tag {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
}

/* ── Key-stat pull-quotes ─────────────────────────────────────────────────── */

.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-bottom: 28px;
}

.stat-block {
  background: var(--paper);
  padding: 16px 20px;
}

.stat-block .stat-label {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 6px;
}

.stat-block .stat-value {
  font-family: var(--serif);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 4px;
}

.stat-block .stat-delta {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink3);
}

.stat-block .stat-delta.pos { color: var(--pos); }
.stat-block .stat-delta.neg { color: var(--neg); }
.stat-block .stat-delta.warn { color: var(--warn); }

/* ── Two-column chart + narrative ─────────────────────────────────────────── */

.chart-narrative {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 32px;
  align-items: start;
  margin-bottom: 40px;
}

.chart-narrative.flip {
  grid-template-columns: 340px 1fr;
}

.chart-narrative.wide {
  grid-template-columns: 1fr;
}

.chart-box {
  border: 1px solid var(--rule);
  background: var(--paper2);
  padding: 16px 20px 12px;
}

.chart-box .chart-title {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 6px;
}

.chart-box canvas {
  width: 100% !important;
  max-height: 240px;
}

.narrative {
  font-family: var(--serif);
  font-size: 0.95rem;
  color: var(--ink2);
  line-height: 1.7;
}

.narrative p { margin-bottom: 12px; }
.narrative p:last-child { margin-bottom: 0; }

.narrative strong { color: var(--ink); font-weight: 700; }

.narrative .callout {
  border-left: 3px solid var(--accent);
  padding: 10px 14px;
  background: var(--paper2);
  font-style: italic;
  margin: 14px 0;
  color: var(--ink2);
  font-size: 0.9rem;
}

/* ── Funnel table (editorial style) ──────────────────────────────────────── */

.funnel-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 13px;
  margin-bottom: 28px;
}

.funnel-table thead th {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
  text-align: left;
  padding: 6px 10px 6px 0;
  border-bottom: 2px solid var(--ink);
}

.funnel-table tbody td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--rule);
  vertical-align: middle;
  color: var(--ink);
}

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

.funnel-table .stage-name {
  font-weight: 600;
  color: var(--ink);
}

.funnel-table .count-cell {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  text-align: right;
  white-space: nowrap;
}

.funnel-table .pct-cell {
  text-align: right;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 12px;
}

.funnel-bar-wrap {
  width: 120px;
  height: 8px;
  background: var(--paper3);
  border-radius: 0;
  overflow: hidden;
}

.funnel-bar-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.8s ease;
}

/* ── Cohort grid ──────────────────────────────────────────────────────────── */

.cohort-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin-bottom: 28px;
}

.cohort-cell {
  background: var(--paper);
  padding: 14px 16px;
}

.cohort-week {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 4px;
}

.cohort-val {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
}

.cohort-sub {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink3);
  margin-top: 2px;
}

/* ── Revenue projection table ─────────────────────────────────────────────── */

.rev-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--sans);
  font-size: 13px;
  margin-bottom: 28px;
}

.rev-table thead th {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
  text-align: left;
  padding: 6px 10px 6px 0;
  border-bottom: 2px solid var(--ink);
}

.rev-table thead th:not(:first-child) { text-align: right; }

.rev-table tbody td {
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--rule);
  color: var(--ink);
}

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

.rev-table .product-name { font-weight: 600; }

.rev-table .num-cell {
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
}

.rev-table .num-cell.pos { color: var(--pos); }
.rev-table .num-cell.neg { color: var(--neg); }

.rev-table tfoot td {
  font-weight: 700;
  border-top: 2px solid var(--ink);
  padding: 8px 10px 6px 0;
}

/* ── Source attribution (small) ───────────────────────────────────────────── */

.data-source {
  font-family: var(--sans);
  font-size: 10px;
  color: var(--ink3);
  border-top: 1px solid var(--rule);
  padding-top: 6px;
  margin-top: 6px;
}

/* ── Access gate overlay ──────────────────────────────────────────────────── */

#gate-overlay {
  position: fixed;
  inset: 0;
  background: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.gate-box {
  border: 2px solid var(--ink);
  padding: 36px 40px;
  max-width: 360px;
  width: 100%;
  text-align: center;
}

.gate-box h2 {
  font-family: var(--serif);
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--ink);
}

.gate-box p {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink3);
  margin-bottom: 20px;
}

.gate-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  background: var(--paper2);
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  margin-bottom: 12px;
  outline: none;
}

.gate-box input:focus { border-color: var(--accent); }

.gate-box button {
  width: 100%;
  padding: 10px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  border: none;
  cursor: pointer;
  text-transform: uppercase;
}

.gate-box button:hover { background: var(--accent); }

.gate-err {
  font-family: var(--sans);
  font-size: 11px;
  color: var(--neg);
  margin-top: 8px;
  display: none;
}

/* ── Footer ───────────────────────────────────────────────────────────────── */

#footer {
  border-top: 2px solid var(--ink);
  padding: 14px var(--pad);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--ink3);
  background: var(--paper2);
  flex-wrap: wrap;
  gap: 8px;
}

#footer strong { color: var(--ink); }

#last-updated { color: var(--ink3); }

/* ── Loading skeleton ─────────────────────────────────────────────────────── */

.skeleton {
  background: linear-gradient(90deg, var(--paper2) 25%, var(--paper3) 50%, var(--paper2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 2px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .chart-narrative,
  .chart-narrative.flip {
    grid-template-columns: 1fr;
  }

  .cohort-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .feature-headline h1 {
    font-size: 1.7rem;
  }

  #masthead {
    flex-direction: column;
    gap: 6px;
  }

  .mast-meta { text-align: left; }
}

@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr 1fr; }
  .cohort-grid { grid-template-columns: 1fr 1fr; }
  .funnel-bar-wrap { width: 60px; }
}
