/* ============================================================ tokens */
:root {
  --bg: #0f1226;
  --bg-2: #151935;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-3: rgba(255, 255, 255, 0.09);
  --stroke: rgba(255, 255, 255, 0.10);
  --stroke-2: rgba(255, 255, 255, 0.16);
  --text: #eef1ff;
  --muted: #9aa3c7;
  --muted-2: #6b739b;

  --primary: #6d8bff;
  --primary-2: #8a6dff;
  --glow: rgba(109, 139, 255, 0.45);

  /* bucket-type accents */
  --gp:   #2dd4a7;   /* Gram Panchayat  */
  --np:   #f4b740;   /* Nagar Panchayat */
  --mun:  #5b9bff;   /* Municipality    */
  --corp: #b07bff;   /* Corporation     */

  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 18px 50px -18px rgba(0, 0, 0, 0.65);
  --shadow-soft: 0 8px 30px -12px rgba(0, 0, 0, 0.5);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 12% -8%, #21274f 0%, transparent 55%),
    radial-gradient(1000px 700px at 110% 10%, #2a1f4d 0%, transparent 55%),
    var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ============================================================ shell */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0));
  backdrop-filter: blur(8px);
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 6px 22px -6px var(--glow), inset 0 1px 0 rgba(255,255,255,0.4);
  display: grid; place-items: center;
  position: relative; overflow: hidden;
}
.brand .logo::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(18px 18px at 70% 25%, rgba(255,255,255,.55), transparent 60%);
}
.brand .logo svg { width: 21px; height: 21px; position: relative; z-index: 1; }
.brand h1 { font-size: 15px; margin: 0; letter-spacing: .2px; font-weight: 650; }
.brand p  { margin: 1px 0 0; font-size: 11.5px; color: var(--muted); font-weight: 500; }

.spacer { flex: 1; }

