/* ══════════════════════════════════════════════════════════════════
   वडा ड्यासबोर्ड — Styles
   ══════════════════════════════════════════════════════════════════ */

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

:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --bg3: #21262d;
  --border: rgba(255,255,255,0.09);
  --text: #e6edf3;
  --text2: #8b949e;
  --primary: #6366f1;
  --primary-glow: rgba(99,102,241,0.18);
  --green: #3fb950;
  --blue: #58a6ff;
  --pink: #f778ba;
  --gold: #f0a742;
  --red: #f85149;
  --teal: #39d353;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Noto Sans Devanagari', 'Inter', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Login ── */
#loginPage {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 60% 40%, #1e1b4b 0%, #0d1117 70%);
}
.login-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2.5rem;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.login-logo { font-size: 3.5rem; margin-bottom: 1rem; }
.login-card h1 { font-size: 1.4rem; font-weight: 700; margin-bottom: .4rem; }
.login-card > p { color: var(--text2); font-size: .9rem; margin-bottom: 1.8rem; }
.login-card small { color: var(--text2); font-size: .75rem; }
.input-wrap {
  display: flex; align-items: center;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 1rem;
  margin-bottom: 1rem;
}
.input-wrap .material-icons-outlined { color: var(--text2); font-size: 20px; margin-right: .5rem; }
.input-wrap input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-size: 1rem; padding: .75rem 0;
  font-family: inherit;
}
.btn-login {
  width: 100%; padding: .85rem;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: white; border: none; border-radius: 10px;
  font-size: 1rem; font-weight: 700;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: .5rem;
  font-family: inherit;
  transition: opacity .2s;
  margin-bottom: .75rem;
}
.btn-login:hover { opacity: .88; }
#loginError { color: var(--red); font-size: .85rem; min-height: 1.2rem; }

/* ── Layout ── */
#dashboard { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 200;
  transition: transform .3s;
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.2rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 1.4rem;
}
.sidebar-brand strong { display: block; font-size: .9rem; font-weight: 700; line-height: 1.2; }
.sidebar-brand small { display: block; color: var(--text2); font-size: .72rem; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem 0; }
.sidebar-nav ul { list-style: none; }
.nav-link {
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem;
  color: var(--text2); text-decoration: none;
  font-size: .85rem; border-radius: 8px;
  margin: 1px .5rem;
  transition: all .2s;
}
.nav-link .material-icons-outlined { font-size: 18px; }
.nav-link:hover { background: var(--bg3); color: var(--text); }
.nav-link.active { background: var(--primary-glow); color: #a5b4fc; font-weight: 600; }
.nav-divider {
  padding: .8rem 1.25rem .3rem;
  font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text2); opacity: .6;
}
.sidebar-footer {
  padding: .75rem;
  border-top: 1px solid var(--border);
}
.btn-ghost-sm {
  width: 100%; padding: .6rem .75rem;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px;
  font-size: .82rem; cursor: pointer; font-family: inherit;
  display: flex; align-items: center; gap: .4rem;
  transition: background .2s;
}
.btn-ghost-sm:hover { background: var(--primary-glow); }
.btn-ghost-sm .material-icons-outlined { font-size: 17px; }

/* ── Main ── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1; display: flex; flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.25rem; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.sidebar-toggle {
  background: none; border: none; color: var(--text2);
  cursor: pointer; display: none; padding: .25rem;
}
.sidebar-toggle .material-icons-outlined { font-size: 24px; }
.topbar-title { flex: 1; font-size: 1rem; font-weight: 700; }
.topbar-actions { display: flex; gap: .5rem; }
.btn {
  padding: .45rem .9rem;
  border-radius: 8px; border: none;
  font-size: .82rem; font-weight: 600;
  cursor: pointer; display: inline-flex;
  align-items: center; gap: .35rem;
  font-family: inherit;
  transition: all .2s; white-space: nowrap;
}
.btn .material-icons-outlined { font-size: 16px; }
.btn-excel { background: #166534; color: #86efac; }
.btn-excel:hover { background: #14532d; }
.btn-pdf { background: #7f1d1d; color: #fca5a5; }
.btn-pdf:hover { background: #6b1a1a; }
.btn-ghost { background: var(--bg3); color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { opacity: .88; }

/* ── Content ── */
.content { flex: 1; padding: 1.5rem; max-width: 1400px; width: 100%; }

.page-section { display: none; }
.page-section.active { display: block; }

.section-head { margin-bottom: 1.5rem; }
.section-head h2 { font-size: 1.3rem; font-weight: 800; margin-bottom: .25rem; }
.section-head p { color: var(--text2); font-size: .875rem; }

