:root {
  --bg: #0a0f14;
  --bg-gradient: linear-gradient(135deg, #0a0f14 0%, #0d1520 50%, #0a1018 100%);
  --card: #0e1822;
  --card-hover: #121f2d;
  --muted: #7a8fa8;
  --border: #1a2a3a;
  --accent: #3aaed8;
  --accent-glow: rgba(58, 174, 216, 0.15);
  --pn-color: #0047ab;
  --plh-color: #c1121f;
  --success: #34d399;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: #e6eef8;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  margin: 0 0 8px;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #a8c5d8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: #fff;
}

h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  color: #e6eef8;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  border-color: rgba(58, 174, 216, 0.2);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.blog-card {
  padding: 12px 14px;
}

.blog-card .section-title {
  margin-bottom: 6px;
}

#summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 0 0 16px;
}

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.ghost-btn:hover {
  background: rgba(58, 174, 216, 0.08);
  border-color: rgba(58, 174, 216, 0.3);
  color: #fff;
}

.ghost-btn.active {
  background: rgba(58, 174, 216, 0.12);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(58, 174, 216, 0.15);
}

.notif-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  margin-left: 6px;
  animation: pulse 1.5s ease-in-out infinite;
}

.notif-dot[hidden] {
  display: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.2); }
}

.blog-card + .blog-card {
  margin-top: 12px;
}

.stat {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.2);
  transition: border-color 0.2s ease;
}

.stat:hover {
  border-color: rgba(58, 174, 216, 0.3);
}

.label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.value {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  font-family: "JetBrains Mono", monospace;
  color: #fff;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

.bar-label {
  font-weight: 600;
}

.bar-value {
  background: #0c1a26;
  border-radius: 10px;
  height: 40px;
  overflow: hidden;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.bar-fill {
  height: 100%;
  border-radius: 9px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 100%);
  border-radius: 9px 9px 0 0;
}

.bar-meta {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.2);
  position: sticky;
  top: 0;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease, background 0.15s ease;
}

th.sortable:hover {
  color: var(--accent);
  background: rgba(58, 174, 216, 0.1);
}

th.sort-asc,
th.sort-desc {
  color: var(--accent);
}

td {
  font-size: 13px;
}

tbody tr {
  transition: background-color 0.15s ease;
}

tbody tr:hover {
  background: rgba(58, 174, 216, 0.05);
}

.progress-track {
  position: relative;
  background: #0c1a26;
  border-radius: 999px;
  height: 6px;
  overflow: hidden;
  margin-top: 6px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #2d8ab8, #3aaed8, #5bc4e8);
  box-shadow: 0 0 8px rgba(58, 174, 216, 0.4);
}

