/* ── Design tokens (matched to NH Forum / nhforum.org) ───────────────── */
:root {
  --navy: #182A4C;
  --blue: #182A4C;
  --blue-hover: #0E1B33;
  --light-blue: #879DAF;
  --sky: #879DAF;
  --cream: #F6F1EA;
  --beige: #DBD6CD;
  --white: #ffffff;
  --grey-50: #F1ECE3;
  --grey-100: #E7E1D7;
  --grey-200: #DBD6CD;
  --grey-300: #C9C3B8;
  --grey-400: #9ca3af;
  --grey-500: #6b7280;
  --grey-600: #4b5563;
  --grey-700: #374151;
  --grey-800: #1f2937;
  --grey-900: #111827;
  --green: #059669;
  --green-bg: #d1fae5;
  --red: #D12921;
  --red-bg: #FBE3E1;
  --amber: #C1941A;
  --amber-bg: #F7ECCF;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --font-body: "Source Sans 3", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: "Source Serif 4", Georgia, serif;
  --transition: 200ms ease;
}

/* ── Reset & base ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--grey-700);
  line-height: 1.6;
}

/* ── Header ────────────────────────────────────────────────────────── */
.header {
  background: var(--navy);
  color: var(--white);
  box-shadow: 0 2px 8px rgba(24,42,76,.18);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0.875rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-icon {
  height: 36px;
  width: auto;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--white);
}
.brand-tagline {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--light-blue);
  letter-spacing: 0.01em;
}

/* ── Nav bar ───────────────────────────────────────────────────────── */
.nav-bar {
  background: var(--white);
  border-bottom: 1px solid var(--grey-200);
  box-shadow: var(--shadow-sm);
}
.nav-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
  display: flex;
  gap: 0;
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--grey-500);
  text-decoration: none;
  border-bottom: 2.5px solid transparent;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--navy);
  background: var(--grey-50);
}
.nav-link--active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* ── Content area ─────────────────────────────────────────────────── */
.content {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  min-height: calc(100vh - 200px);
}

/* ── Footer ───────────────────────────────────────────────────────── */
.footer {
  background: var(--navy);
  color: var(--light-blue);
  text-align: center;
}
.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem 2rem;
}
.footer-inner p {
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.5;
}

/* ── Cards ─────────────────────────────────────────────────────────── */
.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--grey-200);
  transition: box-shadow var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.card .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey-500);
  margin-bottom: 0.4rem;
  font-weight: 600;
}
.card .sublabel {
  font-size: 0.7rem;
  color: var(--grey-500);
  margin-bottom: 0.3rem;
}
.card .value {
  font-family: var(--font-heading);
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.1;
}
.card .sub {
  font-size: 0.78rem;
  color: var(--grey-400);
  margin-top: 0.35rem;
  line-height: 1.4;
}

/* ── Chart container ──────────────────────────────────────────────── */
.chart-container {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--grey-200);
  margin-bottom: 2rem;
}
.chart-container h3 {
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--grey-900);
}

/* ── Page header ──────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 1.5rem;
}
.page-header h2 {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0.25rem;
}
.page-header h3 {
  font-family: var(--font-heading);
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--navy);
  margin-bottom: 0.25rem;
}
.page-header p {
  font-size: 0.9rem;
  color: var(--grey-500);
  max-width: 700px;
}

/* ── Grid layouts ─────────────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.grid-sidebar {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 1.25rem;
  margin-bottom: 2rem;
}

/* ── Controls ─────────────────────────────────────────────────────── */
.control-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--grey-600);
  margin-bottom: 0.35rem;
  display: block;
}
.control-group {
  margin-bottom: 1rem;
}
.control-note {
  font-size: 0.78rem;
  color: var(--grey-400);
  margin-top: 0.75rem;
  line-height: 1.4;
}

/* ── Filter row ───────────────────────────────────────────────────── */
.filter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.filter-item {
  display: flex;
  flex-direction: column;
}

