/* ==========================================================================
   TNHPS Wave II — Survey Monitor · design system
   ========================================================================== */
:root {
  --brand-950: #0b1d47;
  --brand-900: #0f2557;
  --brand-800: #163372;
  --brand-700: #1b3f8b;
  --brand-600: #2451a8;
  --brand-500: #3a67c4;
  --brand-100: #dbe5f6;
  --brand-50:  #eef3fb;
  --accent:    #8dc63f;      /* MIDS green */
  --accent-600:#6fa82a;
  --ink:       #0b1324;
  --ink-2:     #1e293b;
  --muted:     #475569;   /* darker than before for readability */
  --card:      #ffffff;
  --th-bg:     #f1f5fb;
  --line:      #e5e9f2;
  --line-2:    #f1f4f9;
  --bg:        #f4f6fb;
  --radius:    16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow:    0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, .04), 0 18px 40px -18px rgba(15, 23, 42, .25);
  --ease:      cubic-bezier(.22, .61, .36, 1);
}

html { scroll-behavior: smooth; }
/* Component classes below set `display`; make Tailwind's `hidden` always win on them. */
.chip.hidden, .file-chip.hidden, .dropzone.hidden, .alert.hidden, .stat.hidden, .kpi.hidden, .btn.hidden, .tab-panel.hidden { display: none !important; }
body {
  font-family: 'Inter', 'Noto Sans Tamil', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.font-display { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; }
.font-tamil   { font-family: 'Noto Sans Tamil', sans-serif; }
.mono         { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .92em; }
.tnum         { font-variant-numeric: tabular-nums; }
::selection   { background: var(--brand-100); }

/* ---------- Banner --------------------------------------------------------- */
.banner {
  position: relative;
  overflow: hidden;
  background: linear-gradient(115deg, #0f2557 0%, #1b3f8b 48%, #2451a8 100%);
  color: #fff;
}
.banner::before, .banner::after {
  content: ''; position: absolute; border-radius: 50%; pointer-events: none;
}
.banner::before {
  width: 520px; height: 520px; left: -160px; top: -300px;
  background: radial-gradient(circle, rgba(141, 198, 63, .22), transparent 65%);
}
.banner::after {
  width: 600px; height: 600px; right: -200px; bottom: -420px;
  background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 60%);
}
.banner-accent { height: 3px; background: linear-gradient(90deg, var(--accent), #3a67c4 45%, transparent); }
.logo-tile {
  background: #fff; border-radius: 14px; padding: 5px;
  box-shadow: 0 6px 18px -6px rgba(0, 0, 0, .35), 0 0 0 1px rgba(255, 255, 255, .5) inset;
  transition: transform .4s var(--ease);
}
.logo-tile:hover { transform: translateY(-2px) rotate(-1deg); }

/* ---------- Top navigation -------------------------------------------------- */
.topnav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  transition: box-shadow .25s var(--ease);
}
.topnav.is-scrolled { box-shadow: 0 6px 20px -12px rgba(15, 23, 42, .25); }
.nav-link {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .5rem .85rem; border-radius: 10px;
  font-size: .875rem; font-weight: 500; color: var(--ink-2);
  transition: background .2s, color .2s;
}
.nav-link:hover { background: var(--line-2); color: var(--brand-700); }
.nav-link.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; box-shadow: inset 0 0 0 1px var(--brand-100); }
.nav-link svg { opacity: .8; }

.menu {
  position: absolute; right: 0; top: calc(100% + 8px); width: 15rem; z-index: 50;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: .4rem; transform-origin: top right;
  opacity: 0; transform: scale(.96) translateY(-4px); pointer-events: none;
  transition: opacity .16s var(--ease), transform .16s var(--ease);
}
.menu.open { opacity: 1; transform: none; pointer-events: auto; }
.menu a { display: flex; align-items: center; gap: .6rem; padding: .55rem .7rem; border-radius: 9px; font-size: .85rem; color: var(--ink-2); }
.menu a:hover { background: var(--line-2); }

/* ---------- Page header ----------------------------------------------------- */
.eyebrow { font-size: .7rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand-600); }
.page-title { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; font-size: 1.6rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); line-height: 1.2; }
.page-sub { font-size: .85rem; color: var(--muted); }

