/* ─────────────────────────────────────────────────────────
   style.css — Universal Design System
   Semrush-inspired: clean sans-serif, minimal tables,
   color trend indicators, badge system
   Linked after each page's <style> block so same-specificity
   rules here override the page-level monospace settings.
   ───────────────────────────────────────────────────────── */

/* ── 1. FORM ELEMENTS ── */
/* Replace typewriter IBM Plex Mono with clean DM Sans */
select, input, button {
  font-family: var(--sans);
}

/* ── 2. BROAD FONT OVERRIDE ── */
/* Every element that was forced to --mono via page-level rules */
.stat-val, .stat-lbl,
.sub,
.tab, .tab-group .tab,
.sort-btn, #sort-wrap,
.tbl-hdr,
.pivot-col-hdr span,
.g-name, .g-num-val, .g-num-lbl,
.detail-title,
.pill,
#raw-header, #grouped-count,
#loading, footer,
.run-report-btn, .clear-btn,
.filter-lbl, .filter-search input,
.grp-hdr-row td,
.kpi-val, .kpi-lbl,
.matchup-slot-hdr,
/* index.html — all remaining mono classes */
.header-meta,
.kpi-change,
.logo-badge,
.map-inset-label,
.map-tooltip,
.map-breadcrumb,
.map-breadcrumb button,
.tile,
.race-tag,
.wbar-note,
.no-sel-txt,
.insight-header-sub,
.insight-item-meta,
.insight-item-tag,
.insight-empty,
.change-line,
.cbadge,
.cparty,
.cand-slicer,
.party-group-label,
.cand-action-btn,
.cand-district-header,
.cand-district-code,
.cand-district-meta,
.cand-district-spend,
.cand-district-empty,
.cand-district-back,
.cand-district-current,
.cand-loading-note,
.cand-race-label,
.cand-finance-item,
.poll-race-label,
.poll-meta,
.poll-cand-name,
.poll-pct,
.poll-moe,
.poll-none,
.ballot-label,
.ballot-measure-desc,
.ballot-fcc-note,
.ballot-camps,
.msc-dates,
.msc-cands,
.search-wrap input {
  font-family: var(--sans);
}

/* ── 3. STAT NUMBERS ── */
/* Large headline figures: heavier weight, tighter tracking */
.stat-val {
  font-family: var(--sans);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-lbl {
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.05em;
}

/* ── 4. TABLE STRUCTURE ── */
/* Semrush style: clean header, no vertical dividers, subtle hover */
th {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 600;
  color: #6B7280;
  letter-spacing: 0.04em;
  padding: 7px 10px;
  border-bottom: 1.5px solid #E2E8F0;
  border-right: none !important;
  background: #F8FAFC;
  text-align: left;
  white-space: nowrap;
}

td {
  font-family: var(--sans);
  font-size: 0.7rem;
  padding: 7px 10px;
  border-bottom: 1px solid #F1F5F9;
}

tbody tr:hover td {
  background: #F9FAFB;
}

/* ── 5. TREND INDICATORS ── */
/* Semrush-style: colored text + small triangle before the value */
.trend-up {
  color: #16A34A;
  font-family: var(--sans);
  font-weight: 600;
  white-space: nowrap;
}

.trend-up::before {
  content: '▲\00a0';
  font-size: 0.6em;
  vertical-align: 1px;
}

.trend-down {
  color: #DC2626;
  font-family: var(--sans);
  font-weight: 600;
  white-space: nowrap;
}

.trend-down::before {
  content: '▼\00a0';
  font-size: 0.6em;
  vertical-align: 1px;
}

.trend-flat {
  color: #94A3B8;
  font-family: var(--sans);
}

/* Inline trend chip: number + arrow in one element */
.trend-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
}

