/* ============================================================
   Trace My Land — modern UI theme
   Light + dark palettes driven by CSS custom properties.
   [data-theme="dark"] on <html> flips every token.
   color-scheme makes native dropdowns/scrollbars follow too.
   Design system: 4px spacing scale, 5-step type scale, 3 radii,
   flat surfaces (borders over shadows), one accent per meaning.
   ============================================================ */

/* ---------- self-hosted fonts (CSP: no external origins) ---------- */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/inter-latin-var.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/noto-devanagari-var.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+20F0, U+25CC, U+A830-A839, U+A8E0-A8FF, U+11B00-11B09;
}

:root {
  color-scheme: light;

  /* type scale (5 steps) */
  --fs-xs: .75rem;
  --fs-sm: .875rem;
  --fs-base: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;

  /* 4px spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 32px;
  --sp-8: 40px;

  /* radii (3 tokens + 999px pills) */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 14px;

  /* surfaces */
  --bg: #f7f8fa;
  --card: #ffffff;
  --card-2: #f3f5f7;
  --panel: #f8fafb;

  /* ink */
  --ink: #0f172a;
  --muted: #475569;
  --faint: #64748b;

  /* lines & shadows — borders carry the structure, shadows stay subtle */
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-lg: 0 4px 12px rgba(15, 23, 42, .08), 0 16px 40px rgba(15, 23, 42, .12);

  /* brand & status */
  --brand: #0b6e4f;
  --brand-hover: #095c42;
  --brand-soft: #e6f2ed;
  --on-brand: #ffffff;
  --accent: #1d4ed8;
  --terra: #c2410c;            /* warm accent tied to the logo's terracotta plot */
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --danger-soft: #fdecea;
  --ring: rgba(11, 110, 79, .18);

  /* header: translucent card over the page, blurred (modern SaaS look) */
  --hdr-bg: rgba(255, 255, 255, .86);

  --ctl-h: 44px;
  --btn-h: 40px;
  --topbar-h: 68px;

  /* themed native select arrow */
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

[data-theme="dark"] {
  color-scheme: dark;

  /* elevation by surface tone, not shadow */
  --bg: #0b0f17;
  --card: #121826;
  --card-2: #1a2233;
  --panel: #101725;

  --ink: #e5e7eb;
  --muted: #94a3b8;
  --faint: #7c8ba1;

  --line: #1f2937;
  --line-strong: #334155;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, .5), 0 16px 40px rgba(0, 0, 0, .5);

  --brand: #34d399;
  --brand-hover: #6ee7b7;
  --brand-soft: rgba(52, 211, 153, .12);
  --on-brand: #0b0f17;
  --accent: #60a5fa;
  --terra: #fb923c;
  --success: #4ade80;
  --warning: #fbbf24;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, .12);
  --ring: rgba(52, 211, 153, .22);

  --hdr-bg: rgba(18, 24, 38, .86);

  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html {
  scrollbar-gutter: stable;
  scroll-behavior: smooth;
  /* anchored scrolls (report / rates panels) must not hide under the sticky header */
  scroll-padding-top: calc(var(--topbar-h) + var(--sp-2));
  /* devices with notches: let the page extend under them; safe-area insets
     below keep the sticky header / footer content clear of the cutout */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  /* dvh tracks mobile browser chrome (URL bar collapse); 100vh is the fallback */
  min-height: 100vh;
  min-height: 100dvh;
  font-family: 'Inter', 'Noto Sans Devanagari', "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  transition: background-color .25s ease, color .25s ease;
  /* text selection / double-tap zoom had a delay on touch devices */
  -webkit-tap-highlight-color: transparent;
}

/* inputs >= 16px stop Safari iOS from zooming the page on focus */
select, input[type="text"], .dd-trigger, .dd-filter { font-size: max(var(--fs-sm), 16px); }

::selection { background: var(--brand); color: var(--on-brand); }

/* visible keyboard focus everywhere; inputs draw their own ring */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
select:focus, input[type="text"]:focus, .dd-trigger:focus-visible { outline: none; }

/* thin themed scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-6);
  /* notched devices: content starts clear of the cutout, sides handled at breakpoints */
  padding-left: max(var(--sp-6), env(safe-area-inset-left));
  padding-right: max(var(--sp-6), env(safe-area-inset-right));
  padding-top: max(var(--sp-3), env(safe-area-inset-top));
  background: var(--hdr-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.brand .logo {
  width: 44px; height: 44px; flex: 0 0 44px;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand .logo img {
  width: 100%; height: 100%; display: block;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(15, 23, 42, .18));
}
.brand h1 { margin: 0; font-size: var(--fs-lg); font-weight: 700; letter-spacing: -.01em; }
.brand p { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--muted); }

.topbar-tools { display: flex; align-items: center; gap: var(--sp-2); }

.theme-btn, .lang-btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 40px; cursor: pointer;
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  font-family: inherit; font-weight: 600;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.theme-btn { width: 40px; flex: 0 0 40px; }
.lang-btn { padding: 0 14px; font-size: var(--fs-xs); }
.theme-btn:hover, .lang-btn:hover { background: var(--card-2); color: var(--ink); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 600;
  background: var(--card-2); border: 1px solid var(--line); color: var(--muted);
  padding: 5px 12px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: "●"; font-size: .58rem; line-height: 1; }
.pill.busy { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.pill.busy::before { content: none; } /* the spinner replaces the dot */
.pill.err { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.pill.err::before { color: var(--danger); }

/* progress bar rides the header's bottom edge (no hardcoded offset) */
.progress-bar {
  position: absolute; bottom: -1px; left: 0; right: 0;
  height: 2px; z-index: 60; overflow: hidden;
  background: transparent;
  opacity: 0; visibility: hidden;
  transition: opacity .18s ease, visibility .18s ease;
}
.progress-bar::after {
  content: "";
  position: absolute; inset: 0;
  width: 34%;
  background: var(--brand);
  border-radius: 2px;
  animation: progress-slide 1.1s cubic-bezier(.45, .05, .55, .95) infinite;
}
.progress-bar.on { opacity: 1; visibility: visible; }
@keyframes progress-slide {
  0%   { transform: translateX(-110%); }
  100% { transform: translateX(300%); }
}

/* ---------- tabs: underline style, aligned with the panel ----------
 * On phones the strip scrolls horizontally (scroll-snap aligned) instead of
 * squeezing four labels onto one row; app.js scrolls the active tab into view. */
.tabs {
  display: flex; gap: var(--sp-1);
  max-width: 1128px; margin: 0 auto;
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--line);
  padding-left: max(var(--sp-6), env(safe-area-inset-left));
  padding-right: max(var(--sp-6), env(safe-area-inset-right));
}
.tabs::-webkit-scrollbar { display: none; }
.tabs { scrollbar-width: none; }
.tab {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  border: none; background: transparent; color: var(--muted);
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md) var(--r-md) 0 0;
  cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; font-family: inherit;
  transition: color .15s ease, background .15s ease;
}
.tab::after {
  content: "";
  position: absolute; left: var(--sp-3); right: var(--sp-3); bottom: -1px;
  height: 2px; border-radius: 2px 2px 0 0;
  background: var(--brand);
  transform: scaleX(0);
  transition: transform .18s ease;
}
.tab:hover { color: var(--ink); background: var(--card); }
.tab.active { color: var(--brand); }
.tab.active::after { transform: scaleX(1); }
.tab .icon { color: var(--faint); transition: color .15s ease; }
.tab:hover .icon, .tab.active .icon { color: currentColor; }

/* ---------- layout ---------- */
.panel { max-width: 1128px; margin: 0 auto; padding: 0 var(--sp-6) var(--sp-8); }
.card {
  background: var(--card);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6); margin-top: var(--sp-4);
  box-shadow: var(--shadow);
  transition: background .25s ease, border-color .25s ease;
}
.card-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.card-head h2 { margin: 0; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.step {
  width: 26px; height: 26px; border-radius: var(--r-md); flex: 0 0 26px;
  background: var(--brand-soft); color: var(--brand);
  font-size: var(--fs-xs); font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.spacer { flex: 1; }

.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }

/* ---------- forms: uniform aligned fields ---------- */
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-3); }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: var(--fs-xs); color: var(--muted); font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.req { color: var(--danger); }
.row { display: flex; gap: var(--sp-3); align-items: center; flex-wrap: wrap; margin-top: var(--sp-4); }
.captcha-row { margin-top: 0; }
.captcha-row img { margin: 0; }