/* ---------- Cards ----------------------------------------------------------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-lift { transition: transform .25s var(--ease), box-shadow .25s var(--ease); }
.card-lift:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: .9rem; padding: 1.25rem 1.4rem; border-bottom: 1px solid var(--line-2); }
.card-title { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; font-size: 1.05rem; font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
.card-desc { font-size: .8rem; color: var(--muted); margin-top: .2rem; max-width: 46rem; }
.card-body { padding: 1.25rem 1.4rem; }

.section-label {
  display: flex; align-items: center; gap: .5rem;
  font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2);
  margin-bottom: .65rem;
}
.section-label::before { content: ''; width: 6px; height: 6px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 0 3px rgba(141, 198, 63, .2); }

/* ---------- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: 2.25rem; padding: 0 .95rem; border-radius: 10px;
  font-size: .8rem; font-weight: 600; white-space: nowrap; cursor: pointer;
  border: 1px solid transparent;
  transition: background .2s, box-shadow .2s, transform .12s, color .2s, border-color .2s;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: linear-gradient(180deg, #2451a8, #1b3f8b); color: #fff; box-shadow: 0 6px 14px -8px rgba(27, 63, 139, .8), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-primary:hover { background: linear-gradient(180deg, #1f4a9c, #163372); }
.btn-success { background: linear-gradient(180deg, #10b981, #059669); color: #fff; box-shadow: 0 6px 14px -8px rgba(5, 150, 105, .8); }
.btn-success:hover { background: #047857; }
.btn-excel { background: linear-gradient(180deg, #1a8a4f, #107c41); color: #fff; box-shadow: 0 6px 14px -8px rgba(16, 124, 65, .85), inset 0 1px 0 rgba(255, 255, 255, .15); }
.btn-excel:hover { background: linear-gradient(180deg, #13703b, #0b5c30); }
.btn-dark { background: #1e293b; color: #fff; }
.btn-dark:hover { background: #0f172a; }
.btn-ghost { background: var(--card); color: var(--ink-2); border-color: var(--line); box-shadow: var(--shadow-sm); }
.btn-ghost:hover { border-color: #cbd5e1; color: var(--brand-700); background: #fbfcfe; }
.btn-soft { background: var(--brand-50); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); }
.btn-danger-soft { background: #fff1f2; color: #be123c; border-color: #fecdd3; }
.btn-danger-soft:hover { background: #ffe4e6; }
.btn-sm { height: 1.9rem; padding: 0 .7rem; font-size: .75rem; border-radius: 8px; }
.btn-lg { height: 2.75rem; padding: 0 1.25rem; font-size: .9rem; border-radius: 12px; }
.btn .spin-on-click { transition: transform .6s var(--ease); }
.btn.spinning .spin-on-click { animation: spin .8s linear infinite; }

/* ---------- Form fields ----------------------------------------------------- */
.field, .select {
  height: 2.25rem; padding: 0 .8rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font-size: .8rem; font-weight: 500; outline: none;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: var(--shadow-sm);
}
.select {
  appearance: none; -webkit-appearance: none; padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .6rem center; background-size: 14px;
}
.field:focus, .select:focus { border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(58, 103, 196, .14); }
.field-lg { height: 2.75rem; font-size: .9rem; border-radius: 12px; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: #94a3b8; pointer-events: none; }
.input-icon > .field { padding-left: 2.1rem; }
.field-label { display: block; font-size: .75rem; font-weight: 600; color: var(--ink-2); margin-bottom: .35rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.toolbar label.lbl { font-size: .72rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Tables ---------------------------------------------------------- */
.tbl-wrap { border: 1px solid var(--line); border-radius: 14px; overflow: auto; background: var(--card); }
.tbl-wrap.scroll { max-height: 560px; }
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .8125rem; }
.tbl th {
  position: sticky; top: 0; z-index: 5;
  background: var(--th-bg); color: var(--ink-2);
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  text-align: left; padding: .75rem .9rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: .65rem .9rem; border-bottom: 1px solid var(--line-2); white-space: nowrap; color: var(--ink-2); font-weight: 500; }
.tbl tbody tr { transition: background .15s; }
.tbl tbody tr:hover { background: var(--row-hover, #f2f7ff); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Sortable column headings */
.tbl th.sortable { cursor: pointer; user-select: none; transition: color .15s, background .15s; }
.tbl th.sortable:hover { color: var(--brand-600); }
.tbl th.sortable::after, .tbl th .sort-link::after {
  content: ''; display: inline-block; width: 7px; height: 10px; margin-left: .4rem; vertical-align: -1px; opacity: .45;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M3.5 0L7 4H0zM3.5 10L0 6h7z'/%3E%3C/svg%3E") no-repeat center / contain;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M3.5 0L7 4H0zM3.5 10L0 6h7z'/%3E%3C/svg%3E") no-repeat center / contain;
}
.tbl th.sort-asc, .tbl th.sort-desc, .tbl th .sort-link.active { color: var(--brand-600); }
.tbl th.sort-asc::after, .tbl th .sort-link.asc::after {
  opacity: 1;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M3.5 1L7 6H0z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M3.5 1L7 6H0z'/%3E%3C/svg%3E");
}
.tbl th.sort-desc::after, .tbl th .sort-link.desc::after {
  opacity: 1;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M0 4h7L3.5 9z'/%3E%3C/svg%3E");
          mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 7 10'%3E%3Cpath d='M0 4h7L3.5 9z'/%3E%3C/svg%3E");
}
.tbl th .sort-link { color: inherit; display: inline-flex; align-items: center; }
.tbl th .sort-link:hover { color: var(--brand-600); }
html.dark .tbl th.sort-asc, html.dark .tbl th.sort-desc, html.dark .tbl th.sortable:hover, html.dark .tbl th .sort-link.active, html.dark .tbl th .sort-link:hover { color: #8fb1ff; }
.tbl .strong { font-weight: 600; color: var(--ink); }
.tbl tr.is-selected { background: var(--brand-50) !important; box-shadow: inset 3px 0 0 var(--brand-600); }
.tbl tr.total td { background: var(--th-bg); font-weight: 700; color: var(--ink); border-top: 1px solid var(--line); }
.tbl td.wrap { white-space: normal; min-width: 11rem; max-width: 15rem; }
.tbl td.empty { text-align: center; color: var(--muted); padding: 2.2rem 1rem; white-space: normal; }
.tbl-note { font-size: .75rem; color: var(--muted); margin-bottom: .5rem; }

/* ---------- Status tones ---------------------------------------------------- */
.t-comp  { color: #047857; }  .t-repg { color: #1d4ed8; }  .t-repr { color: #b45309; }
.t-repna { color: #be123c; }  .t-inc  { color: #475569; }
.tone-comp  { --tone: #059669; --tone-bg: #ecfdf5; --tone-line: #a7f3d0; --tone-ink: #047857; }
.tone-repg  { --tone: #2563eb; --tone-bg: #eff6ff; --tone-line: #bfdbfe; --tone-ink: #1d4ed8; }
.tone-repr  { --tone: #d97706; --tone-bg: #fffbeb; --tone-line: #fde68a; --tone-ink: #b45309; }
.tone-repna { --tone: #e11d48; --tone-bg: #fff1f2; --tone-line: #fecdd3; --tone-ink: #be123c; }
.tone-inc   { --tone: #64748b; --tone-bg: #f1f5f9; --tone-line: #e2e8f0; --tone-ink: #475569; }
.tone-brand { --tone: #1b3f8b; --tone-bg: #eef3fb; --tone-line: #dbe5f6; --tone-ink: #1b3f8b; }
.tone-indigo{ --tone: #4f46e5; --tone-bg: #eef2ff; --tone-line: #c7d2fe; --tone-ink: #4338ca; }

.badge {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .2rem .6rem; border-radius: 999px;
  font-size: .72rem; font-weight: 600; line-height: 1.2;
  background: var(--tone-bg, #f1f5f9); color: var(--tone-ink, #475569);
  border: 1px solid var(--tone-line, #e2e8f0);
}
.badge.dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--tone, #64748b); }

/* ---------- KPI tiles ------------------------------------------------------- */
.kpi {
  position: relative; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem; box-shadow: var(--shadow);
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.kpi::after {
  content: ''; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%;
  background: radial-gradient(circle, var(--tone-bg, #eef3fb), transparent 70%); opacity: .9;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.kpi-top { display: flex; align-items: center; gap: .6rem; position: relative; z-index: 1; }
.kpi-icon {
  width: 2.2rem; height: 2.2rem; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--tone-bg, #eef3fb); color: var(--tone, #1b3f8b); box-shadow: inset 0 0 0 1px var(--tone-line, #dbe5f6);
}
.kpi-label { font-size: .7rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-2); line-height: 1.25; }
.kpi-value { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; font-size: 1.85rem; font-weight: 800; letter-spacing: -.02em; color: var(--ink); margin-top: .55rem; font-variant-numeric: tabular-nums; position: relative; z-index: 1; }
.kpi-value small { font-size: .85rem; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.kpi-foot { font-size: .75rem; color: var(--muted); margin-top: .1rem; position: relative; z-index: 1; }
.kpi-bar { height: 4px; border-radius: 4px; background: var(--line-2); margin-top: .75rem; overflow: hidden; position: relative; z-index: 1; }
.kpi-bar > span { display: block; height: 100%; border-radius: 4px; background: var(--tone, #1b3f8b); transform-origin: left; animation: grow 1.1s var(--ease) both .2s; }

.stat { border-radius: 14px; padding: .8rem .95rem; background: var(--tone-bg, #f8fafc); border: 1px solid var(--tone-line, var(--line)); }
.stat-label { font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tone-ink, var(--muted)); }
.stat-value { font-family: 'Plus Jakarta Sans', 'Inter', sans-serif; font-size: 1.35rem; font-weight: 800; color: var(--tone-ink, var(--ink)); margin-top: .2rem; font-variant-numeric: tabular-nums; }

/* ---------- Progress / mini bars -------------------------------------------- */
.progress { display: flex; align-items: center; gap: .6rem; min-width: 9rem; }
.progress .track { flex: 1; height: 6px; border-radius: 6px; background: #edf1f7; overflow: hidden; }
.progress .track > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #34d399, #059669); transform-origin: left; animation: grow 1s var(--ease) both; }
.progress .val { font-size: .72rem; font-weight: 600; color: var(--ink-2); width: 3rem; text-align: right; font-variant-numeric: tabular-nums; }
.minibar { display: inline-block; vertical-align: middle; width: 64px; height: 6px; border-radius: 6px; background: #edf1f7; overflow: hidden; margin-right: .5rem; }
.minibar > span { display: block; height: 100%; background: linear-gradient(90deg, #3a67c4, #1b3f8b); border-radius: 6px; transform-origin: left; animation: grow .9s var(--ease) both; }

/* ---------- Dashboard tabs -------------------------------------------------- */
.tabs-bar {
  position: sticky; top: 64px; z-index: 30;
  background: rgba(255, 255, 255, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  padding: .35rem; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none;
}
.tabs-bar::-webkit-scrollbar { display: none; }
.tab-btn {
  display: inline-flex; align-items: center; gap: .45rem; flex-shrink: 0;
  padding: .55rem .9rem; border-radius: 10px;
  font-size: .8rem; font-weight: 600; color: var(--muted);
  transition: background .2s, color .2s, box-shadow .2s;
}
.tab-btn svg { width: 16px; height: 16px; opacity: .75; }
.tab-btn:hover { color: var(--brand-700); background: var(--line-2); }
.tab-btn.active {
  color: #fff; background: linear-gradient(180deg, #2451a8, #1b3f8b);
  box-shadow: 0 8px 16px -10px rgba(27, 63, 139, .9);
}
.tab-btn.active svg { opacity: 1; }
.tab-num { font-size: .65rem; font-weight: 700; width: 1.15rem; height: 1.15rem; border-radius: 6px; display: grid; place-items: center; background: var(--line-2); color: var(--muted); }
.tab-btn.active .tab-num { background: rgba(255, 255, 255, .2); color: #fff; }

/* ---------- Briefing text --------------------------------------------------- */
.brief {
  white-space: pre-wrap; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .78rem; line-height: 1.7;
  color: var(--ink-2); background: linear-gradient(180deg, #fbfcfe, #fff);
  border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 12px; padding: 1.1rem 1.25rem;
}

/* ---------- Chips ----------------------------------------------------------- */
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .7rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--card); border: 1px solid var(--line); color: var(--ink-2); box-shadow: var(--shadow-sm); }
.chip.live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #10b981; box-shadow: 0 0 0 0 rgba(16, 185, 129, .5); animation: pulse 2s infinite; }

/* ---------- Alerts ---------------------------------------------------------- */
.alert { display: flex; align-items: flex-start; gap: .65rem; padding: .85rem 1rem; border-radius: 12px; font-size: .85rem; border: 1px solid; animation: slideDown .45s var(--ease) both; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-error   { background: #fff1f2; border-color: #fecdd3; color: #9f1239; }
.alert .close { margin-left: auto; opacity: .6; } .alert .close:hover { opacity: 1; }
.alert.hide { animation: fadeOut .3s var(--ease) forwards; }

/* ---------- Dropzone -------------------------------------------------------- */
.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem;
  padding: 2.2rem 1rem; text-align: center; cursor: pointer;
  border: 2px dashed #cdd6e6; border-radius: 16px;
  background: linear-gradient(180deg, #fbfcfe, #f6f8fc);
  transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone.drop-active { border-color: var(--brand-500); background: var(--brand-50); }
.dropzone.drop-active { transform: scale(1.01); }
.dz-icon { width: 3.5rem; height: 3.5rem; border-radius: 16px; display: grid; place-items: center; color: var(--brand-700); background: #fff; box-shadow: var(--shadow); animation: float 3s ease-in-out infinite; }
.file-chip { display: flex; align-items: center; gap: .7rem; padding: .7rem .85rem; border: 1px solid var(--brand-100); background: var(--brand-50); border-radius: 12px; animation: popIn .35s var(--ease) both; }
.radio-card { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; transition: border-color .2s, background .2s, box-shadow .2s; }
.radio-card:hover { border-color: #cbd5e1; }
.radio-card:has(input:checked) { border-color: var(--brand-500); background: var(--brand-50); box-shadow: 0 0 0 3px rgba(58, 103, 196, .12); }
.radio-card.danger:has(input:checked) { border-color: #fb7185; background: #fff1f2; box-shadow: 0 0 0 3px rgba(244, 63, 94, .12); }
.step-num { width: 1.6rem; height: 1.6rem; border-radius: 8px; display: grid; place-items: center; font-size: .75rem; font-weight: 800; background: var(--brand-50); color: var(--brand-700); flex-shrink: 0; }
.import-bar { height: 4px; border-radius: 4px; overflow: hidden; background: var(--brand-100); }
.import-bar > span { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--accent), var(--brand-600)); border-radius: 4px; animation: indeterminate 1.2s ease-in-out infinite; }

/* ---------- Modal dialog ---------------------------------------------------- */
.modal {
  width: min(32rem, calc(100vw - 2rem)); padding: 0; border: 0; border-radius: 20px;
  background: var(--card); color: var(--ink); box-shadow: 0 30px 80px -20px rgba(15, 23, 42, .45);
}
.modal[open] { animation: modalIn .28s var(--ease) both; }
.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); animation: fadeIn .2s ease both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* ---------- Avatar ---------------------------------------------------------- */
.avatar { width: 2.1rem; height: 2.1rem; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: .8rem; color: #fff; background: linear-gradient(135deg, var(--brand-600), var(--brand-800)); flex-shrink: 0; }
.avatar.accent { background: linear-gradient(135deg, #a3d65c, var(--accent-600)); color: var(--brand-950); }

/* ---------- Skeleton -------------------------------------------------------- */
.skeleton { position: relative; overflow: hidden; background: #e9edf5; border-radius: 12px; }
.skeleton::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent); animation: shimmer 1.4s infinite; }

/* ---------- Animations ------------------------------------------------------ */
@keyframes fadeUp     { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn     { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut    { to { opacity: 0; transform: translateY(-6px); height: 0; padding: 0; margin: 0; border-width: 0; } }
@keyframes slideDown  { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes popIn      { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes grow       { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes shimmer    { to { transform: translateX(100%); } }
@keyframes spin       { to { transform: rotate(360deg); } }
@keyframes float      { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes pulse      { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .45); } 70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); } 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); } }
@keyframes indeterminate { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }
@keyframes rowIn      { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
@keyframes blob       { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(30px, -20px) scale(1.08); } 66% { transform: translate(-20px, 20px) scale(.95); } }

.fade-up    { animation: fadeUp .55s var(--ease) both; }
.stagger > * { animation: fadeUp .55s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.panel-in   { animation: fadeUp .4s var(--ease) both; }
.row-in     { animation: rowIn .4s var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* ---------- Print ----------------------------------------------------------- */
@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; }
  .tbl-wrap.scroll { max-height: none; overflow: visible; }
  .tabs-bar, .topnav { display: none !important; }
}

/* ==========================================================================
   Readability — darker text everywhere (overrides light Tailwind greys)
   ========================================================================== */
html:not(.dark) .text-slate-300 { color: #94a3b8 !important; }
html:not(.dark) .text-slate-400 { color: #64748b !important; }
html:not(.dark) .text-slate-500 { color: #475569 !important; }
html:not(.dark) .text-slate-600 { color: #334155 !important; }
html:not(.dark) .text-slate-700 { color: #1e293b !important; }
.field::placeholder { color: #64748b; opacity: 1; }
.card-desc, .page-sub, .tbl-note { color: var(--muted); }
.stat-label { color: var(--tone-ink, var(--ink-2)); }

/* ==========================================================================
   Night mode
   ========================================================================== */
html.dark {
  color-scheme: dark;
  --bg: #0a1020;
  --card: #111a2e;
  --th-bg: #16223b;
  --line: #233150;
  --line-2: #1a2640;
  --ink: #eef3ff;
  --ink-2: #d5dded;
  --muted: #a3b1c9;
  --row-hover: #18243d;
  --brand-50: #172a52;
  --brand-100: #22396b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px -14px rgba(0, 0, 0, .7);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .45), 0 22px 46px -18px rgba(0, 0, 0, .85);
}
html.dark body { background: radial-gradient(1200px 600px at 10% -10%, rgba(58, 103, 196, .16), transparent 60%), radial-gradient(900px 500px at 100% 0%, rgba(141, 198, 63, .08), transparent 60%), var(--bg); }
html.theme-switching *, html.theme-switching *::before, html.theme-switching *::after { transition: background-color .4s ease, color .4s ease, border-color .4s ease, box-shadow .4s ease !important; }

/* Tailwind utility overrides */
html.dark .bg-white, html.dark .bg-slate-50, html.dark .bg-slate-100 { background-color: var(--card) !important; }
html.dark .bg-white\/70, html.dark .bg-slate-50\/60 { background-color: rgba(17, 26, 46, .75) !important; }
html.dark .\!bg-slate-50 { background-color: #0e1729 !important; }
html.dark .text-slate-900, html.dark .text-slate-800 { color: var(--ink) !important; }
html.dark .text-slate-700, html.dark .text-slate-600 { color: var(--ink-2) !important; }
html.dark .text-slate-500, html.dark .text-slate-400 { color: var(--muted) !important; }
html.dark .text-slate-300 { color: #64748b !important; }
html.dark .border-slate-200, html.dark .border-slate-100, html.dark .border-slate-200\/80 { border-color: var(--line) !important; }
html.dark .hover\:bg-slate-100:hover, html.dark .hover\:bg-slate-50:hover { background-color: #1a2742 !important; }
html.dark .bg-brand-50 { background-color: var(--brand-50) !important; }
html.dark .text-brand-700, html.dark .text-brand-800 { color: #8fb1ff !important; }
html.dark .ring-brand-50, html.dark .ring-brand-50\/50 { --tw-ring-color: rgba(58, 103, 196, .25) !important; }
html.dark .from-emerald-50 { --tw-gradient-from: rgba(16, 185, 129, .14) var(--tw-gradient-from-position) !important; --tw-gradient-to: transparent var(--tw-gradient-to-position) !important; }
html.dark .to-white { --tw-gradient-to: transparent var(--tw-gradient-to-position) !important; }
html.dark .bg-rose-50 { background-color: rgba(244, 63, 94, .15) !important; }
html.dark .ring-rose-50\/60 { --tw-ring-color: rgba(244, 63, 94, .12) !important; }

/* Components */
html.dark .topnav { background: rgba(10, 16, 32, .82); border-color: var(--line); }
html.dark .nav-link { color: var(--ink-2); }
html.dark .nav-link:hover { background: #1a2742; color: #fff; }
html.dark .nav-link.active { background: linear-gradient(135deg, rgba(58, 103, 196, .35), rgba(141, 198, 63, .18)); color: #fff; box-shadow: inset 0 0 0 1px rgba(143, 177, 255, .35); }
html.dark .tabs-bar { background: rgba(17, 26, 46, .9); }
html.dark .tab-btn { color: var(--muted); }
html.dark .tab-btn:hover { background: #1a2742; color: #fff; }
html.dark .tab-num { background: #1f2d4b; color: var(--ink-2); }
html.dark .select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23a3b1c9' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E"); }
html.dark .field, html.dark .select { background-color: #0e1729; }
html.dark .field::placeholder { color: #7c8aa5; }
html.dark .btn-ghost { background: #15213a; color: var(--ink-2); border-color: var(--line); }
html.dark .btn-ghost:hover { background: #1b2a48; color: #fff; }
html.dark .btn-soft { background: #1b2d55; color: #a9c3ff; }
html.dark .btn-soft:hover { background: #233a6d; }
html.dark .btn-danger-soft { background: rgba(244, 63, 94, .14); color: #fda4af; border-color: rgba(244, 63, 94, .35); }
html.dark .menu a:hover { background: #1a2742; }
html.dark .tone-comp  { --tone-bg: rgba(16, 185, 129, .14); --tone-line: rgba(16, 185, 129, .35); --tone-ink: #6ee7b7; }
html.dark .tone-repg  { --tone-bg: rgba(59, 130, 246, .16); --tone-line: rgba(59, 130, 246, .38); --tone-ink: #93c5fd; }
html.dark .tone-repr  { --tone-bg: rgba(245, 158, 11, .15); --tone-line: rgba(245, 158, 11, .38); --tone-ink: #fcd34d; }
html.dark .tone-repna { --tone-bg: rgba(244, 63, 94, .15); --tone-line: rgba(244, 63, 94, .38); --tone-ink: #fda4af; }
html.dark .tone-inc   { --tone-bg: rgba(148, 163, 184, .14); --tone-line: rgba(148, 163, 184, .3); --tone-ink: #cbd5e1; }
html.dark .tone-brand { --tone-bg: rgba(58, 103, 196, .2); --tone-line: rgba(58, 103, 196, .45); --tone-ink: #a9c3ff; }
html.dark .tone-indigo{ --tone-bg: rgba(99, 102, 241, .18); --tone-line: rgba(99, 102, 241, .4); --tone-ink: #c7d2fe; }
html.dark .t-comp { color: #6ee7b7; } html.dark .t-repg { color: #93c5fd; } html.dark .t-repr { color: #fcd34d; }
html.dark .t-repna { color: #fda4af; } html.dark .t-inc { color: #cbd5e1; }
html.dark .tbl tr.is-selected { background: #1a2b52 !important; }
html.dark .progress .track, html.dark .minibar, html.dark .kpi-bar { background: #1f2c48; }
html.dark .brief { background: linear-gradient(180deg, #0f1830, #111a2e); color: var(--ink-2); }
html.dark .alert-success { background: rgba(16, 185, 129, .12); border-color: rgba(16, 185, 129, .35); color: #a7f3d0; }
html.dark .alert-error   { background: rgba(244, 63, 94, .12); border-color: rgba(244, 63, 94, .35); color: #fecdd3; }
html.dark .dropzone { background: linear-gradient(180deg, #111a2e, #0e1729); border-color: #2c3c60; }
html.dark .dropzone:hover, html.dark .dropzone.drop-active { background: #15244a; border-color: #5b82d8; }
html.dark .dz-icon { background: #1a2742; color: #a9c3ff; }
html.dark .file-chip { background: #15244a; border-color: #2c3c60; }
html.dark .radio-card { border-color: var(--line); }
html.dark .radio-card:has(input:checked) { background: #15244a; border-color: #5b82d8; }
html.dark .radio-card.danger:has(input:checked) { background: rgba(244, 63, 94, .12); border-color: #fb7185; }
html.dark .step-num { background: #1b2d55; color: #a9c3ff; }
html.dark .skeleton { background: #172238; }
html.dark .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .06), transparent); }
html.dark .modal::backdrop { background: rgba(0, 0, 0, .6); }
html.dark .stat { background: var(--tone-bg, #15213a); }
html.dark .kpi::after { opacity: .5; }
html.dark ::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark ::-webkit-scrollbar-thumb { background: #2a3a5e; border-radius: 10px; }
html.dark ::-webkit-scrollbar-track { background: #0e1729; }
html.dark .captcha-box { border-color: var(--line); }
html.dark .login-form-panel { background: var(--bg); }

/* ---------- Theme toggle ---------------------------------------------------- */
.theme-toggle {
  position: relative; width: 2.5rem; height: 2.5rem; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--card); border: 1px solid var(--line); color: #f59e0b; box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .2s var(--ease), background .3s;
}
.theme-toggle:hover { transform: translateY(-1px); }
.theme-toggle > span { position: absolute; display: grid; place-items: center; transition: transform .5s var(--ease), opacity .35s; }
.theme-toggle .moon { color: #a5b4fc; transform: translateY(150%) rotate(-90deg); opacity: 0; }
html.dark .theme-toggle .sun { transform: translateY(-150%) rotate(90deg); opacity: 0; }
html.dark .theme-toggle .moon { transform: none; opacity: 1; }
.theme-toggle.pop { animation: popIn .45s var(--ease); }

/* ---------- Captcha -------------------------------------------------------- */
.captcha-box { position: relative; flex-shrink: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow-sm); height: 2.75rem; }
.captcha-box img { display: block; height: 100%; width: auto; user-select: none; }
/* Box matches the image's 170×52 ratio at 44px height, so nothing is cropped */
.captcha-box { width: 9rem; height: 2.75rem; background: #eef3fb; }
.captcha-box img { width: 100%; height: 100%; object-fit: fill; }
.captcha-refresh { flex-shrink: 0; width: 2.75rem; height: 2.75rem; border-radius: 12px; display: grid; place-items: center; background: var(--card); border: 1px solid var(--line); color: var(--brand-700); box-shadow: var(--shadow-sm); transition: background .2s, color .2s; }
.captcha-refresh:hover { background: var(--brand-50); color: var(--brand-900); }
html.dark .captcha-refresh { color: #a9c3ff; }
.captcha-refresh.spinning svg { animation: spin .6s linear; }

/* ==========================================================================
   Colourful dashboard
   ========================================================================== */
/* Animated gradient hero */
.hero {
  position: relative; overflow: hidden; border-radius: 22px; color: #fff; padding: 1.6rem 1.75rem;
  background: linear-gradient(120deg, #1b3f8b, #2451a8 25%, #6d28d9 50%, #0e7490 75%, #1b3f8b);
  background-size: 300% 300%; animation: heroShift 16s ease-in-out infinite;
  box-shadow: 0 24px 50px -24px rgba(27, 63, 139, .75);
}
.hero::before, .hero::after { content: ''; position: absolute; border-radius: 50%; filter: blur(8px); pointer-events: none; }
.hero::before { width: 320px; height: 320px; right: -80px; top: -150px; background: radial-gradient(circle, rgba(141, 198, 63, .55), transparent 65%); animation: blob 12s ease-in-out infinite; }
.hero::after { width: 260px; height: 260px; left: 30%; bottom: -170px; background: radial-gradient(circle, rgba(244, 114, 182, .45), transparent 65%); animation: blob 15s ease-in-out infinite reverse; }
.hero > * { position: relative; z-index: 1; }
.hero .eyebrow { color: #d9f99d; }
.hero .page-title { color: #fff; font-size: 1.85rem; }
html .hero .page-sub, html .hero .page-sub * { color: rgba(255, 255, 255, .9) !important; }
html .hero .page-sub strong { color: #fff !important; }
.hero .chip { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .25); color: #fff; backdrop-filter: blur(6px); }
.hero .btn-ghost { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .3); color: #fff; backdrop-filter: blur(6px); }
.hero .btn-ghost:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.hero .btn-primary { background: #fff; color: var(--brand-800); }
.hero .btn-primary:hover { background: #eef3fb; }
.hero-dots { position: absolute; inset: 0; background-image: radial-gradient(rgba(255, 255, 255, .16) 1px, transparent 1px); background-size: 18px 18px; mask-image: linear-gradient(90deg, transparent, #000 60%); -webkit-mask-image: linear-gradient(90deg, transparent, #000 60%); }
@keyframes heroShift { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }

/* Vivid gradient KPI tiles */
.kpi-vivid { border: 0; color: #fff; isolation: isolate; }
.kpi-vivid::after { background: radial-gradient(circle, rgba(255, 255, 255, .28), transparent 70%); opacity: 1; width: 140px; height: 140px; right: -40px; top: -50px; }
.kpi-vivid::before {
  content: ''; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, .35) 48%, transparent 66%);
  transform: translateX(-120%); animation: shine 1.4s var(--ease) both; animation-delay: calc(var(--i, 0) * 90ms + .35s);
}
.kpi-vivid:hover::before { animation: shine 1s var(--ease); }
.kpi-vivid .kpi-label { color: rgba(255, 255, 255, .92); }
.kpi-vivid .kpi-value { color: #fff; text-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.kpi-vivid .kpi-value small { color: rgba(255, 255, 255, .85); }
.kpi-vivid .kpi-foot { color: rgba(255, 255, 255, .9); font-weight: 500; }
.kpi-vivid .kpi-icon { background: rgba(255, 255, 255, .2); color: #fff; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .3); backdrop-filter: blur(4px); }
.kpi-vivid .kpi-bar { background: rgba(255, 255, 255, .25); }
.kpi-vivid .kpi-bar > span { background: #fff; }
.kpi-vivid:hover { transform: translateY(-5px) scale(1.015); }
.kpi-vivid .spark { position: absolute; right: .9rem; top: 3.4rem; width: 42%; height: 30px; z-index: 1; opacity: .95; }
.kpi-vivid .spark path.line { fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 400; stroke-dashoffset: 400; animation: draw 1.6s var(--ease) forwards .5s; }
.kpi-vivid .spark path.area { fill: rgba(255, 255, 255, .18); opacity: 0; animation: fadeIn .8s ease forwards 1.2s; }
.grad-blue   { background: linear-gradient(135deg, #2563eb, #1b3f8b); box-shadow: 0 16px 32px -18px rgba(37, 99, 235, .9); }
.grad-green  { background: linear-gradient(135deg, #10b981, #047857); box-shadow: 0 16px 32px -18px rgba(16, 185, 129, .9); }
.grad-cyan   { background: linear-gradient(135deg, #06b6d4, #2563eb); box-shadow: 0 16px 32px -18px rgba(6, 182, 212, .9); }
.grad-amber  { background: linear-gradient(135deg, #f59e0b, #ea580c); box-shadow: 0 16px 32px -18px rgba(245, 158, 11, .9); }
.grad-rose   { background: linear-gradient(135deg, #f43f5e, #be123c); box-shadow: 0 16px 32px -18px rgba(244, 63, 94, .9); }
.grad-violet { background: linear-gradient(135deg, #8b5cf6, #6d28d9); box-shadow: 0 16px 32px -18px rgba(139, 92, 246, .9); }
.grad-slate  { background: linear-gradient(135deg, #64748b, #334155); box-shadow: 0 16px 32px -18px rgba(71, 85, 105, .9); }
.grad-pink   { background: linear-gradient(135deg, #ec4899, #8b5cf6); box-shadow: 0 16px 32px -18px rgba(236, 72, 153, .9); }
@keyframes shine { from { transform: translateX(-120%); } to { transform: translateX(120%); } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Colourful tabs: each tab gets its own accent */
.tab-btn { --c: #1b3f8b; }
.tab-btn svg, .tab-btn .tab-num { color: var(--c); }
.tab-btn .tab-num { background: color-mix(in srgb, var(--c) 14%, transparent); }
.tab-btn.active { background: linear-gradient(135deg, var(--c), color-mix(in srgb, var(--c) 70%, #0b1324)); box-shadow: 0 10px 20px -10px var(--c); }
.tab-btn.active svg, .tab-btn.active .tab-num { color: #fff; }
.tab-btn[data-tab="daily"]      { --c: #2563eb; }
.tab-btn[data-tab="monthly"]    { --c: #7c3aed; }
.tab-btn[data-tab="overview"]   { --c: #db2777; }
.tab-btn[data-tab="district"]   { --c: #059669; }
.tab-btn[data-tab="psu"]        { --c: #0891b2; }
.tab-btn[data-tab="enumerator"] { --c: #ea580c; }
.tab-btn[data-tab="status"]     { --c: #dc2626; }
.tab-btn[data-tab="matrix"]     { --c: #4f46e5; }
html.dark .tab-btn svg, html.dark .tab-btn .tab-num { color: color-mix(in srgb, var(--c) 55%, #fff); }

/* Coloured accent strip on cards inside the dashboard */
.card-accent { position: relative; overflow: hidden; }
.card-accent::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: linear-gradient(90deg, var(--c1, #2563eb), var(--c2, #8b5cf6), var(--c3, #10b981)); background-size: 200% 100%; animation: stripe 6s linear infinite; }
@keyframes stripe { to { background-position: 200% 0; } }
.card-accent .eyebrow { color: var(--c1, var(--brand-600)); }

/* Section label dots cycle colours */
.section-label::before { background: linear-gradient(135deg, var(--c1, #8dc63f), var(--c2, #2563eb)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c1, #8dc63f) 25%, transparent); }

/* Table header with gentle colour wash */
.tbl th { background: linear-gradient(180deg, var(--th-bg), color-mix(in srgb, var(--th-bg) 88%, #c7d2fe)); }
html.dark .tbl th { background: linear-gradient(180deg, #172440, #142039); }
.tbl tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--c1, #2563eb); }