.progress-label {
  font-size: 13px;
  color: var(--muted);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.delta-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.delta-item {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 6px 0;
}

.delta-name {
  font-weight: 600;
}

.delta-pos {
  color: #5ef0a6;
}

.delta-neg {
  color: #f87171;
}

.muted {
  color: var(--muted);
  margin: 0;
}

.pill {
  padding: 8px 14px;
  background: linear-gradient(135deg, #13263b 0%, #0e1f30 100%);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.02em;
}

footer {
  margin: 16px 0 0;
  font-size: 13px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin: 16px auto 0;
  display: none;
}

.blog-post h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.blog-post p {
  margin: 0 0 10px;
  color: #d7e1ed;
}

.blog-post p.muted {
  color: var(--muted);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.chart {
  width: 100%;
  min-height: 320px;
  overflow-x: auto;
}

.chart svg {
  width: 100%;
  height: auto;
  min-width: 600px;
}

.chart-grid {
  stroke: rgba(255, 255, 255, 0.06);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
  font-family: "JetBrains Mono", "Fira Code", monospace;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #e6eef8;
}

.legend-item strong {
  color: #fff;
}

.delta-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.delta-party {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* Trend Analysis Styles */
.velocity-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 14px;
}

.velocity-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.velocity-icon {
  font-size: 20px;
}

.velocity-title {
  font-weight: 600;
  color: #fff;
  font-size: 14px;
}

.velocity-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 22px;
  font-weight: 600;
  margin: 4px 0;
}

.velocity-value.widening {
  color: var(--success);
}

.velocity-value.closing {
  color: #f87171;
}

.velocity-value.stable {
  color: var(--muted);
}

.velocity-detail {
  font-size: 12px;
  color: var(--muted);
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.trend-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.trend-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.trend-party-name {
  font-weight: 600;
  color: #fff;
}

.trend-confidence {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.trend-confidence.high {
  background: rgba(52, 211, 153, 0.2);
  color: #34d399;
}

.trend-confidence.medium {
  background: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

.trend-confidence.low {
  background: rgba(156, 163, 175, 0.2);
  color: #9ca3af;
}

.trend-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.trend-row:last-child {
  border-bottom: none;
}

.trend-label {
  color: var(--muted);
  font-size: 12px;
}

.trend-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: #fff;
}

.trend-value.positive {
  color: var(--success);
}

.trend-value.negative {
  color: #f87171;
}

.confidence-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.confidence-range {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.confidence-fill {
  position: absolute;
  height: 100%;
  border-radius: 3px;
  opacity: 0.7;
}

.confidence-mid {
  position: absolute;
  width: 3px;
  height: 12px;
  top: -3px;
  background: #fff;
  border-radius: 2px;
}

.confidence-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
  font-family: "JetBrains Mono", monospace;
}

.winner-card {
  border-width: 2px;
}

.winner-card .trend-label {
  font-size: 12px;
  margin-bottom: 4px;
}

.winner-card .trend-value {
  font-size: 18px;
  margin-bottom: 2px;
}

/* Remaining Votes Analysis */
.remaining-votes-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.remaining-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.remaining-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}

.remaining-box.pn-lean {
  border-color: rgba(0, 71, 171, 0.4);
  background: linear-gradient(135deg, rgba(0, 71, 171, 0.15) 0%, rgba(0, 0, 0, 0.25) 100%);
}

.remaining-box.plh-lean {
  border-color: rgba(193, 18, 31, 0.4);
  background: linear-gradient(135deg, rgba(193, 18, 31, 0.15) 0%, rgba(0, 0, 0, 0.25) 100%);
}

.remaining-box-title {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.remaining-box-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 600;
  color: #fff;
}

.remaining-box-detail {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.remaining-dept-list {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 12px;
  max-height: 250px;
  overflow-y: auto;
}

.remaining-dept-item {
  display: grid;
  grid-template-columns: 1fr 80px 100px;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.remaining-dept-item:last-child {
  border-bottom: none;
}

.remaining-dept-name {
  color: #e6eef8;
}

.remaining-dept-votes {
  font-family: "JetBrains Mono", monospace;
  color: var(--muted);
  text-align: right;
}

.remaining-dept-lean {
  font-family: "JetBrains Mono", monospace;
  text-align: right;
  font-weight: 500;
}

.remaining-dept-lean.pn {
  color: var(--pn-color);
}

.remaining-dept-lean.plh {
  color: var(--plh-color);
}

/* Reporting Source Styles */
.reporting-source-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.reporting-alert {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.reporting-alert-icon {
  font-size: 20px;
}

.reporting-alert-text {
  flex: 1;
}

.reporting-alert-title {
  font-weight: 600;
  color: #fbbf24;
  margin-bottom: 4px;
}

.reporting-alert-detail {
  font-size: 13px;
  color: var(--muted);
}

.reporting-breakdown {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.reporting-breakdown-item {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.reporting-breakdown-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.reporting-breakdown-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  font-weight: 600;
}

.reporting-breakdown-value.pn {
  color: var(--pn-color);
}

.reporting-breakdown-value.plh {
  color: var(--plh-color);
}

.reporting-dept-list {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 8px;
  padding: 12px;
}

.reporting-dept-item {
  display: grid;
  grid-template-columns: 1fr 100px 80px;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 13px;
}

.reporting-dept-item:last-child {
  border-bottom: none;
}

.reporting-dept-bar {
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
  display: flex;
}

.reporting-dept-bar-pn {
  height: 100%;
  background: var(--pn-color);
}

.reporting-dept-bar-plh {
  height: 100%;
  background: var(--plh-color);
}

.impact-positive {
  color: var(--success);
}

.impact-negative {
  color: #f87171;
}