/* every control: same height, same border -> rows line up.
   Native selects with themed arrow via appearance:none + SVG chevron;
   color-scheme above makes the popup list match the theme as well. */
select, input[type="text"] {
  width: 100%; height: var(--ctl-h);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: var(--fs-sm); background: var(--card); color: var(--ink);
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease, background .25s ease, color .25s ease;
}select {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
  text-overflow: ellipsis;
}
/* programmatic focus() after selection must not scroll the page sideways on phones */
select:focus, input[type="text"]:focus { scroll-margin-left: 0; }
select:focus, input[type="text"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
select:disabled, input:disabled {
  background: var(--card-2); color: var(--faint);
  cursor: not-allowed; box-shadow: none;
  border-style: dashed;
}
select:disabled { background-image: none; }
input::placeholder { color: var(--faint); }

/* text input with a leading search icon */
.search-field { position: relative; min-width: 0; }
.search-field .icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--faint); pointer-events: none;
}
.search-field input { padding-left: 38px; }

/* search inside the loaded plot report only */
.report-tools {
  display: flex; align-items: center; gap: var(--sp-3);
  margin: 2px 0 var(--sp-3);
  flex-wrap: wrap;
}
.report-tools .search-field { flex: 1 1 260px; max-width: 420px; }
.report-tools .hint { margin: 0; }
/* हे. ⇄ चौ.मी switch for the plot report's areas */
.unit-toggle { padding: 4px 12px; font-size: var(--fs-xs); }
@media print { .unit-toggle { display: none !important; } }
.owner-card.hidden { display: none; }

/* collapsed long owner lists: only the first MAX_VISIBLE_OWNERS cards show */
.owners.is-collapsed:not(.is-expanded) .owner-extra { display: none; }
.owners-more { margin-top: var(--sp-1); align-self: center; }

/* ---------- buttons: three tiers (primary / secondary / sm) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--btn-h);
  border: 1px solid transparent; border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-4);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer; white-space: nowrap;
  font-family: inherit; user-select: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.btn .icon { flex: 0 0 auto; }
.btn.sm { min-height: 32px; padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); }
.btn.primary { background: var(--brand); color: var(--on-brand); }
.btn.primary:hover:enabled { background: var(--brand-hover); }
.btn.ghost { background: var(--card); color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover:enabled { background: var(--card-2); }
.btn:active:enabled { transform: translateY(1px); }
.btn:disabled {
  background: var(--card-2); color: var(--faint);
  border-color: var(--line); cursor: not-allowed; box-shadow: none;
}
.btn.loading { pointer-events: none; }

.hint { color: var(--muted); font-size: var(--fs-xs); margin: 0 0 var(--sp-1); line-height: 1.5; }
.meta {
  color: var(--ink); font-size: var(--fs-sm);
  margin-bottom: var(--sp-3);
  padding: 9px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.status { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.status .err, .err { color: var(--danger); }

/* ---------- loading animations ---------- */
/* inline spinner used in buttons & the status pill — follows currentColor,
   inline-block so it keeps its shape outside flex parents */
