/* ================================================================
   MGNREGA Analytics — IndiaSpend-inspired editorial light theme
   Teal-blue accent, clean white surfaces, serif headlines.
================================================================== */

:root {
  /* Surfaces — clean white, IndiaSpend-style */
  --bg:            #ffffff;
  --bg-elev:       #fafafa;
  --surface:       #ffffff;
  --surface-2:     #f5f5f5;
  --surface-3:     #eeeeee;

  /* Lines — Bootstrap-derived greys IndiaSpend uses */
  --line:          #dddddd;
  --line-bright:   #cccccc;

  /* Text — IndiaSpend body is #2a3744 (dark slate) */
  --text:          #2a3744;
  --text-2:        #3c3c3c;
  --text-3:        #777777;
  --text-faint:    #888888;

  /* Accent — IndiaSpend brand blue (taken directly from logo.svg #0070cc) */
  --accent:        #0070cc;
  --accent-soft:   #4d9ddc;
  --accent-deep:   #005aa3;
  --accent-darker: #003e72;
  --accent-link:   #0070cc;
  --accent-hover:  #005aa3;
  --accent-glow:   rgba(0, 112, 204, 0.16);
  --accent-tint:   rgba(0, 112, 204, 0.08);

  /* Back-compat aliases (unchanged var names used in markup/JS) */
  --saffron:       var(--accent);
  --saffron-soft:  var(--accent-soft);
  --saffron-deep:  var(--accent-deep);
  --saffron-glow:  var(--accent-glow);

  /* Status */
  --emerald:       #12b76a;
  --rose:          #e13530;     /* IndiaSpend uses warmer reds */
  --indigo:        #3b5998;
  --cyan:          #06aed4;

  /* Type — IndiaSpend uses Noto Serif for editorial, system sans for body */
  --serif:  'Noto Serif', Georgia, 'Times New Roman', serif;
  --sans:   -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono:   Menlo, Monaco, Consolas, 'Courier New', monospace;

  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  --shadow-sm: 0 1px 2px rgba(15, 26, 36, 0.04);
  --shadow-md: 0 2px 8px rgba(15, 26, 36, 0.06);
  --shadow-lg: 0 8px 24px rgba(15, 26, 36, 0.08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-feature-settings: 'cv11', 'ss01', 'ss03';
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Atmospheric background — light, airy ───────────────────────── */
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(to right, rgba(15, 26, 36, 0.025) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 26, 36, 0.025) 1px, transparent 1px);
  background-size: 56px 56px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at top, black 30%, transparent 80%);
}
.bg-glow {
  position: fixed;
  top: -240px; left: 30%;
  width: 800px; height: 800px;
  background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
  filter: blur(40px);
}

/* ── Layout ─────────────────────────────────────────────────────── */
.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f7f8fa 100%);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  position: sticky; top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  padding: 0 2px;
  text-decoration: none;
}
.brand-logo {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
}

.nav { flex: 1; overflow-y: auto; padding-right: 4px; }
.nav-section + .nav-section { margin-top: 22px; }
.nav-section-title {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  padding: 0 10px 8px;
}

.nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  position: relative;
  transition: background 120ms, color 120ms;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active {
  background: var(--accent-tint);
  color: var(--accent-deep);
  font-weight: 500;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -18px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--accent-glow);
}
.nav-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.nav-item.active .nav-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.nav-item:hover .nav-dot { background: var(--text-2); }

.sidebar-footer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.footer-meta {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 6px;
}
.footer-label {
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
.footer-value {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-2);
}
.status-live { color: var(--emerald); display: inline-flex; align-items: center; gap: 6px; }
.status-pulse {
  width: 6px; height: 6px;
  background: var(--emerald);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(18,183,106,0.6);
  animation: pulse 1.8s infinite;
}
.status-down { color: var(--rose) !important; }
.status-down .status-pulse { background: var(--rose); animation: none; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(18,183,106,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(18,183,106,0); }
  100% { box-shadow: 0 0 0 0 rgba(18,183,106,0); }
}

/* ── Main column ────────────────────────────────────────────────── */
.main {
  min-width: 0;
  padding: 0 0 64px;
  background: var(--bg);
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 32px;
  padding: 36px 40px 28px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}
.topbar-left { min-width: 0; }

.page-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 38px;
  line-height: 1.05;
  letter-spacing: -0.025em;
  font-variation-settings: 'opsz' 80, 'SOFT' 30, 'WONK' 0;
  margin: 0 0 6px;
  color: var(--text);
}
.page-title .accent { color: var(--accent); font-style: italic; }

