html, body { background: #0f1419; margin: 0; padding: 0; }
body { font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, sans-serif; color: #e8eaed; }

.hero { background: linear-gradient(135deg, #1a1f2e 0%, #2d1b3d 100%); color: #fff; padding: 15px 24px; text-align: center; }
.hero h1 { margin: 0; font-size: 42px; font-weight: 700; }

.sec { max-width: 1400px; margin: 0 auto; padding: 60px 40px; background: transparent; }
.sec-inner { display: flex; flex-direction: column; gap: 32px; align-items: center; }
.sec-text { flex: 0 0 auto; max-width: 380px; }
.sec-text h2 { margin: 0 0 16px; font-size: 32px; color: #f5f5f5; font-weight: 700; }
.sec-text p { margin: 0; color: #b8bcc4; line-height: 1.7; }
.sec-chart { flex: 1 1 0; width: 100%; position: relative; }
.sec-chart { flex: 1 1 0; width: 100%; position: relative; }

@media (min-width: 900px) {
  .sec-inner { flex-direction: row; gap: 48px; align-items: center; }
  .sec-text { margin-bottom: 0; }
  .sec-right .sec-inner { flex-direction: row-reverse; }
}

@media (max-width: 899px) {
  .sec { padding: 40px 24px; }
  .viz-grid.has-detail { flex-direction: column; }
  .viz-grid.has-detail > * { max-width: 100%; }
}

h1 { margin-bottom: 4px; }
h3 { color: #f5f5f5; font-size: 20px; margin: 0; }

#map-sec.mode-detail { padding: 20px 40px; }
#map-sec .sec-head { margin-bottom: 10px; }
#map-sec .sec-head h2 { margin: 0 0 4px; font-size: 22px; color: #f5f5f5; font-weight: 700; }
#map-sec .sec-head p { margin: 0; color: #b8bcc4; line-height: 1.3; font-size: 13px; }

.map-row { display: flex; gap: 12px; align-items: flex-start; width: 100%; }
#map-sec.mode-detail .map-row { gap: 2px; }
#map-sec.mode-main .map-row { justify-content: flex-start; flex-direction: row; }
#map-sec.mode-detail .map-row { justify-content: flex-start; flex-direction: column; }

#us-map-wrap { flex: 1 1 auto; transition: all 0.6s ease; background: transparent; min-width: 0; padding: 0; }
#map-sec.mode-main #us-map-wrap { width: 100%; }
#map-sec.mode-detail #us-map-wrap { width: 100%; max-width: 70%; max-height: 35vh; margin: 0 auto; padding-bottom: 8px; transition: all 0.6s ease; }
#map-sec.mode-detail #us-map-wrap svg { max-height: 35vh; transition: max-height 0.6s ease; }

#cty-map-wrap { 
  flex: 1 1 0; 
  min-width: 0; 
  display: none; 
  opacity: 0;
  transition: opacity 0.4s ease;
  background: transparent;
  width: 100%;
  max-height: 42vh;
  padding: 0;
  padding-top: 0;
}
#map-sec.mode-detail #cty-map-wrap { 
  display: block; 
  opacity: 1;
  margin-top: 2px;
}
#map-sec.mode-detail #cty-map-wrap svg { max-height: 42vh; }

#us-map-wrap svg, #cty-map-wrap svg { width: 100%; height: auto; display: block; background: transparent; }
#map rect.bg-white { fill: #0f1419 !important; pointer-events: all; }

#legend { margin-top: 3px; margin-bottom: 0; font-size: 13px; color: #d1d5db; }
#map-sec.mode-detail #legend { margin-bottom: 8px; }
#detail-legend { margin-top: 4px; margin-bottom: 0; font-size: 13px; color: #d1d5db; }
#detail-legend-sticky { 
  position: fixed; 
  bottom: 20px; 
  left: 140px; 
  background: rgba(15, 23, 42, 0.95); 
  padding: 12px 16px 12px 20px; 
  border-radius: 8px; 
  border: 1px solid #2a3340;
  font-size: 13px; 
  color: #d1d5db; 
  z-index: 1000;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
#map-sec.mode-detail #detail-legend-sticky { display: block; }
#map-sec.mode-detail #detail-legend-sticky[style*="opacity: 1"] { pointer-events: auto; }

#map .state { stroke: #2a3340 !important; stroke-width: 1.2px !important; vector-effect: non-scaling-stroke; }
#map path, #state-detail path { display: inline; opacity: 1; }

.cty-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; margin-top: 0; }
#detail-title { margin-right: 20px; padding-right: 16px; }
#reset { padding: 8px 14px; border-radius: 6px; border: 1px solid #3a404a; background: #1f2937; color: #e8eaed; cursor: pointer; font-weight: 500; }
#reset:hover { background: #374151; border-color: #4b5563; }

.scatter-wrap {
  background: transparent;
  padding: 0;
  border-radius: 0;
  width: 100%;
}

#scatter svg text {
  fill: #e5e7eb;
}

.reg-legend .reg-item {
  cursor: pointer;
}

.reg-legend .reg-item text {
  font-size: 11px;
}

.reg-legend .reg-item:hover circle {
  r: 6;
}

.reg-legend .reg-item:hover text {
  fill: #f5f5f5;
}

.radar-wrap {
  max-width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
}

@media (max-width: 899px) {
  #map-sec.mode-main #us-map-wrap { width: 100%; }
}

#scatter { width: 100%; height: auto; display: block; background: transparent; border-radius: 0; }

#radar {
  width: 100%;
  height: auto;
  display: block;
  background: transparent;
  max-width: 520px;
  margin: 0 auto;
}

.radar-grid circle {
  fill: none;  
  /* already styled in JS */
}


.radar-area {
  transition: d 0.3s ease-out;
}


/* === State Mini Dashboard === */

#state-dashboard {
  margin-top: 24px;
  font-size: 13px;
  max-width: 100%;
  max-height: 400px;
  overflow-y: auto;
  border-radius: 8px;
}

.state-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #2a3340;
  background: #1a1f2e;
}