.spinner {
  display: inline-block;
  width: 1em; height: 1em; flex: 0 0 auto;
  border: 2px solid rgba(128, 128, 128, .3);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* shimmer skeleton for the owner-cards area while the report loads */
@keyframes shimmer {
  0% { background-position: 175% 0; }
  100% { background-position: -75% 0; }
}
.skel-card {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--card);
  padding: 13px 16px;
}
.skel-line {
  height: 11px; border-radius: var(--r-sm);
  margin: 9px 0;
  background: linear-gradient(90deg,
    var(--line) 25%, var(--line-strong) 45%, var(--line) 65%);
  background-size: 250% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skel-line.w60 { width: 60%; }
.skel-line.w40 { width: 40%; }
.skel-line.w80 { width: 80%; }

/* gentle fade-in for freshly rendered content */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(7px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fade-up .28s ease both; }

/* ---------- toasts (replace alert()) ---------- */
.toast-stack {
  position: fixed; right: var(--sp-4); bottom: var(--sp-4); z-index: 100;
  display: flex; flex-direction: column; gap: var(--sp-2);
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--card); color: var(--ink);
  border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  padding: 11px 14px; font-size: var(--fs-sm); line-height: 1.45;
  opacity: 0; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast .icon { flex: 0 0 auto; margin-top: 2px; }
.toast.info .icon { color: var(--accent); }
.toast.success { border-left-color: var(--success); }
.toast.success .icon { color: var(--success); }
.toast.warn { border-left-color: var(--warning); }
.toast.warn .icon { color: var(--warning); }
.toast.error { border-left-color: var(--danger); }
.toast.error .icon { color: var(--danger); }

/* ---------- part plan map (MRSAC cadastral) ---------- */
.map-block {
  margin: 0 0 var(--sp-3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  overflow: hidden;
}
.map-head {
  display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap;
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
}
.map-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--fs-xs); font-weight: 600; color: var(--ink);
}
.map-title .icon { color: var(--terra); }
#bn-map-status { margin: 0; }
/* Compact by default (the report continues just below the fold); Expand
 * grows it to full height. Height animates via transition; app.js calls
 * map.invalidateSize() after it settles. */
.map-canvas {
  height: 300px;
  background: var(--card-2);
  position: relative;
  z-index: 0;
  transition: height .3s ease;
}
.map-canvas.pp-expanded { height: 640px; }
.map-canvas.pp-expanded .leaflet-container { background: #e8ecef; }
.map-foot {
  display: flex; gap: var(--sp-3); flex-wrap: wrap; justify-content: space-between;
  padding: 6px var(--sp-3);
  font-size: .62rem; color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--card-2);
}
/* dark theme control restyle (leaflet widgets are white by default) */
[data-theme="dark"] .map-canvas .leaflet-control-container .leaflet-bar a,
[data-theme="dark"] .map-canvas .leaflet-control-attribution {
  background: var(--card); color: var(--muted);
}
[data-theme="dark"] .map-canvas .leaflet-control-attribution a { color: var(--accent); }
[data-theme="dark"] .map-canvas .leaflet-bar a:hover { background: var(--card-2); }
[data-theme="dark"] .map-canvas .leaflet-bar { border-color: var(--line-strong); box-shadow: var(--shadow); }
.map-canvas .leaflet-container { background: var(--card-2); font: inherit; }
/* built-in measure tools: no plugin, CSP-safe. Dashed sketch lines +
 * crosshair cursor while measuring; results popup styled like the rest. */
.map-canvas.pp-measuring { cursor: crosshair; }
.map-canvas .pp-popup .pp-sub b { font-variant-numeric: tabular-nums; }
/* wheel-hijack guard hint: wheel-zoom is armed by a click, disarmed on leave */
.pp-zoom-hint {
  color: var(--faint);
}
.pp-zoom-hint.armed { color: var(--brand); font-weight: 600; }
/* live readout chip that rides above the newest sketch vertex */
.pp-live {
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--terra);
  box-shadow: var(--shadow);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 999px;
}
.pp-live::before { display: none; }
/* satellite mode: crosshair cursor invites click-to-inspect */
.map-canvas.satellite { cursor: crosshair; }
/* survey-number labels (one per parcel, zoom-gated) */
.pp-num-wrap { background: none; border: none; }
.pp-num {
  display: inline-block;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, .88);
  color: #1f2937;
  border: 1px solid rgba(15, 23, 42, .25);
  border-radius: 4px;
  padding: 0 4px;
  font-size: 10px; font-weight: 700; line-height: 15px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
[data-theme="dark"] .pp-num {
  background: rgba(18, 24, 38, .88); color: #e5e7eb; border-color: rgba(229, 231, 235, .3);
}
.map-canvas.satellite .pp-num { background: rgba(15, 23, 42, .72); color: #fff; border-color: rgba(255,255,255,.35); }
/* parcel labels & popups (font inherits app typography) */
.pp-tip {
  background: var(--card); color: var(--ink); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); font-size: var(--fs-xs); font-weight: 600;
  border-radius: var(--r-sm); padding: 2px 8px;
}
.pp-tip::before { display: none; }
.pp-label {
  background: var(--terra); color: #fff; border: none;
  font-size: var(--fs-xs); font-weight: 700;
  box-shadow: 0 2px 8px rgba(194, 65, 12, .45);
}
.pp-label::before { display: none; }
.pp-popup .leaflet-popup-content-wrapper {
  border-radius: var(--r-md); font-family: inherit; font-size: var(--fs-sm);
}
.pp-popup .pp-sub { color: var(--muted); font-size: var(--fs-xs); }
.pp-popup .pp-open { margin-top: 6px; }