/* segmented app toggle */
.segment {
  position: relative;
  display: flex;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--stroke);
  border-radius: 999px;
  gap: 2px;
}
.segment .thumb {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 6px 20px -6px var(--glow), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .42s var(--spring), width .42s var(--spring);
  z-index: 0;
}
.segment button {
  position: relative; z-index: 1;
  border: 0; background: transparent; cursor: pointer;
  color: var(--muted); font-weight: 600; font-size: 12.5px;
  letter-spacing: .4px;
  padding: 8px 18px; border-radius: 999px;
  transition: color .3s var(--ease);
  font-family: inherit;
}
.segment button.active { color: #fff; }
.seg-label { font-size: 11px; color: var(--muted-2); margin-right: -6px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .8px; }

/* ============================================================ layout */
.main {
  display: grid;
  grid-template-columns: 60% 40%;   /* panel (left) | map (right) */
  min-height: 0;
}
.panel    { order: 1; }
.map-wrap { order: 2; }
@media (max-width: 1100px) { .main { grid-template-columns: 56% 44%; } }
@media (max-width: 860px)  {
  .main { grid-template-columns: 1fr; grid-template-rows: 40vh 1fr; }
  .map-wrap { order: 1; }   /* map back on top (compact) when stacked */
  .panel    { order: 2; }
}

/* map */
.map-wrap {
  position: relative; min-height: 0; overflow: hidden;
  background:
    radial-gradient(120% 90% at 50% 0%, #181d3e 0%, transparent 60%),
    radial-gradient(100% 80% at 50% 110%, #1a1430 0%, transparent 55%),
    #0c0f24;
}
/* slow drifting aurora behind the polygons */
.map-wrap::before {
  content: ""; position: absolute; inset: -25%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(38% 38% at 26% 30%, rgba(123,111,239,.28), transparent 70%),
    radial-gradient(34% 34% at 76% 64%, rgba(45,212,167,.18), transparent 70%),
    radial-gradient(40% 40% at 62% 18%, rgba(255,94,168,.16), transparent 70%);
  filter: blur(34px); animation: auroraDrift 24s var(--ease) infinite alternate;
}
/* faint engineering grid, masked to a soft circle */
.map-wrap::after {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(255,255,255,.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.028) 1px, transparent 1px);
  background-size: 40px 40px;
  -webkit-mask: radial-gradient(circle at 50% 45%, #000 50%, transparent 100%);
          mask: radial-gradient(circle at 50% 45%, #000 50%, transparent 100%);
}
#map { position: absolute; inset: 0; background: transparent; z-index: 1; }
.leaflet-container { background: transparent; font-family: inherit; outline: none; }
.leaflet-overlay-pane path.leaflet-interactive {
  transition: fill .4s var(--ease), fill-opacity .4s var(--ease), stroke .25s var(--ease), stroke-width .2s var(--ease), filter .3s var(--ease);
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}
.leaflet-overlay-pane path.leaflet-interactive:hover { filter: drop-shadow(0 0 9px rgba(255,255,255,.6)); }
.leaflet-overlay-pane path.sel-glow { animation: selPulse 2.4s ease-in-out infinite; }

@keyframes auroraDrift {
  0%   { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(3%, -2.5%) scale(1.08); }
  100% { transform: translate(-2.5%, 3%) scale(1.05); }
}
@keyframes selPulse {
  0%, 100% { filter: drop-shadow(0 0 3px rgba(255,255,255,.55)); }
  50%      { filter: drop-shadow(0 0 11px rgba(255,255,255,.95)); }
}

.map-legend {
  position: absolute; left: 16px; bottom: 16px; z-index: 500;
  background: rgba(16, 19, 41, 0.72);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
  animation: rise .6s var(--ease-out) both .25s;
}
.map-legend h4 { margin: 0 0 8px; font-size: 10.5px; letter-spacing: .8px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.legend-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-top: 5px; transition: color .2s var(--ease); }
.legend-row:hover { color: var(--text); }
.legend-swatch { width: 22px; height: 11px; border-radius: 4px; flex: none; box-shadow: 0 0 8px -1px currentColor, inset 0 0 0 1px rgba(255,255,255,.18); }

.map-hint {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 500; font-size: 12px; color: var(--muted);
  background: rgba(16,19,41,.7); border: 1px solid var(--stroke);
  padding: 7px 14px; border-radius: 999px; backdrop-filter: blur(10px);
  animation: rise .6s var(--ease-out) both .35s, floaty 4s ease-in-out 1s infinite;
  pointer-events: none; white-space: nowrap;
}

/* permanent polygon labels (district / mandal) */
.poly-label { background: transparent; border: 0; box-shadow: none; }
.poly-label .pl-inner {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; align-items: center; gap: 4px; white-space: nowrap; pointer-events: none;
  font-weight: 700; color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,.95), 0 0 3px rgba(0,0,0,.85);
}
.dist-label .pl-inner { font-size: 10px; }
.dist-label .pl-inner.off { opacity: .55; font-weight: 600; }
.mandal-label .pl-inner { font-size: 9px; letter-spacing: .2px; }
.mandal-label .pl-inner.off { opacity: .5; }

/* district identity landmark chip (district view) */
.landmark-chip {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 13px;
  font-size: 12px; font-weight: 650; color: var(--text);
  background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 16%, var(--surface)), var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 26%, var(--stroke));
  border-radius: 999px; padding: 6px 13px 6px 11px;
  animation: rise .5s var(--ease-out) both;
}
.landmark-chip .lm-ico { width: 15px; height: 15px; flex: none; color: var(--primary-2); }

/* district tooltip */
.dist-tip {
  background: rgba(16,19,41,.92) !important;
  border: 1px solid var(--stroke-2) !important;
  border-radius: 10px !important;
  color: var(--text) !important;
  box-shadow: var(--shadow) !important;
  padding: 9px 12px !important;
  font-family: inherit !important;
}
.dist-tip::before { display: none !important; }
.dist-tip .tt-name { font-weight: 650; font-size: 13px; }
.dist-tip .tt-sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.dist-tip .tt-chips { display: flex; gap: 4px; margin-top: 6px; }
.tt-chip { font-size: 10px; padding: 2px 7px; border-radius: 999px; font-weight: 700; color: #0c0f22; }

/* ============================================================ panel */
.panel {
  position: relative;
  min-height: 0;
  border-right: 1px solid var(--stroke);
  background: linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0));
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.panel-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--stroke); }
.search {
  position: relative; display: flex; align-items: center;
}
.search svg { position: absolute; left: 13px; width: 16px; height: 16px; color: var(--muted-2); pointer-events: none; }
.search input {
  width: 100%; padding: 11px 14px 11px 38px;
  background: var(--surface-2); border: 1px solid var(--stroke);
  border-radius: 12px; color: var(--text); font-size: 13.5px; font-family: inherit;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease);
}
.search input::placeholder { color: var(--muted-2); }
.search input:focus {
  outline: none; border-color: var(--primary);
  background: var(--surface-3);
  box-shadow: 0 0 0 4px rgba(109,139,255,.16);
}
/* inline search results (rendered in the panel body) */
.result { padding: 12px 14px; }
.result-row { display: flex; align-items: center; gap: 11px; }
.result-text { flex: 1; min-width: 0; }
.result .card-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result .card-sub { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.result.active { border-color: var(--primary); background: var(--surface-2); box-shadow: 0 0 0 3px rgba(109,139,255,.14); }
.result.active::before { transform: scaleY(1); }
.sr-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.sr-kind { flex: none; font-size: 9.5px; font-weight: 800; letter-spacing: .4px; text-transform: uppercase;
  color: var(--muted); background: var(--surface-3); border: 1px solid var(--stroke);
  padding: 3px 7px; border-radius: 6px; }

/* search scope filter chips */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.filter-chip {
  font-family: inherit; cursor: pointer;
  font-size: 11px; font-weight: 650; letter-spacing: .2px;
  color: var(--muted); background: var(--surface-2);
  border: 1px solid var(--stroke); border-radius: 999px;
  padding: 5px 11px;
  transition: color .22s var(--ease), background .22s var(--ease), border-color .22s var(--ease), transform .18s var(--ease-out);
}
.filter-chip:hover { color: var(--text); border-color: var(--stroke-2); }
.filter-chip:active { transform: scale(.94); }
.filter-chip.active {
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  box-shadow: 0 5px 16px -6px var(--glow);
}

/* breadcrumb + reset */
.crumb-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 22px; font-size: 12px; flex: 1; min-width: 0; }
.reset-icon {
  flex: none; display: grid; place-items: center; cursor: pointer;
  width: 30px; height: 30px; border-radius: 9px;
  color: var(--muted); background: var(--surface-2); border: 1px solid var(--stroke);
  transition: color .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease), transform .4s var(--spring);
}
.reset-icon svg { width: 15px; height: 15px; }
.reset-icon:hover { color: var(--text); background: var(--surface-3); border-color: var(--stroke-2); transform: rotate(-130deg); }
.reset-icon:active { transform: rotate(-300deg) scale(.92); }
.crumb { color: var(--muted); cursor: pointer; transition: color .2s var(--ease); display: inline-flex; align-items: center; gap: 6px; }
.crumb:hover { color: var(--text); }
.crumb.current { color: var(--text); font-weight: 650; cursor: default; }
.crumb-sep { color: var(--muted-2); }

