:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --accent: #0ea5e9;
  --good: #16a34a;
  --warn: #ea580c;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: #f1f5f9; color: var(--ink); line-height: 1.5; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: linear-gradient(135deg, #1e3a8a, #2563eb 55%, #0ea5e9);
  color: #fff;
  padding: 22px 0;
  box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.brand { font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; }
.brand-mark { margin-right: 4px; }
.tagline { color: #dbeafe; font-size: .95rem; }

/* Cards / sections */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.controls { margin-top: -22px; position: relative; z-index: 5; }
main.wrap { padding-bottom: 60px; }

.section-title { font-size: 1.05rem; margin: 28px 0 12px; color: var(--ink); }

/* Controls */
.control-row { margin-bottom: 14px; }
.control-row.inline { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.control-row:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.grow { flex: 1; }
.field.end { align-items: flex-end; justify-content: flex-end; }
.field-label { font-size: .78rem; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }

input[type="text"], select {
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-width: 140px;
}
input[type="text"]:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.location-input { display: flex; gap: 8px; }
.location-input input { flex: 1; }

.btn {
  font: inherit; font-weight: 600;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; transition: .15s;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-ink); }
.btn-ghost { background: transparent; }

/* Suggestions */
.suggestions {
  list-style: none; margin: 4px 0 0; padding: 4px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff;
  box-shadow: var(--shadow); position: absolute; width: 100%; max-width: 420px; z-index: 20;
}
.suggestions li { padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.suggestions li:hover { background: #eff6ff; }

/* Source chips */
.source-list { display: flex; flex-wrap: wrap; gap: 8px; }
.src-chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; cursor: pointer; font-size: .9rem; user-select: none;
}
.src-chip input { accent-color: var(--brand); }
.src-chip.disabled { opacity: .5; cursor: not-allowed; }
.src-chip .swatch { width: 11px; height: 11px; border-radius: 3px; }
.src-chip .badge { font-size: .68rem; color: var(--warn); border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; }

/* Toggle */
.toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.toggle-btn { font: inherit; padding: 9px 14px; border: 0; background: #fff; cursor: pointer; color: var(--ink-soft); }
.toggle-btn.active { background: var(--brand); color: #fff; }

/* Status */
.status { margin: 18px 0; padding: 12px 14px; border-radius: 8px; background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.status.error { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.status.loading { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* Cards (divergence) */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.metric-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.metric-card .k { font-size: .76rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; }
.metric-card .v { font-size: 1.5rem; font-weight: 800; margin-top: 4px; }
.metric-card .sub { font-size: .8rem; color: var(--ink-soft); margin-top: 8px; }

/* Per-source labeled mini-list cards */
.list-card .src-values { list-style: none; margin: 10px 0 0; padding: 0; }
.list-card .src-values li { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: .92rem; }
.list-card .src-values .dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.list-card .src-values .nm { color: var(--ink); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-card .src-values .vl { font-weight: 700; font-variant-numeric: tabular-nums; }
.list-card .src-values .vl .partial { font-weight: 600; }
.list-card .src-values li.partial-row { color: var(--ink-soft); opacity: .75; }
.list-card .src-values .star { color: var(--warn); }
.list-card .partial { color: var(--warn); }

/* Charts — stacked full-width metric blocks */
.metric-block { margin-top: 28px; }
.metric-head { display: flex; align-items: center; justify-content: flex-start; gap: 10px; flex-wrap: wrap; }
.metric-head .section-title { margin: 0 0 12px; margin-right: auto; }
.temp-toggle { margin-bottom: 12px; }
.temp-toggle .toggle-btn { padding: 6px 14px; font-size: .9rem; }
.reset-zoom { padding: 6px 12px; font-size: .85rem; margin-bottom: 12px; }
.chart-area canvas { cursor: crosshair; }
.chart-area { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
/* Single overlay / bar chart: fixed-height container, canvas fills it. */
.chart-area:has(> canvas) { height: 452px; }
.chart-area > canvas { width: 100% !important; height: 100% !important; }
.multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.multiples .mini { border: 1px solid var(--line); border-radius: 8px; padding: 10px; height: 280px; display: flex; flex-direction: column; }
.multiples .mini h4 { margin: 0 0 6px; font-size: .85rem; color: var(--ink-soft); }
.multiples .mini canvas { flex: 1 1 auto; min-height: 0; width: 100% !important; }

/* Table */
.table-head { display: flex; align-items: center; justify-content: space-between; }
.table-wrap { overflow: auto; max-height: 460px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.data-table { border-collapse: collapse; width: 100%; font-size: .85rem; }
.data-table th, .data-table td { padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: right; }
.data-table th:first-child, .data-table td:first-child { text-align: left; position: sticky; left: 0; background: #fff; }
.data-table thead th { position: sticky; top: 0; background: #f8fafc; z-index: 2; }
.data-table .group-head { text-align: center; border-left: 2px solid var(--line); }
.data-table .partial { color: var(--warn); font-weight: 600; font-size: .82em; }

/* Empty / footer */
.empty { margin-top: 28px; padding: 40px; text-align: center; color: var(--ink-soft); background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); }
.site-footer { margin-top: 40px; padding: 24px 0; background: var(--bg); color: #cbd5e1; font-size: .85rem; }
.site-footer .fine { color: #94a3b8; font-size: .78rem; }

@media (max-width: 640px) {
  .control-row.inline { flex-direction: column; align-items: stretch; }
  .field.end { align-items: stretch; }
}