/* ---------- empty states ---------- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  text-align: center; color: var(--muted);
  padding: var(--sp-6) var(--sp-4);
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--panel);
}
.empty-state .icon { color: var(--faint); width: 28px; height: 28px; }
.empty-state p { margin: 0; font-size: var(--fs-sm); max-width: 48ch; }

/* locate row: converted plot coordinates + Maps/Earth/KML actions */
.locate-row {
  display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap;
  margin: 0 0 var(--sp-3); padding: 9px 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-md);
}
.locate-coords {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink); font-size: var(--fs-sm); font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.locate-coords .icon { color: var(--terra); }

/* ---------- report header (structured) ---------- */
.report-head {
  display: flex; flex-direction: column; gap: var(--sp-3);
  margin-bottom: var(--sp-4);
  padding: var(--sp-4);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}
.report-head-top { display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; }
.plot-badge {
  flex: 0 0 auto;
  min-width: 54px; text-align: center;
  padding: 9px 14px;
  background: var(--brand-soft);
  color: var(--brand); font-weight: 700; font-size: var(--fs-lg);
  font-variant-numeric: tabular-nums;
  border-radius: var(--r-md);
}
.report-title { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.crumb {
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plot-sub { font-size: var(--fs-xs); color: var(--muted); }
.area-chip {
  flex: 0 0 auto; margin-left: auto;
  display: flex; flex-direction: column; gap: 1px;
  padding: 7px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  text-align: right;
}
.area-chip .k {
  font-size: .62rem; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.area-chip b { font-size: var(--fs-sm); font-variant-numeric: tabular-nums; color: var(--terra); }
.report-counts { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.count-chip {
  font-size: var(--fs-xs); font-weight: 600; color: var(--brand);
  background: var(--brand-soft);
  border: 1px solid transparent;
  padding: 3px 10px; border-radius: 999px;
}
.count-chip.alt { color: var(--muted); background: var(--card); border-color: var(--line); }

/* ---------- owner cards ---------- */
.owners { display: grid; gap: var(--sp-3); }
.owner-card {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--sp-4);
  background: var(--card);
  transition: border-color .15s ease, background .25s ease;
}
.owner-card:hover { border-color: var(--line-strong); }
.owner-main {
  display: flex; gap: var(--sp-4); align-items: center; flex-wrap: wrap;
  justify-content: space-between;
}
.owner-idblock { display: flex; align-items: center; gap: 11px; min-width: 180px; }
.avatar {
  flex: 0 0 40px; width: 40px; height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft);
  color: var(--brand); font-weight: 700; font-size: var(--fs-xs);
  border-radius: 50%;
}
.owner-who { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.owner-name {
  font-weight: 600; color: var(--ink);
  white-space: normal; overflow: visible;
  word-break: break-word;
}
.owner-khata { font-size: var(--fs-xs); color: var(--muted); }
.owner-grid {
  display: grid; grid-template-columns: repeat(3, auto);
  gap: var(--sp-2) 26px; font-size: var(--fs-sm);
  flex: 1 1 auto; justify-content: start;
}
.owner-grid .k {
  color: var(--muted); display: block; font-size: .66rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
}
.owner-grid b { font-weight: 600; word-break: break-word; }
.owner-b12 { margin-top: var(--sp-3); border-top: 1px dashed var(--line); padding-top: var(--sp-3); }
.owner-b12 .b12-cap-img {
  height: 44px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: #fff; padding: 2px 6px; margin: 0;
}
.owner-b12 .b12-cap-in { max-width: 150px; height: 40px; }
.owner-b12 .row { margin-top: var(--sp-2); }
.owner-b12 .b12-rep img,
#b12-report img {
  max-width: 100%; height: auto;
  background: #fff; /* reports are white documents — keep them readable in dark mode */
  border: 1px solid var(--line);
  border-radius: var(--r-md); margin: var(--sp-2) 0;
  box-shadow: var(--shadow);
}
#b12-captcha-img {
  height: 46px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: #fff; padding: 3px 8px;
}
#b12-captcha { max-width: 190px; }
.info-fragment {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: var(--fs-sm); line-height: 1.55; white-space: pre-wrap; word-break: break-word;
  background: var(--panel); border: 1px dashed var(--line); border-radius: var(--r-md); padding: var(--sp-3);
}
.info-fragment .icon { flex: 0 0 auto; margin-top: 2px; color: var(--faint); }

/* ---------- ASR rates as a complementary block on the Plot Report tab ----------
 * Hidden until the report's "Get ASR Rates" action fetches them, so the
 * report card stays uncluttered (one fetch trigger, not two).
 */
.rates-block {
  margin-top: var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--panel);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
}
.rates-block-head {
  display: flex; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap;
  margin-bottom: var(--sp-3);
}
.rates-block-title { font-weight: 600; font-size: var(--fs-sm); }
.rates-block-head .hint { margin: 0; }

/* ---------- eASR rates tab ---------- */
/* embedded rates card nested inside the plot-tab rates block */
.asr-embed { margin-top: var(--sp-3); background: var(--panel); padding: var(--sp-4); }
#bn-rates-panel .card-head h2 { font-size: var(--fs-base); }

/* fetch row: label field and button share one baseline */
.row.align-end { align-items: flex-end; }
.row.align-end .btn { margin-bottom: 1px; } /* offsets the label's 6px gap */