/* scroll area + view transitions */
.scroll { overflow-y: auto; overflow-x: hidden; padding: 16px 18px 28px; scrollbar-width: thin; scrollbar-color: var(--stroke-2) transparent; }
.scroll::-webkit-scrollbar { width: 9px; }
.scroll::-webkit-scrollbar-thumb { background: var(--stroke-2); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }

.view { animation: viewIn .4s var(--ease-out) both; }
.view.out { animation: viewOut .22s var(--ease) both; }

.section-title { font-size: 11px; letter-spacing: .9px; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 2px 0 12px; }

/* ============================================================ cards */
.cards { display: grid; gap: 11px; }
.card {
  --accent: var(--primary);
  position: relative;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 15px 16px;
  cursor: pointer;
  overflow: hidden;
  transform: translateZ(0);
  transition: transform .3s var(--ease-out), border-color .3s var(--ease), background .3s var(--ease), box-shadow .3s var(--ease);
  animation: rise .5s var(--ease-out) both;
}
.card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--accent); opacity: .9;
  transform: scaleY(.4); transform-origin: center; transition: transform .35s var(--spring);
}
.card:hover { transform: translateY(-3px); border-color: var(--stroke-2); background: var(--surface-2);
  box-shadow: var(--shadow-soft); }
.card:hover::before { transform: scaleY(1); }
.card:active { transform: translateY(-1px) scale(.995); }

