:root {
  --bg: #f7f7f5;
  --panel-bg: #ffffff;
  --border: #e0ddd6;
  --text: #2b2924;
  --text-muted: #6b675f;
  --accent: #2f6f4f;
  --accent-soft: #e7f1ec;
  --electric: #b8860b;
  --water: #2b6ca8;
  --wastewater: #4a7a8c;
  --other: #7a6a8f;
  --chart-positive: #b3441e;
  --chart-negative: #2e7d5b;
  --driver-usage: #1f7a8c;
  --driver-rate: #b8730c;
  --tier-1: #3a5fcd;
  --tier-2: #d9932b;
  --tier-3: #b3341e;
  --tier-4: #000000;
  --warning: #a15c00;
  --error: #a3311f;
  --info: #3a6ea5;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

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

.app-subtitle {
  color: var(--text-muted);
  max-width: 640px;
  margin: 0 0 24px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 28px;
  text-align: center;
  background: var(--panel-bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  outline: none;
}
.dropzone p { margin: 4px 0; }
.dropzone-hint { color: var(--text-muted); font-size: 0.9rem; }

.file-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-item {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}

.file-item-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.file-status-icon { font-size: 1.1rem; width: 1.4em; text-align: center; }
.file-name { font-weight: 600; flex: 1; }
.file-summary { color: var(--text-muted); font-size: 0.9rem; }
.file-remove {
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 6px;
}
.file-remove:hover, .file-remove:focus-visible { color: var(--error); background: var(--accent-soft); outline: none; }

.file-warnings {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 0.85rem;
}
.file-warnings li.severity-error { color: var(--error); }
.file-warnings li.severity-warning { color: var(--warning); }
.file-warnings li.severity-info { color: var(--info); }

.results { margin-top: 32px; }

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.tab-button {
  background: var(--panel-bg);
  border: 2px solid var(--border);
  padding: 12px 20px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.tab-button:hover, .tab-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}
.tab-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chart-card, .bills-table-card, .category-panel, .compare-picker, .headline-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 18px;
}
.chart-card h2, .bills-table-card h2 { margin: 0 0 8px; font-size: 1.05rem; }

.chart-container { width: 100%; overflow-x: auto; }
.chart { width: 100%; height: auto; display: block; }
.chart-empty { color: var(--text-muted); font-style: italic; }
.chart-gridline { stroke: var(--border); stroke-width: 1; }
.chart-zero-line { stroke: var(--text-muted); stroke-width: 1; }
.chart-axis-label { fill: var(--text-muted); font-size: 10px; }
.chart-bar-label { fill: var(--text); font-size: 12px; }
.chart-bar-sublabel { fill: var(--text-muted); font-size: 10.5px; }
.chart-bar-value { fill: var(--text); font-size: 11px; }
.chart-bar-value-inside { font-size: 11px; font-weight: 600; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; font-size: 0.85rem; color: var(--text-muted); }
.chart-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend-swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.chart-note { font-size: 0.82rem; color: var(--text-muted); margin: 6px 0 0; }

/* Persistent explainer paragraph placed after a category's rate-breakdown
   bar chart -- covers the tiered system, actual tier thresholds, the
   conservation rationale, and (electric only) seasonal vs. yearly rates.
   Replaces the earlier hover-"?"-tooltip design testers found too slow,
   too text-heavy, too numerous, and poorly placed. */
.category-explainer {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 10px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.category-explainer strong { color: var(--text); }
.swatch-inline { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 3px; vertical-align: middle; }
.swatch-positive { background: var(--chart-positive); }
.swatch-negative { background: var(--chart-negative); }

/* Trend dashboard: one large featured chart + a strip of equally-sized,
   clickable thumbnails so no single sparse-data series dominates the page. */
.trend-featured-card .chart-container { min-height: 220px; }
.trend-hint { color: var(--text-muted); font-size: 0.85rem; margin: -6px 0 12px; }
.trend-thumb-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.trend-thumb {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.trend-thumb:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}
.trend-thumb.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.trend-thumb-title { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }
.trend-thumb.active .trend-thumb-title { color: var(--accent); }
.trend-thumb-chart { display: block; width: 100%; }
.trend-thumb-chart .chart { pointer-events: none; }

.table-scroll { overflow-x: auto; }
.bills-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.bills-table th, .bills-table td { text-align: right; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.bills-table th:first-child, .bills-table td:first-child { text-align: left; }

.compare-picker { display: flex; gap: 24px; flex-wrap: wrap; }
.compare-picker label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--text-muted); }
.compare-picker select { padding: 6px 8px; font-size: 0.95rem; }

.headline-card { text-align: center; }
.headline-narrative {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 12px;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
}
.headline-figures {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}
.headline-delta { font-size: 1.6rem; font-weight: 700; }
.headline-delta.positive { color: var(--chart-positive); }
.headline-delta.negative { color: var(--chart-negative); }
.headline-range { color: var(--text-muted); font-size: 0.9rem; }
.headline-footnote {
  color: var(--text-muted);
  font-size: 0.8rem;
  max-width: 560px;
  margin: 10px auto 0;
}

.category-panel h3 { margin: 0 0 6px; }
.category-narrative { font-size: 1rem; line-height: 1.45; margin: 0 0 8px; }
.category-panel-summary { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 10px; }

/* Usage vs. rate: a consistent color identity used everywhere a dollar
   effect is attributed to "you used more/less" vs "the rate changed" --
   in narrative text, chips, and the tier-effect bar charts alike, so a
   reader can connect the sentence to the chart without doing the math. */
.driver-usage { color: var(--driver-usage); font-weight: 600; }
.driver-rate { color: var(--driver-rate); font-weight: 600; }

.driver-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.driver-chip {
  display: flex;
  align-items: baseline;
  gap: 6px;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}
.driver-chip-usage { border-color: var(--driver-usage); background: color-mix(in srgb, var(--driver-usage) 10%, transparent); }
.driver-chip-rate { border-color: var(--driver-rate); background: color-mix(in srgb, var(--driver-rate) 10%, transparent); }
.chip-label { font-weight: 700; text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.03em; color: var(--text-muted); }
.chip-value { font-weight: 600; }

/* Category name colors used inline in the overall narrative sentence, so
   "electricity" in the text visually matches the electric bars/charts. */
.cat-electric { color: var(--electric); font-weight: 700; }
.cat-water { color: var(--water); font-weight: 700; }
.cat-wastewater { color: var(--wastewater); font-weight: 700; }
.cat-other { color: var(--other); font-weight: 700; }
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}
.badge.estimated { background: #fbe9d3; color: var(--warning); }
.badge.major-driver { background: #f6dcd6; color: var(--error); }

.self-check-warning {
  font-size: 0.85rem;
  color: var(--warning);
  margin-top: 8px;
}

details.category-details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

@media (max-width: 640px) {
  .app { padding: 16px 10px 48px; }
  .compare-picker { gap: 12px; }
}
