* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: #f4f5f7;
  color: #1f2328;
}
.topbar {
  background: #14532d;
  color: #fff;
  padding: 14px 24px;
  font-size: 18px;
  font-weight: 600;
}

/* ---------- layout ---------- */
.layout { display: flex; align-items: stretch; min-height: calc(100vh - 48px); }
.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e2e5e9;
  padding: 16px 12px;
}
.nav-group-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #9ca3af;
  padding: 6px 10px;
}
.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 14px;
  color: #374151;
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover { background: #f3f4f6; }
.nav-item.active { background: #14532d; color: #fff; }

.content { flex: 1; padding: 24px 28px; max-width: 1160px; }
.page { display: none; }
.page.active { display: block; }
.page-title { margin: 0 0 16px; font-size: 20px; font-weight: 650; color: #111827; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid #e2e5e9; margin-bottom: 18px; }
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 16px;
  font-size: 14px;
  color: #6b7280;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: #14532d; }
.tab.active { color: #14532d; font-weight: 600; border-bottom-color: #14532d; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-hint { font-size: 13px; color: #6b7280; margin: 0 0 16px; }

/* ---------- sub-tabs ---------- */
.subtabs { display: flex; gap: 6px; margin-bottom: 16px; }
.subtab {
  background: #f3f4f6;
  border: 1px solid #e2e5e9;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  color: #6b7280;
  cursor: pointer;
}
.subtab:hover { color: #14532d; }
.subtab.active { background: #14532d; border-color: #14532d; color: #fff; font-weight: 600; }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

/* ---------- context bar ---------- */
.context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}
.context-label { color: #9ca3af; }
#vdVillageName { font-weight: 600; color: #111827; }
.link-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: #14532d;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

/* ---------- data-table toolbar + paging ---------- */
.kh-download-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.kh-download-bar .folder-input {
  flex: 1;
  min-width: 220px;
  padding: 8px 10px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-size: 13px;
}
.kh-download-bar .action-btn { padding: 8px 14px; }

.jb-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  color: #374151;
}
.jb-settings label { display: inline-flex; align-items: center; gap: 5px; }
.jb-settings input, .jb-settings select {
  width: 52px;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid #d7dbe0;
  border-radius: 5px;
  font-size: 13px;
}
/* ---------- CS <-> RS correlation ---------- */
.cr-pick { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; font-size: 13px; color: #374151; }
.cr-pick label { display: inline-flex; align-items: center; gap: 6px; }
.cr-pick select { min-width: 220px; }
.cr-pick input[type="text"] { flex: 1; min-width: 220px; }
.cr-sides { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 10px; }
.cr-side { border: 1px solid #e2e5e9; border-radius: 8px; padding: 10px 12px; background: #fafbfc; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.cr-side-head { font-weight: 600; color: #111827; display: flex; align-items: center; gap: 6px; }
.cr-or { color: #6b7280; display: flex; align-items: center; gap: 6px; }
.cr-or select { flex: 1; min-width: 0; }
.rg-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-top: 12px; }
.rg-step { border: 1px solid #e2e5e9; border-radius: 8px; padding: 10px 12px; background: #fafbfc; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.rg-step .row { gap: 8px; flex-wrap: wrap; }
/* scanning has no known total: a moving stripe shows it is working */
.kh-progress-fill.rg-indet.moving {
  width: 100% !important;
  background-color: #14532d;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.28) 0 10px, transparent 10px 20px);
  background-size: 28px 28px;
  animation: rg-stripes 0.8s linear infinite;
}
@keyframes rg-stripes { from { background-position: 0 0; } to { background-position: 28px 0; } }
.rg-logbox { margin-top: 10px; font-size: 13px; }
.na-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.na-btns .action-btn.active { outline: 3px solid #f59e0b; }
.na-result { margin-top: 12px; font-size: 13px; color: #374151; }
.na-result .na-sum { margin-bottom: 8px; }
.na-chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 220px; overflow: auto; }
.na-chip { padding: 2px 8px; border-radius: 10px; background: #5b0f1a; color: #fff; font-size: 12px; cursor: pointer; border: 0; }
.na-chip.nomap { background: #e5e7eb; color: #374151; cursor: default; }
.na-map { margin-top: 14px; }
.na-map h3 { margin: 0 0 6px; font-size: 14px; color: #14532d; }
.na-map .ku-svg { height: 560px; }
.ku-svg path.audit-hit { fill: #5b0f1a; stroke: #2b050b; stroke-width: 1.6; }
.ku-svg text.audit-hit { fill: #fff; font-weight: 700; }
.ku-svg path.audit-focus { stroke: #f59e0b; stroke-width: 4; }
.rg-search { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 14px; align-items: end; padding: 12px; background: #f8f9fb; border: 1px solid #e2e5e9; border-radius: 8px; margin-bottom: 10px; font-size: 13px; }
.rg-search label { display: flex; flex-direction: column; gap: 4px; color: #6b7280; }
.rg-search input, .rg-search select { padding: 6px 8px; border: 1px solid #d7dbe0; border-radius: 5px; font-size: 13px; min-width: 0; }
.rg-range { display: flex; align-items: center; gap: 6px; }
.rg-range input { width: 100%; }
.rg-search-btns { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
.cr-chip.hit { background: #fde68a; color: #7c2d12; font-weight: 700; outline: 2px solid #f59e0b; }
.rg-logbox summary { cursor: pointer; color: #1d4ed8; }
.ku-chau { display: grid; grid-template-columns: 1fr; gap: 14px; }
.ku-map { border: 1px solid #e2e5e9; border-radius: 8px; background: #fff; overflow: hidden; }
.ku-map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; background: #f8f9fb; border-bottom: 1px solid #e2e5e9; font-size: 13px; }
.ku-map-tools .pager-btn { min-width: 36px; }
.ku-legend { margin-left: auto; color: #4b5563; display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.ku-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-left: 8px; }
.ku-svg { display: block; width: 100%; height: 520px; cursor: grab; user-select: none; }
.ku-svg.dragging { cursor: grabbing; }
.ku-svg path { vector-effect: non-scaling-stroke; stroke-width: 0.8; stroke: #9ca3af; fill: #f9fafb; cursor: pointer; }
.ku-svg path:hover { fill: #fef3c7; }
.ku-svg path.side { stroke-width: 1.6; }
.ku-svg path.target { stroke: #dc2626; stroke-width: 3; fill: rgba(220, 38, 38, 0.28); }
.ku-svg text { font-family: Arial, sans-serif; text-anchor: middle; dominant-baseline: middle; fill: #6b7280; pointer-events: none; }
.ku-svg text.side { font-weight: 700; }
.ku-svg text.target { fill: #991b1b; font-weight: 700; }
.ku-svg.hide-nums text, .ku-svg.far text.plain { display: none; }
/* full screen: the map takes the whole screen */
.ku-map:fullscreen { display: flex; flex-direction: column; border-radius: 0; }
.ku-map:fullscreen .ku-svg { flex: 1; height: auto; }
.ku-map.ku-full-fallback { position: fixed; inset: 0; z-index: 1000; display: flex; flex-direction: column; border-radius: 0; }
.ku-map.ku-full-fallback .ku-svg { flex: 1; height: auto; }
.ku-map-hint { font-size: 12px; color: #9ca3af; padding: 4px 10px 6px; }
.ku-chau-table td { vertical-align: top; }
.ku-chau-table input { width: 100%; min-width: 140px; padding: 5px 7px; border: 1px solid #d7dbe0; border-radius: 5px; font-size: 13px; }
.ku-side { font-weight: 700; }
.ku-side.east { color: #b45309; } .ku-side.west { color: #1d4ed8; } .ku-side.north { color: #047857; } .ku-side.south { color: #7c3aed; }
.ku-open { color: #9ca3af; font-size: 12px; display: block; }
.ku-h3 { margin: 16px 0 6px; font-size: 14px; color: #14532d; }
.ku-langs { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.ku-lang { border: 1px solid #e2e5e9; border-radius: 8px; padding: 10px; background: #fafbfc; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.ku-lang b { color: #111827; }
.ku-lang input, .ku-lang textarea { padding: 6px 8px; border: 1px solid #d7dbe0; border-radius: 5px; font-size: 13px; font-family: inherit; }
.ku-lang textarea { min-height: 120px; resize: vertical; }
.jd-lookups { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 8px 14px; font-size: 13px; }
.jd-lookups label { display: flex; flex-direction: column; gap: 3px; color: #6b7280; }
.jd-lookups .v { color: #111827; font-weight: 600; padding: 6px 0; }
.jd-lookups select, .jd-lookups input { padding: 6px 8px; border: 1px solid #d7dbe0; border-radius: 5px; font-size: 13px; }
.jd-lookups .jd-meta { grid-column: 1 / -1; color: #4b5563; }
.jd-detail { margin-top: 14px; border: 1px solid #e2e5e9; border-radius: 8px; padding: 12px 14px; background: #fafbfc; }
.jd-detail h3 { margin: 12px 0 6px; font-size: 14px; color: #14532d; }
.jd-detail h3:first-child { margin-top: 0; }
.jd-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 4px 14px; font-size: 13px; }
.jd-kv span { color: #6b7280; }
.jd-kv b { color: #111827; font-weight: 600; }
.jd-detail .data-table { margin-top: 4px; font-size: 12.5px; }
.jd-warn { color: #92400e; font-size: 12.5px; }
.on-source { font-size: 13px; color: #374151; background: #f8f9fb; border: 1px solid #e2e5e9; border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; line-height: 1.6; }
.on-source.missing { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.on-tables-head { font-size: 13px; color: #6b7280; margin-bottom: 6px; }
.on-tables { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.on-tables label { display: flex; align-items: center; gap: 8px; }
.on-tables .muted, .on-source .muted { color: #9ca3af; }
.cr-insert-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.cr-settings { margin-top: 10px; font-size: 13px; color: #374151; }
.cr-settings summary { cursor: pointer; color: #1d4ed8; }
.cr-settings-table { border-collapse: collapse; margin: 8px 0; }
.cr-settings-table th, .cr-settings-table td { padding: 4px 8px; text-align: left; font-weight: 500; }
.cr-settings-table input { width: 150px; padding: 5px 7px; border: 1px solid #d7dbe0; border-radius: 5px; font-size: 13px; }
.cr-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.cr-card { background: #f8f9fb; border: 1px solid #e2e5e9; border-radius: 8px; padding: 10px 12px; }
.cr-card .v { font-size: 20px; font-weight: 700; color: #111827; }
.cr-card .k { font-size: 12px; color: #6b7280; margin-top: 2px; }
.cr-card.bad .v { color: #b91c1c; }
.cr-card.good .v { color: #166534; }
.cr-downloads { display: flex; gap: 8px; margin-bottom: 10px; }
.cr-downloads a { text-decoration: none; display: inline-block; }
.cr-sheets { font-size: 12.5px; color: #4b5563; margin-bottom: 12px; line-height: 1.6; }
.cr-sheets b { color: #111827; }
.cr-table td { vertical-align: top; }
.cr-chip { display: inline-block; padding: 1px 7px; margin: 1px 4px 1px 0; border-radius: 10px; background: #eef2ff; color: #1e3a8a; font-size: 12px; white-space: nowrap; }
.cr-chip.old { background: #fef2f2; color: #991b1b; }

/* Map Management: naksa pickers */
.mm-pick { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 18px; }
.mm-pick select { min-width: 320px; }
.mm-naksa-pick { margin-left: 12px; font-size: 13px; }
.mm-naksa-pick select { padding: 3px 6px; }

/* Village Data -> Khesra Add (parcel editor) */
.ka-editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; height: 78vh; min-height: 520px; border: 1px solid #e2e5e9; border-radius: 8px; overflow: hidden; background: #fff; margin-top: 12px; }
.ka-editor.full { position: fixed; inset: 0; height: auto; z-index: 900; border-radius: 0; margin: 0; }
.ka-left { min-width: 0; display: flex; flex-direction: column; }
.ka-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 10px; border-bottom: 1px solid #e2e5e9; background: #f8f9fb; font-size: 13px; }
.ka-toolbar .pager-btn.on { background: #1e3a8a; color: #fff; border-color: #1e3a8a; }
.ka-xy { font: 11px Consolas, monospace; color: #4b5563; }
.ka-summary { margin-left: auto; font-size: 12px; color: #374151; }
.ka-viewport { position: relative; flex: 1; overflow: hidden; background: #ddd8ce; cursor: grab; }
.ka-viewport.drag { cursor: grabbing; }
.ka-viewport.picking { cursor: crosshair; }
.ka-stage { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.ka-stage img { display: block; user-select: none; pointer-events: none; }
.ka-overlay { position: absolute; left: 0; top: 0; overflow: visible; }
.ka-overlay .kp { fill: transparent; stroke: transparent; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: pointer; }
.ka-overlay.outlines .kp { stroke: #2563eb88; }
.ka-overlay .kp:hover { fill: #2563eb32; stroke: #245f91; }
.ka-overlay .kp.saved { fill: #16a34a33; stroke: #15803d; }
.ka-overlay .kp.numbered { fill: #f59e0b33; stroke: #b45309; }
.ka-overlay .kp.rejected { fill: #6b728033; }
.ka-overlay .kp.outside { fill: #9ca3af55; stroke: #6b7280; }
.ka-overlay .kp.road { fill: #f59e0b66 !important; stroke: #d97706 !important; stroke-width: 3; }
.ka-overlay.show-exist .kp.saved { fill: #16a34aa6; stroke: #166534; }
.ka-overlay.show-missing .kp.missing { fill: #7f1d1d; fill-opacity: 0.85; stroke: #fff; stroke-width: 2; }
.ka-overlay .kp.nb { fill: #2563eb55 !important; stroke: #1d4ed8 !important; stroke-width: 2.5; }
.ka-overlay .kp.selected { fill: #dc26264b !important; stroke: #dc2626 !important; stroke-width: 3; }
.ka-overlay .kp.custom { stroke: #b45309; stroke-dasharray: 6 4; }
.ka-overlay .kdraw { fill: #f59e0b33; stroke: #b45309; stroke-width: 2; stroke-dasharray: 4 3; vector-effect: non-scaling-stroke; }
.ka-overlay .kdraw.open { fill: none; stroke-width: 2.5; }
.ka-overlay .kstrip { fill: #f59e0b55; stroke: #b45309; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.ka-draw-as { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 12.5px; align-items: center; }
.ka-draw-as label { display: inline-flex; align-items: center; gap: 4px; margin: 0; font-weight: 400; text-transform: none; letter-spacing: 0; color: inherit; }
.ka-draw-as input[type="number"] { width: 64px; margin: 0; padding: 3px 5px; }
.ka-overlay .kvertex { fill: #b45309; stroke: #fff; stroke-width: 1; vector-effect: non-scaling-stroke; }
.ka-labels { position: absolute; left: 0; top: 0; pointer-events: none; }
.ka-tag { position: absolute; transform: translate(-50%, -50%); background: #245f91; color: #fff; padding: 0 .3em; border-radius: 3px; font-size: inherit; white-space: nowrap; }
.ka-tag.saved { background: #15803d; }
.ka-tag.numbered { background: #b45309; }
.ka-gcp { position: absolute; transform: translate(-50%, -50%); width: 34px; height: 34px; border: 4px solid #e11d48; border-radius: 50%; background: #fff; color: #9f1239; font: bold 16px/26px Arial; text-align: center; }
.ka-float { position: absolute; z-index: 20; left: 12px; top: 12px; width: 310px; max-height: 92%; overflow: auto; padding: 12px; background: #fffdf8f0; border: 1px solid #bcae91; border-radius: 6px; box-shadow: 0 5px 18px #0003; font-size: 13px; cursor: default; }
.ka-float h3 { margin: 0 0 6px; font-size: 15px; }
.ka-float select, .ka-float input { width: 100%; margin-top: 6px; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; box-sizing: border-box; }
.ka-float label { display: block; margin-top: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.ka-float button { width: 100%; margin-top: 7px; padding: 7px; border: 0; border-radius: 4px; cursor: pointer; background: #e5e7eb; }
.ka-float .ka-close { position: absolute; top: 6px; right: 6px; width: auto; margin: 0; padding: 2px 8px; background: #f0e2df; color: #8a2d22; }
.ka-drawside { padding: 10px 12px; border-bottom: 1px solid #e2e5e9; background: #fffbeb; font-size: 13px; }
.ka-drawside-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ka-drawside h3 { margin: 0; font-size: 15px; color: #92400e; }
.ka-close { padding: 4px 10px; border: 0; border-radius: 5px; background: #f0e2df; color: #8a2d22; cursor: pointer; font-size: 12.5px; }
.ka-drawside .ka-draw-xy { max-height: 90px; }
/* GCP / Road panels in the sidebar: their inputs and lists */
.ka-modepanel { max-height: 55%; overflow: auto; }
.ka-modepanel label { display: block; margin-top: 8px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #374151; }
.ka-modepanel select, .ka-modepanel input { width: 100%; margin-top: 4px; padding: 6px 8px; border: 1px solid #d1d5db; border-radius: 4px; box-sizing: border-box; }
.ka-modepanel .ka-road-item input { margin-top: 2px; }
.ka-modepanel .ka-road-item .head button { padding: 2px 8px; border: 0; border-radius: 4px; background: #fee2e2; color: #991b1b; font-size: 11px; cursor: pointer; }
.ka-gcp-ll { display: grid; grid-template-columns: 1fr 1fr 70px; gap: 5px; }
.ka-gcp-status, .ka-draw-xy { margin-top: 8px; font: 11px/1.5 Consolas, monospace; white-space: pre; max-height: 130px; overflow: auto; }
.ka-road-item { border-bottom: 1px solid #e5e7eb; padding: 5px 0; }
.ka-road-item .head { display: flex; justify-content: space-between; align-items: center; }
.ka-road-item .head button { width: auto; margin: 0; padding: 2px 8px; background: #fee2e2; color: #991b1b; font-size: 11px; }
.ka-road-item .sides { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.ka-side { border-left: 1px solid #e2e5e9; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ka-sidehead { padding: 10px; border-bottom: 1px solid #e2e5e9; display: grid; gap: 6px; }
.ka-sidehead input, .ka-sidehead select { padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 5px; }
.ka-export { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ka-panel { padding: 10px 12px; border-bottom: 1px solid #e2e5e9; overflow: auto; max-height: 62%; font-size: 13px; }
.ka-panel label { display: block; margin-top: 9px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #374151; }
.ka-panel input, .ka-panel select { width: 100%; margin-top: 4px; padding: 7px 8px; border: 1px solid #d1d5db; border-radius: 5px; box-sizing: border-box; }
.ka-panel .idline { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ka-panel .badge { font-size: 11px; padding: 2px 7px; border-radius: 10px; background: #e5e7eb; }
.ka-panel .badge.saved { background: #dcfce7; color: #166534; }
.ka-khline { display: flex; gap: 6px; margin-top: 4px; }
.ka-khline input { flex: 1; margin-top: 0 !important; }
.ka-khline .action-btn { white-space: nowrap; padding: 6px 12px; }
.ka-guess { display: grid; gap: 4px; margin-top: 6px; }
.ka-guess:empty { display: none; }
.ka-guess-chip { display: flex; gap: 8px; align-items: baseline; text-align: left; padding: 5px 8px; border: 1px solid #d1d5db; border-radius: 6px; background: #fff; cursor: pointer; font-size: 12px; }
.ka-guess-chip b { font-size: 14px; color: #1e3a8a; min-width: 38px; }
.ka-guess-chip span { color: #4b5563; }
.ka-guess-chip:hover { background: #f0f9ff; }
.ka-guess-chip.best { border-color: #15803d; box-shadow: 0 0 0 1px #15803d; }
.ka-area { margin-top: 8px; padding: 7px 9px; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 6px; font-size: 12.5px; line-height: 1.5; }
.ka-area:empty { display: none; }
.ka-chau { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.ka-chau label { margin-top: 0; }
.ka-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.ka-actions button, .ka-wide { padding: 8px; border: 0; border-radius: 5px; cursor: pointer; background: #e5e7eb; font-size: 12.5px; }
.ka-wide { width: 100%; margin-top: 8px; }
.ka-add { background: #15803d !important; color: #fff; font-weight: 700; }
.ka-verify { margin-top: 6px; display: grid; gap: 5px; font-size: 12.5px; }
.ka-verify:empty { display: none; }
.ka-verify-img { max-width: 100%; max-height: 220px; object-fit: contain; border: 1px solid #d1d5db; border-radius: 4px; background: #000; }
.ka-verify-head { padding: 6px 8px; border-radius: 5px; }
.ka-verify-head.ok { background: #dcfce7; color: #166534; }
.ka-verify-head.bad { background: #fee2e2; color: #991b1b; }
.ka-verify-head.warn { background: #fef3c7; color: #92400e; }
.ka-verify-row .pager-btn { margin-left: 6px; padding: 2px 8px; }
.ka-verify-row .used { color: #b45309; }
.ka-numcheck { margin-top: 8px; display: grid; gap: 4px; }
.ka-numcheck-row { padding: 6px 8px; border: 1px solid #e5e7eb; border-radius: 5px; cursor: pointer; font-size: 12.5px; }
.ka-numcheck-row:hover { background: #f3f4f6; }
.ka-numcheck-row .used { color: #b45309; }
.ka-del { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.ka-del:hover { background: #fecaca; }
.ka-add:disabled { background: #9ca3af !important; cursor: default; }
.ka-kh { margin-top: 8px; display: grid; gap: 6px; }
.ka-kh-row { border: 1px solid #e5e7eb; border-radius: 6px; padding: 7px 8px; cursor: pointer; font-size: 12.5px; line-height: 1.45; }
.ka-kh-row:hover { background: #f9fafb; }
.ka-kh-row.on { border-color: #15803d; background: #f0fdf4; box-shadow: 0 0 0 1px #15803d; }
.ka-kh-row .used { color: #b45309; }
.ka-list { flex: 1; overflow: auto; min-height: 80px; }
.ka-row { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 7px 10px; border-bottom: 1px solid #f1f1f1; cursor: pointer; font-size: 12px; }
.ka-row:hover { background: #f7f5ef; }
.ka-row b { color: #245f91; }
.ka-row .st { color: #6b7280; text-align: right; }
.ka-row.saved .st { color: #15803d; font-weight: 600; }

/* Registry: deed register window */
.deed-link { color: #1d4ed8; text-decoration: underline; cursor: pointer; font-weight: 700; background: none; border: 0; padding: 0; font: inherit; }
.deed-modal { position: fixed; inset: 0; z-index: 1000; background: rgba(17, 24, 39, .55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.deed-modal[hidden] { display: none; }
.deed-modal-box { background: #fff; border-radius: 10px; width: min(1100px, 100%); height: min(90vh, 100%); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.deed-modal-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #e2e5e9; background: #f8f9fb; }
.deed-modal-head .spacer { flex: 1; }
.deed-modal-box iframe { flex: 1; width: 100%; border: 0; background: #fff; }
/* Registry -> NF khesra -> Khesra Add in its own browser tab */
.rg-nf-link { background: none; border: 0; padding: 0; font: inherit; color: #1d4ed8; text-decoration: underline; cursor: pointer; font-weight: 600; }
.rg-nf-link:hover { color: #1e3a8a; }
.rg-portal-note { margin: 0 0 10px; padding: 8px 12px; border: 1px solid #bfdbfe; border-radius: 8px; background: #eff6ff; color: #1e3a8a; font-size: 13px; }

/* Registry -> Download history */
.rg-history > summary { cursor: pointer; list-style: revert; }
.rg-history .table-scroll { max-height: 360px; margin-top: 8px; }
.rg-history small.bad { color: #b91c1c; }

/* Registry -> Old registry / eNibandhan */
.rg-sources { margin: 4px 0 12px; }
.enb-period-cards { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px; }
.enb-card { flex: 1 1 260px; display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 2px solid #d1d5db; border-radius: 10px; background: #fff; cursor: pointer; }
.enb-card:hover { border-color: #0e7490; }
.enb-card.on { border-color: #14532d; background: #f0fdf4; box-shadow: 0 0 0 1px #14532d inset; }
.enb-card input { margin-top: 3px; }
.enb-card b { display: block; font-size: 15px; color: #14532d; }
.enb-card small { display: block; color: #4b5563; margin-top: 2px; }
.enb-phases { grid-column: span 3; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 16px; padding: 6px 0; font-size: 13px; color: #374151; }
/* .rp-grid stacks labels in a column - the phase tick boxes stay on one line */
.rp-grid .enb-phases label.chk-label { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; font-size: 14px; }
.enb-phases[hidden] { display: none; }
.enb-captcha { margin-top: 10px; padding: 10px 12px; border: 1px solid #f59e0b; border-radius: 8px; background: #fffbeb; color: #78350f; font-size: 14px; }

/* Registry -> Verify downloads */
.rg-linkcheck { margin-top: 10px; padding: 8px 10px; border: 1px solid #e2e5e9; border-radius: 8px; background: #fff; font-size: 13px; }
.rg-lc-sum { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.rg-lc-sum .ka-close { margin-left: auto; }
.rg-linkcheck .ok { color: #15803d; }
.rg-linkcheck .warn { color: #b45309; }
.rg-linkcheck .bad { color: #b91c1c; }
.rg-lc-wrap { max-height: 320px; margin-top: 6px; }

/* Registry -> deed files: 📷 screenshots / 📄 PDF */
.rg-files-inline { display: flex; gap: 4px; margin-top: 2px; }
.rg-file { text-decoration: none; font-size: 13px; padding: 0 3px; border-radius: 4px; }
.rg-file:hover { background: #e0f2fe; }
.rg-files { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 8px; }
.rg-files a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: #0e7490; text-decoration: none; }
.rg-files img { max-height: 140px; max-width: 320px; border: 1px solid #e5e7eb; border-radius: 4px; }
.rg-files .rg-file-doc { padding: 6px 10px; border: 1px solid #bae6fd; border-radius: 6px; background: #f0f9ff; }

/* Registry -> Add deed by paste */
.rp-panel > summary { cursor: pointer; list-style: revert; }
.rp-panel h3 { margin: 16px 0 6px; font-size: 14px; color: #14532d; }
.rp-panel textarea { width: 100%; font: inherit; font-size: 12px; padding: 8px; border: 1px solid #d7dbe0; border-radius: 6px; box-sizing: border-box; margin: 6px 0; }
.rp-panel .rp-new { background: #0e7490; border-color: #0e7490; }
.rp-image { margin: 8px 0; padding: 10px; border: 2px dashed #99c5b5; border-radius: 8px; background: #f6fbf9; min-height: 52px; outline: none; }
.rp-image:focus, .rp-image.drag { border-color: #0e7490; background: #ecfeff; }
.rp-image-hint { font-size: 13px; color: #374151; }
.rp-image-pick { color: #0e7490; text-decoration: underline; cursor: pointer; }
.rp-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.rp-thumb { position: relative; }
.rp-thumb img { display: block; max-height: 220px; max-width: 520px; border: 1px solid #e5e7eb; border-radius: 4px; }
.rp-thumb span { position: absolute; top: 4px; left: 4px; background: #0e7490; color: #fff; font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 10px; }
.rp-thumb button { position: absolute; top: 4px; right: 4px; }
.rp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 10px; }
.rp-grid label, .rp-row label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: #374151; }
.rp-grid .rp-wide { grid-column: 1 / -1; }
.rp-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px 8px; align-items: end; padding: 8px; margin-bottom: 8px; border: 1px solid #e5e7eb; border-radius: 6px; position: relative; padding-right: 40px; }
.rp-row .rp-w2 { grid-column: span 2; }
.rp-row .rp-del { position: absolute; top: 6px; right: 6px; }

/* Village Data -> Areas: selected parcels -> ticked areas */
.ar-assign { margin-top: 12px; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 8px; background: #f9fafb; }
.ar-assign-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; margin-bottom: 8px; }
.ar-assign-list { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-bottom: 8px; }
.ar-assign-list .chk-label { padding: 4px 8px; border: 1px solid #e2e5e9; border-radius: 6px; background: #fff; }
.ar-assign-list small { color: #6b7280; }

/* Village Data -> Areas */
.ar-name-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 12px; align-items: end; }
.ar-name-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: #374151; }
.ar-name-grid .ar-wide { grid-column: span 3; }
.ar-name-grid .chk-label.ar-wide { flex-direction: row; align-items: center; grid-column: span 4; }
.ar-name-grid textarea { font: inherit; }
.ar-editor { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 12px; margin-top: 12px; }
.ar-tools .pager-btn.on { background: #14532d; color: #fff; border-color: #14532d; }
.ar-svg { height: 600px; }
.ar-svg.ar-drawing { cursor: crosshair; }
.ar-svg.ar-picking path[data-id] { cursor: pointer; }
.ar-svg.ar-picking path[data-id]:hover { stroke: #0f766e; stroke-width: 2.5; }
.ku-svg path.ar-in { fill: #0f766e; stroke: #064e3b; }
.ku-svg path.ar-add { fill: #2563eb; stroke: #1e3a8a; }
.ku-svg path.ar-rem { fill: #fecaca; stroke: #ef4444; }
.ku-svg text.ar-lbl { fill: #fff; font-weight: 700; }
.ku-svg .ar-shape { fill: rgba(245, 158, 11, 0.12); stroke: #d97706; stroke-width: 2.5; stroke-dasharray: 8 5; vector-effect: non-scaling-stroke; pointer-events: none; }
.ku-svg .ar-draft { fill: rgba(245, 158, 11, 0.18); stroke: #b45309; stroke-width: 2; vector-effect: non-scaling-stroke; pointer-events: none; }
.ku-svg polyline.ar-draft { fill: none; }
.ku-svg .ar-dot { fill: #b45309; pointer-events: none; }
.ar-side { border: 1px solid #e2e5e9; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 8px; max-height: 680px; }
.ar-count { font-size: 14px; }
/* "Add khesras of other areas" - a short scrolling checkbox list + button */
.ar-from { border: 1px solid #e2e5e9; border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.ar-from summary { cursor: pointer; font-weight: 600; }
.ar-from-list { max-height: 180px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin: 6px 0; }
.ar-from-list .chk-label { font-size: 13px; }
.ar-list { overflow-y: auto; flex: 1; }
.ar-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px; border-bottom: 1px solid #f1f5f9; cursor: pointer; font-size: 13px; }
.ar-row:hover { background: #f8fafc; }
.ar-row.added b { color: #1d4ed8; }
.ar-row small { color: #6b7280; }
@media (max-width: 900px) { .ar-editor { grid-template-columns: 1fr; } .ar-name-grid { grid-template-columns: 1fr 1fr; } .ar-name-grid .ar-wide, .ar-name-grid .chk-label.ar-wide { grid-column: span 2; } }

/* Registry -> Deeds: Only plots on a map + Deed details under the row */
.rg-view-opts { display: flex; gap: 14px; align-items: center; margin: 8px 0; }
.rg-offmap { display: inline-block; margin-left: 4px; color: #6b7280; white-space: nowrap; }
.rg-detail-row > td { background: #f8fafc; position: relative; }
.rg-detail-close { position: absolute; top: 8px; right: 10px; z-index: 1; }

/* Jamabandi Records -> khesra buttons + verify-the-link panel */
.jd-khs { white-space: normal; }
.jd-kh { margin: 1px 3px 1px 0; padding: 1px 7px; border: 1px solid #93c5fd; border-radius: 10px; background: #eff6ff; color: #1d4ed8; font: inherit; cursor: pointer; }
.jd-kh:hover { background: #dbeafe; }
.jd-kh.verified { border-color: #86efac; background: #dcfce7; color: #166534; font-weight: 600; }
.jd-kh.rejected { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
.jd-kh-none { margin-right: 4px; color: #9ca3af; }
.jd-link-row > td { background: #f8fafc; }
.jd-link { padding: 8px 4px; }
.jd-link-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.jd-link-head .ka-close { margin-left: auto; }
.jd-link-table tr.jd-ok td { background: #f0fdf4; }
.jd-link-table tr.jd-no td { background: #fef2f2; color: #6b7280; }
.jd-conf { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.jd-conf.HIGH { background: #dcfce7; color: #166534; }
.jd-conf.MEDIUM { background: #fef9c3; color: #854d0e; }
.jd-conf.LOW { background: #f3f4f6; color: #4b5563; }
.jd-fam { color: #166534; }
.jd-nofam { color: #b45309; }
.jd-acts { white-space: nowrap; }

/* Khesra Add -> Search all maps */
.ka-find { margin-top: 8px; padding: 8px; border: 1px solid #d1d5db; border-radius: 8px; background: #f9fafb; font-size: 13px; }
.ka-find[hidden] { display: none; }
.ka-find-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.ka-find-head .ka-close { margin-left: auto; }
.ka-find-hit { display: block; width: 100%; text-align: left; margin-top: 4px; padding: 6px 8px; border: 1px solid #bbf7d0; border-radius: 6px; background: #f0fdf4; cursor: pointer; font: inherit; }
.ka-find-hit:hover { background: #dcfce7; }
.ka-find-go { float: right; color: #166534; font-weight: 600; }
.ka-find-del { display: block; margin: 2px 0 6px auto; padding: 2px 8px; border: 1px solid #fca5a5; border-radius: 6px; background: #fef2f2; color: #991b1b; font-size: 12px; cursor: pointer; }
.ka-find-del:hover { background: #fee2e2; }
.na-chip.na-add { color: #1d4ed8; text-decoration: underline; cursor: pointer; }
.na-chip.na-add:hover { color: #1e3a8a; background: #dbeafe; }
.rg-dnv { display: inline-block; margin-top: 4px; padding: 1px 6px; border-radius: 4px; background: #e5e7eb; color: #374151; font-size: 11px; font-weight: 600; white-space: nowrap; }
.rg-actions { white-space: nowrap; }
.rg-actions .rg-dnv-btn { margin-left: 4px; }
.ka-popup-note { margin: 0 0 12px; padding: 10px 12px; border: 1px solid #fcd34d; background: #fffbeb; border-radius: 8px; color: #78350f; }
.ka-popup-note.error { border-color: #fca5a5; background: #fef2f2; color: #991b1b; }
/* the app opened in that tab (?popup=khesraAdd): only the Khesra Add tab */
body.popup .topbar, body.popup .sidebar, body.popup #page-villageData > .page-title,
body.popup #page-villageData > .context-bar, body.popup #page-villageData > .tabs { display: none; }
body.popup .layout { min-height: 100vh; }
body.popup .content { max-width: none; padding: 12px 14px; }

/* Registry -> Verify: plot flags */
.rg-flags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.rg-flag-btn { border: 1px solid #d1d5db; background: #fff; border-radius: 14px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; }
.rg-flag-btn.on { outline: 2px solid #1e3a8a; }
.rg-verify-wrap { max-height: 460px; overflow: auto; }
.rg-verify-wrap .data-table { font-size: 12.5px; }
.flag { display: inline-block; min-width: 34px; text-align: center; padding: 1px 6px; border-radius: 4px; font-weight: 700; font-size: 11.5px; letter-spacing: .3px; }
.flag-NOM { background: #dcfce7; color: #166534; }
.flag-REV { background: #e0f2fe; color: #075985; }
.flag-ON { background: #fef9c3; color: #854d0e; }
.flag-OO { background: #ffedd5; color: #9a3412; }
.flag-LST { background: #ede9fe; color: #5b21b6; }
.flag-NF { background: #fee2e2; color: #991b1b; }
.cr-flag { display: block; font-size: 12px; color: #92400e; }
.cr-flag.info { color: #6b7280; }
.cr-conf { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 10px; }
.cr-conf.high { background: #dcfce7; color: #166534; }
.cr-conf.medium { background: #e0f2fe; color: #075985; }
.cr-conf.low { background: #fef3c7; color: #92400e; }
.cr-table tr.low td { background: #fffbeb; }
.cr-table tr.minor td, .cr-table tr.sliver td { color: #9ca3af; }
.cr-count { font-size: 13px; color: #6b7280; }
.cr-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.cr-dot.cs { background: #c00000; }
.cr-dot.rs { background: #0050c8; }
.cr-map-wrap { position: relative; border: 1px solid #e2e5e9; background: #fff; }
.cr-svg { display: block; width: 100%; height: 640px; cursor: grab; user-select: none; }
.cr-svg.dragging { cursor: grabbing; }
.cr-svg path { fill: transparent; vector-effect: non-scaling-stroke; }
.cr-svg .cs path { stroke: #c00000; stroke-width: 1.1; }
.cr-svg .rs path { stroke: #0050c8; stroke-width: 0.8; }
.cr-svg .cs path.sel { fill: rgba(192, 0, 0, 0.28); stroke-width: 2.5; }
.cr-svg .rs path.sel { fill: rgba(0, 80, 200, 0.25); stroke-width: 2.5; }
.cr-svg path.flag { stroke-dasharray: 3 2; }
.cr-svg text { font-family: Arial, sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.cr-svg .cs text { fill: #c00000; font-weight: 700; }
.cr-svg .rs text { fill: #0050c8; }
.cr-svg.hide-labels text, .cr-svg.far text { display: none; }
.cr-info { position: absolute; top: 8px; right: 8px; max-width: 320px; background: rgba(255, 255, 255, 0.95); border: 1px solid #e2e5e9; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: #374151; box-shadow: 0 2px 8px rgba(0,0,0,.08); }
.cr-info b { color: #111827; }
.jb-dl-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: -4px 0 12px;
  font-size: 13px;
  color: #6b7280;
}
.jb-dl-stats .jb-stat-ok { color: #166534; font-weight: 600; }
.jb-dl-stats .jb-stat-skip { color: #1d4ed8; }
.jb-dl-stats .jb-stat-bad { color: #b91c1c; font-weight: 600; }
.jb-link { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }

/* display:flex would otherwise beat the hidden attribute (idle "0 / 0" bars showing) */
.kh-progress[hidden] { display: none; }
.kh-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 13px;
}
.kh-progress-track {
  flex: 1;
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.kh-progress-fill {
  height: 100%;
  width: 0%;
  background: #14532d;
  border-radius: 999px;
  transition: width .2s ease;
}
.kh-progress-count { font-weight: 600; color: #14532d; white-space: nowrap; }

/* ---------- View Khatiyan ---------- */
.khv-pickers {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
@media (max-width: 900px) { .khv-pickers { grid-template-columns: 1fr; } }
.khv-picker {
  border: 1px solid #e2e5e9;
  border-radius: 10px;
  background: #fff;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.khv-picker-head {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #14532d;
  border-bottom: 1px solid #f0f1f3;
}
.khv-count {
  display: inline-block;
  margin-left: 6px;
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  font-size: 11px;
  padding: 0 7px;
  font-weight: 600;
}
.khv-search {
  margin: 8px;
  padding: 6px 8px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-size: 12px;
}
.khv-list {
  list-style: none;
  margin: 0;
  padding: 0 4px 6px;
  overflow-y: auto;
  max-height: 240px;
}
.khv-list li {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px;
  font-size: 12.5px;
  border-radius: 4px;
  cursor: pointer;
}
.khv-list li:hover { background: #f9fafb; }
.khv-list li.sel { background: #ecfdf5; }
.khv-list li input { margin: 0; flex-shrink: 0; }
.khv-list .khv-none { color: #b0b4bb; padding: 8px; cursor: default; }
.khv-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.khv-actions .action-btn { padding: 8px 16px; }

/* ---------- Map Management ---------- */
.mm-card {
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.mm-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}
.mm-card-head h3 { margin: 0; font-size: 15px; color: #14532d; }
.mm-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.mm-status-badge.done { background: #ecfdf5; color: #166534; }
.mm-card-head .spacer { flex: 1; }
.mm-delete-btn {
  background: none;
  border: none;
  color: #b91c1c;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}
.mm-stages {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 14px;
}
@media (max-width: 1200px) { .mm-stages { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .mm-stages { grid-template-columns: 1fr; } }
.mm-stage {
  border: 1px solid #f0f1f3;
  border-radius: 10px;
  padding: 12px;
  background: #f8f9fb;
}
.mm-stage.disabled { opacity: .5; pointer-events: none; }
.mm-stage h4 { margin: 0 0 8px; font-size: 12.5px; color: #374151; }
.mm-stage-row { display: flex; gap: 6px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.mm-stage-row input[type="number"] {
  width: 66px;
  padding: 6px 8px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-size: 12.5px;
}
.mm-stage-row label { font-size: 11.5px; color: #6b7280; display: flex; align-items: center; gap: 4px; }
.mm-stage .submit-btn { padding: 6px 12px; font-size: 12.5px; }
.mm-stage-info { font-size: 11.5px; color: #6b7280; margin-top: 4px; }
.mm-stage-info.error { color: #b91c1c; }
.mm-preview {
  margin-top: 8px;
  display: block;
  max-width: 100%;
  max-height: 180px;
  border-radius: 6px;
  border: 1px solid #e2e5e9;
  background: #111;
  cursor: zoom-in;
}
.mm-tool-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #f0f1f3;
}
.mm-tool-row label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11.5px;
  color: #6b7280;
  flex: 1;
  min-width: 220px;
}
.mm-tool-row input[type="text"] {
  padding: 7px 9px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-size: 12.5px;
}
.mm-tool-row .action-btn { padding: 7px 14px; font-size: 12.5px; }
.mm-tool-row .mm-stage-info { flex-basis: 100%; margin-top: 0; }
.mm-tool-primary { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; width: 100%; }
.mm-tool-primary .mm-stage-info { flex-basis: auto; flex: 1; min-width: 180px; }
.mm-tool-override { width: 100%; margin-top: 6px; }
.mm-tool-override summary { cursor: pointer; font-size: 11.5px; color: #6b7280; }
.mm-tool-override[open] summary { margin-bottom: 8px; }
.mm-tool-override label { min-width: 0; }
.mm-ocr-progress { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 8px; font-size: 12.5px; }
.mm-ocr-bar { flex: 1; height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.mm-ocr-bar-fill { height: 100%; width: 0%; background: #7c2d12; border-radius: 999px; transition: width .2s ease; }
.mm-ocr-progress span { font-weight: 600; color: #7c2d12; white-space: nowrap; }
.khv-card {
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 16px;
}
.khv-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  color: #14532d;
}
.khv-head {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 20px;
  font-size: 13px;
  margin-bottom: 14px;
}
.khv-head .k { color: #9ca3af; }
.khv-head .v { color: #111827; font-weight: 500; }
.khv-head .khv-label-line { grid-column: 1 / -1; color: #374151; }
.khv-sub-title { font-size: 12px; font-weight: 600; color: #6b7280; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.khv-card .data-table { font-size: 12.5px; }
.khv-card .data-table th { background: #f8f9fb; }
.khv-empty { color: #6b7280; font-size: 14px; }
.kh-progress-label { color: #6b7280; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40%; }

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  background: #f8f9fb;
  border: 1px solid #e2e5e9;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  font-size: 13px;
}
.table-toolbar .spacer { flex: 1; }
.chk-label { display: inline-flex; align-items: center; gap: 6px; color: #374151; }
.chk-label select { min-width: 0; padding: 4px 6px; font-size: 13px; }
.sel-count { color: #166534; font-weight: 600; }
.table-scroll { overflow-x: auto; border: 1px solid #e2e5e9; }
.table-scroll .data-table { margin-top: 0; }
.table-scroll .data-table th {
  position: sticky;
  top: 0;
  border-bottom: 1px solid #e2e5e9;
}
.data-table td.chk-col, .data-table th.chk-col { width: 34px; text-align: center; padding-left: 6px; padding-right: 6px; }
.data-table tbody tr:hover { background: #f9fafb; }
.kh-filter-row th { padding: 4px 6px; background: #fff; border-bottom: 1px solid #e2e5e9; position: sticky; top: 32px; }
.kh-filter-row input {
  width: 100%;
  min-width: 60px;
  padding: 4px 6px;
  border: 1px solid #d7dbe0;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 400;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid #e2e5e9;
  border-top: none;
  border-radius: 0 0 10px 10px;
  font-size: 13px;
  color: #6b7280;
}
.pager-btn {
  background: #fff;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.pager-btn:hover:not(:disabled) { background: #f3f4f6; }
.pager-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- master grid ---------- */
.master-grid {
  display: grid;
  /* Fixed narrower width per card (was 1fr, stretching each card to fill
     the row) so all 5 columns - State, District, Thana, Panchayat, Village -
     fit without the last one overflowing off-screen. */
  grid-template-columns: repeat(5, minmax(0, 200px));
  gap: 14px;
}
.pick-item .panchayat-tag { font-size: 11px; opacity: .7; margin-left: 4px; }
@media (max-width: 980px) { .master-grid { grid-template-columns: repeat(2, 1fr); } }
.master-col {
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  min-height: 340px;
}
.master-col.disabled { opacity: .5; }
.master-col.disabled .add-row,
.master-col.disabled .pick-list { pointer-events: none; }
.master-col-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.master-col-head h3 { margin: 0; font-size: 14px; font-weight: 600; color: #14532d; }
.badge {
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  font-size: 12px;
  padding: 1px 8px;
}
.ctx-line { font-size: 12px; color: #9ca3af; margin-bottom: 8px; min-height: 15px; }
.pick-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  flex: 1;
  overflow-y: auto;
  max-height: 260px;
  border: 1px solid #f0f1f3;
  border-radius: 8px;
}
.pick-item {
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #f4f5f7;
}
.pick-item:last-child { border-bottom: none; }
.pick-item:hover { background: #f9fafb; }
.pick-item.selected { background: #14532d; color: #fff; }
.pick-empty { padding: 10px; font-size: 12px; color: #b0b4bb; }
.add-row { display: flex; gap: 6px; }
.add-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-size: 13px;
}
.add-row .submit-btn { padding: 7px 12px; }

.breadcrumb { margin-top: 18px; font-size: 13px; color: #374151; font-weight: 500; }
.crumb-mini { font-size: 12px; color: #9ca3af; margin: -4px 0 4px; }

/* ---------- shared components ---------- */
.panel {
  background: #fff;
  border: 1px solid #e2e5e9;
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
  color: #14532d;
}
.subsection {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f0f1f3;
}
.subsection h3 {
  margin: 0 0 10px;
  font-size: 14px;
  color: #374151;
}
.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
select, input[type="text"] {
  padding: 8px 10px;
  border: 1px solid #d7dbe0;
  border-radius: 6px;
  font-size: 14px;
}
select { min-width: 200px; }
.subsection input[type="text"] { flex: 1; min-width: 180px; }
.submit-btn {
  background: #14532d;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
}
.submit-btn:hover { background: #0f3d21; }
.status-line {
  margin-top: 8px;
  font-size: 13px;
  color: #6b7280;
}
.status-line.error { color: #b91c1c; }
.status-line.success { color: #166534; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 13px;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #f0f1f3;
}
.data-table th { color: #6b7280; font-weight: 600; background: #f8f9fb; }
.button-grid {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.action-btn {
  background: #7c2d12;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
}
.action-btn:hover { background: #5c2109; }
.action-btn:disabled { background: #9ca3af; cursor: not-allowed; }
.result-box {
  background: #0f172a;
  color: #e2e8f0;
  padding: 12px;
  border-radius: 8px;
  margin-top: 10px;
  font-size: 12px;
  max-height: 300px;
  overflow: auto;
  white-space: pre-wrap;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: #1f2937;
  color: #fff;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  max-width: 340px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* registry: party name with its Hindi / Urdu form */
.rg-name + .rg-name { margin-top: 4px; }
.rg-name small { display: block; color: #64748b; font-size: 11px; }

/* Khatiyan -> Scanned pages (1972) */
.rs72-form { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.rs72-fields { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.rs72-fields label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
.rs72-fields input[type="text"] { padding: 7px 9px; border: 1px solid #d7dbe0; border-radius: 6px; font: inherit; }
.rs72-viewer { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rs72-zoombar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rs72-zoompct { min-width: 46px; text-align: center; font-size: 13px; font-variant-numeric: tabular-nums; }
.rs72-drop { position: relative; height: 460px; border: 2px dashed #b6c2cf; border-radius: 10px; background: #f8fafc; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; outline: none; touch-action: none; }
.rs72-drop:focus, .rs72-drop.over { border-color: #14532d; background: #f0fdf4; }
.rs72-drop.has-img { cursor: grab; background: #e5e7eb; }
.rs72-drop.has-img.panning { cursor: grabbing; }
/* zoom / pan: the image is placed with a transform (app.js rs72View) */
.rs72-drop img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; user-select: none; display: block; }
.rs72-drop-hint { color: #6b7280; text-align: center; font-size: 14px; line-height: 1.6; padding: 20px; }
.rs72-check { margin: 4px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.rs72-chip { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #dcfce7; color: #14532d; font-size: 12px; white-space: nowrap; margin: 1px 0; }
.rs72-chip.missing { background: #fee2e2; color: #991b1b; }
/* Registry: "Create Khesra Report" tick (shared by Read deeds + Paste a deed) */
.rg-make-report { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; }
.rg-make-report input { width: auto; margin: 0; }
.rs72-thumb { width: 120px; max-height: 80px; object-fit: cover; border: 1px solid #e5e7eb; border-radius: 4px; display: block; }

/* Admin login + users (app.js "Admin login" / "Users") */
.auth-overlay { position: fixed; inset: 0; z-index: 5000; background: #f3f4f6; display: flex; align-items: center; justify-content: center; padding: 16px; }
.auth-overlay[hidden], .auth-box[hidden], .auth-box label[hidden] { display: none; }
.auth-box { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 26px 24px; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.auth-brand { font-size: 20px; font-weight: 800; color: #14532d; text-align: center; margin-bottom: 4px; }
.auth-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
.auth-box input { padding: 9px 10px; border: 1px solid #d7dbe0; border-radius: 6px; font: inherit; }
.topbar { display: flex; align-items: center; justify-content: space-between; }
.user-menu { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #e5e7eb; }
.user-menu[hidden] { display: none; }
.user-menu .link-btn { color: #fff; }
/* a normal user: no Master Data editing, Village Setup or System */
body.role-user #page-master .add-row,
body.role-user #col-panchayat,
body.role-user .tab[data-tab="villageSetup"],
body.role-user .nav-item[data-page="system"],
body.role-user .nav-item[data-page="customers"],
body.role-user:not(.role-manager) .nav-item[data-page="users"] { display: none !important; }
/* a manager manages their own team, nothing else */
body.role-manager #ufRoleRow, body.role-manager #ufManagerRow { display: none !important; }
.user-type { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.user-type.manager { background: #ede9fe; color: #5b21b6; }
.user-type.super { background: #dcfce7; color: #166534; }
#ufCopyRow[hidden] { display: none; }
.perm-hidden { display: none !important; }
.view-only-note { margin: 0 0 10px; padding: 8px 12px; border: 1px solid #fcd34d; background: #fffbeb; color: #92400e; border-radius: 8px; font-size: 13px; }
.user-form { margin-top: 14px; padding: 14px; border: 1px solid #e5e7eb; border-radius: 10px; background: #fafafa; }
.user-form[hidden] { display: none; }
.user-form h3 { margin: 0 0 10px; }
.user-form h4 { margin: 14px 0 6px; font-size: 13px; }
.user-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.user-form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; color: #374151; }
.user-form-grid input[type="text"], .user-form-grid select { padding: 7px 9px; border: 1px solid #d7dbe0; border-radius: 6px; font: inherit; }
#ufManagerRow[hidden], #ufTeamBox[hidden] { display: none; }
.manager-only { display: none !important; }
body.role-manager .manager-only { display: inline-block !important; }
.uf-villages { margin-top: 6px; max-height: 220px; overflow: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; font-size: 13px; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px; }
.uf-villages label { display: flex; gap: 6px; align-items: baseline; }
.uf-villages .uf-place { color: #6b7280; font-size: 11px; }
.uf-tabs td, .uf-tabs th { text-align: center; }
.uf-tabs td:nth-child(-n+2), .uf-tabs th:nth-child(-n+2) { text-align: left; }

/* Users -> Activity */
.act-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.act-filters select, .act-filters input[type="text"], .act-filters input[type="date"] { padding: 6px 8px; border: 1px solid #d7dbe0; border-radius: 6px; font: inherit; font-size: 13px; }
.act-filters input[type="text"] { min-width: 220px; }
.act-table td { font-size: 12.5px; vertical-align: top; }
.act-table tr.act-row { cursor: pointer; }
.act-table tr.act-row:hover { background: #f9fafb; }
.act-kind { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.act-kind.signin { background: #e0e7ff; color: #3730a3; }
.act-kind.nav { background: #f3f4f6; color: #4b5563; }
.act-kind.view, .act-kind.search { background: #ecfeff; color: #0e7490; }
.act-kind.change { background: #dcfce7; color: #166534; }
.act-kind.job { background: #fef3c7; color: #92400e; }
.act-kind.refused { background: #fee2e2; color: #991b1b; }
.act-detail td { background: #fafafa; font-size: 12px; }
.act-detail table { border-collapse: collapse; margin: 4px 0; }
.act-detail th, .act-detail td td { padding: 2px 8px; text-align: left; border-bottom: 1px solid #eee; }
.act-detail .before { color: #991b1b; text-decoration: line-through; }
.act-detail .after { color: #166534; }
.act-dev { color: #6b7280; white-space: nowrap; }
.uf-cascade { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0; font-size: 13px; }
.uf-cascade select { padding: 5px 8px; border: 1px solid #d7dbe0; border-radius: 6px; font: inherit; min-width: 140px; }
.uf-chosen { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; font-size: 12.5px; }
.uf-chosen .chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: #dcfce7; color: #14532d; }
.uf-chosen .chip button { border: 0; background: none; color: #14532d; cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }

/* Excel-like column filters (app.js attachColumnFilters) */
.col-filter-row th { padding: 3px 4px !important; background: #f9fafb; }
.col-filter-row input { width: 100%; min-width: 60px; box-sizing: border-box; padding: 4px 6px; border: 1px solid #d7dbe0; border-radius: 4px; font: inherit; font-size: 12px; font-weight: 400; }
.col-filter-row input.on { border-color: #15803d; background: #f0fdf4; }
.col-filter-note { margin-top: 4px; }