.card-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-title { font-size: 14.5px; font-weight: 650; letter-spacing: .2px; }
.card-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.count-pill {
  font-size: 12px; font-weight: 700; color: var(--text);
  background: var(--surface-3); border: 1px solid var(--stroke);
  padding: 4px 10px; border-radius: 999px; flex: none;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 11px; }
.chip {
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
  padding: 4px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--stroke); color: var(--muted);
}
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }

/* type accents */
.t-GP   { --accent: var(--gp); }
.t-NP   { --accent: var(--np); }
.t-Mun  { --accent: var(--mun); }
.t-Corp { --accent: var(--corp); }

/* ============================================================ cascade selector */
.selector-title {
  background: linear-gradient(90deg, #8ea2ff, #b08cff 55%, #ff9ec4);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  font-weight: 800; opacity: 1;
}
.sel-hint {
  font-size: 12.5px; color: var(--muted); line-height: 1.55;
  margin: -2px 0 16px; padding: 12px 14px 12px 15px;
  background:
    radial-gradient(420px 120px at 0% 0%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 70%),
    radial-gradient(420px 140px at 100% 120%, color-mix(in srgb, var(--primary-2) 16%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, var(--stroke));
  border-left: 3px solid var(--primary-2);
  border-radius: var(--radius-sm);
}
.sel-box { display: grid; gap: 11px; }
.dd-row { display: grid; gap: 6px; animation: rise .45s var(--ease-out) both; }
.dd-row:nth-child(1) { animation-delay: .02s; }
.dd-row:nth-child(2) { animation-delay: .06s; }
.dd-row:nth-child(3) { animation-delay: .10s; }
.dd-row:nth-child(4) { animation-delay: .14s; }
.dd-row:nth-child(5) { animation-delay: .18s; }
.dd-row:nth-child(6) { animation-delay: .22s; }
.dd-row { --lv: var(--primary); }
.dd-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .7px; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 7px;
}
.dd-dot { width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--lv); box-shadow: 0 0 9px -1px var(--lv); }
.dd-opt {
  font-size: 8.5px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted-2);
  background: var(--surface-2); border: 1px solid var(--stroke); padding: 2px 6px; border-radius: 6px;
}
.dd-wrap { position: relative; }
.dd {
  width: 100%; appearance: none; -webkit-appearance: none;
  font-family: inherit; font-size: 13.5px; font-weight: 550; color: var(--text);
  padding: 11px 38px 11px 14px;
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px; cursor: pointer;
  transition: border-color .25s var(--ease), box-shadow .25s var(--ease), background .25s var(--ease);
}
.dd:hover:not(:disabled) { border-color: var(--stroke-2); background: var(--surface-3); }
.dd:focus { outline: none; border-color: var(--lv); box-shadow: 0 0 0 4px color-mix(in srgb, var(--lv) 22%, transparent); }
.dd:disabled { opacity: .5; cursor: not-allowed; }
.dd option { background: var(--bg-2); color: var(--text); }
.dd-caret {
  position: absolute; right: 13px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted-2); pointer-events: none; transition: color .25s var(--ease);
}
.dd-row.filled .dd {
  border-color: color-mix(in srgb, var(--lv) 60%, var(--stroke));
  background: color-mix(in srgb, var(--lv) 9%, var(--surface-2));
  box-shadow: inset 3px 0 0 var(--lv);
}
.dd-row.filled .dd-label { color: var(--text); }
.dd-row.filled .dd-caret { color: var(--lv); }
.dd-row.muted { opacity: .5; }

