/* ================================================================
   MGNREGA Analytics — Dark editorial / data-terminal aesthetic
   Saffron accent, Fraunces serif headlines, Geist sans body, mono numbers.
================================================================== */

:root {
  /* Surfaces */
  --bg:            #0a0b0d;
  --bg-elev:       #101216;
  --surface:       #13151a;
  --surface-2:     #181b22;
  --surface-3:     #1f232c;

  /* Lines */
  --line:          #22262e;
  --line-bright:   #2c313b;

  /* Text */
  --text:          #e8eaed;
  --text-2:        #b8bcc4;
  --text-3:        #8a8f99;
  --text-faint:    #5b6068;

  /* Accents */
  --saffron:       #ff9f43;
  --saffron-soft:  #f5b76a;
  --saffron-deep:  #b56d20;
  --saffron-glow:  rgba(255, 159, 67, 0.18);

  --emerald:       #34d399;
  --rose:          #fb7185;
  --indigo:        #818cf8;
  --cyan:          #67e8f9;

  /* Type */
  --serif:  'Fraunces', ui-serif, Georgia, serif;
  --sans:   'Geist', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --mono:   'Geist Mono', ui-monospace, 'SF Mono', Menlo, monospace;

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

* { 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 ─────────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0;
  background-image:
    linear-gradient(to right, rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255,255,255,0.018) 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: -200px; left: 30%;
  width: 800px; height: 800px;
  background: radial-gradient(circle, var(--saffron-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, rgba(19,21,26,0.6) 0%, rgba(10,11,13,0.4) 100%);
  border-right: 1px solid var(--line);
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  position: sticky; top: 0;
  height: 100vh;
  backdrop-filter: blur(8px);
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand-mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--surface-3);
  border: 1px solid var(--line-bright);
  border-radius: var(--r-md);
  color: var(--saffron);
  box-shadow: 0 0 0 4px rgba(255,159,67,0.04);
}
.brand-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: -0.02em;
  font-variation-settings: 'opsz' 14, 'SOFT' 30;
}
.brand-sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--saffron);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 1px;
}

.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); color: var(--text); }
.nav-item.active {
  background: var(--surface-2);
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -18px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px;
  background: var(--saffron);
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--saffron-glow);
}
.nav-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-faint);
  flex-shrink: 0;
}
.nav-item.active .nav-dot { background: var(--saffron); box-shadow: 0 0 6px var(--saffron); }
.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(52,211,153,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(52,211,153,0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* ── Main column ────────────────────────────────────────────────── */
.main {
  min-width: 0;
  padding: 0 0 64px;
}

/* ── 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: linear-gradient(180deg, rgba(13,14,17,0.4) 0%, transparent 100%);
}
.topbar-left { min-width: 0; }

.page-title {
  font-family: var(--serif);
  font-weight: 400;
  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(--saffron); 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;
}
.select:hover { border-color: var(--saffron-deep); }
.select:focus { border-color: var(--saffron); box-shadow: 0 0 0 3px var(--saffron-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) 25%, var(--surface-2) 50%, var(--surface) 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;
}
.kpi-card:hover {
  border-color: var(--line-bright);
  transform: translateY(-1px);
}
.kpi-card.featured {
  background: linear-gradient(135deg, var(--surface-2) 0%, var(--surface) 100%);
  border-color: var(--saffron-deep);
}
.kpi-card.featured::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--saffron), 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(--saffron); }

.kpi-value {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.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: 400;
  font-size: 22px;
  letter-spacing: -0.015em;
  margin: 0;
  font-variation-settings: 'opsz' 36;
}
.section-meta {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.06em;
}

/* ── Chart panel ───────────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 24px;
}
.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;
}
.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: var(--bg-elev);
  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;
}
.search-input:focus { border-color: var(--saffron); box-shadow: 0 0 0 3px var(--saffron-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: 500; }

.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: 500;
  text-align: right;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  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(--text); }
table.dt thead th .sort-ind {
  display: inline-block;
  margin-left: 4px;
  color: var(--saffron);
  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: 400;
  position: sticky; left: 0;
  background: var(--surface);
  z-index: 1;
}
table.dt tbody tr:hover td { background: var(--surface-2); }
table.dt tbody tr:hover td:first-child { background: var(--surface-3); }
table.dt tbody tr.is-total td {
  background: var(--bg-elev);
  color: var(--text);
  font-weight: 500;
  border-top: 1px solid var(--saffron-deep);
  border-bottom: 1px solid var(--saffron-deep);
}
table.dt tbody tr.is-total td:first-child {
  background: var(--bg-elev);
  color: var(--saffron);
  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;
  position: relative;
}
.report-card:hover {
  border-color: var(--saffron-deep);
  transform: translateY(-2px);
  background: var(--surface-2);
}
.report-card-num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--saffron);
  letter-spacing: 0.18em;
  margin-bottom: 8px;
  text-transform: uppercase;
}
.report-card-title {
  font-family: var(--serif);
  font-weight: 400;
  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(--text);
  font-weight: 500;
  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(--saffron); transform: translate(2px, -2px); }

/* ── Errors / empty ─────────────────────────────────────────────── */
.error-panel {
  border: 1px solid var(--rose);
  background: rgba(251,113,133,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; }
}

/* ── 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); } }