.input-number {
  width: 80px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--grey-700);
  background: var(--grey-50, #f7f7f7);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
}

/* ── Slider & Concentration result ────────────────────────────────── */
#voting-metrics-row {
  grid-template-columns: 1fr 1fr 2fr;
}
#voting-metrics-row .card {
  padding: 0.75rem 1rem;
}
.card--concentration {
  max-width: none;
}
.concentration-layout {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 0.4rem;
}
.concentration-sliders {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 0 0 auto;
  width: 65%;
}
.slider-item {
  min-width: 0;
}
.slider-item .control-label {
  margin-bottom: 0.15rem;
  display: block;
  font-size: 0.75rem;
}
.slider {
  width: 100%;
  accent-color: var(--blue);
  cursor: pointer;
}
.concentration-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.concentration-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}
.concentration-pct {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--blue);
  line-height: 1;
}
.concentration-desc {
  font-size: 0.7rem;
  color: var(--grey-600);
  text-align: center;
}
.concentration-detail {
  font-size: 0.85rem;
  color: var(--grey-500);
  text-align: center;
  margin: 0.5rem 0 0;
}
.concentration-bar-wrap {
  max-width: 100%;
  margin: 0 auto 0.25rem;
}
.concentration-count {
  font-size: 0.8rem;
  color: var(--grey-500);
  margin: 0;
}

/* ── Dropdown checkbox ────────────────────────────────────────────── */
.dropdown-check {
  position: relative;
}
.dropdown-check-btn {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--grey-700);
  background: var(--grey-50, #f7f7f7);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.dropdown-check-btn:hover {
  border-color: var(--grey-300);
}
.dropdown-check-btn:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 42, 76, 0.12);
}
.dropdown-check-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-height: 220px;
  overflow-y: auto;
  margin-top: 4px;
  padding: 0.25rem 0;
}
.dropdown-check.open .dropdown-check-list {
  display: block;
}
.dropdown-check-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}
.dropdown-check-item:hover {
  background: var(--grey-50, #f9f9f9);
}

/* ── Form controls ────────────────────────────────────────────────── */
.form-select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--grey-700);
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: auto;
}
.form-select:hover {
  border-color: var(--grey-300);
}
.form-select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(24, 42, 76, 0.12);
}
.form-select[multiple] {
  min-height: 80px;
}

.radio-group {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.radio-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--grey-600);
  cursor: pointer;
}
.radio-group input[type="radio"] {
  accent-color: var(--blue);
}

/* ── Voter count badge ────────────────────────────────────────────── */
.voter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--green-bg);
  color: #065f46;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.3rem 0.75rem;
  border-radius: 99px;
  margin-top: 0.75rem;
}

/* ── Table ─────────────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
}
.table-container table {
  width: 100%;
  border-collapse: collapse;
}
.table-container th,
.table-container td {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--grey-100);
  font-size: 0.875rem;
}
.table-container th {
  background: var(--grey-50);
  font-weight: 600;
  color: var(--grey-600);
  white-space: nowrap;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.table-container tr:hover td {
  background: rgba(135,157,175,.12);
}

/* ── CSS Bar charts ───────────────────────────────────────────────── */
.bar-chart-container {
  padding: 0.5rem 0;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.bar-label {
  width: 200px;
  flex-shrink: 0;
  text-align: right;
  font-size: 0.85rem;
  color: var(--grey-600);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  flex: 1;
  height: 20px;
  background: var(--grey-200);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  min-width: 2px;
}
.bar-fill--navy { background: var(--navy); }
.bar-fill--blue { background: var(--blue); }
.bar-fill--green { background: var(--green); }
.bar-fill--red { background: var(--red); }
.bar-fill--amber { background: var(--amber); }
.bar-fill--sky { background: var(--sky); }
.bar-value {
  min-width: 60px;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--grey-700);
}