.page-blurb {
  margin: 0;
  color: var(--text-3);
  font-size: 14px;
  max-width: 64ch;
}

.period-picker { display: flex; flex-direction: column; gap: 4px; }
.period-label {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
}
.select-wrap { position: relative; }
.select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line-bright);
  border-radius: var(--r-md);
  padding: 9px 36px 9px 14px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  outline: none;
  min-width: 140px;
  transition: border-color 120ms, box-shadow 120ms;
  box-shadow: var(--shadow-sm);
}
.select:hover { border-color: var(--accent-soft); }
.select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.select-chev {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

/* ── Content shell ──────────────────────────────────────────────── */
.content { padding: 32px 40px; }

/* ── Skeleton loading ───────────────────────────────────────────── */
.loading-shimmer { display: flex; flex-direction: column; gap: 14px; max-width: 800px; }
.shim {
  height: 56px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-md);
  animation: shimmer 1.4s infinite linear;
}
.shim-1 { width: 100%; }
.shim-2 { width: 80%; height: 80px; }
.shim-3 { width: 92%; height: 200px; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── KPI grid ───────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  margin-bottom: 36px;
}
.kpi-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px 18px 20px;
  overflow: hidden;
  transition: border-color 180ms, transform 180ms, box-shadow 180ms;
  box-shadow: var(--shadow-sm);
}
.kpi-card:hover {
  border-color: var(--line-bright);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.kpi-card.featured {
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-tint) 100%);
  border-color: var(--accent-soft);
}
.kpi-card.featured::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.kpi-label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.kpi-card.featured .kpi-label { color: var(--accent-deep); }

.kpi-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.kpi-card.featured .kpi-value { color: var(--accent-deep); }
.kpi-unit {
  font-size: 12px;
  color: var(--text-3);
  margin-left: 4px;
  font-weight: 400;
}
.kpi-sub {
  margin-top: 12px;
  font-size: 12px;
  color: var(--text-3);
  display: flex; gap: 10px; align-items: center;
}
.kpi-sub strong { color: var(--text); font-family: var(--mono); font-weight: 500; }