.state-table .header .col {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}

.state-table .header .col:hover {
  color: #2563eb;
}

.state-row {
  display: grid;
  grid-template-columns: 60px repeat(4, minmax(0, 1fr)) 80px;
  column-gap: 8px;
  align-items: center;
  padding: 4px 8px;
  color: #e8eaed;
}

.state-row.header {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #252d3a;
  position: sticky;
  top: 0;
  z-index: 1;
  color: #d1d5db;
}

.state-row.data-row:nth-child(odd) {
  background: #1f2630;
}

.state-row.data-row:nth-child(even) {
  background: #1a1f2e;
}

.state-row.header .col {
  cursor: pointer;
}

.state-row.header .col:hover {
  color: #94b3fd;
}

.col {
  display: flex;
  align-items: center;
}

.col-state {
  font-weight: 500;
}

.bar-track {
  position: relative;
  flex: 1;
  height: 10px;
  background: #2a3340;
  border-radius: 999px;
  overflow: hidden;
  margin-right: 6px;
}

.bar-fill {
  height: 100%;
  background: #5b8ef4;
}

.bar-label {
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: #d1d5db;
}

.col-respondents {
  justify-content: flex-end;
  gap: 4px;
}

.resp-bar {
  display: inline-block;
  width: 40px;
  height: 6px;
  background: #2a3340;
  border-radius: 999px;
  overflow: hidden;
  margin-right: 4px;
}

.resp-fill {
  display: block;
  height: 100%;
  background: #6b7b94;
}

.resp-label {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: #b8bcc4;
}

/* --- MINI DASHBOARD TILE CSS FIX --- */
#stateTiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.tile {
  background: #1a1f2e;
  border: 1px solid #2a3340;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.2);
  font-family: system-ui, sans-serif;
}

.tile h3 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 600;
  color: #f5f5f5;
}

.tile .metric {
  font-size: 14px;
  margin: 3px 0;
  color: #e8eaed;
}

.tile .label {
  font-weight: 600;
  color: #d1d5db;
}

#parallel {
  width: 100%;
  height: auto;
  display: block;
  background: #1a1f2e;
  border-radius: 8px;
  margin-top: 16px;
}

.small-note {
  font-size: 13px;
  color: #b8bcc4;
  margin-bottom: 4px;
}

label { display: inline-block; margin: 0 8px 12px 0; font-weight: 500; color: #d1d5db; }
select { padding: 8px 12px; border: 1px solid #3a404a; border-radius: 6px; background: #1f2937; color: #e8eaed; font-size: 14px; cursor: pointer; }
select:hover { border-color: #4b5563; background: #374151; }
select:focus { outline: none; border-color: #5b8ef4; box-shadow: 0 0 0 3px rgba(91,142,244,0.1); }

#work-interfere text {
  fill: #f9fafb;
}

.pc-instructions {
  font-size: 14px;
  color: #4b5563;
  margin-bottom: 8px;
  margin-top: -6px;
}

.pc-hint {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f3f4ff;            /* soft indigo-ish */
  border: 1px solid #e0e7ff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  font-size: 13px;
  color: #374151;
}

.pc-hint-title {
  font-weight: 600;
  font-size: 13px;
  color: #4f46e5;
  margin-bottom: 4px;
}

.pc-hint ul {
  margin: 0;
  padding-left: 18px;
}

.pc-hint li {
  margin: 2px 0;
}

.state-col-header {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
}

.state-col-header:hover {
  color: #2563eb; /* blue hover */
}

.sd-hint {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 6px;
}

.process-link {
  position: fixed;
  top: 16px;
  right: 24px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(15,23,42,0.92);
  color: #e5e7eb;
  font-size: 13px;
  text-decoration: none;
  border: 1px solid rgba(148,163,184,0.7);
  z-index: 1000;
}

.process-link:hover {
  background: #0f172a;
  border-color: #fbbf24;
}

/* === Consistent font sizes for axis labels and ticks === */
svg .tick text {
  font-size: 12px !important;
  fill: #e5e7eb !important;
  font-weight: 500 !important;
}

svg .domain {
  stroke: #4b5563 !important;
}

svg .tick line {
  stroke: #4b5563 !important;
}


/* === Dashboard Layout === */
.dashboard-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  width: 100%;
}

.dashboard-left {
  flex: 1 1 60%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.dashboard-right {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}

.chart-panel {
  background: #1a1f2e;
  border: 1px solid #2a3340;
  border-radius: 12px;
  padding: 16px;
}

.chart-panel h3 {
  margin: 0 0 12px;
  font-size: 28px;
  font-weight: 600;
  color: #f5f5f5;
}

.chart-panel svg {
  width: 100%;
  height: auto;
  display: block;
  max-height: 300px;
}

.chart-panel label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: #d1d5db;
}

.chart-panel select {
  width: 100%;
  margin-bottom: 16px;
}

@media (max-width: 1200px) {
  .dashboard-layout {
    flex-direction: column;
  }
  
  .dashboard-right {
    flex: 1 1 auto;
    width: 100%;
  }
  
  .dashboard-right {
    flex-direction: row;
    flex-wrap: wrap;
  }
  
  .chart-panel {
    flex: 1 1 calc(50% - 12px);
    min-width: 300px;
  }
}

@media (max-width: 768px) {
  .filters-container {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .filter-buttons {
    flex-wrap: wrap;
  }
  
  .chart-panel {
    flex: 1 1 100%;
  }
}