/* AVMS portal – नागरी विकास मंच brand (forest, saffron, warm cream; Mukta) */
@font-face { font-family: "Mukta"; src: url("fonts/Mukta-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Mukta"; src: url("fonts/Mukta-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Mukta"; src: url("fonts/Mukta-ExtraBold.ttf") format("truetype"); font-weight: 800; font-display: swap; }
@font-face { font-family: "Noto Nastaliq Urdu"; src: url("fonts/NotoNastaliqUrdu.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }

:root {
  --surface: #FBF6EC; --surface-2: #F1E6D2; --line: #D9CBB3; --field: #9C8468;
  --ink: #3A1F14; --ink-muted: #6B5446; --forest: #1F5E3B; --forest-2: #2D7A4F; --forest-tint: #DDF0E3;
  --saffron: #E8751A; --saffron-text: #8E420A; --saffron-tint: #FCE6D2;
  --danger: #A3321F; --danger-tint: #F9E3DF; --white: #FFFFFF;
  --r-sm: 4px; --r-md: 8px; --r-lg: 16px;
  --font: "Mukta", "Noto Sans Devanagari", "FreeSans", system-ui, sans-serif;
}
html[lang="ur"] { --font: "Noto Nastaliq Urdu", "Mukta", system-ui, sans-serif; }
html[lang="ur"] body { line-height: 2.1; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--surface); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.55; min-height: 100vh; }
a { color: var(--forest); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--saffron); outline-offset: 2px; }
.skip { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }   /* not left:-9999px: that scrolls in RTL */
.skip:focus { width: auto; height: auto; clip: auto; inset-inline-start: 8px; top: 8px; z-index: 100; background: var(--white); padding: 8px 12px; border-radius: var(--r-md); }
.boot { padding: 40px; text-align: center; color: var(--ink-muted); }
.muted { color: var(--ink-muted); }
.small { font-size: 14px; }
.mono { font-family: "DejaVu Sans Mono", ui-monospace, monospace; letter-spacing: .5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
[hidden] { display: none !important; }

/* header */
.top { background: var(--forest); color: var(--white); position: sticky; top: 0; z-index: 10; }
.top-in { max-width: 1320px; margin: 0 auto; padding: 10px 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; }
.brand { display: flex; flex-direction: column; line-height: 1.2; text-decoration: none; color: var(--white); }
.brand b { font-size: 22px; font-weight: 800; }
.brand span { font-size: 12px; letter-spacing: 1px; color: #D8EEDD; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; order: 3; flex-basis: 100%; margin: -4px 0 -2px; margin-inline-start: -12px; }
.top-in > .brand { flex-grow: 1; }
.nav a { color: var(--white); text-decoration: none; padding: 8px 12px; border-radius: var(--r-md); }
.nav a[aria-current="page"] { background: var(--forest-2); font-weight: 700; }
.top select { height: 40px; border: 1px solid #A8D8B5; border-radius: var(--r-md); background: #14432A; color: var(--white); padding: 0 8px; }
.top label { display: flex; flex-direction: column; font-size: 12px; color: #D8EEDD; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.who .av { width: 34px; height: 34px; border-radius: 50%; background: var(--saffron); color: var(--ink); display: grid; place-items: center; font-weight: 800; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 12px; font-size: 13px; font-weight: 700; }
.pill.sync { background: var(--saffron-tint); color: var(--saffron-text); }
.pill.off { background: #EDE6DA; color: #5A463A; }
.btn-ghost-light { background: transparent; border: 1px solid #A8D8B5; color: var(--white); border-radius: var(--r-md); height: 36px; padding: 0 10px; cursor: pointer; }

main { max-width: 1320px; margin: 0 auto; padding: 24px 20px 64px; position: relative; }
h1 { margin: 0; font-size: 30px; line-height: 1.25; font-weight: 800; color: var(--forest); }
h2 { margin: 0 0 12px; font-size: 20px; font-weight: 800; color: var(--forest); }
h3 { margin: 0 0 8px; font-size: 17px; font-weight: 800; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex-grow: 1; }

/* buttons & inputs */
.btn { height: 44px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid var(--field); background: var(--white); color: var(--forest); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.btn.primary { background: var(--forest); border-color: var(--forest); color: var(--white); }
.btn.danger { color: var(--danger); border-color: #C9A79E; }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: var(--white); }
.btn.link { border: none; background: none; height: auto; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field input, .field select, .field textarea { height: 44px; padding: 0 12px; border: 1px solid var(--field); border-radius: var(--r-sm); background: var(--white); font-size: 16px; }
.field textarea { height: auto; min-height: 80px; padding: 10px 12px; }
.field .hint { font-size: 14px; color: var(--ink-muted); font-weight: 400; }
.field .err, .err { color: var(--danger); font-size: 14px; font-weight: 400; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--forest); flex-shrink: 0; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button { height: 44px; padding: 0 14px; border: 1px solid var(--field); border-radius: 22px; background: var(--white); cursor: pointer; }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--forest); color: var(--white); border-color: var(--forest); font-weight: 700; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }

/* cards & layout */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.card.warn { background: var(--saffron-tint); border-color: var(--saffron); }
.cols { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tag { display: inline-flex; padding: 2px 10px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 14px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-sm); font-weight: 700; font-size: 14px; }
.status.verified { background: var(--forest-tint); color: var(--forest); }
.status.pending { background: var(--saffron-tint); color: var(--saffron-text); }
.status.unverified { background: var(--surface-2); color: var(--ink-muted); }
.status.removed { background: #EDE6DA; color: #5A463A; }
.notice { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); font-size: 14px; }
.notice.bad { background: var(--danger-tint); color: #7A2416; font-weight: 700; }

/* table */
.table-wrap { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { background: var(--surface-2); text-align: start; padding: 11px 14px; font-weight: 700; white-space: nowrap; }
td { padding: 11px 14px; border-top: 1px solid #E8DCC6; vertical-align: top; }
td .sub { color: var(--ink-muted); font-size: 14px; }
.empty { padding: 36px; text-align: center; color: var(--ink-muted); }

/* family tree */
.tree { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tree-row { display: flex; justify-content: center; gap: 14px; flex-wrap: wrap; }
.tree-link { width: 2px; height: 18px; background: var(--field); }
.node { min-width: 170px; max-width: 220px; padding: 10px 12px; border-radius: 12px; border: 2px solid #3E8E5A; background: var(--white); text-align: center; cursor: pointer; }
.node.root { background: var(--forest); color: var(--white); border-color: var(--forest); cursor: default; }
.node.pending { border-color: var(--saffron); background: #FFF6EC; }
.node.removed { border-color: var(--field); background: #EDE6DA; }
.node.out { border-style: dashed; border-color: var(--field); cursor: default; }
.node b { display: block; font-size: 16px; }
.node span { font-size: 13px; }

/* map placeholder */
.map { position: relative; height: 150px; border-radius: var(--r-md); background:
  linear-gradient(0deg, transparent 47%, #fff 47%, #fff 53%, transparent 53%),
  linear-gradient(90deg, transparent 30%, #fff 30%, #fff 34%, transparent 34%, transparent 70%, #fff 70%, #fff 74%, transparent 74%), #EFE7D6; }
.map .pin { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -22px 0 0 -11px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--saffron); border: 3px solid var(--white); }

/* dialog */
dialog { border: none; border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100vw - 24px)); box-shadow: 0 20px 50px rgba(35,22,14,.3); }
dialog::backdrop { background: rgba(35,22,14,.55); }
.dlg { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; }
.dlg-head h2 { flex-grow: 1; margin: 0; color: var(--ink); }
.dlg-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.icon-btn { width: 44px; height: 44px; border: none; border-radius: var(--r-md); background: var(--surface-2); cursor: pointer; font-size: 20px; }

/* toast & watermark */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: var(--r-md); box-shadow: 0 10px 30px rgba(35,22,14,.3); max-width: calc(100vw - 32px); }
.toast.bad { background: #7A2416; }
.wm { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; opacity: .04; user-select: none; }
.wm-in { position: absolute; inset: -20%; display: flex; flex-wrap: wrap; gap: 90px 130px; padding: 40px; transform: rotate(-18deg); font-weight: 800; font-size: 17px; color: var(--ink); }

/* login */
.login { max-width: 420px; margin: 8vh auto; }
.login .card { display: flex; flex-direction: column; gap: 16px; padding: 28px; }
.login h1 { font-size: 28px; }

@media (max-width: 860px) {
  .cols, .g2, .g3 { grid-template-columns: minmax(0, 1fr); }
  .span2, .span3 { grid-column: auto; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  h1 { font-size: 26px; }
  .hide-sm { display: none; }
}
@media print { .top, .wm { display: none; } }
a.node { color: inherit; text-decoration: none; display: block; }
.node.root, .node.root.pending, .node.root.removed { background: var(--forest); color: var(--white); border-color: var(--forest); border-style: solid; }
.grow { flex-grow: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 15px; }
.kv dt { color: var(--ink-muted); }
.kv dd { margin: 0; font-weight: 700; }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); overflow: hidden; min-width: 120px; }
.bar i { display: block; height: 100%; background: var(--forest); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { background: var(--white); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 16px; }
.tile b { display: block; font-size: 28px; color: var(--forest); }
.tile.hot b { color: var(--danger); }

/* Stage 3: polling day, outreach, slips, booth map, admin */
fieldset.plain { border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; margin: 0; }
fieldset.plain legend { font-weight: 700; padding: 0 6px; }
details > summary { cursor: pointer; font-weight: 700; color: var(--forest); }
.seg[role="tablist"] button[aria-selected="true"] { background: var(--forest); color: var(--white); border-color: var(--forest); font-weight: 700; }

.mapcard { padding: 12px; }
.boothmap { width: 100%; height: auto; display: block; border-radius: var(--r-md); }
.bm-bg { fill: #EFE7D6; }
.bm-route { fill: none; stroke: var(--forest-2); stroke-width: 4; stroke-dasharray: 10 8; stroke-linejoin: round; }
.bm-pin circle { fill: var(--forest); stroke: var(--white); stroke-width: 3; }
.bm-pin.pending circle { fill: var(--saffron); }
.bm-pin text { fill: var(--white); font: 800 17px var(--font); }
.bm-pin.pending text { fill: var(--ink); }
.bm-scale rect { fill: var(--ink); }
.bm-scale text, .bm-n { fill: var(--ink); font: 700 15px var(--font); }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--forest); display: inline-block; }
.dot.pending { background: var(--saffron); }

.slip-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.slip { background: var(--white); border: 1.5px dashed var(--field); border-radius: var(--r-md); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.4; break-inside: avoid; }
.slip-head { display: flex; justify-content: space-between; gap: 8px; border-bottom: 2px solid var(--forest); padding-bottom: 4px; color: var(--forest); font-size: 13px; }
.slip-head span { color: var(--saffron-text); font-weight: 700; }
.slip-name { font-size: 20px; font-weight: 800; }
.slip-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 4px; font-weight: 700; text-align: center; }
@media (max-width: 860px) { .slip-sheet { grid-template-columns: minmax(0, 1fr); } }

@media print {
  @page { size: A4; margin: 8mm; }
  body { background: #fff; }
  .no-print, .toast, dialog { display: none !important; }
  main { padding: 0; max-width: none; }
  .slip-sheet { gap: 0; grid-template-columns: 1fr 1fr; }
  .slip { height: 68mm; overflow: hidden; border-radius: 0; font-size: 11.5pt; }
  .slip:nth-child(8n) { break-after: page; }
}

/* Part A · SIR */
.print-only { display: none; }
.review-img { max-width: min(100%, 900px); max-height: 360px; object-fit: contain; align-self: flex-start; height: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--white); }
.worklist td .btn.link { text-align: start; font-weight: 700; }
@media print {
  .print-only { display: block; }
  [role="tablist"], .notice { display: none !important; }
  th.print-only, td.print-only { display: table-cell; }
  .worklist { font-size: 10.5pt; }
  .worklist th, .worklist td { padding: 4px 6px; border: 1px solid #999; }
  .worklist td.remark { width: 28%; }
  .worklist .btn.link { text-decoration: none; color: #000; }
  .table-wrap { border: none; overflow: visible; }
  .worklist tr { break-inside: avoid; }
}
/* Admin · constituencies & parts */
.notice.warn { background: var(--saffron-tint); color: var(--saffron-text); }
tr.sel td { background: var(--forest-tint); }
a.btn { text-decoration: none; }
