:root {
  --bg-primary: #f6f7f9;
  --bg-card: #ffffff;
  --text-main: #14171a;
  --text-muted: #536471;
  --text-dim: #71767b;
  --border-light: #e1e8ed;
  --border-card: #cfd9de;
  --accent-red: #c62828;
  --accent-red-hover: #b71c1c;
  --accent-red-bg: #ffebee;
  --accent-red-border: #ffcdd2;
  --accent-green: #2e7d32;
  --accent-green-bg: #e8f5e9;
  --accent-green-border: #c8e6c9;
  --header-dark: #0f1419;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 6px 16px rgba(198, 40, 40, 0.12), 0 2px 4px rgba(0, 0, 0, 0.06);
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   HEADER & MASTHEAD
   ============================================================ */

.site-header {
  background: #ffffff;
  border-bottom: 2px solid var(--header-dark);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.masthead {
  padding: 14px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.masthead-main {
  flex: 1;
  min-width: 250px;
}

.site-title-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
}

.site-title-link:hover .site-title {
  color: var(--accent-red);
}

.site-title {
  font-size: clamp(1.5rem, 2.6vw, 2.2rem);
  font-weight: 900;
  color: var(--header-dark);
  letter-spacing: -0.02em;
  line-height: 1.1;
  transition: color 0.15s ease;
}

.masthead-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  background: #f1f3f5;
  border: 1px solid var(--border-card);
  border-radius: 6px;
  padding: 0 10px;
  transition: border-color 0.2s, background-color 0.2s;
  width: 280px;
}

.search-box:focus-within {
  background: #ffffff;
  border-color: var(--accent-red);
  box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.15);
}

.search-icon {
  color: var(--text-dim);
  margin-right: 8px;
  flex-shrink: 0;
}

.search-box input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--text-main);
  padding: 8px 0;
  width: 100%;
  font-family: inherit;
}

.search-box input::placeholder {
  color: var(--text-dim);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  display: none;
  line-height: 1;
}

.clear-btn:hover {
  color: var(--text-main);
}

/* ============================================================
   10x10 MATRIX GRID
   ============================================================ */

.matrix-wrapper {
  flex: 1;
  padding: 12px;
  max-width: 100%;
}

.matrix-grid {
  display: grid;
  /* Exactly 10 columns on wide screens */
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

/* Responsive Grid Breakpoints */
@media (max-width: 1680px) {
  .matrix-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 1100px) {
  .matrix-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
}

@media (max-width: 768px) {
  .matrix-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .masthead {
    padding: 10px 14px;
  }
  .search-box {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .matrix-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

/* ============================================================
   NEWS TILE CARD (CLICKABLE)
   ============================================================ */

.tile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-top: 3px solid var(--accent-red);
  border-radius: 4px;
  padding: 10px 11px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--card-shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
}

.tile-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  border-color: #adb5bd;
  border-top-color: var(--accent-red-hover);
}

.tile-card:focus-visible {
  outline: 2px solid var(--accent-red);
  outline-offset: 2px;
}

.card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  margin-bottom: 7px;
  flex-wrap: wrap;
}

.card-index {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  background: #f1f3f5;
  padding: 1px 5px;
  border-radius: 3px;
  letter-spacing: 0.04em;
}

.card-badge {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid var(--accent-red-border);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--header-dark);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

.card-summary {
  font-size: 11.5px;
  line-height: 1.45;
  color: var(--text-muted);
  flex-grow: 1;
}

.card-click-hint {
  font-size: 10px;
  color: var(--accent-red);
  font-weight: 600;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.tile-card:hover .card-click-hint {
  opacity: 1;
  text-decoration: underline;
}

/* ============================================================
   ELECTION MODAL DIALOG
   ============================================================ */

dialog.election-modal {
  border: none;
  border-radius: 8px;
  padding: 0;
  max-width: 640px;
  width: 92vw;
  background: #ffffff;
  color: var(--text-main);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.08);
  position: fixed;
  inset: 0;
  margin: auto;
  overflow: hidden;
}

dialog.election-modal::backdrop {
  background: rgba(15, 20, 25, 0.72);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

dialog.election-modal[open] {
  animation: modalScaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-box {
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  overflow-y: auto;
  padding: 24px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-location {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-close {
  background: #f1f3f5;
  border: 1px solid var(--border-card);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: var(--text-main);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s, color 0.15s;
}

.modal-close:hover {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border-color: var(--accent-red-border);
}

.modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--header-dark);
  line-height: 1.3;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--border-light);
  padding-bottom: 12px;
}

.modal-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

@media (max-width: 580px) {
  .modal-stats-grid {
    grid-template-columns: 1fr;
  }
}

.stat-card {
  border-radius: 6px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
}

.stat-inc {
  background: var(--accent-red-bg);
  border: 1px solid var(--accent-red-border);
  border-top: 3px solid var(--accent-red);
}

.stat-opp {
  background: var(--accent-green-bg);
  border: 1px solid var(--accent-green-border);
  border-top: 3px solid var(--accent-green);
}

.stat-total {
  background: #f1f3f5;
  border: 1px solid var(--border-card);
  border-top: 3px solid var(--header-dark);
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 900;
  font-family: var(--font-mono);
  color: var(--header-dark);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-inc .stat-value {
  color: var(--accent-red);
}

.stat-opp .stat-value {
  color: var(--accent-green);
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

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

.modal-subheading {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-top: 4px;
}

.modal-summary-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-main);
  background: #fafafa;
  padding: 10px 12px;
  border-radius: 4px;
  border-left: 3px solid var(--accent-red);
}

.modal-details-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
}

.modal-context-box {
  background: #f8f9fa;
  border: 1px solid var(--border-card);
  border-left: 3px solid var(--header-dark);
  border-radius: 4px;
  padding: 12px 14px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 12.5px;
}

.context-item {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  line-height: 1.45;
}

.context-label {
  font-weight: 700;
  color: var(--header-dark);
  min-width: 145px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.context-value {
  color: var(--text-main);
  flex: 1;
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border-light);
  padding-top: 14px;
}

.modal-btn {
  background: var(--header-dark);
  color: #ffffff;
  border: none;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.modal-btn:hover {
  background: var(--accent-red);
}

/* ============================================================
   NO RESULTS STATE
   ============================================================ */

.no-results {
  text-align: center;
  padding: 60px 20px;
  background: #ffffff;
  border: 1px dashed var(--border-card);
  border-radius: 8px;
  margin: 30px auto;
  max-width: 500px;
}

.no-results h3 {
  font-size: 1.2rem;
  color: var(--header-dark);
  margin-bottom: 8px;
}

.no-results p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.hidden {
  display: none !important;
}

/* ============================================================
   FOOTER
   ============================================================ */

.site-footer {
  background: #ffffff;
  border-top: 1px solid var(--border-card);
  padding: 16px 20px;
  margin-top: auto;
}

.footer-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-brand strong {
  color: var(--accent-red);
  font-size: 13px;
  letter-spacing: 0.02em;
}