.mode-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.mode-row[hidden] { display: none; }
.radio-pill {
  position: relative;
  display: inline-flex; align-items: center; gap: var(--sp-2);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px; cursor: pointer;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted);
  background: var(--card-2);
  transition: border-color .15s ease, background .15s ease, color .15s ease, box-shadow .15s ease;
}
.radio-pill:hover { border-color: var(--brand); color: var(--ink); transform: translateY(-1px); }
.radio-pill:active { transform: translateY(0); }
.radio-pill:has(input:checked) {
  border-color: var(--brand); color: var(--brand);
  background: var(--brand-soft);
  box-shadow: 0 0 0 3px var(--ring);
}
/* tick that pops in on the selected pill (dots stay for keyboard clarity) */
.radio-pill::after {
  content: ""; width: 0; height: 0; flex: 0 0 0;
  margin-left: 0; border-radius: 50%;
  background: var(--brand);
  transition: width .18s cubic-bezier(.34, 1.56, .64, 1),
              height .18s cubic-bezier(.34, 1.56, .64, 1),
              flex-basis .18s cubic-bezier(.34, 1.56, .64, 1),
              margin-left .18s ease;
}
.radio-pill:has(input:checked)::after {
  width: 7px; height: 7px; flex-basis: 7px; margin-left: 2px;
}
.radio-pill input { accent-color: var(--brand); margin: 0; }
.radio-pill input:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* pill entrance: quick pop with stagger (first 8) */
.mode-row .radio-pill {
  animation: pillIn .28s cubic-bezier(.2, .7, .2, 1) backwards;
}
.mode-row .radio-pill:nth-child(2) { animation-delay: .04s; }
.mode-row .radio-pill:nth-child(3) { animation-delay: .08s; }
.mode-row .radio-pill:nth-child(4) { animation-delay: .12s; }
.mode-row .radio-pill:nth-child(5) { animation-delay: .15s; }
.mode-row .radio-pill:nth-child(6) { animation-delay: .18s; }
.mode-row .radio-pill:nth-child(7) { animation-delay: .21s; }
.mode-row .radio-pill:nth-child(8) { animation-delay: .24s; }
@keyframes pillIn { from { opacity: 0; transform: scale(.9) translateY(4px); } }

/* labelled option groups: "Record type" / "Search by" sit as quiet sub-cards */
.field-group {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--card-2) 55%, transparent);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  margin-top: var(--sp-3);
  transition: border-color .25s ease, background .25s ease;
}
.field-group-label {
  display: inline-flex; align-items: center; gap: 6px;
  margin: 0 0 var(--sp-3);
  font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted);
}
.field-group-label .icon { color: var(--brand); }
.field-group .mode-row { margin-top: 0; }
.field-group .hint { margin: var(--sp-2) 0 0; }
#asr-mode-hint { margin: 0; }
#asr-srno-field { max-width: 280px; }

.rates-table {
  width: 100%; border-collapse: collapse; font-size: var(--fs-sm);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  overflow: hidden;
}
/* tables scroll sideways on narrow screens instead of squeezing */
#asr-table, #bn-rates-table { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* source + verification note under every ASR rates table (legal cover) */
.src-note {
  margin: var(--sp-3) 0 0;
  padding-top: var(--sp-2);
  border-top: 1px dashed var(--line-strong);
  color: var(--muted);
  font-size: var(--fs-xs);
  line-height: 1.5;
}
/* prominent warning panel (village map downloads) */
.notice {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-start;
  margin: var(--sp-4) 0 0;
  padding: var(--sp-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-2);
  font-size: var(--fs-xs);
  line-height: 1.55;
}
.notice > .icon { flex: 0 0 auto; margin-top: 2px; }
.notice b { display: block; margin-bottom: 2px; }
.notice-warn {
  border-color: var(--warning);
  background: color-mix(in srgb, var(--warning) 9%, transparent);
}
.notice-warn > .icon, .notice-warn b { color: var(--warning); }
.notice-warn ul { margin: 0; padding-left: 18px; }
.notice-warn li { margin: 2px 0; color: var(--ink); }
.rates-table th, .rates-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: top;
}
.rates-table thead th {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); background: var(--card-2);
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
}
.rates-table tbody tr:last-child td { border-bottom: 0; }
.rates-table tbody tr:hover { background: var(--panel); }
.rates-table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

