/* Dashboard page — extends ../styles.css */

:root {
  --surface: #ffffff;
  --page-plane: #f9f9f7;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  /* Categorical slots, fixed order (validated: adjacent CVD ΔE ≥ 9.1) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --volume: #b9b7ae;
}

.dash-main {
  max-width: 72rem;
  padding: 2.5rem 2rem 3rem;
}

/* Hero */
.dash-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0 0 0.75rem;
}
.dash-lead {
  max-width: 44rem;
  color: var(--muted);
  margin: 0;
}
.dv-pending {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--accent);
}

/* Stat tiles */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: 0.75rem;
  margin: 2rem 0 0;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 0.9rem 1rem;
  background: var(--page-plane);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.2;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--ink-2);
}

/* Sections */
.dash-section {
  margin-top: 2.75rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}
.section-intro {
  color: var(--muted);
  font-size: 0.95rem;
  margin: -0.4rem 0 1.25rem;
  max-width: 48rem;
}
.h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.75rem 0 0.6rem;
}
.fine {
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 48rem;
}
.fine a {
  color: var(--accent);
}

/* Filters: one row above the chart */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.ctl {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.75rem;
  color: var(--ink-2);
  min-width: 0;
}
.ctl[hidden] {
  display: none;
}
.ctl select {
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--axis);
  border-radius: 4px;
  background: var(--surface);
  max-width: 18rem;
}
.ctl select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Topic / party chips */
.chips-wrap {
  margin-bottom: 1rem;
}
.chips-label {
  font-size: 0.75rem;
  color: var(--ink-2);
  margin: 0 0 0.35rem;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.chip {
  font: inherit;
  font-size: 0.78rem;
  line-height: 1.2;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--axis);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.chip:hover {
  border-color: var(--accent);
}
.chip[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--text);
  font-weight: 600;
}
.chip:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.chip-key {
  width: 12px;
  height: 2px;
  border-radius: 1px;
  display: inline-block;
}

/* Chart card */
.chart-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1rem 0.75rem;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  font-size: 0.8rem;
  color: var(--ink-2);
  margin-bottom: 0.5rem;
  min-height: 1.2rem;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.legend-key {
  width: 16px;
  height: 2px;
  border-radius: 1px;
}
.chart {
  width: 100%;
  position: relative;
}
.chart svg {
  display: block;
  width: 100%;
  overflow: visible;
}
.chart-sub-title {
  font-size: 0.75rem;
  color: var(--ink-2);
  margin: 0.5rem 0 0.1rem;
}
.chart text {
  font-family: var(--font-sans);
  font-size: 11px;
  fill: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.chart .label-end {
  font-size: 11px;
  fill: var(--ink-2);
}
.chart .empty {
  font-size: 13px;
  fill: var(--ink-2);
}
.chart-note {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
  min-height: 1rem;
}
.chart-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.btn-small {
  font: inherit;
  font-size: 0.8rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--muted);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}
.btn-small:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Tooltip */
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid rgba(11, 11, 11, 0.12);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
  min-width: 10rem;
  z-index: 5;
}
.tooltip[hidden] {
  display: none;
}
.tt-head {
  color: var(--ink-2);
  margin-bottom: 0.3rem;
}
.tt-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  line-height: 1.5;
}
.tt-row strong {
  font-variant-numeric: tabular-nums;
  min-width: 3.2rem;
}
.tt-row span:last-child {
  color: var(--ink-2);
}
.tt-foot {
  color: var(--ink-muted);
  margin-top: 0.25rem;
}

/* Table view */
.table-wrap {
  max-height: 22rem;
  overflow: auto;
  margin-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.table-wrap table {
  border-collapse: collapse;
  font-size: 0.78rem;
  width: 100%;
  font-variant-numeric: tabular-nums;
}
.table-wrap th,
.table-wrap td {
  padding: 0.3rem 0.5rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-wrap th:first-child,
.table-wrap td:first-child {
  text-align: left;
}
.table-wrap thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--ink-2);
  font-weight: 600;
}

/* Coverage */
.coverage-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2rem;
}
@media (max-width: 760px) {
  .coverage-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
.coverage-list {
  font-size: 0.8rem;
}
.cov-head,
.cov-row {
  display: grid;
  grid-template-columns: 7.5rem minmax(0, 1fr) 4.5rem 5.5rem;
  gap: 0.5rem;
  align-items: center;
  padding: 0.15rem 0;
}
.cov-head {
  color: var(--ink-2);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.2rem;
}
.cov-row {
  cursor: pointer;
  border-radius: 3px;
}
.cov-row:hover,
.cov-row:focus-visible {
  background: var(--page-plane);
  outline: none;
}
.cov-bar {
  height: 10px;
  background: var(--series-1);
  border-radius: 0 3px 3px 0;
  min-width: 2px;
}
.cov-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cov-span {
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}
.chart-years {
  margin-top: 0.25rem;
}

/* Download cards */
.dl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}
.dl-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.dl-card h3 {
  font-size: 1rem;
  margin: 0 0 0.4rem;
}
.dl-card p {
  font-size: 0.88rem;
  margin: 0 0 0.6rem;
  line-height: 1.5;
}
.dl-card .dl-files {
  color: var(--ink-2);
  font-size: 0.78rem;
  margin-top: auto;
}
.dl-card code {
  background: var(--code-bg);
  padding: 0.05rem 0.3rem;
  border-radius: 3px;
}
.rules {
  padding-left: 1.2rem;
  margin: 0;
  max-width: 48rem;
  font-size: 0.92rem;
}
.rules li {
  margin-bottom: 0.4rem;
}

@media (max-width: 600px) {
  .dash-main {
    padding: 1.75rem 1rem 2.5rem;
  }
  .cov-head,
  .cov-row {
    grid-template-columns: 6rem minmax(0, 1fr) 4rem;
  }
  .cov-span {
    display: none;
  }
}

.tooltip-fixed {
  position: fixed;
}
