*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: monospace;
  font-size: 13px;
  background: #0d1117;
  color: #c9d1d9;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}
.header h1 { margin: 0; font-size: 1.1em; color: #58a6ff; }
.header .meta { font-size: 0.85em; color: #8b949e; }
.header .meta.pulsing { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ── Demo control bar ────────────────────────────────────────────── */
.demo-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #1c2128;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
  font-size: 0.85em;
}
.demo-bar select,
.demo-bar button {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font-size: 0.85em;
  padding: 2px 8px;
  cursor: pointer;
}
.demo-bar button:hover { background: #30363d; }

.demo-badge {
  border-radius: 10px;
  padding: 1px 8px;
  font-size: 0.8em;
  font-weight: bold;
}
.demo-badge--running { background: #1f6feb; color: #fff; }
.demo-badge--paused  { background: #9e6a03; color: #e3b341; }
.demo-badge--done    { background: #30363d; color: #8b949e; }
.demo-badge--idle    { background: #30363d; color: #8b949e; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  letter-spacing: .05em;
}
.badge--demo {
  background: #92400e;
  color: #fcd34d;
}
.badge--live {
  background: #14532d;
  color: #4ade80;
}
.badge-dot {
  width: 6px;
  height: 6px;
  background: #4ade80;
  border-radius: 50%;
  animation: badge-pulse 2s ease-in-out infinite;
}
@keyframes badge-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ── Three columns ───────────────────────────────────────────────── */
.columns {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid #30363d;
  overflow: hidden;
}
.col-parties  {}
.col-candidates {}
.col-detail { flex: 1; border-right: none; }

.col-header {
  padding: 6px 12px;
  border-bottom: 1px solid #21262d;
  color: #8b949e;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.col-body {
  overflow-y: auto;
  flex: 1;
  padding: 4px 0;
}

/* ── Party rows ──────────────────────────────────────────────────── */
.party-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 12px;
  cursor: pointer;
  user-select: none;
}
.party-row:hover { background: #161b22; }
.party-row.selected {
  background: #1c2128;
  border-left: 2px solid #3fb950;
}
.party-row.selected .party-name { color: #e6edf3; font-weight: bold; }
.party-row input[type=checkbox] { margin-top: 2px; flex-shrink: 0; accent-color: #3fb950; }
.party-name { color: #e6edf3; }
.party-sub  { color: #8b949e; font-size: 0.85em; margin-top: 1px; }
.flip-gain  { color: #3fb950; }
.flip-lose  { color: #f85149; }

/* ── Candidate rows ──────────────────────────────────────────────── */
.party-group-label {
  padding: 4px 12px 2px;
  color: #8b949e;
  font-size: 0.8em;
  text-transform: uppercase;
  margin-top: 6px;
}
.candidate-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 5px 12px;
  cursor: pointer;
  user-select: none;
}
.candidate-row:hover { background: #161b22; }
.candidate-row.focused {
  background: #1c2128;
  border-left: 2px solid #388bfd;
}
.cand-name { color: #e6edf3; }
.cand-sub  { color: #8b949e; font-size: 0.85em; margin-top: 1px; }

/* ── Right panel ─────────────────────────────────────────────────── */
.detail-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1;
}
.detail-placeholder {
  color: #8b949e;
  padding: 24px 16px;
}
.detail-section-label {
  color: #8b949e;
  font-size: 0.8em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 12px 0 4px;
  border-top: 1px solid #21262d;
  padding-top: 8px;
}
.detail-section-label:first-child { border-top: none; margin-top: 0; padding-top: 0; }

/* ── Tables ──────────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}
.data-table th {
  color: #8b949e;
  text-align: left;
  padding: 3px 6px;
  border-bottom: 1px solid #21262d;
  font-weight: normal;
}
.data-table th:last-child { text-align: right; }
.data-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #161b22;
  color: #e6edf3;
}
.data-table td:last-child { text-align: right; color: #3fb950; }
.data-table td.null-votes { color: #8b949e; text-align: right; }

/* ── Candidate feed items ────────────────────────────────────────── */
.feed-item-cand { color: #3fb950; font-size: 0.9em; margin: 2px 0; }

/* ── Party detail ────────────────────────────────────────────────── */
.party-detail-block { margin-bottom: 16px; }
.party-detail-name  { color: #e6edf3; font-weight: bold; margin-bottom: 4px; }
.party-detail-meta  { color: #8b949e; font-size: 0.9em; margin-bottom: 6px; }

/* ── Feed panel ──────────────────────────────────────────────────── */
.feed-panel {
  flex-shrink: 0;
  border-top: 2px solid #58a6ff;
  background: #0d1117;
  display: flex;
  flex-direction: column;
  min-height: 52px;
  position: relative;
}
.feed-panel-resize {
  position: absolute;
  top: -4px;
  left: 0;
  right: 0;
  height: 8px;
  cursor: ns-resize;
  z-index: 10;
}
.feed-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 12px;
  background: #161b22;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}
.feed-panel-label { color: #8b949e; font-size: 0.8em; text-transform: uppercase; }
.feed-panel-count { color: #58a6ff; font-size: 0.8em; }
.feed-panel-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}
.feed-panel-empty { color: #8b949e; font-size: 0.85em; padding: 8px 12px; }
.feed-place-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 0.88em;
  border-bottom: 1px solid #21262d;
}
.feed-place-row:hover { background: #161b22; }
.feed-place-row.selected { background: #1f2937; border-left: 2px solid #58a6ff; padding-left: 10px; }
.feed-place-time { color: #484f58; font-size: 0.85em; min-width: 36px; }
.feed-place-name { color: #58a6ff; flex: 1; }
.feed-place-type { color: #8b949e; font-size: 0.85em; }
.feed-place-region { color: #484f58; font-size: 0.85em; }

/* ── Detail tabs ─────────────────────────────────────────────────── */
.detail-tabs { display: flex; border-bottom: 1px solid #21262d; }
.detail-tab {
  padding: 6px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #8b949e;
  cursor: pointer;
  font-size: 0.85em;
}
.detail-tab.active { color: #c9d1d9; border-bottom-color: #58a6ff; }
.detail-tab:hover { color: #c9d1d9; }

/* ── Sted detail ─────────────────────────────────────────────────── */
.sted-detail { padding: 8px 12px; }
.sted-name { color: #e6edf3; font-weight: bold; margin-bottom: 2px; }
.sted-meta { color: #8b949e; font-size: 0.85em; margin-bottom: 8px; }
.delta-pos { color: #3fb950; text-align: right; }

/* ── Column resize handles ───────────────────────────────────────── */
.col-resize-handle {
  width: 4px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  transition: background 0.15s;
}
.col-resize-handle:hover { background: #58a6ff44; }

/* ── Scrollbar ───────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

/* ── About button ─────────────────────────────────────────────────── */
.about-btn {
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 4px;
  color: #c9d1d9;
  font-family: monospace;
  font-size: 0.85em;
  padding: 2px 10px;
  cursor: pointer;
  flex-shrink: 0;
}
.about-btn:hover { background: #30363d; }

/* ── About modal ──────────────────────────────────────────────── */
.about-backdrop {
  position: fixed;
  inset: 0;
  background: #000000bb;
  z-index: 100;
}
.about-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 101;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 6px;
  width: min(560px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.about-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}
.about-modal-title {
  color: #58a6ff;
  font-size: 1.05em;
  font-weight: bold;
}
.about-close {
  background: none;
  border: none;
  color: #8b949e;
  cursor: pointer;
  font-size: 1em;
  padding: 2px 6px;
  border-radius: 3px;
}
.about-close:hover { background: #21262d; color: #c9d1d9; }
.about-modal-body {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.about-section-heading {
  color: #c9d1d9;
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 0.9em;
}
.about-section p {
  color: #8b949e;
  line-height: 1.6;
  margin: 0;
}
.about-section a { color: #58a6ff; }
.about-section a:hover { text-decoration: underline; }
.about-section code {
  background: #21262d;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.9em;
  color: #c9d1d9;
}

/* ── Candidate breakdown in party detail ─────────────────────── */
.cand-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 3px 0;
  font-size: 0.9em;
}
.cand-breakdown-row.cand-in  { color: #e6edf3; }
.cand-breakdown-row.cand-out { color: #8b949e; }
.cand-breakdown-name { flex: 1; }
.cand-breakdown-kreds { color: #484f58; font-size: 0.85em; margin-right: 8px; }
.cand-breakdown-sk {
  color: #60a5fa;
  font-size: 0.78em;
  opacity: 0.85;
  white-space: nowrap;
}
.cand-breakdown-votes { color: #3fb950; text-align: right; min-width: 60px; }
.cand-breakdown-row.cand-out .cand-breakdown-votes { color: #8b949e; }
.cand-cutoff {
  border-top: 1px dashed #388bfd44;
  margin: 4px 0;
  padding-top: 4px;
  font-size: 0.78em;
  color: #484f58;
}
.cand-breakdown-prelim-note {
  color: #8b949e;
  font-size: 0.85em;
  font-style: italic;
  padding: 4px 0 8px;
}

/* ── Storkreds group header (candidates column) ────────────────────────────── */
.sk-group-header {
  padding: 5px 10px;
  font-size: 0.75em;
  font-weight: 600;
  color: #8b949e;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #21262d;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sk-group-header:hover {
  background: #161b22;
  color: #c9d1d9;
}

.sk-group-header--active {
  color: #58a6ff;
  background: #0d1117;
}

.sk-active-indicator {
  color: #58a6ff;
}

/* ── Storkreds detail panel heading ────────────────────────────────────────── */
.sk-detail-heading {
  font-size: 0.85em;
  font-weight: 600;
  color: #58a6ff;
  padding: 8px 12px 4px;
  border-bottom: 1px solid #21262d;
  margin-bottom: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* ── Elected / Ikke valgt section labels ───────────────────────────────────── */
.sk-section-label {
  font-size: 0.7em;
  font-weight: 600;
  color: #8b949e;
  padding: 6px 12px 2px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ── Mangler annotation ────────────────────────────────────────────────────── */
.cand-breakdown-mangler {
  font-size: 0.8em;
  color: #f85149;
  margin-left: 6px;
  white-space: nowrap;
}
.cand-mandate-type {
  font-size: 0.75em;
  margin-left: 6px;
  white-space: nowrap;
}