/* clickable close-match suggestions when a taluka/village can't be matched */
.close-matches {
  margin-top: 6px;
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.close-matches > .hint { flex-basis: 100%; }
.close-match {
  font-family: inherit; font-size: var(--fs-sm);
  padding: 4px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: transparent; color: var(--ink);
  cursor: pointer; user-select: none;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.close-match:hover {
  border-color: var(--brand); background: var(--brand-soft); color: var(--brand);
}
.close-match.best {
  border-color: var(--brand); color: var(--brand); font-weight: 600;
}
/* the "All villages…" picker styled as the last pill in the row */
.close-match.select-pill {
  appearance: none; -webkit-appearance: none; -moz-appearance: none;
  padding-right: 30px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  max-width: 280px;
  text-overflow: ellipsis;
  font-weight: 600; color: var(--ink);
  cursor: pointer;
}

/* ---------- site banner (admin-controlled notification) ----------
 * Rendered by app.js from /api/bootstrap; markup is text-only (textContent)
 * and carries data-en/data-mr so the language toggle applies. */
.site-banner {
  position: relative;
  display: flex; align-items: flex-start; gap: var(--sp-2);
  padding: 10px 44px 10px var(--sp-5);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.45;
  border-bottom: 1px solid var(--line);
  animation: bannerIn .32s cubic-bezier(.2, .7, .2, 1);
}
@keyframes bannerIn { from { opacity: 0; transform: translateY(-8px); } }
.site-banner .banner-close {
  position: absolute; right: 10px; top: 50%; translate: 0 -50%;
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: transparent; color: inherit;
  cursor: pointer; font-size: 15px; line-height: 1;
}
.site-banner .banner-close:hover { border-color: currentColor; }
.site-banner.info { background: color-mix(in srgb, #2563eb 10%, var(--card)); color: color-mix(in srgb, #2563eb 70%, var(--ink)); border-color: color-mix(in srgb, #2563eb 35%, var(--line)); }
.site-banner.success { background: var(--brand-soft); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); }
.site-banner.warning { background: color-mix(in srgb, var(--warning) 10%, var(--card)); color: color-mix(in srgb, var(--warning) 75%, var(--ink)); border-color: color-mix(in srgb, var(--warning) 40%, var(--line)); }
.site-banner.error { background: color-mix(in srgb, var(--danger) 9%, var(--card)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* ---------- footer ---------- */
footer {
  padding: var(--sp-5) var(--sp-6) 36px; color: var(--muted); font-size: var(--fs-xs); text-align: center;
  border-top: 1px solid var(--line);
  margin-top: 26px;
}
footer a { color: var(--brand); text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer .link-btn {
  background: none; border: none; padding: 0; font: inherit; color: var(--brand);
  cursor: pointer; text-decoration: none;
}
footer .link-btn:hover { text-decoration: underline; }

/* ---------- disclaimer dialog ---------- */
#disclaimer-dialog {
  width: min(680px, 92vw);
  max-height: min(78vh, 720px);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  background: var(--card);
  color: var(--ink);
}
#disclaimer-dialog::backdrop {
  background: rgba(10, 20, 30, .45);
  backdrop-filter: blur(2px);
}
#disclaimer-dialog .dlg-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--card-2);
  color: var(--ink);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
#disclaimer-dialog .dlg-head h2 { margin: 0; font-size: var(--fs-base); font-weight: 600; }
#disclaimer-dialog .dlg-close {
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
}
#disclaimer-dialog .dlg-close:hover { background: var(--card); color: var(--ink); }
#disclaimer-dialog .dlg-body {
  padding: var(--sp-4);
  overflow-y: auto;
  font-size: var(--fs-sm);
  line-height: 1.55;
  color: var(--ink);
}
#disclaimer-dialog .dlg-body h3 {
  font-size: var(--fs-sm); margin: var(--sp-4) 0 6px; color: var(--brand);
}
#disclaimer-dialog .dlg-body h3:first-of-type { margin-top: var(--sp-1); }
#disclaimer-dialog .dlg-body p, #disclaimer-dialog .dlg-body ol { margin: 6px 0; }
#disclaimer-dialog .dlg-body ol { padding-left: 22px; }
#disclaimer-dialog .dlg-body a { color: var(--accent); }
#disclaimer-dialog .dlg-updated { color: var(--muted); font-size: var(--fs-xs); margin-top: 0; }
#disclaimer-dialog .dlg-note { color: var(--muted); border-top: 1px dashed var(--line); padding-top: 10px; margin-top: var(--sp-4); }

@media print {
  #disclaimer-dialog, #disclaimer-link { display: none !important; }
}

/* wrapper keeps the labelled field layout intact around the dropdown widget */
.select-wrap { display: flex; flex-direction: column; min-width: 0; }

/* visually-hidden but functionally-active native select (state holder) */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; border: 0;
  clip: rect(0 0 0 0); clip-path: inset(50%);
  overflow: hidden; white-space: nowrap;
}

/* ---------- custom themed dropdown ----------
 * Native <select> popups are drawn by the OS and cannot be styled, so the UI
 * renders a fully themed listbox (driven by a hidden native select that
 * keeps form state). Works identically in light & dark. Long lists get a
 * filter box at the top of the popup.
 */
.dropdown { position: relative; }

.dd-trigger {
  width: 100%; height: var(--ctl-h);
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-3);
  border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--card); color: var(--ink);
  font-family: inherit; font-size: var(--fs-sm); text-align: left;
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease, background .25s ease, color .25s ease;
}
.dd-trigger:hover:enabled { border-color: var(--line-strong); }
.dd-trigger:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
/* open state: trigger answers the popup visually */
.dropdown.open .dd-trigger:enabled {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--ring);
}
.dropdown.open .dd-arrow { color: var(--brand); }
/* a value is chosen: quiet accent on the trigger label */
.dd-trigger.has-value { color: var(--ink); font-weight: 600; }
.dd-trigger:disabled {
  background: var(--card-2); color: var(--faint);
  border-style: dashed; cursor: not-allowed;
}
.dd-label {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dd-arrow { display: flex; color: var(--muted); transition: transform .18s ease; flex: 0 0 auto; }
.dropdown.open .dd-arrow { transform: rotate(180deg); }

/* popup panel: optional filter row + scrolling listbox */
.dd-pop {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  z-index: 40;
  background: var(--card);
  border: 1px solid var(--line-strong); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(-6px) scale(.99); pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.dropdown.open .dd-pop { opacity: 1; transform: none; pointer-events: auto; }

.dd-filter-row { padding: var(--sp-2) var(--sp-2) 4px; border-bottom: 1px solid var(--line); }
.dd-filter {
  height: 34px; font-size: var(--fs-sm);
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card-2); color: var(--ink);
  width: 100%; padding: 0 10px; font-family: inherit;
}
.dd-filter:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring); outline: none; }

.dd-menu {
  margin: 0; padding: 6px; list-style: none;
  max-height: 280px; overflow-y: auto; overscroll-behavior: contain;
}
.dd-option {
  position: relative;
  display: flex; align-items: center; gap: 6px;
  padding: 9px 30px 9px 11px; border-radius: var(--r-sm);
  font-size: var(--fs-sm); color: var(--ink);
  cursor: pointer; user-select: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .12s ease, color .12s ease, transform .12s ease;
}
.dd-option:hover, .dd-option.active-option {
  background: var(--brand-soft); color: var(--brand);
}
.dd-option:active { transform: scale(.985); }
.dd-option[aria-selected="true"] { font-weight: 600; }
/* check rides in from the left instead of floating via float:right */
.dd-option::after {
  content: ""; position: absolute; right: 11px; top: 50%;
  width: 0; height: 0; opacity: 0;
  transform: translate(-4px, -50%);
  border: 2px solid var(--brand); border-top: 0; border-left: 0;
  transition: width .18s ease, height .18s ease, opacity .18s ease, transform .18s ease;
}
.dd-option[aria-selected="true"]::after {
  width: 6px; height: 11px; opacity: 1;
  transform: translate(0, -50%) rotate(45deg);
}
/* options cascade in while the popup opens (short list only — filtered
   lists re-render too often for it to read as anything but lag) */