/* ward multi-select */
.ward-count { margin-left: auto; font-size: 9.5px; font-weight: 700; letter-spacing: .3px;
  color: color-mix(in srgb, var(--lv) 75%, #fff); text-transform: none; }
.ward-chips { display: flex; flex-wrap: wrap; gap: 7px; padding: 11px;
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px; }
.ward-row.filled .ward-chips { border-color: color-mix(in srgb, var(--lv) 45%, var(--stroke)); }
.ward-row.muted .ward-chips { opacity: .6; }
.ward-empty { font-size: 12px; color: var(--muted-2); padding: 3px 2px; }
.ward-chip {
  font-family: inherit; cursor: pointer; font-size: 11.5px; font-weight: 600;
  color: var(--muted); background: var(--surface-3); border: 1px solid var(--stroke);
  border-radius: 999px; padding: 6px 12px;
  transition: color .2s var(--ease), background .2s var(--ease), border-color .2s var(--ease), transform .18s var(--ease-out);
}
.ward-chip:hover { color: var(--text); border-color: var(--stroke-2); transform: translateY(-1px); }
.ward-chip:active { transform: scale(.95); }
.ward-chip.on {
  color: #0c0f22; font-weight: 700; border-color: transparent;
  background: linear-gradient(135deg, var(--lv), color-mix(in srgb, var(--lv) 70%, #000 6%));
  box-shadow: 0 5px 14px -6px var(--lv);
}
.ward-chip.ward-all { color: color-mix(in srgb, var(--lv) 80%, #fff); background: transparent;
  border-color: color-mix(in srgb, var(--lv) 45%, var(--stroke)); }
.ward-chip.ward-all.on { color: #0c0f22; background: linear-gradient(135deg, var(--lv), color-mix(in srgb, var(--lv) 70%, #000 6%)); }

/* colored path preview */
.sel-path { display: none; flex-wrap: wrap; align-items: center; gap: 7px; margin-top: 16px; }
.sel-path.show { display: flex; animation: rise .35s var(--ease-out) both; }
.path-chip { --lv: var(--primary);
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 650; color: var(--text);
  padding: 5px 11px 5px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--lv) 16%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--lv) 40%, var(--stroke));
}
.path-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lv); box-shadow: 0 0 8px -1px var(--lv); }
.path-arrow { color: var(--muted-2); font-size: 13px; }

.sel-actions { display: flex; gap: 10px; margin-top: 18px; align-items: stretch; }
.see-btn {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  font-family: inherit; font-size: 13.5px; font-weight: 650; letter-spacing: .2px; cursor: pointer;
  color: #fff; border: 0; border-radius: 12px; padding: 13px 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 26px -10px var(--glow), inset 0 1px 0 rgba(255,255,255,.3);
  transition: transform .2s var(--ease-out), box-shadow .25s var(--ease), filter .25s var(--ease);
}
.see-btn svg { width: 17px; height: 17px; flex: none; }
.see-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.see-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 16px 34px -12px var(--glow); }
.see-btn:active:not(:disabled) { transform: translateY(0) scale(.99); }
.see-btn:disabled { filter: grayscale(.55) brightness(.65); cursor: not-allowed; box-shadow: none; }

/* ============================================================ tree */
.tree { display: grid; gap: 8px; }
.node { animation: rise .45s var(--ease-out) both; }
.node-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  cursor: pointer; user-select: none;
  transition: background .25s var(--ease), border-color .25s var(--ease), transform .2s var(--ease-out);
}
.node-head:hover { background: var(--surface-2); border-color: var(--stroke-2); }
.node-head:active { transform: scale(.992); }
.caret {
  width: 16px; height: 16px; flex: none; color: var(--muted);
  transition: transform .34s var(--spring);
}
.node.open > .node-head .caret { transform: rotate(90deg); }
.node-ico { width: 9px; height: 9px; border-radius: 3px; flex: none; box-shadow: 0 0 10px -1px currentColor; }
.node-name { font-size: 13.5px; font-weight: 600; flex: 1; }
.node-meta { font-size: 11px; color: var(--muted); }