/* ── KPI Grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  position: relative; overflow: hidden;
  transition: transform .2s, box-shadow .2s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(0,0,0,.3); }
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--c, var(--primary));
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-icon { font-size: 1.8rem; margin-bottom: .5rem; }
.kpi-label { font-size: .72rem; color: var(--text2); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi-value { font-size: 2rem; font-weight: 800; color: var(--c, var(--text)); line-height: 1.1; margin-top: .25rem; }

/* ── Card ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  overflow: hidden;
}
.card-header {
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: .95rem; font-weight: 700; }
.card-toolbar {
  padding: .75rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; gap: .75rem; flex-wrap: wrap;
  align-items: center;
}
.search-wrap {
  display: flex; align-items: center;
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: 20px; padding: 0 .75rem;
  flex: 1; max-width: 300px;
}
.search-wrap .material-icons-outlined { color: var(--text2); font-size: 17px; margin-right: .35rem; }
.search-input {
  background: none; border: none; outline: none;
  color: var(--text); font-size: .875rem; padding: .5rem 0;
  font-family: inherit; width: 100%;
}
.filter-select {
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); padding: .45rem .75rem;
  border-radius: 8px; font-size: .82rem; font-family: inherit;
  cursor: pointer; outline: none;
}

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
thead th {
  padding: .65rem 1rem;
  background: var(--bg3);
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text2); text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid rgba(255,255,255,.04); transition: background .15s; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: .7rem 1rem; font-size: .875rem; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }
.loading-cell, .empty-cell {
  text-align: center; padding: 3rem;
  color: var(--text2); font-size: .9rem;
}
.table-footer {
  padding: .65rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text2); font-size: .8rem;
}

/* ── Mini progress bar in table ── */
.mini-bar-wrap { display: flex; align-items: center; gap: .5rem; min-width: 120px; }
.mini-bar-track { flex: 1; height: 6px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.mini-bar-fill { height: 100%; border-radius: 99px; transition: width .4s; }
.mini-bar-pct { font-size: .75rem; color: var(--text2); min-width: 35px; }

/* ── Badges ── */
.badge {
  padding: .18rem .55rem;
  border-radius: 20px; font-size: .72rem; font-weight: 700;
  display: inline-block;
}
.badge-blue { background: rgba(99,102,241,.15); color: #a5b4fc; }
.badge-green { background: rgba(63,185,80,.15); color: #3fb950; }
.badge-red { background: rgba(248,81,73,.15); color: #f85149; }
.badge-gold { background: rgba(240,167,66,.15); color: #f0a742; }

/* ── Chart containers ── */
.chart-row {
  display: flex; gap: 1.25rem; margin-bottom: 1.25rem; flex-wrap: wrap;
}
.chart-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem; flex: 1;
  min-width: 240px;
}
.chart-card.wide { flex: 2; }
.chart-card.full { margin-bottom: 1.25rem; }
.chart-card-header { margin-bottom: 1rem; }
.chart-card-header h3 { font-size: .9rem; font-weight: 700; }
.legend-wrap {
  display: flex; flex-wrap: wrap; gap: .5rem;
  justify-content: center; margin-top: .75rem;
}
.legend-item {
  display: flex; align-items: center; gap: .3rem;
  font-size: .75rem; color: var(--text2);
}
.legend-dot {
  width: 10px; height: 10px;
  border-radius: 50%; flex-shrink: 0;
}

/* ── Infrastructure Grid ── */
.infra-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

/* ── No-data overlay ── */
#noDataOverlay {
  position: fixed; inset: 0;
  background: rgba(13,17,23,.85);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; backdrop-filter: blur(4px);
}
.nodata-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3rem 2rem;
  text-align: center; max-width: 380px;
}
.nodata-box h2 { font-size: 1.4rem; margin: 1rem 0 .5rem; }
.nodata-box p { color: var(--text2); margin-bottom: 1.5rem; font-size: .9rem; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-toggle { display: block; }
  .main-wrap { margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-row { flex-direction: column; }
  .chart-card.wide, .chart-card { flex: 1 1 100%; }
  .infra-grid { grid-template-columns: 1fr; }
}

@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; }

/* ── Household Detail Modal ── */
.detail-modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 600; display: flex;
  align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.detail-modal-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 95%; max-width: 900px;
  max-height: 90vh; display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
}
.detail-modal-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between;
  align-items: center;
}
.detail-modal-header h2 { font-size: 1.1rem; font-weight: 700; }
.detail-modal-body {
  padding: 1.5rem; overflow-y: auto; flex: 1;
}
.detail-section {
  margin-bottom: 1.5rem;
  background: var(--bg3);
  border-radius: 10px;
  overflow: hidden;
}
.detail-section-title {
  padding: .75rem 1rem;
  background: rgba(99,102,241,.1);
  font-weight: 700; font-size: .9rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .5rem;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1px; background: var(--border);
}
.detail-item {
  padding: .6rem .9rem;
  background: var(--bg2);
}
.detail-item-label {
  font-size: .7rem; color: var(--text2);
  text-transform: uppercase; letter-spacing: .5px;
  font-weight: 600; margin-bottom: .15rem;
}
.detail-item-value {
  font-size: .95rem; font-weight: 600;
}
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: rgba(99,102,241,.08); }