.dd-pop:not(:has(.dd-filter-row)) .dd-option {
  animation: ddOptIn .2s ease backwards;
}
.dd-pop:not(:has(.dd-filter-row)) .dd-option:nth-child(2) { animation-delay: .03s; }
.dd-pop:not(:has(.dd-filter-row)) .dd-option:nth-child(3) { animation-delay: .06s; }
.dd-pop:not(:has(.dd-filter-row)) .dd-option:nth-child(4) { animation-delay: .09s; }
.dd-pop:not(:has(.dd-filter-row)) .dd-option:nth-child(5) { animation-delay: .12s; }
.dd-pop:not(:has(.dd-filter-row)) .dd-option:nth-child(n+6) { animation-delay: .15s; }
@keyframes ddOptIn { from { opacity: 0; transform: translateX(-5px); } }
.dd-empty { padding: 10px 12px; color: var(--faint); font-size: var(--fs-sm); cursor: default; }

/* reveal animation, replayed via the .reveal class (b12 name fields, ULPIN
   block, captcha rows, result card — anything un-hidden by app.js) */
.reveal { animation: revealIn .32s cubic-bezier(.2, .7, .2, 1); }
@keyframes revealIn { from { opacity: 0; transform: translateY(6px); } }

/* captcha image loads: soft fade-scale in */
.captcha-row img { animation: capIn .28s ease; }
@keyframes capIn { from { opacity: 0; transform: scale(.96); } }

/* result card lands with a touch more presence */
#b12-result:not([hidden]) { animation: revealIn .38s cubic-bezier(.2, .7, .2, 1); }

/* [hidden] must beat any display rule (e.g. .locate-row / .owner-card) */
.hidden, [hidden] { display: none !important; }

/* tables scroll sideways on narrow screens; first column pins so the row
 * identity (zone / survey no) stays visible while the numbers scroll */
@media (max-width: 760px) {
  .rates-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .rates-table th, .rates-table td { white-space: nowrap; }
  .rates-table th:first-child, .rates-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
    background: var(--card);
    box-shadow: 1px 0 0 var(--line-strong);
  }
  .rates-table thead th:first-child { background: var(--card-2); z-index: 2; }
}

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .grid4, .grid3 { grid-template-columns: 1fr 1fr; }
  .panel { padding: 0 var(--sp-4) var(--sp-7); }
  .tabs { padding-left: var(--sp-4); padding-right: var(--sp-4); }
  .topbar { padding-left: var(--sp-4); padding-right: var(--sp-4); }
}

@media (max-width: 760px) {
  /* keep the tagline on mobile, just clamp it to one line */
  .brand p {
    max-width: 40vw;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  /* the tab strip scrolls instead of squeezing four labels onto one row */
  .tabs {
    gap: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    justify-content: flex-start;
  }
  .tab {
    flex: 0 0 auto;
    scroll-snap-align: start;
    padding: var(--sp-3) var(--sp-3);
  }
  .tab span { font-size: .82rem; }
  .grid2 { grid-template-columns: 1fr; }
  .card { padding: var(--sp-4); }
  .owner-grid { grid-template-columns: 1fr 1fr; gap: 10px 16px; }
  .owner-idblock { min-width: 0; }
  .area-chip { margin-left: 0; text-align: left; }
  .locate-row .btn { flex: 1 1 auto; }
  /* map toolbar: one scrollable row of tools instead of three wrapped lines
     that would eat the map's height */
  .map-head {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .map-head::-webkit-scrollbar { display: none; }
  .map-head .btn, .map-head .map-title { flex: 0 0 auto; }
  .map-canvas { height: clamp(240px, 42dvh, 340px); }
  .map-canvas.pp-expanded { height: 78dvh; }
  .map-foot { font-size: .58rem; }
}

@media (max-width: 520px) {
  .topbar {
    padding-left: max(var(--sp-3), env(safe-area-inset-left));
    padding-right: max(var(--sp-3), env(safe-area-inset-right));
  }
  .brand .logo { width: 38px; height: 38px; flex-basis: 38px; }
  .brand h1 { font-size: var(--fs-base); }
  .brand p { display: none; }
  .pill { display: none; } /* the busy state still shows via progress bar + buttons */
  .panel { padding-left: max(var(--sp-3), env(safe-area-inset-left)); padding-right: max(var(--sp-3), env(safe-area-inset-right)); }
  .tabs { padding-left: max(var(--sp-3), env(safe-area-inset-left)); padding-right: max(var(--sp-3), env(safe-area-inset-right)); }
  .grid4, .grid3 { grid-template-columns: 1fr; }
  /* compact but readable owner grid: two short-value columns fit at 360px */
  .owner-grid { gap: 10px 14px; }
  .btn { min-height: 44px; } /* comfortable touch target (sm buttons keep their size) */
  .btn { padding: var(--sp-2) var(--sp-3); }
  .row .btn { flex: 1 1 auto; }
  .captcha-row img { flex: 0 0 auto; }
  #b12-captcha { max-width: none; flex: 1 1 130px; }
  /* the report header stacks cleanly on a phone */
  .report-head { padding: var(--sp-3); }
  .report-head-top { align-items: flex-start; }
  .plot-badge { padding: 7px 11px; }
  .area-chip { flex-direction: row; align-items: baseline; gap: 6px; padding: 6px 11px; }
  .area-chip .k { font-size: .58rem; }
  /* full-width dialogs that fit small screens with the browser UI visible */
  #disclaimer-dialog {
    width: calc(100vw - 16px);
    max-height: 86dvh;
  }
  #disclaimer-dialog .dlg-head { padding: var(--sp-3); }
  #disclaimer-dialog .dlg-body { padding: var(--sp-3); }
  .toast-stack {
    left: var(--sp-3); right: var(--sp-3); max-width: none;
    bottom: calc(var(--sp-3) + env(safe-area-inset-bottom));
  }
  footer { padding-bottom: calc(36px + env(safe-area-inset-bottom)); }
}

/* short landscape phones: reclaim vertical space */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { position: static; }
  .brand .logo { display: none; }
  .brand p { display: none; }
}

