/* ── Election Tracker ─────────────────────────────────────────────────────── */

#section-elections {
  padding: 0;
  overflow-x: hidden;
}

.el-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 20px 28px 48px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.el-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.el-last-poll {
  margin-right: auto;
  color: #6b7b96;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.el-data-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  border: 1px solid #195AB4;
  background: #0f4f9f;
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 6px 14px rgba(25, 90, 180, 0.16);
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.el-data-download::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  background:
    linear-gradient(#fff, #fff) 5px 0 / 2px 7px no-repeat,
    linear-gradient(135deg, transparent 45%, #fff 46% 55%, transparent 56%) 2px 4px / 8px 8px no-repeat,
    linear-gradient(45deg, transparent 45%, #fff 46% 55%, transparent 56%) 2px 4px / 8px 8px no-repeat,
    linear-gradient(#fff, #fff) 1px 10px / 10px 2px no-repeat;
}

.el-data-download:hover {
  background: #001F62;
  border-color: #001F62;
  box-shadow: 0 8px 18px rgba(0, 31, 98, 0.2);
}

#el-report-link::before {
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6'/%3E%3Cpolyline points='15 3 21 3 21 9'/%3E%3Cline x1='10' y1='14' x2='21' y2='3'/%3E%3C/svg%3E") center / 13px 13px no-repeat;
}

/* ── Panel (mirrors .ftm-panel) ────────────────────────────────────────────── */
.el-panel {
  min-width: 0;
  box-sizing: border-box;
  background: #fff;
  border: 1px solid #e3e9f3;
  border-radius: 8px;
  padding: 20px 24px 26px;
  box-shadow: 0 1px 2px rgba(0, 31, 98, 0.04);
}

.el-panel-header {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #c8d6ea;
}

.el-header-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.el-range-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: #EFF2F8;
}

.el-range-btn {
  padding: 4px 11px;
  border: 0;
  border-radius: 4px;
  background: none;
  color: #6B7B96;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  transition: all .12s;
}

.el-range-btn:hover {
  color: #001F62;
}

.el-range-btn.active {
  background: #fff;
  color: #195AB4;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}

.el-source-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 5px 6px 5px 12px;
  border: 1px solid #9fc3f0;
  border-radius: 8px;
  background: #edf6ff;
  box-shadow: 0 1px 0 rgba(25, 90, 180, 0.08);
}

.el-source-label {
  color: #0f4f9f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.4px;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

.el-source-select {
  min-width: 190px;
  max-width: 280px;
  height: 32px;
  border: 1px solid #8bb8ec;
  border-radius: 6px;
  background: #fff;
  color: #001F62;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 0 10px;
}

.el-source-select:focus {
  outline: none;
  border-color: #195AB4;
  box-shadow: 0 0 0 2px rgba(25, 90, 180, 0.12);
}

.el-panel-title {
  min-width: 0;
  font-size: 16px;
  font-weight: 700;
  color: #001F62;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0;
}

.el-note {
  font-size: 12px;
  color: #6f7f95;
  margin-bottom: 18px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

/* ── Charts ────────────────────────────────────────────────────────────────── */
.el-split-chart {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  align-items: stretch;
  gap: 22px;
  min-width: 0;
}

.el-chart-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: hidden;
}
.el-chart-lg   { height: 430px; }

.el-chart-wrap canvas {
  max-width: 100% !important;
}

.el-latest-card {
  min-width: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 14px 12px;
  border: 1px solid #e3e9f3;
  border-radius: 8px;
  background: #fbfcff;
}

.el-latest-title {
  min-height: 38px;
  text-align: center;
  color: #001F62;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.el-latest-title span,
.el-latest-title small {
  display: block;
}

.el-latest-title small {
  margin-top: 3px;
  color: #6b7b96;
  font-size: 11px;
  font-weight: 600;
}

.el-latest-chart-wrap {
  position: relative;
  min-width: 0;
  height: 310px;
}

.el-latest-chart-wrap canvas {
  max-width: 100% !important;
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.el-scenario-tabs,
.el-ps-tab-bar {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.el-scenario-tab,
.el-ps-tab {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid #d1daea;
  background: #fff;
  color: #24324a;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.el-scenario-tab:hover,
.el-ps-tab:hover {
  border-color: #195AB4;
  color: #195AB4;
  background: #f7f9fc;
}

.el-scenario-tab.active,
.el-ps-tab.active {
  background: #0f4f9f;
  border-color: #195AB4;
  color: #fff;
}

/* ── Pollster grid ─────────────────────────────────────────────────────────── */
.el-pollster-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 4px;
  min-width: 0;
}

.el-pollster-breakdown-panel {
  display: none;
}

.el-pollster-card {
  min-width: 0;
  box-sizing: border-box;
  background: #fbfcff;
  border: 1px solid #e4ebf5;
  border-radius: 8px;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.el-analysts-card {
  padding: 16px 24px;
}

.el-analysts-card .analysts-footer {
  padding: 0;
  gap: 18px;
}

.el-pc-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.el-pc-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #001F62;
}

.el-pc-date {
  font-size: 11px;
  color: #7b8da6;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.el-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.el-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: #334155;
  background: #f5f7fb;
  border: 1px solid #dce4ef;
  border-radius: 4px;
  padding: 3px 7px 3px 5px;
}

.el-badge strong {
  color: #111827;
  font-weight: 700;
}

.el-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--candidate-color);
}

/* ── Mini chart ─────────────────────────────────────────────────────────────── */
.el-pc-chart-wrap {
  position: relative;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  height: 155px;
}

.el-pc-chart-wrap canvas {
  max-width: 100% !important;
}

/* ── Error ──────────────────────────────────────────────────────────────────── */
.el-error {
  color: #dc2626;
  padding: 24px;
  font-size: 14px;
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .el-wrap { padding: 16px 18px 42px; }
  .el-split-chart { grid-template-columns: minmax(0, 1fr) minmax(260px, 320px); gap: 16px; }
  .el-chart-lg { height: 380px; }
  .el-latest-chart-wrap { height: 280px; }
  .el-pollster-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1180px) {
  .el-split-chart { grid-template-columns: minmax(0, 1fr) minmax(270px, 330px); }
}

@media (max-width: 768px) {
  .el-wrap           { padding: 12px 14px 36px; gap: 18px; }
  .el-panel          { padding: 16px 14px 20px; }
  .el-panel-header   { align-items: stretch; flex-direction: column; }
  .el-topbar         { align-items: stretch; flex-direction: column; justify-content: stretch; }
  .el-last-poll      { margin-right: 0; }
  .el-data-download  { width: 100%; }
  .el-header-controls { align-items: stretch; flex-direction: column; }
  .el-range-toggle   { justify-content: stretch; }
  .el-range-btn      { flex: 1; }
  .el-source-control { width: 100%; box-sizing: border-box; justify-content: space-between; }
  .el-source-select  { max-width: none; width: 100%; }
  .el-split-chart    { grid-template-columns: 1fr; }
  .el-chart-lg       { height: 300px; }
  .el-latest-chart-wrap { height: 240px; }
  .el-pollster-grid  { grid-template-columns: 1fr; }
  .el-pc-chart-wrap  { height: 130px; }
}

@media (max-width: 520px) {
  .el-wrap { padding: 10px 10px 30px; }
  .el-panel { padding: 14px 10px 18px; }
  .el-panel-title { font-size: 14px; line-height: 1.25; }
  .el-chart-lg { height: 280px; }
  .el-latest-card { padding: 12px 10px; }
  .el-latest-chart-wrap { height: 220px; }
  .el-analysts-card { padding: 14px 16px; }
  .el-scenario-tab,
  .el-ps-tab {
    font-size: 11.5px;
    padding: 5px 9px;
  }
}