.trend-chip.up   { color: #16A34A; background: #F0FDF4; }
.trend-chip.down { color: #DC2626; background: #FEF2F2; }
.trend-chip.flat { color: #64748B; background: #F8FAFC; }

.trend-chip.up::before   { content: '▲\00a0'; font-size: 0.6em; }
.trend-chip.down::before { content: '▼\00a0'; font-size: 0.6em; }

/* ── 6. BADGE / PILL SYSTEM ── */
/* Small rounded labels — replaces ad-hoc inline pills across pages */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-family: var(--sans);
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  border: none;
  line-height: 1.5;
}

.badge-green  { background: #DCFCE7; color: #16A34A; }
.badge-amber  { background: #FEF3C7; color: #D97706; }
.badge-red    { background: #FEE2E2; color: #DC2626; }
.badge-blue   { background: #DBEAFE; color: #2563EB; }
.badge-gray   { background: #F1F5F9; color: #64748B; }
.badge-purple { background: #EDE9FE; color: #7C3AED; }

/* Party shorthand: applies badge styling to existing .party-r/d/i pills */
.party-r, td .party-r { background: #FEE2E2; color: #DC2626; border-radius: 99px; padding: 1px 6px; font-size: 0.6rem; font-weight: 700; font-family: var(--sans); }
.party-d, td .party-d { background: #DBEAFE; color: #2563EB; border-radius: 99px; padding: 1px 6px; font-size: 0.6rem; font-weight: 700; font-family: var(--sans); }
.party-i, td .party-i { background: #F1F5F9; color: #64748B; border-radius: 99px; padding: 1px 6px; font-size: 0.6rem; font-weight: 700; font-family: var(--sans); }

/* ── 7. SUBHEADER / META ── */
.sub {
  font-family: var(--sans);
}

/* ── 8. LOADING / EMPTY STATE ── */
#loading {
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: 0.06em;
}

/* ── 9. FOOTER ── */
footer {
  font-family: var(--sans);
}

/* ── 10. HEADER AUTH WIDGET ── */
#header-auth {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-auth-user {
  font-family: var(--sans);
  font-size: 0.62rem;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.header-auth-login {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 5px;
  padding: 5px 13px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.header-auth-login:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.header-auth-request {
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 600;
  color: #fff;
  background: var(--blue);
  border: none;
  border-radius: 5px;
  padding: 5px 13px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.header-auth-request:hover {
  background: var(--blue-light);
}

.header-auth-logout {
  font-family: var(--sans);
  font-size: 0.6rem;
  color: rgba(255,255,255,0.4);
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  transition: color 0.15s;
  white-space: nowrap;
}

.header-auth-logout:hover {
  color: rgba(255,255,255,0.8);
}

/* ── 11. PUBLIC FILE: RECORD GRID STRUCTURE ── */
/* Column separators on th — fix unresolved --border-faint var */
#grouped th, #raw-wrap th {
  border-right: 1px solid #D8DFE8;
}
#grouped th:last-child, #raw-wrap th:last-child {
  border-right: none;
}

/* Visible row + column separators in td */
#grouped td, #raw-wrap td {
  border-bottom: 1px solid #E3E8EF;
  border-right: 1px solid #EDF1F5;
}
#grouped td:last-child, #raw-wrap td:last-child {
  border-right: none;
}

/* Explicit odd/even so contrast shows against the detail-wrap #F8FAFC background */
#grouped tbody tr:nth-child(odd) td,
#raw-wrap tbody tr:nth-child(odd) td {
  background: #fff;
}
#grouped tbody tr:nth-child(even) td,
#raw-wrap tbody tr:nth-child(even) td {
  background: #F4F7FA;
}
#grouped tbody tr:hover td,
#raw-wrap tbody tr:hover td {
  background: #EEF4FD;
}

/* Last row inside detail-wrap: no hanging bottom border */
#grouped .detail-wrap tbody tr:last-child td {
  border-bottom: none;
}

/* ── 12. MINI LOGIN MODAL ── */
#mini-login-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  backdrop-filter: blur(3px);
  z-index: 300;
  align-items: flex-start;
  justify-content: flex-end;
  padding-top: 56px;
  padding-right: 12px;
}

#mini-login-overlay.open {
  display: flex;
}

#mini-login-card {
  background: #fff;
  border-radius: 8px;
  width: 300px;
  padding: 22px 20px 18px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.22);
  border: 1px solid #E2E8F0;
}

.mini-login-title {
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}

.mini-login-field {
  margin-bottom: 11px;
}

.mini-login-field label {
  display: block;
  font-family: var(--sans);
  font-size: 0.55rem;
  font-weight: 600;
  color: #6B7280;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.mini-login-field input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #D1D5DB;
  border-radius: 5px;
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--text);
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}

.mini-login-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.mini-login-btn {
  width: 100%;
  padding: 8px;
  border: none;
  border-radius: 5px;
  background: var(--blue);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  margin-top: 4px;
  transition: background 0.15s;
}

.mini-login-btn:hover {
  background: var(--blue-light);
}

.mini-login-err {
  font-family: var(--sans);
  font-size: 0.58rem;
  color: #DC2626;
  margin-top: 8px;
  min-height: 16px;
}

.mini-login-footer {
  font-family: var(--sans);
  font-size: 0.58rem;
  color: #9CA3AF;
  text-align: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #F3F4F6;
}

.mini-login-footer a {
  color: var(--blue);
  text-decoration: none;
}

.mini-login-footer a:hover {
  text-decoration: underline;
}