/* ── Section heading ────────────────────────────────────────────── */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 24px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--text);
  font-variation-settings: 'opsz' 36;
}
.section-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}
.section-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  cursor: pointer;
  transition: border-color 160ms, color 160ms, background 160ms, transform 120ms;
}
.btn-download:hover {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent-deep);
}
.btn-download:active { transform: translateY(1px); }
.btn-download svg { display: block; }
.btn-download-mini {
  padding: 4px 8px;
  font-size: 10px;
  letter-spacing: 0.08em;
}
.ask-chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.ask-chart-head .ask-chart-title { margin-bottom: 0; }
.section-head-sub {
  margin-top: 8px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.section-title-sm {
  font-size: 16px;
  font-weight: 500;
  font-variation-settings: 'opsz' 24;
  color: var(--text-2);
}
.kpi-card-secondary {
  background: linear-gradient(180deg, var(--surface) 0%, rgba(0,0,0,0.012) 100%);
}
.kpi-card-secondary .kpi-value {
  font-size: 22px;
}

/* ── Chart panel ───────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.chart-wrap { position: relative; height: 420px; }
.chart-foot {
  display: flex; justify-content: space-between;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

/* ── Data table ─────────────────────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.search-input {
  background: #ffffff;
  border: 1px solid var(--line-bright);
  border-radius: var(--r-sm);
  padding: 7px 12px;
  font-family: var(--sans);
  font-size: 13px;
  color: var(--text);
  width: 240px;
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.search-input::placeholder { color: var(--text-faint); }
.toolbar-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.06em;
}
.toolbar-meta strong { color: var(--text); font-weight: 600; }

.table-scroll { overflow-x: auto; max-height: 640px; overflow-y: auto; }
table.dt {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.dt thead th {
  position: sticky; top: 0;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3);
  font-weight: 600;
  text-align: right;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line-bright);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  z-index: 1;
}
table.dt thead th:first-child {
  text-align: left;
  background: var(--surface-2);
  position: sticky; left: 0;
  z-index: 2;
}
table.dt thead th:hover { color: var(--accent-deep); }
table.dt thead th .sort-ind {
  display: inline-block;
  margin-left: 4px;
  color: var(--accent);
  font-family: var(--mono);
}

table.dt tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-family: var(--mono);
  color: var(--text-2);
  white-space: nowrap;
}
table.dt tbody td:first-child {
  text-align: left;
  font-family: var(--sans);
  color: var(--text);
  font-weight: 500;
  position: sticky; left: 0;
  background: var(--surface);
  z-index: 1;
}
table.dt tbody tr:hover td { background: var(--accent-tint); }
table.dt tbody tr:hover td:first-child { background: var(--accent-tint); color: var(--accent-deep); }
table.dt tbody tr.is-total td {
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 600;
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
}
table.dt tbody tr.is-total td:first-child {
  background: var(--bg-elev);
  color: var(--accent-deep);
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}
table.dt tbody td:last-child { padding-right: 18px; }

/* ── Reports grid (overview page) ───────────────────────────────── */
.report-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.report-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  cursor: pointer;
  transition: border-color 180ms, transform 180ms, background 180ms, box-shadow 180ms;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.report-card:hover {
  border-color: var(--accent-soft);
  transform: translateY(-2px);
  background: linear-gradient(135deg, #ffffff 0%, var(--accent-tint) 100%);
  box-shadow: var(--shadow-md);
}
.report-card-num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--accent);
  letter-spacing: 0.18em;
  margin-bottom: 8px;
  text-transform: uppercase;
  font-weight: 600;
}
.report-card-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
  margin-bottom: 6px;
  font-variation-settings: 'opsz' 24;
}
.report-card-blurb {
  font-size: 12.5px;
  color: var(--text-3);
  line-height: 1.5;
  margin: 0 0 14px;
}
.report-card-stat {
  font-family: var(--mono);
  font-size: 18px;
  color: var(--accent-deep);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.report-card-foot {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-top: 4px;
}
.report-card-arrow {
  position: absolute;
  top: 16px; right: 16px;
  color: var(--text-faint);
  transition: color 180ms, transform 180ms;
}
.report-card:hover .report-card-arrow { color: var(--accent); transform: translate(2px, -2px); }

/* ── Errors / empty ─────────────────────────────────────────────── */
.error-panel {
  border: 1px solid var(--rose);
  background: rgba(240, 68, 56, 0.06);
  border-radius: var(--r-md);
  padding: 16px;
  color: var(--rose);
  font-family: var(--mono);
  font-size: 13px;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; gap: 16px; padding: 16px; }
  .nav { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 12px; }
  .nav-section { flex: 1 1 220px; }
  .sidebar-footer { display: none; }
  .topbar { flex-direction: column; align-items: flex-start; gap: 16px; padding: 24px; }
  .content { padding: 20px; }
  .page-title { font-size: 30px; }
}

/* ── Compare page ───────────────────────────────────────────────── */
.compare-form {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}
.compare-form-field {
  display: flex; flex-direction: column; gap: 4px;
  min-width: 180px; flex: 1;
}
.compare-form-field .select { width: 100%; min-width: 0; }
.btn-primary {
  background: var(--accent);
  color: #ffffff;
  border: 0;
  border-radius: var(--r-md);
  padding: 0 22px;
  height: 38px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 140ms, box-shadow 140ms, transform 140ms;
  box-shadow: 0 1px 2px var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-deep);
  box-shadow: 0 4px 14px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.empty-hint {
  border: 1px dashed var(--line-bright);
  background: var(--bg-elev);
  border-radius: var(--r-lg);
  padding: 48px 24px;
  text-align: center;
  color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty-hint svg { color: var(--accent-soft); }
.empty-hint strong { color: var(--accent-deep); font-weight: 600; }

.compare-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
  margin-bottom: 24px;
}
@media (max-width: 760px) { .compare-kpis { grid-template-columns: 1fr; } }

.year-tag {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  background: var(--accent-tint);
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  text-transform: uppercase;
  vertical-align: 2px;
}
.year-tag-alt {
  color: #b56d20;
  background: rgba(255, 159, 67, 0.12);
  border-color: rgba(255, 159, 67, 0.55);
}

.trend-up    { color: var(--emerald) !important; }
.trend-down  { color: var(--rose) !important; }
.trend-flat  { color: var(--text-3) !important; }