/* smooth collapse via grid-template-rows */
.node-kids {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .38s var(--ease-out);
}
.node.open > .node-kids { grid-template-rows: 1fr; }
.node-kids > .kids-inner { overflow: hidden; min-height: 0; }
.kids-pad { padding: 8px 0 2px 16px; display: grid; gap: 7px;
  margin-left: 7px; border-left: 1.5px dashed var(--stroke); }

/* flat (single-item) section */
.flat-sec { animation: rise .45s var(--ease-out) both; }
.flat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 13px;
  background: var(--surface); border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--primary);
}
.flat-sec.t-GP   .flat-head { border-left-color: var(--gp); }
.flat-sec.t-NP   .flat-head { border-left-color: var(--np); }
.flat-sec.t-Mun  .flat-head { border-left-color: var(--mun); }
.flat-sec.t-Corp .flat-head { border-left-color: var(--corp); }
.flat-head.clickable { cursor: pointer; transition: background .25s var(--ease), border-color .25s var(--ease), transform .2s var(--ease-out); }
.flat-head.clickable:hover { background: var(--surface-2); transform: translateX(2px); }
.flat-head .fh-name { font-size: 13.5px; font-weight: 650; color: var(--text); }
.flat-head .fh-meta { font-size: 11px; color: var(--muted); margin-left: auto; }
.flat-head.clickable .go { width: 15px; height: 15px; color: var(--muted-2); margin-left: 8px; transition: transform .25s var(--ease-out), color .25s var(--ease); }
.flat-head.clickable:hover .go { transform: translateX(3px); color: var(--primary); }
.flat-leaves { display: grid; gap: 7px; margin: 8px 0 2px; padding-left: 14px;
  margin-left: 7px; border-left: 1.5px dashed var(--stroke); }

.leaf {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 13px; border-radius: 10px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--stroke);
  transition: background .22s var(--ease), border-color .22s var(--ease), transform .2s var(--ease-out);
}
.leaf:hover { background: var(--surface-2); border-color: var(--stroke-2); transform: translateX(2px); }
.leaf .leaf-name { font-size: 12.5px; font-weight: 550; flex: 1; }
.leaf .leaf-meta { font-size: 10.5px; color: var(--muted-2); }
.leaf .go { width: 15px; height: 15px; color: var(--muted-2); transition: transform .25s var(--ease-out), color .25s var(--ease); }
.leaf:hover .go { transform: translateX(3px); color: var(--primary); }

/* ============================================================ detail */
.detail-hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  padding: 18px;
  background:
    radial-gradient(420px 180px at 90% -40%, color-mix(in srgb, var(--accent) 40%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid var(--stroke-2);
  margin-bottom: 16px;
  animation: rise .5s var(--ease-out) both;
}
.detail-hero .badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 800; letter-spacing: .4px;
  color: #0c0f22; background: var(--accent);
  padding: 4px 11px; border-radius: 999px;
  box-shadow: 0 6px 18px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
.detail-hero h2 { margin: 11px 0 2px; font-size: 18px; line-height: 1.3; font-weight: 680; }
.detail-hero .loc { font-size: 12.5px; color: var(--muted); }

.cond-strip { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.cond {
  font-size: 11px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--stroke);
  padding: 5px 10px; border-radius: 8px;
}
.cond b { color: var(--text); font-weight: 650; }

/* plot-extent band switch */
.band-switch {
  display: inline-flex; padding: 4px; gap: 3px; margin: 0 0 14px;
  background: var(--surface-2); border: 1px solid var(--stroke); border-radius: 12px;
}
.band-btn {
  font-family: inherit; cursor: pointer; border: 0; background: transparent;
  color: var(--muted); font-weight: 650; font-size: 12.5px; letter-spacing: .2px;
  padding: 8px 16px; border-radius: 9px;
  transition: color .25s var(--ease), background .3s var(--ease), box-shadow .3s var(--ease);
}
.band-btn:hover { color: var(--text); }
.band-btn.active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #000 12%));
  box-shadow: 0 6px 18px -7px var(--accent);
}