/* motion preferences */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}

/* hover effects only where hover actually exists (no sticky hover on touch) */
@media (hover: none) {
  .tab:hover, .owner-card:hover { border-color: var(--line); background: transparent; }
  /* touch screens: no hover to lean on - make active presses communicate */
  .tab:active { background: var(--card-2); }
  .btn:active:enabled { transform: scale(.985); }
  .dd-option:active { background: var(--brand-soft); }
  .radio-pill:active { background: var(--card); }
}

/* larger tap targets on touch screens (mouse users keep compact rows) */
@media (pointer: coarse) {
  .close-match { padding: 8px 14px; }
  .dd-option { padding-top: 11px; padding-bottom: 11px; }
  .radio-pill { padding: 11px 18px; }
  .map-foot { padding-block: 8px; }
}

/* ---------- print ---------- */
.print-only { display: none !important; }
@media print {
  /* chrome, tools and in-page actions never reach paper (coords + owner
     count stay — they're useful on paper; their buttons/inputs do not) */
  .topbar, .tabs, .progress-bar, footer, .toast-stack,
  .close-matches, .owner-b12,
  .captcha-row, .captcha-empty, .empty-state,
  .report-tools input, .btn, .dd-pop,
  .map-block { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  @page { margin: 12mm; }

  .print-only { display: flex !important; }
  .print-header {
    align-items: center; gap: var(--sp-3);
    border-bottom: 2px solid #222; padding-bottom: 8px; margin-bottom: 14px;
    break-after: avoid;
  }
  .print-header img { width: 40px; height: 40px; }
  .print-header b { font-size: 1.05rem; display: block; }
  .print-header span { font-size: .78rem; color: #444; }
  .print-footer {
    margin-top: 18px; padding-top: 8px; border-top: 1px solid #999;
    font-size: .72rem; color: #444; line-height: 1.5;
    break-inside: avoid;
  }
}

/* ============================================================
   Shared motion layer — modern transitions & micro-animations.
   Token-based, targeted, fully disabled under reduced-motion.
   ============================================================ */

/* tab panels crossfade in instead of popping */
.panel { animation: appPanel .34s cubic-bezier(.2, .7, .2, 1); }
@keyframes appPanel { from { opacity: 0; transform: translateY(10px); } }

/* cards rise gently; unhiding a results card replays the entrance */
.card { animation: appRise .35s cubic-bezier(.2, .7, .2, 1); }
@keyframes appRise { from { opacity: 0; transform: translateY(8px); } }

/* owner cards stagger in (first 10; long lists cap the delay) */
.owners .owner-card { animation: appRise .32s cubic-bezier(.2, .7, .2, 1); }
.owners .owner-card:nth-child(2) { animation-delay: .04s; }
.owners .owner-card:nth-child(3) { animation-delay: .08s; }
.owners .owner-card:nth-child(4) { animation-delay: .12s; }
.owners .owner-card:nth-child(5) { animation-delay: .16s; }
.owners .owner-card:nth-child(6) { animation-delay: .19s; }
.owners .owner-card:nth-child(7) { animation-delay: .22s; }
.owners .owner-card:nth-child(8) { animation-delay: .25s; }
.owners .owner-card:nth-child(9) { animation-delay: .27s; }
.owners .owner-card:nth-child(10) { animation-delay: .29s; }

/* rate-table rows fade in (opacity only — transforms don't animate on <tr>) */
.rates-table tbody tr { animation: appFade .3s ease; }
.rates-table tbody tr:nth-child(2) { animation-delay: .04s; }
.rates-table tbody tr:nth-child(3) { animation-delay: .08s; }
.rates-table tbody tr:nth-child(4) { animation-delay: .12s; }
.rates-table tbody tr:nth-child(5) { animation-delay: .15s; }
.rates-table tbody tr:nth-child(6) { animation-delay: .18s; }
@keyframes appFade { from { opacity: 0; } }

/* tab underline + ink slide smoothly */
.tab { transition: color .18s ease, background .18s ease; }
.tab::after { transition: transform .22s cubic-bezier(.2, .7, .2, 1); }

/* subtle button feedback */
.btn.primary:not(:disabled):hover { filter: brightness(1.04); }
.btn.primary:not(:disabled):active { transform: translateY(1px); }

@media (prefers-reduced-motion: reduce) {
  .panel, .card, .owners .owner-card, .rates-table tbody tr { animation: none !important; }
  .tab, .tab::after, .btn, .dd-pop { transition: none !important; }
  /* polished entrances from the option-group work */
  .mode-row .radio-pill, .dd-pop .dd-option,
  .reveal, .captcha-row img, #b12-result:not([hidden]) { animation: none !important; }
  .radio-pill::after, .dd-option::after { transition: none !important; }
  .radio-pill:hover, .dd-option:active { transform: none !important; }
}