/* ── Stacked bar (likes/dislikes) ─────────────────────────────────── */
.stacked-track {
  flex: 1;
  height: 20px;
  background: var(--grey-200);
  border-radius: 4px;
  overflow: hidden;
  display: flex;
}
.stacked-fill--green {
  background: var(--green);
  height: 100%;
  transition: width 0.6s ease;
}
.stacked-fill--red {
  background: var(--red);
  height: 100%;
  transition: width 0.6s ease;
}

/* ── Legend ────────────────────────────────────────────────────────── */
.legend {
  margin-bottom: 12px;
  font-size: 0.82rem;
}
.legend-green { color: var(--green); margin-right: 16px; }
.legend-red { color: var(--red); }

/* ── Inline bar in voting table ───────────────────────────────────── */
.inline-bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inline-bar-track {
  flex: 1;
  background: var(--grey-200);
  border-radius: 4px;
  height: 18px;
  overflow: hidden;
}
.inline-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
  transition: width 0.6s ease;
}
.inline-bar-pct {
  min-width: 55px;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── Divider ──────────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--grey-200);
  margin: 1rem 0;
}

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
  color: var(--grey-400);
  font-size: 0.9rem;
  padding: 1rem 0;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner { padding: 0.75rem 1rem; }
  .nav-inner { padding: 0 1rem; overflow-x: auto; }
  .nav-link { padding: 0.75rem 1rem; font-size: 0.85rem; }
  .content { padding: 1.25rem 1rem; }
  .card-row { grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-sidebar { grid-template-columns: 1fr; }
  .filter-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .card-row { grid-template-columns: 1fr; }
  .brand-tagline { display: none; }
}

/* ── Pagination ───────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1rem 0 0.25rem;
}
.pag-btn {
  padding: 0.4rem 1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--blue);
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.pag-btn:hover:not(:disabled) {
  background: var(--grey-50);
  border-color: var(--blue);
}
.pag-btn:disabled {
  color: var(--grey-300);
  cursor: not-allowed;
}
.pag-info {
  font-size: 0.85rem;
  color: var(--grey-500);
  font-weight: 500;
}

/* ── Issue row clickable ──────────────────────────────────────────── */
.issue-row:hover td {
  background: rgba(24, 42, 76, 0.06) !important;
}

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.modal-overlay--visible {
  opacity: 1;
  pointer-events: auto;
}
.modal {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--grey-200);
}
.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
  padding-right: 1rem;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--grey-400);
  cursor: pointer;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color var(--transition);
}
.modal-close:hover {
  color: var(--grey-700);
}
.modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
}
.modal-description {
  margin: 0 0 1.25rem 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--grey-700, #444);
}
.modal-dimension-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.modal-tab {
  padding: 0.35rem 0.9rem;
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--grey-500);
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: 99px;
  cursor: pointer;
  transition: all var(--transition);
}
.modal-tab:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.modal-tab--active {
  background: var(--blue);
  color: var(--white);
  border-color: var(--blue);
}
.modal-tab--active:hover {
  color: var(--white);
}

/* ── What-If Panel ────────────────────────────────────────────────── */
.filter-section {
  margin-bottom: 1rem;
}
.filter-section .control-label {
  margin-bottom: 0.4rem;
}
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.cb-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.84rem;
  color: var(--grey-600);
  cursor: pointer;
}
.cb-label input[type="checkbox"] {
  accent-color: var(--blue);
}
.voting-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.whatif-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}
.whatif-card {
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.whatif-card-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--navy);
  margin-bottom: 0.5rem;
}
.whatif-list {
  padding-left: 1.25rem;
  margin: 0;
}
.whatif-list li {
  font-size: 0.82rem;
  color: var(--grey-600);
  line-height: 1.7;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.whatif-votes {
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--grey-400);
  margin-left: 0.5rem;
  flex-shrink: 0;
}