/* iframe-style chart frame */
.iframe-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
}
.iframe-header {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #f4f6f8 0%, #eceff3 100%);
  border-bottom: 1px solid var(--line);
}
.iframe-dots { display: inline-flex; gap: 6px; }
.iframe-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.12);
}
.iframe-url {
  flex: 1;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-3);
  background: #ffffff;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--line);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.iframe-metric {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.select-mini {
  min-width: 0;
  padding: 5px 28px 5px 10px;
  font-size: 11.5px;
  height: 28px;
  box-shadow: none;
}
.iframe-body {
  padding: 22px 22px 24px;
  background:
    linear-gradient(135deg, var(--surface-2) 0%, transparent 35%),
    radial-gradient(circle at 80% 0%, var(--accent-tint) 0%, transparent 50%),
    #ffffff;
}

/* Side-by-side compare tables */
.compare-tables {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 1100px) { .compare-tables { grid-template-columns: 1fr; } }
.compare-table .table-toolbar { gap: 12px; }
.compare-table .year-tag,
.compare-table .year-tag-alt { font-size: 11px; padding: 4px 10px; }

/* ── Sidebar AI badge ───────────────────────────────────────────── */
.nav-item-ai { padding-right: 8px; }
.nav-badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), var(--indigo));
  color: #ffffff;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 0 12px var(--accent-glow);
}

/* ── Ask the data — hero ───────────────────────────────────────── */
.ask-hero {
  position: relative;
  padding: 8px 0 24px;
  margin-bottom: 8px;
  max-width: 780px;
}
.ask-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 12px;
  display: inline-flex; align-items: center; gap: 8px;
}
.ask-eyebrow::before {
  content: '';
  width: 22px; height: 1px;
  background: var(--accent);
}
.ask-headline {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 44px;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 14px;
  color: var(--text);
  font-variation-settings: 'opsz' 96, 'SOFT' 30, 'WONK' 1;
}
.ask-headline em {
  font-style: italic;
  color: var(--accent-deep);
  font-variation-settings: 'opsz' 96, 'SOFT' 100, 'WONK' 1;
}
.ask-headline-accent {
  font-style: italic;
  background: linear-gradient(120deg, var(--accent) 0%, var(--indigo) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ask-sub {
  font-size: 15px;
  color: var(--text-3);
  margin: 0;
  max-width: 64ch;
  line-height: 1.55;
}

/* ── Ask input card ────────────────────────────────────────────── */
.ask-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--shadow-md);
  margin-bottom: 28px;
  position: relative;
  overflow: hidden;
}
.ask-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--indigo) 50%, var(--accent) 100%);
  background-size: 200% 100%;
  animation: ask-shine 6s linear infinite;
}
@keyframes ask-shine {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.ask-input-label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 4px 4px 10px;
}
.ask-input-wrap {
  display: flex;
  gap: 12px;
  align-items: stretch;
}
.ask-input {
  flex: 1;
  resize: vertical;
  min-height: 64px;
  background: var(--bg);
  border: 1px solid var(--line-bright);
  border-radius: var(--r-md);
  padding: 14px 16px;
  font-family: var(--sans);
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms;
  line-height: 1.5;
}
.ask-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
}
.ask-input::placeholder { color: var(--text-faint); }

.ask-submit {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: #ffffff;
  border: 0;
  border-radius: var(--r-md);
  padding: 0 22px;
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px var(--accent-glow);
  transition: transform 160ms, box-shadow 160ms, opacity 160ms;
  min-height: 64px;
  align-self: stretch;
}
.ask-submit:hover { transform: translateY(-1px); box-shadow: 0 6px 20px var(--accent-glow); }
.ask-submit:active { transform: translateY(0); }
.ask-submit:disabled { opacity: 0.7; cursor: not-allowed; transform: none; }
.ask-submit.is-loading svg { animation: ask-spin 1s linear infinite; }
@keyframes ask-spin { to { transform: rotate(360deg); } }

.ask-suggestions {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
  margin-top: 14px;
  padding: 4px 4px 0;
}
.ask-suggest-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-right: 4px;
}
.ask-chip {
  border: 1px solid var(--line-bright);
  background: var(--surface-2);
  color: var(--text-2);
  border-radius: 999px;
  padding: 6px 12px;
  font-family: var(--sans);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 140ms, color 140ms, background 140ms, transform 140ms;
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ask-chip:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-tint);
  transform: translateY(-1px);
}