/* SLA chain */
.sla-wrap { animation: rise .4s var(--ease-out) both; }
.sla-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 11px 14px; margin-bottom: 12px;
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--stroke)); border-radius: 12px;
}
.sla-cat { font-size: 12.5px; font-weight: 650; color: var(--text); }
.sla-total { font-size: 12px; color: var(--muted); }
.sla-total b { color: var(--text); }
.sla-sub { color: var(--muted-2); margin-left: 6px; padding-left: 8px; border-left: 1px solid var(--stroke-2); }

/* main administrative body (UDA / ULB / DTCP) — collapsible */
.sla-main { animation: rise .42s var(--ease-out) both; margin-bottom: 10px; }
.sla-main-head {
  display: flex; align-items: center; gap: 11px; cursor: pointer; user-select: none;
  padding: 11px 13px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--stroke));
  border-left: 3px solid var(--accent);
  transition: background .22s var(--ease), border-color .22s var(--ease);
}
.sla-main-head:hover { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.sla-main.open .sla-main-head { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.sla-main-head .caret { width: 16px; height: 16px; flex: none; color: var(--accent); transition: transform .34s var(--spring); }
.sla-main.open > .sla-main-head .caret { transform: rotate(90deg); }
.main-badge {
  flex: none; font-size: 11px; font-weight: 800; letter-spacing: .5px; color: #0c0f22;
  background: var(--accent); padding: 4px 9px; border-radius: 7px;
  box-shadow: 0 5px 14px -6px var(--accent);
}
.main-text { flex: 1; min-width: 0; }
.main-name { font-size: 13px; font-weight: 650; color: var(--text); }
.main-sub { font-size: 10.5px; color: var(--muted); margin-top: 1px; }

.sla-group-kids { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .34s var(--ease-out); }
.sla-main.open > .sla-group-kids { grid-template-rows: 1fr; }
.sla-group-kids > .kids-inner { overflow: hidden; min-height: 0; }
.sla-main-body {
  padding: 10px 11px 11px;
  background: color-mix(in srgb, var(--accent) 4%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--stroke)); border-top: 0;
  border-radius: 0 0 12px 12px;
}

/* "Assigned per …" sub-heading inside a main body */
.sub-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 10px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: var(--muted);
  margin: 4px 0 8px;
}
.sub-head:first-child { margin-top: 0; }
.sub-head .sg-bar { width: 11px; height: 3px; flex: none; border-radius: 99px; background: var(--accent); box-shadow: 0 0 8px -1px var(--accent); }
.sub-body { display: grid; gap: 7px; margin-bottom: 12px; }
.sub-body:last-child { margin-bottom: 0; }

/* one level */
.sla-level { animation: slideIn .4s var(--ease-out) both; }
.sla-level.single {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--stroke); border-radius: 11px;
  transition: transform .22s var(--ease-out), border-color .22s var(--ease), background .22s var(--ease);
}
.sla-level.single:hover { transform: translateX(3px); border-color: var(--stroke-2); background: var(--surface-2); }
.sla-level.single.unnamed .o-name { color: var(--muted-2); font-style: italic; }
.sla-level .o-main { flex: 1; min-width: 0; }

.lv {
  width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
}
.days-pill {
  flex: none; font-size: 13px; font-weight: 800; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  padding: 4px 10px; border-radius: 9px;
}
.days-pill span { font-size: 10px; font-weight: 700; opacity: .7; }

