/* Palette: dark-only instance of the validated reference palette (see the
   dataviz skill's references/palette.md) — this is an internal, single-
   operator tool with no theme toggle, so only the dark steps are used. */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-raised: #202020;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --success: #0ca30c;
  --danger: #e66767;

  --series-1: #3987e5; /* blue — categorical slot 1 */
  --series-1-fill: rgba(57, 135, 229, 0.10);
  --series-2: #d95926; /* orange — categorical slot 2 */
  --series-2-fill: rgba(217, 89, 38, 0.10);
}

* {
  box-sizing: border-box;
}

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

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Login page */
.login-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
}

.login-card h1 {
  font-size: 1.1rem;
  margin: 0 0 1.5rem;
  text-align: center;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid var(--series-1);
  outline-offset: 1px;
}

button {
  padding: 0.65rem;
  background: var(--series-1);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
}

.login-card button {
  width: 100%;
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

.error {
  color: var(--danger);
  font-size: 0.85rem;
  margin: -0.5rem 0 1rem;
  min-height: 1.1em;
}

/* Dashboard shell */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1rem;
  margin: 0;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

header button {
  padding: 0.4rem 0.9rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.loading {
  color: var(--text-muted);
}

.dashboard-section {
  margin-bottom: 2.5rem;
}

.dashboard-section h2 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0 0 1rem;
  font-weight: 600;
}

/* Overview: KPI 2x2 grid on the left, plan-split donut on the right */
.overview-layout {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Stat tiles */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  grid-template-rows: repeat(2, 1fr);
  gap: 1rem;
  flex: 2 1 420px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
}

.stat-tile-hero {
  padding: 1.5rem;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.stat-value {
  /* Proportional figures, not tabular-nums, for a large standalone number —
     equal-width digits make it look loose at display sizes. */
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text-primary);
}

.stat-tile-hero .stat-value {
  font-size: 2.25rem;
}

.stat-sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.35rem;
}

/* Plan split donut */
.plan-split-card {
  flex: 1 1 340px;
  max-width: 420px;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.donut-center-value {
  fill: var(--text-primary);
  font-size: 22px;
  font-weight: 600;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.donut-center-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.donut-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.donut-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.donut-legend-label {
  color: var(--text-secondary);
}

.donut-legend-value {
  color: var(--text-primary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Trend charts */
.trend-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

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

.chart-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.75rem;
}

.chart-svg-wrap {
  position: relative;
  width: 100%;
}

.chart-svg-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.gridline {
  stroke: var(--gridline);
  stroke-width: 1;
}

.axis-label {
  fill: var(--text-muted);
  font-size: 10px;
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.crosshair {
  stroke: var(--axis);
  stroke-width: 1;
}

.chart-hit-rect {
  cursor: crosshair;
}

.chart-hover-hidden {
  display: none;
}

.chart-tooltip {
  position: absolute;
  transform: translate(-50%, -130%);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.chart-tooltip-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.chart-tooltip-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.chart-table-toggle {
  margin-top: 0.75rem;
}

.chart-table-toggle summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.chart-table {
  margin-top: 0.5rem;
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  max-height: 200px;
  display: block;
  overflow-y: auto;
}

.chart-table td {
  padding: 0.25rem 0.5rem;
  border-bottom: 1px solid var(--gridline);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.chart-table td:last-child {
  text-align: right;
  color: var(--text-primary);
}

.generated-at {
  color: var(--text-muted);
  font-size: 0.8rem;
}
