:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #121c2f;
  --text: #e8eefc;
  --muted: #9fb0d1;
  --border: #23314f;
  --accent: #66b3ff;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, system-ui, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; }
.topbar p { margin: 6px 0 0; color: var(--muted); }
button {
  background: var(--accent);
  color: #06111f;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  padding: 24px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
}
.card h2 { margin-top: 0; }
.list { display: grid; gap: 10px; }
.item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
}
.item strong { display: block; margin-bottom: 4px; }
.item .muted { color: var(--muted); font-size: 14px; }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

/* ── Stats bar ─────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 0;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.stat-item {
  flex: 1;
  padding: 0 20px;
  border-right: 1px solid var(--border);
}
.stat-item:first-child { padding-left: 0; }
.stat-item:last-child  { border-right: none; }
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Cards grid ─────────────────────────────────── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 24px;
}

/* ── Party card ─────────────────────────────────── */
.party-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color 0.15s;
}
.party-card:hover {
  border-color: var(--accent);
}

/* ── Party badge ─────────────────────────────────── */
.party-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  width: fit-content;
}

/* ── Party name ─────────────────────────────────── */
.party-nombre {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

/* ── Section meta (donaciones, donantes) ─────────── */
.section-meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
}
.section-meta strong {
  color: var(--text);
}

/* ── Button link ─────────────────────────────────── */
.btn-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 6px 0;
  margin-top: auto;
  border: none;
  background: none;
  cursor: pointer;
}
.btn-link:hover {
  text-decoration: underline;
}

/* ── Empty state ─────────────────────────────────── */
.empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ── Page header (title + subtitle) ─────────────── */
.page-header {
  padding: 28px 24px 20px;
}
.page-header h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 700;
}
.page-header p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── Report page sections ────────────────────────── */
.report-header {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 28px 32px;
}
.report-header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
}
.report-header .subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 16px;
}
.report-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.report-body {
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 960px;
}
.report-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}
.report-section-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.report-section-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}
.report-section-body {
  padding: 16px 18px;
}

/* ── Data table ─────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.data-table tr:last-child td {
  border-bottom: none;
}
.data-table tr:hover td {
  background: rgba(255,255,255,0.02);
}

/* ── Badges / pills ─────────────────────────────── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-critico  { background: #3d1010; color: #ff6b6b; }
.badge-alto     { background: #2d1a0a; color: #ff9f43; }
.badge-medio    { background: #2a2000; color: #ffd32a; }
.badge-senal    { background: #1a2a1a; color: #66d966; }
.badge-real     { background: #0a1f0a; color: #44cc44; border: 1px solid #2a5a2a; }

/* ── Score bar ─────────────────────────────────── */
.score-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}
.score-track {
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
}
.score-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  min-width: 32px;
  text-align: right;
}

/* ── Fuentes section ────────────────────────────── */
.fuentes-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.fuente-item {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.fuente-ok   { color: #44cc44; font-weight: 700; }
.fuente-miss { color: var(--border); font-weight: 700; }

/* ── Container ─────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Topbar right links ─────────────────────────── */
.tb-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.tb-right a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}
.tb-right a:hover {
  color: var(--text);
}
.topbar-logo {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}
.topbar-logo span {
  color: var(--accent);
}

/* ── Explorer pages ─────────────────────────────── */
.explorer-controls {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.explorer-controls input[type=search] {
  width: 100%;
  max-width: 480px;
  padding: 10px 14px;
  font-size: 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.explorer-controls input[type=search]:focus { border-color: var(--accent); }
.explorer-controls input[type=search]::placeholder { color: var(--muted); }

/* Tables in explorer pages */
.container table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 16px 24px;
  width: calc(100% - 48px);
}
.container table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.container table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--text);
}
.container table tr:last-child td { border-bottom: none; }
.container table tr:hover td { background: rgba(255,255,255,.02); }
.container table a { color: var(--accent); text-decoration: none; }
.container table a:hover { text-decoration: underline; }
.container h1 {
  padding: 24px 24px 8px;
  margin: 0;
  font-size: 22px;
}
.container > .section-meta {
  padding: 0 24px 16px;
  margin: 0;
}
.container > p.section-meta { padding: 8px 24px; }

/* RACI grouping */
.raci-group { margin: 16px 24px; }
.raci-group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.raci-group-header strong { color: var(--text); font-size: 14px; }
.raci-group table { margin: 0; width: 100%; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  font-size: 13px;
  color: var(--muted);
}
.pagination button {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.pagination button:hover { border-color: var(--accent); }

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 640px) {
  .cards-grid {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .stats-bar {
    flex-wrap: wrap;
    gap: 12px;
  }
  .stat-item {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0 0 12px;
  }
  .report-body {
    padding: 16px;
  }
}
