:root {
  color-scheme: light;
  --page-plane: #f9f9f7;
  --surface-1: #fcfcfb;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --gridline: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.1);
  --success-text: #006300;

  --series-1: #2a78d6;
  --series-2: #008300;
  --series-3: #e87ba4;
  --series-4: #eda100;
  --series-5: #1baf7a;
  --series-6: #eb6834;
  --series-7: #4a3aa7;
  --series-8: #e34948;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme='light'])) {
    color-scheme: dark;
    --page-plane: #0d0d0d;
    --surface-1: #1a1a19;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --gridline: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.1);
    --success-text: #0ca30c;

    --series-1: #3987e5;
    --series-2: #008300;
    --series-3: #d55181;
    --series-4: #c98500;
    --series-5: #199e70;
    --series-6: #d95926;
    --series-7: #9085e9;
    --series-8: #e66767;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --page-plane: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --success-text: #0ca30c;

  --series-1: #3987e5;
  --series-2: #008300;
  --series-3: #d55181;
  --series-4: #c98500;
  --series-5: #199e70;
  --series-6: #d95926;
  --series-7: #9085e9;
  --series-8: #e66767;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--page-plane);
  color: var(--text-primary);
  line-height: 1.6;
}

.report {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 20px 64px;
}

header.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}

header.report-header h1 {
  font-size: 1.6rem;
  margin: 0 0 4px;
}

header.report-header .subtitle {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

button.chip-btn {
  font: inherit;
  font-size: 0.85rem;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-primary);
  cursor: pointer;
}
button.chip-btn:hover { background: var(--gridline); }

#load-status {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: -12px 0 24px;
}
#load-status.load-error { color: var(--series-8); }

section.report-section {
  margin-bottom: 40px;
}

section.report-section h2 {
  font-size: 1.15rem;
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.narrative p {
  color: var(--text-secondary);
  margin: 0 0 12px;
  font-size: 0.98rem;
}
.narrative strong { color: var(--text-primary); }

.exec-summary {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 28px;
}
.exec-summary h2 { margin-top: 0; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
}
.stat-label {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.stat-value {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 600;
}
.stat-sub {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.chart-container {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
}

.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-empty { color: var(--text-muted); text-align: center; padding: 40px 0; }

.chart-grid { stroke: var(--gridline); stroke-width: 1; }
.chart-axis-label { font-size: 10px; fill: var(--text-muted); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { stroke: var(--surface-1); stroke-width: 2; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-end-label { font-size: 11px; font-weight: 600; }
.chart-crosshair { stroke: var(--baseline); stroke-width: 1; pointer-events: none; }

.chart-bar { }
.chart-bar-label { font-size: 12px; fill: var(--text-secondary); }
.chart-bar-value { font-size: 12px; fill: var(--text-secondary); }

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.legend-item {
  font-size: 0.82rem;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-swatch, .tt-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-tooltip {
  position: absolute;
  background: var(--text-primary);
  color: var(--surface-1);
  font-size: 0.78rem;
  padding: 8px 10px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 10;
  line-height: 1.5;
  white-space: nowrap;
}
.tt-title { font-weight: 600; margin-bottom: 4px; }

footer.report-footer {
  margin-top: 48px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

@media (max-width: 600px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  header.report-header { flex-direction: column; }
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
}

.login-card h1 {
  font-size: 1.3rem;
  margin: 0 0 4px;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin: 0 0 24px;
}

.login-card label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.login-card input {
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--page-plane);
  color: var(--text-primary);
  margin-bottom: 16px;
}
.login-card input:focus {
  outline: 2px solid var(--series-1);
  outline-offset: 1px;
}

.login-submit {
  background: var(--series-1);
  color: #fff;
  border: none;
  padding: 12px;
  font-weight: 600;
  margin-top: 4px;
}
.login-submit:hover { opacity: 0.92; }
.login-submit:disabled { opacity: 0.6; cursor: default; }

.login-error {
  color: var(--series-8);
  font-size: 0.85rem;
  margin: 12px 0 0;
}
