:root {
  --bg: #f6f7f4;
  --surface: #ffffff;
  --surface-soft: #eef1eb;
  --text: #171a18;
  --muted: #6e746f;
  --border: #dde2dc;
  --green: #2f8f68;
  --green-soft: #e6f4ed;
  --orange: #e8843d;
  --orange-soft: #fff0e4;
  --dark: #202521;
  --danger: #b7463e;
  --shadow: 0 20px 60px rgba(24, 31, 26, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-family: Manrope, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(47,143,104,.28); outline-offset: 3px; }

.site-header, .page-shell, .site-footer { width: min(100% - 36px, 1120px); margin-inline: auto; }
.site-header { min-height: 82px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand > span:last-child { display: grid; gap: 1px; }
.brand strong { font-size: 15px; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.brand-mark { width: 37px; height: 37px; display: flex; align-items: end; justify-content: center; gap: 3px; padding: 8px; border-radius: 12px; background: var(--dark); box-shadow: 0 9px 20px rgba(28,34,29,.17); }
.brand-mark i { display: block; width: 4px; border-radius: 6px; background: #fff; }
.brand-mark i:nth-child(1) { height: 9px; opacity: .55; }
.brand-mark i:nth-child(2) { height: 16px; opacity: .8; }
.brand-mark i:nth-child(3) { height: 22px; }
.header-status { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; font-weight: 800; }
.header-status span, .notification-status span { width: 8px; height: 8px; border-radius: 50%; background: #a4aaa5; }
.header-status.live span, .notification-status.active span { background: var(--green); box-shadow: 0 0 0 5px rgba(47,143,104,.12); }
.header-status.error span, .notification-status.error span { background: var(--danger); }

.page-shell { padding: 24px 0 72px; }
.section-kicker { display: block; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }

.notification-panel { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; padding: 28px; border: 1px solid rgba(47,143,104,.19); border-radius: 26px; background: linear-gradient(135deg, #f0f8f4 0%, #fff 57%, #fff7ef 100%); box-shadow: var(--shadow); }
.notification-icon { width: 66px; height: 66px; display: grid; place-items: center; border-radius: 22px; background: var(--dark); font-size: 29px; box-shadow: 0 14px 28px rgba(22,26,23,.17); }
.notification-copy h1 { margin: 6px 0 7px; font-size: clamp(24px, 3vw, 36px); line-height: 1.06; letter-spacing: -.045em; }
.notification-copy p { margin: 0; max-width: 670px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.notification-status { margin-top: 12px; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; font-weight: 800; }
.primary-action { min-height: 49px; padding: 0 20px; border: 0; border-radius: 14px; background: var(--dark); color: #fff; font-size: 12px; font-weight: 800; white-space: nowrap; box-shadow: 0 13px 28px rgba(24,29,25,.18); transition: transform .18s ease, box-shadow .18s ease; }
.primary-action:hover { transform: translateY(-1px); box-shadow: 0 16px 32px rgba(24,29,25,.23); }
.primary-action.active { background: var(--green); }
.primary-action.install { background: var(--orange); }
.primary-action:disabled { cursor: not-allowed; opacity: .55; transform: none; box-shadow: none; }

.results-section { margin-top: 56px; }
.section-heading, .panel-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.section-heading h2, .panel-heading h2, .acts-panel h2 { margin: 5px 0 0; font-size: clamp(24px, 3vw, 34px); letter-spacing: -.045em; }
.refresh-button { border: 1px solid var(--border); border-radius: 12px; padding: 9px 13px; background: rgba(255,255,255,.72); color: var(--muted); font-size: 11px; font-weight: 800; }

.candidate-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.candidate-card { position: relative; overflow: hidden; padding: 25px; border: 1px solid var(--border); border-radius: 24px; background: var(--surface); box-shadow: 0 14px 36px rgba(26,31,27,.055); }
.candidate-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 4px; background: var(--candidate); }
.candidate-a { --candidate: var(--green); --candidate-soft: var(--green-soft); }
.candidate-b { --candidate: var(--orange); --candidate-soft: var(--orange-soft); }
.candidate-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.candidate-avatar { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 15px; background: var(--candidate-soft); color: var(--candidate); font-size: 12px; font-weight: 900; }
.candidate-party { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.candidate-head h3 { margin: 3px 0 0; font-size: 15px; line-height: 1.25; }
.candidate-badge { padding: 6px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 9px; font-weight: 900; }
.candidate-badge.leader { color: var(--candidate); background: var(--candidate-soft); }
.candidate-percentage { display: block; margin-top: 27px; font-size: clamp(42px, 7vw, 70px); line-height: .95; letter-spacing: -.065em; }
.candidate-progress { height: 8px; margin-top: 20px; overflow: hidden; border-radius: 999px; background: #edf0ec; }
.candidate-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--candidate); transition: width .45s ease; }
.candidate-footer { margin-top: 13px; display: flex; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.candidate-footer strong { color: var(--candidate); }
.difference-strip { margin-top: 14px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 16px; padding: 17px 20px; border-radius: 16px; background: var(--dark); color: #fff; }
.difference-strip > span { color: rgba(255,255,255,.55); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.difference-strip p { margin: 0; font-size: 12px; }
.difference-strip > strong { font-size: 15px; }

.chart-panel { margin-top: 54px; padding: 25px; border: 1px solid var(--border); border-radius: 25px; background: var(--surface); box-shadow: var(--shadow); }
.panel-heading small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 14px; color: var(--muted); font-size: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 18px; height: 3px; border-radius: 999px; }
.legend-a { background: var(--green); }
.legend-b { background: var(--orange); }
.chart-wrap { position: relative; padding: 14px 8px 0 42px; }
#trendChart { width: 100%; height: auto; min-height: 245px; display: block; overflow: visible; touch-action: pan-y; }
.grid-lines line { stroke: #e8ece7; stroke-width: 1; stroke-dasharray: 4 6; }
.line-path { fill: none; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.line-a { stroke: var(--green); }
.line-b { stroke: var(--orange); }
.area-path { pointer-events: none; }
.chart-dot { stroke: #fff; stroke-width: 3; }
.chart-dot-a { fill: var(--green); }
.chart-dot-b { fill: var(--orange); }
.chart-y-label { position: absolute; left: 0; color: #919792; font-size: 9px; font-weight: 700; }
.chart-y-label.top { top: 42px; }
.chart-y-label.middle { top: 50%; transform: translateY(-50%); }
.chart-y-label.bottom { bottom: 33px; }
.chart-x-labels { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0 0; color: #919792; font-size: 9px; }
.chart-hit-area { fill: transparent; cursor: crosshair; }
.chart-hover-line { stroke: #9aa19b; stroke-width: 1; stroke-dasharray: 4 5; pointer-events: none; }
.chart-focus { stroke: #fff; stroke-width: 3; pointer-events: none; }
.chart-focus-a { fill: var(--green); }
.chart-focus-b { fill: var(--orange); }
.chart-tooltip { position: absolute; z-index: 4; width: min(240px, calc(100% - 30px)); padding: 13px; border: 1px solid var(--border); border-radius: 13px; background: rgba(24,29,25,.96); color: #fff; box-shadow: 0 17px 38px rgba(14,18,15,.25); pointer-events: none; transform: translate(-50%, calc(-100% - 15px)); }
.chart-tooltip strong { display: block; margin-bottom: 7px; font-size: 11px; }
.chart-tooltip .tooltip-row { display: flex; justify-content: space-between; gap: 12px; margin-top: 5px; font-size: 10px; }
.chart-tooltip .tooltip-row span { color: rgba(255,255,255,.66); }
.chart-tooltip .tooltip-lead { margin-top: 9px; padding-top: 8px; border-top: 1px solid rgba(255,255,255,.13); font-size: 10px; font-weight: 800; }

.acts-panel { margin-top: 54px; display: grid; grid-template-columns: 1.08fr .92fr; gap: 22px; padding: 28px; border-radius: 25px; background: var(--dark); color: #fff; }
.acts-panel .section-kicker { color: rgba(255,255,255,.48); }
.acts-number { display: flex; align-items: baseline; gap: 11px; margin-top: 22px; }
.acts-number strong { font-size: clamp(43px, 7vw, 67px); line-height: .92; letter-spacing: -.06em; }
.acts-number span { color: #8fdda9; font-size: 11px; font-weight: 800; }
.acts-progress { height: 9px; margin-top: 21px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.12); }
.acts-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green), #7cc8a5); transition: width .45s ease; }
.acts-main p { margin: 12px 0 0; color: rgba(255,255,255,.62); font-size: 11px; }
.update-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.update-grid div { min-height: 91px; padding: 15px; border: 1px solid rgba(255,255,255,.09); border-radius: 15px; background: rgba(255,255,255,.055); }
.update-grid span { display: block; color: rgba(255,255,255,.49); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.update-grid strong { display: block; margin-top: 9px; font-size: 11px; line-height: 1.45; }

.source-notice { margin-top: 18px; padding: 17px 19px; border: 1px solid var(--border); border-radius: 16px; background: rgba(255,255,255,.66); }
.source-notice strong { font-size: 11px; }
.source-notice p { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.site-footer { padding: 0 0 calc(35px + env(safe-area-inset-bottom)); color: var(--muted); text-align: center; font-size: 9px; }

.install-dialog { width: min(92vw, 470px); padding: 29px; border: 0; border-radius: 23px; background: #fff; box-shadow: 0 30px 90px rgba(18,23,19,.3); }
.install-dialog::backdrop { background: rgba(18,22,19,.56); backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--surface-soft); color: var(--muted); font-size: 21px; }
.dialog-icon { display: block; font-size: 35px; }
.install-dialog h2 { margin: 12px 0; font-size: 25px; letter-spacing: -.04em; }
.install-dialog ol { margin: 0 0 15px; padding-left: 23px; color: var(--text); font-size: 12px; line-height: 1.75; }
.install-dialog p { color: var(--muted); font-size: 11px; line-height: 1.6; }
.install-dialog .primary-action { width: 100%; margin-top: 5px; }

.toast { position: fixed; z-index: 20; right: 22px; bottom: calc(22px + env(safe-area-inset-bottom)); width: min(390px, calc(100% - 28px)); display: flex; gap: 12px; align-items: flex-start; padding: 15px; border-radius: 16px; background: var(--dark); color: #fff; box-shadow: 0 20px 50px rgba(18,22,19,.3); opacity: 0; transform: translateY(18px); pointer-events: none; transition: .22s ease; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: rgba(255,255,255,.12); }
.toast strong { font-size: 11px; }
.toast p { margin: 3px 0 0; color: rgba(255,255,255,.65); font-size: 10px; line-height: 1.5; }
.toast.error { background: #702e29; }

@media (max-width: 820px) {
  .notification-panel { grid-template-columns: auto 1fr; }
  .notification-panel .primary-action { grid-column: 1 / -1; width: 100%; }
  .acts-panel { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .site-header, .page-shell, .site-footer { width: min(100% - 24px, 1120px); }
  .site-header { min-height: 68px; }
  .header-status { font-size: 9px; }
  .page-shell { padding-top: 10px; }
  .notification-panel { grid-template-columns: 1fr; gap: 15px; padding: 22px; border-radius: 21px; }
  .notification-icon { width: 51px; height: 51px; border-radius: 17px; font-size: 22px; }
  .notification-copy h1 { font-size: 27px; }
  .results-section, .chart-panel, .acts-panel { margin-top: 38px; }
  .candidate-grid { grid-template-columns: 1fr; }
  .candidate-card { padding: 21px; border-radius: 20px; }
  .candidate-percentage { font-size: 55px; }
  .difference-strip { grid-template-columns: 1fr auto; }
  .difference-strip > span { grid-column: 1 / -1; }
  .section-heading, .panel-heading { align-items: flex-start; }
  .panel-heading { flex-direction: column; }
  .legend { justify-content: flex-start; }
  .chart-panel { padding: 20px 12px 18px; }
  .chart-wrap { padding-left: 35px; }
  #trendChart { min-height: 220px; }
  .chart-x-labels span:nth-child(even) { display: none; }
  .acts-panel { padding: 23px; border-radius: 21px; }
  .update-grid { grid-template-columns: 1fr; }
  .update-grid div { min-height: 73px; }
  .toast { right: 14px; }
}

/* ===== Monetización, historial editorial y páginas informativas ===== */
.header-nav { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.header-nav a { color: var(--muted); text-decoration: none; font-size: .84rem; font-weight: 700; }
.header-nav a:hover { color: var(--text); }

.ad-panel {
  position: relative;
  min-height: 110px;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(255,255,255,.72);
  overflow: hidden;
}
.ad-panel[hidden] { display: none !important; }
.ad-label { position: absolute; top: 8px; left: 14px; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.ad-mount { width: 100%; min-height: 70px; text-align: center; }
.ad-mount .adsbygoogle { min-height: 90px; }

.history-insights,
.explain-panel,
.support-panel {
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 34px);
}

.insight-grid,
.explain-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 22px;
}
.insight-grid article,
.explain-grid article {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-soft);
  padding: 18px;
}
.insight-grid span { display: block; color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.insight-grid strong { display: block; margin-top: 8px; font-size: clamp(1.15rem, 2.2vw, 1.55rem); }
.insight-grid small { display: block; margin-top: 6px; color: var(--muted); line-height: 1.45; }
.history-narrative { margin: 18px 0 0; color: var(--muted); line-height: 1.7; }
.secondary-link { color: var(--green); font-weight: 800; text-decoration: none; white-space: nowrap; }
.secondary-link:hover { text-decoration: underline; }
.inline-link { display: inline-block; margin-top: 18px; }

.support-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(210px, 290px);
  align-items: center;
  gap: clamp(22px, 5vw, 46px);
  background: linear-gradient(135deg, #fff 0%, #f8f3ff 100%);
}
.support-copy h2 { margin: 5px 0 10px; font-size: clamp(1.45rem, 3vw, 2rem); }
.support-copy p { color: var(--muted); line-height: 1.7; }
.support-note { font-size: .82rem; }
.support-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.support-actions span { font-size: .86rem; color: var(--muted); }
.secondary-action {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 11px 16px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.secondary-action:hover { border-color: #9b67d4; color: #7b3db8; }
.qr-card {
  justify-self: center;
  width: min(100%, 270px);
  padding: 14px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid #eadcf7;
  box-shadow: 0 16px 40px rgba(93, 48, 137, .10);
  text-align: center;
}
.qr-card span { display: block; margin-bottom: 10px; color: #6f3ba0; font-size: .78rem; font-weight: 800; }
.qr-card img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 14px; background: #faf8fc; }

.explain-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.explain-grid strong { display: block; margin-bottom: 8px; }
.explain-grid p { margin: 0; color: var(--muted); line-height: 1.6; font-size: .9rem; }

.site-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  max-width: 1180px;
  margin: 36px auto 0;
  padding: 28px 24px 42px;
  color: var(--muted);
}
.site-footer div { display: grid; gap: 4px; }
.site-footer strong { color: var(--text); }
.site-footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 18px; }
.site-footer a { color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 700; }
.site-footer a:hover { color: var(--green); }

/* Páginas editoriales */
.content-shell { width: min(100% - 32px, 980px); margin: 26px auto 70px; }
.content-hero,
.content-card,
.history-table-panel {
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 44px);
}
.content-hero { margin-bottom: 18px; }
.content-hero h1 { margin: 8px 0 12px; font-size: clamp(2rem, 6vw, 3.4rem); letter-spacing: -.045em; }
.content-hero p { max-width: 740px; margin: 0; color: var(--muted); line-height: 1.75; }
.content-card + .content-card { margin-top: 16px; }
.content-card h2 { margin-top: 0; }
.content-card h3 { margin-top: 26px; }
.content-card p,
.content-card li { color: var(--muted); line-height: 1.75; }
.content-card a { color: var(--green); }
.content-meta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.content-meta span { padding: 7px 11px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: .78rem; font-weight: 700; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.page-actions a,
.page-actions button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 999px; padding: 0 17px; text-decoration: none; font: inherit; font-weight: 800; cursor: pointer; }
.page-actions .primary-page-action { background: var(--dark); color: #fff; border: 1px solid var(--dark); }
.page-actions .secondary-page-action { background: #fff; color: var(--text); border: 1px solid var(--border); }

.history-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 20px 0; }
.history-summary-grid article { padding: 16px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface-soft); }
.history-summary-grid span { display: block; color: var(--muted); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.history-summary-grid strong { display: block; margin-top: 7px; font-size: 1.2rem; }
.table-scroll { overflow: auto; border: 1px solid var(--border); border-radius: 16px; }
.history-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.history-table th,
.history-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); text-align: right; font-size: .85rem; }
.history-table th:first-child,
.history-table td:first-child { text-align: left; }
.history-table th { position: sticky; top: 0; z-index: 1; background: #f8faf7; color: var(--muted); font-size: .7rem; letter-spacing: .05em; text-transform: uppercase; }
.history-table tbody tr:hover { background: #fafcf9; }
.history-table .leader-cell { font-weight: 800; }
.empty-state { padding: 32px; text-align: center; color: var(--muted); }

.contact-links { display: grid; gap: 12px; margin-top: 20px; }
.contact-links a { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 15px; padding: 15px 16px; text-decoration: none; color: var(--text); font-weight: 800; }
.contact-links a:hover { border-color: var(--green); }
.contact-links [hidden] { display: none !important; }

@media (max-width: 900px) {
  .header-nav { display: none; }
  .insight-grid,
  .history-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .support-panel { grid-template-columns: 1fr; }
  .qr-card { justify-self: start; }
  .site-footer { flex-direction: column; }
  .site-footer nav { justify-content: flex-start; }
}

@media (max-width: 620px) {
  .insight-grid,
  .explain-grid,
  .history-summary-grid { grid-template-columns: 1fr; }
  .ad-panel { min-height: 90px; padding: 18px 10px; }
  .support-panel { padding: 22px; }
  .qr-card { width: min(100%, 250px); justify-self: center; }
  .panel-heading { align-items: flex-start; }
  .secondary-link { white-space: normal; }
}