/* multi-officer level */
.sla-level.multi {
  padding: 10px 12px 11px; border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--stroke));
}
.sla-level-head { display: flex; align-items: center; gap: 10px; }
.lv-desig { font-size: 12.5px; font-weight: 650; color: var(--text); flex: 1; min-width: 0; }
.lv-count { font-size: 10px; font-weight: 700; color: var(--muted-2); text-transform: uppercase; letter-spacing: .4px; }
.people { display: grid; gap: 6px; margin-top: 9px; }
.pcard {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  background: var(--surface); border: 1px solid var(--stroke); border-radius: 10px;
  animation: slideIn .4s var(--ease-out) both;
  transition: transform .2s var(--ease-out), border-color .2s var(--ease), background .2s var(--ease);
}
.pcard:hover { transform: translateX(3px); border-color: var(--stroke-2); background: var(--surface-2); }
.pcard .o-main { flex: 1; min-width: 0; }
.pc-av {
  width: 28px; height: 28px; border-radius: 50%; flex: none; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #0c0f22;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 90%, #fff), color-mix(in srgb, var(--accent) 55%, #000 8%));
}

.o-name { font-size: 11.5px; font-weight: 600; letter-spacing: .1px; word-break: break-word; }
.o-desig { font-size: 9.5px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }

/* related-ward chips under a ward-mapped officer (officer → wards) — constant ward color */
.ward-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.ward-tag {
  font-size: 9.5px; font-weight: 650; line-height: 1; letter-spacing: .2px;
  padding: 3px 7px; border-radius: 999px; color: #ffadcb;
  background: color-mix(in srgb, #ff7ba6 13%, var(--surface-2));
  border: 1px solid color-mix(in srgb, #ff7ba6 32%, var(--stroke));
  white-space: nowrap;
}
.ward-tag.sel {
  color: #1a0d13; font-weight: 800; border-color: transparent;
  background: linear-gradient(135deg, #ff8fb8, #ff5ea8);
}
.ward-tag.extra { display: none; }
.ward-tags.open .ward-tag.extra { display: inline-flex; }
.ward-tag.more {
  cursor: pointer; font-family: inherit; color: #ff7ba6; background: transparent;
  border-style: dashed; border-color: color-mix(in srgb, #ff7ba6 45%, var(--stroke));
  transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
.ward-tag.more:hover { color: #ffadcb; background: color-mix(in srgb, #ff7ba6 12%, transparent); border-color: #ff7ba6; }
.sla-level.single .ward-tags { margin-top: 5px; }
.pcard.has-wards { align-items: flex-start; }
.pcard.has-wards .pc-av { margin-top: 1px; }

/* "+N more" toggle on the filter-screen ward multi-select */
.ward-chip.ward-more { color: color-mix(in srgb, var(--lv) 85%, #fff); background: transparent; border-style: dashed; }
.ward-chip.ward-more:hover { color: #fff; border-color: var(--lv); }

.note { font-size: 11.5px; color: var(--muted-2); line-height: 1.55; margin-top: 16px;
  padding: 11px 13px; background: var(--surface); border: 1px solid var(--stroke); border-radius: 11px; }

.empty { color: var(--muted); font-size: 13px; text-align: center; padding: 40px 20px; }

/* back button */
.back {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; color: var(--muted); cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--stroke);
  padding: 7px 13px; border-radius: 999px; margin-bottom: 14px;
  transition: all .25s var(--ease-out); font-weight: 600;
}
.back:hover { color: var(--text); transform: translateX(-3px); border-color: var(--stroke-2); }
.back svg { width: 14px; height: 14px; }

/* ============================================================ keyframes */
@keyframes rise   { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes slideIn{ from { opacity: 0; transform: translateX(-10px); } to { opacity: 1; transform: none; } }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px) scale(.995); } to { opacity: 1; transform: none; } }
@keyframes viewOut{ from { opacity: 1; } to { opacity: 0; transform: translateY(-6px); } }
@keyframes floaty { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(-4px); } }
@keyframes pulse  { 0% { box-shadow: 0 0 0 0 var(--glow); } 70% { box-shadow: 0 0 0 12px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* loading */
.loader { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 999;
  transition: opacity .5s var(--ease); }
.loader.hide { opacity: 0; pointer-events: none; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid var(--stroke);
  border-top-color: var(--primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

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