/* ── Empty / loading ───────────────────────────────────────────── */
.ask-empty {
  border: 1px dashed var(--line-bright);
  border-radius: var(--r-lg);
  padding: 40px 24px;
  text-align: center;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
}
.ask-empty-mark {
  width: 48px; height: 48px;
  margin: 0 auto 14px;
  display: grid; place-items: center;
  background: var(--accent-tint);
  border-radius: 50%;
  color: var(--accent-deep);
}
.ask-empty-title {
  font-family: var(--serif);
  font-size: 18px;
  color: var(--text);
  margin-bottom: 4px;
}
.ask-empty-sub {
  color: var(--text-3);
  font-size: 13px;
  max-width: 42ch;
  margin: 0 auto;
}

.ask-loading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.ask-loading-spinner {
  width: 22px; height: 22px;
  border: 2.5px solid var(--accent-tint);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ask-spin 0.9s linear infinite;
}
.ask-loading-text {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-2);
}

/* ── Answer block ─────────────────────────────────────────────── */
.ask-answer {
  background: linear-gradient(135deg, var(--surface) 0%, var(--accent-tint) 140%);
  border: 1px solid var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: var(--r-lg);
  padding: 18px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
}
.ask-answer-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}
.ask-answer-query {
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.4;
  color: var(--text);
  font-style: italic;
  margin-bottom: 10px;
  font-variation-settings: 'opsz' 36, 'SOFT' 50;
}
.ask-answer-text {
  margin: 0;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.55;
}

/* ── Charts grid ──────────────────────────────────────────────── */
.ask-charts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 12px;
}
@media (min-width: 1180px) {
  .ask-charts:has(.ask-chart-panel + .ask-chart-panel) {
    grid-template-columns: 1.4fr 1fr;
  }
}
.ask-chart-panel { margin-bottom: 0; }
.ask-chart-title {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-3);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}

/* Highlight #1 row in ask result */
table.dt tbody tr.is-top td:first-child {
  position: relative;
}
table.dt tbody tr.is-top td:first-child::before {
  content: '★';
  margin-right: 6px;
  color: var(--accent);
  font-size: 11px;
}

/* ── SQL block ────────────────────────────────────────────────── */
.ask-sql {
  background: #0f1a24;
  color: #e4e7ec;
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin: 0 0 24px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  border: 1px solid #1f2a37;
  box-shadow: var(--shadow-md);
}
.ask-sql code {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  color: inherit;
}
.ask-copy {
  background: var(--surface-2);
  border: 1px solid var(--line-bright);
  color: var(--text-2);
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 140ms, color 140ms, background 140ms;
}
.ask-copy:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
  background: var(--accent-tint);
}

@media (max-width: 720px) {
  .ask-headline { font-size: 32px; }
  .ask-input-wrap { flex-direction: column; }
  .ask-submit { min-height: 48px; padding: 12px 18px; justify-content: center; }
}

/* ── Stagger entrance ───────────────────────────────────────────── */
.stagger > * {
  opacity: 0;
  transform: translateY(8px);
  animation: rise 380ms cubic-bezier(0.2, 0.7, 0.2, 1) forwards;
}
.stagger > *:nth-child(1) { animation-delay: 40ms; }
.stagger > *:nth-child(2) { animation-delay: 90ms; }
.stagger > *:nth-child(3) { animation-delay: 140ms; }
.stagger > *:nth-child(4) { animation-delay: 190ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 290ms; }
.stagger > *:nth-child(7) { animation-delay: 340ms; }
.stagger > *:nth-child(8) { animation-delay: 390ms; }
@keyframes rise { to { opacity: 1; transform: translateY(0); } }

/* ── Data-not-found modal ───────────────────────────────────────── */
.dnf-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: dnf-fade 180ms ease-out;
}
.dnf-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
}
.dnf-card {
  position: relative;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
  padding: 20px 44px 20px 20px;
  max-width: 460px;
  width: 100%;
  animation: dnf-rise 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.dnf-icon {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(240, 68, 56, 0.08);
  color: var(--rose);
  display: flex;
  align-items: center;
  justify-content: center;
}
.dnf-body { flex: 1; min-width: 0; }
.dnf-eyebrow {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-faint);
  margin-bottom: 6px;
}
.dnf-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 20px;
  letter-spacing: -0.01em;
  color: var(--text);
  margin: 0 0 6px;
}
.dnf-text {
  margin: 0;
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.5;
}
.dnf-text strong { color: var(--text); font-weight: 600; }
.dnf-close {
  position: absolute;
  top: 12px; right: 12px;
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 6px;
  color: var(--text-3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 160ms, color 160ms;
}
.dnf-close:hover { border-color: var(--line-bright); color: var(--text); }
@keyframes dnf-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes dnf-rise {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
