:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #1b2420;
  --muted: #5f6b66;
  --line: #dfe5e2;
  --brand: #0f5132;
  --brand-ink: #ffffff;
  --ok: #157347;
  --warn: #b26a00;
  --bad: #b02a37;
  --chip: #e8eeeb;
  --b-current: #3a8f5c;
  --b-1-30: #d6a400;
  --b-31-60: #e07b00;
  --b-61-90: #d1495b;
  --b-90: #8e1b2b;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111614;
    --surface: #1a211e;
    --text: #e6ece9;
    --muted: #9aa7a1;
    --line: #2b3531;
    --brand: #2fa36b;
    --chip: #24302b;
    --ok: #4cc286;
    --warn: #f0a23a;
    --bad: #ef6a77;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); }

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px calc(84px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.25rem; margin: 0; }
h2 { font-size: 1rem; margin: 16px 0 8px; }
h3 { font-size: .95rem; margin: 12px 0 4px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 -16px 8px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--brand);
  color: var(--brand-ink);
}
.topbar h1 { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { color: inherit; text-decoration: none; font-size: 2rem; line-height: 1; padding: 0 6px 4px 0; }
.net { font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: rgb(255 255 255 / .18); color: inherit; text-decoration: none; white-space: nowrap; }
.net.on { background: rgb(255 255 255 / .18); }
.net.sync { background: #b26a00; }
.net.off { background: var(--bad); }
.card .net, h2 .net { font-size: .7rem; vertical-align: middle; color: #fff; background: var(--ok); }
h2 .net.off { background: var(--bad); }
h2 .net.sync { background: var(--warn); }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  color: inherit;
  text-decoration: none;
}
.loan-card:active { transform: scale(.99); }

.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 6px; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.section-head h2 { margin: 8px 0; }

.stats, .grid2 {
  display: grid;
  gap: 8px;
  margin: 8px 0 4px;
}
.stats { grid-template-columns: repeat(4, 1fr); }
.grid2 { grid-template-columns: 1fr 1fr; }
.stat {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  color: inherit;
  text-decoration: none;
  min-width: 0;
}
.stat span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat strong { font-size: 1.05rem; overflow-wrap: anywhere; }
.stat small { color: var(--muted); font-size: .78rem; }
.stat.warn strong { color: var(--warn); }
@media (max-width: 380px) { .stats { grid-template-columns: 1fr 1fr; } }

.badge {
  flex: none;
  font-size: .75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
  color: #fff;
}
.b-current { background: var(--b-current); }
.b-1-30 { background: var(--b-1-30); color: #241c00; }
.b-31-60 { background: var(--b-31-60); }
.b-61-90 { background: var(--b-61-90); }
.b-90\+ { background: var(--b-90); }
.b-closed { background: var(--muted); }

.tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--chip); }
.tag-warn { background: #fff1d6; color: #7a4a00; }
.tag-bad { background: #fde2e5; color: #8e1b2b; }
.tag-ok { background: #d9f2e4; color: #0f5132; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { min-height: 34px; font-size: .85rem; padding: 0 10px; }
.btn.big { min-height: 52px; flex: 1; font-size: 1.05rem; }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1 1 auto; }
.actions.sticky {
  position: sticky;
  bottom: calc(70px + env(safe-area-inset-bottom));
  z-index: 4;
  margin: 12px 0;
  padding: 8px;
  background: var(--bg);
  border-radius: var(--radius);
}

.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.form label.check, .form label.radio { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.form .field { display: flex; flex-direction: column; gap: 4px; }
/* An input with a button beside it, e.g. the PIN with its show/hide eye. */
.with-eye { display: flex; gap: 8px; }
.with-eye input { flex: 1; min-width: 0; }
.btn.eye { min-width: 48px; padding: 0 12px; color: var(--muted); }
input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  width: 100%;
}
input[type=checkbox], input[type=radio] { width: 20px; min-height: 20px; accent-color: var(--brand); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
fieldset.modes { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
fieldset.modes legend { font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
fieldset.modes .radio { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; }
.alert { border-left: 4px solid var(--bad); }
.alert strong { color: var(--bad); }
.struck { text-decoration: line-through; color: var(--muted); }
.warn-note { background: #fff1d6; color: #5c3a00; margin: 10px 0; }
.sync-line { margin: 4px 0 8px; font-size: .88rem; font-weight: 600; }
.sync-line.ok { color: var(--ok); }
.sync-line.warn { color: var(--warn); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 12px 0; }
.facts dt { color: var(--muted); font-size: .88rem; }
.facts dd { margin: 0; text-align: right; font-weight: 500; }
.facts .amount { font-size: 1.3rem; font-weight: 700; }
.tabs a { text-decoration: none; }
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--chip);
  font-size: .88rem;
}
.banner-actions { display: flex; gap: 6px; flex: none; }
.note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--chip); font-size: .88rem; }
.slip-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 120px;
  padding: 10px;
  border: 2px dashed var(--line);
  border-radius: 10px;
  color: var(--text);
  text-align: center;
  cursor: pointer;
}
.slip-preview img, .slip-view img {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 0 auto;
  border-radius: 8px;
  object-fit: contain;
}
.slip-preview span { font-size: .8rem; color: var(--muted); }
.slip-view { margin: 10px 0; text-align: center; }
.error { color: var(--bad); margin: 0; min-height: 1em; font-size: .9rem; }

.search input { margin: 4px 0 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--chip);
  color: var(--text);
  border-radius: 99px;
  padding: 6px 12px;
  font: inherit;
  font-size: .85rem;
  cursor: pointer;
}
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
a.chip { text-decoration: none; }

/* State Heads: my team */
.mt-person { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.mt-dc > .mt-person:first-child { border-top: 0; padding-top: 0; }
.mt-person.off { opacity: .6; }
.mt-who { min-width: 0; flex: 1 1 180px; }
.mt-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.mt-actions form { gap: 6px; }
.mt-agents { margin-left: 12px; }
.mt-rejected { padding: 8px 0; border-top: 1px solid var(--line); }
.mt-msg { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.mt-msg input { flex: 1; }
.bad-text { color: var(--bad); }
.warn-text { color: var(--warn); }

/* Giving accounts to an agent in bulk */
.loan-card.pick, .pin-row { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.loan-card.pick input, .pin-row input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
.pick-body { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.loan-card.pick.locked { opacity: .55; cursor: default; }
.allot-bar { position: sticky; bottom: 72px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: 0 6px 20px rgb(0 0 0 / .12); margin-top: 8px; }
.allot-bar select { flex: 1; min-width: 140px; }

/* WhatsApp message box */
dialog.wa-dialog { width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 32px); border: 0; border-radius: 16px; padding: 18px; background: var(--surface); color: var(--text); }
dialog.wa-dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog.wa-dialog h2 { margin: 0; font-size: 1.1rem; }
.wa-saved { display: flex; flex-wrap: wrap; gap: 6px; max-height: 28vh; overflow-y: auto; }
.wa-saved .chip.mine { display: inline-flex; align-items: center; padding: 0; }
.wa-saved .chip.mine button { border: 0; background: none; font: inherit; color: inherit; padding: 6px 4px 6px 12px; cursor: pointer; }
.wa-saved .chip.mine .x { padding: 6px 10px 6px 4px; opacity: .6; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 12px; position: relative; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
}

details summary { cursor: pointer; font-weight: 600; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; margin-top: 8px; }
th, td { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.schedule tr.paid td { color: var(--muted); }
.schedule tr.late td:last-child { color: var(--bad); font-weight: 600; }
.kv td:last-child { text-align: right; font-weight: 600; }

.big-number { font-size: 2rem; font-weight: 700; color: var(--ok); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 7.5em 1fr auto; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-size: .85rem; }
.bar-track { height: 12px; background: var(--chip); border-radius: 99px; overflow: hidden; }
.bar { display: block; height: 100%; border-radius: 99px; }
.bar-val { color: var(--muted); white-space: nowrap; }

.receipt dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; margin: 14px 0; }
.receipt dt { color: var(--muted); font-size: .88rem; }
.receipt dd { margin: 0; text-align: right; font-weight: 500; }
.receipt .amount { font-size: 1.3rem; font-weight: 700; color: var(--ok); }

.setup { text-align: center; padding-top: 48px; }
.setup .form { text-align: left; margin-top: 16px; }

/* Language picker: top of the login screen and in Settings. */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.setup { position: relative; }
.setup-lang { display: flex; justify-content: flex-end; margin: -32px 0 8px; }
.lang-toggle { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.lang-toggle button {
  min-height: 38px; padding: 0 14px; border: 0; border-radius: 999px;
  background: none; color: var(--text); font: inherit; font-size: .95rem; font-weight: 600; cursor: pointer;
}
.lang-toggle button[aria-pressed="true"] { background: var(--brand); color: #fff; }
.lang-toggle button:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; }
.lang-toggle.wide { display: flex; }
.lang-toggle.wide button { flex: 1; }
.logo {
  width: 72px; height: 72px; margin: 0 auto 12px;
  display: grid; place-items: center;
  border-radius: 20px; background: var(--brand); color: #fff;
  font-size: 40px; font-weight: 700;
}

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr; /* four tabs, or five for State Heads */
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 10px;
  font-size: .75rem;
  color: var(--muted);
  text-decoration: none;
}
.nav a span { font-size: 1.25rem; }
.nav a.active { color: var(--brand); font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 10px;
  background: #1b2420;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transition: .2s;
  z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); }
.toast.warn { background: #8a5300; }
img.logo { display: block; background: none; }

@media print {
  .topbar, .nav, .actions, .toast { display: none !important; }
  body { background: #fff; }
  .receipt { border: 1px dashed #000; }
}

/* ---------- help & guides ---------- */
.help-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgb(255 255 255 / .2);
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}
.help-item { display: flex; flex-direction: column; gap: 2px; }
/* Video guides (Google Drive player, portrait reels) */
.video-entry { border-left: 4px solid var(--brand); }
.video-item { flex-direction: row; align-items: center; gap: 12px; }
.video-no { flex: none; width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font-weight: 700; }
.video-frame { width: min(100%, calc(68vh * 9 / 16)); aspect-ratio: 9 / 16; margin: 8px auto 12px; background: #000; border-radius: var(--radius); overflow: hidden; }
.video-frame iframe { display: block; width: 100%; height: 100%; border: 0; }
.help-article { line-height: 1.55; }
.help-article h4 { margin: 14px 0 6px; font-size: .95rem; }
.help-article ul, .help-article ol { padding-left: 20px; margin: 6px 0; }
.help-article li { margin-bottom: 6px; }
.help-steps { counter-reset: step; list-style: none; padding-left: 0 !important; }
.help-steps li { counter-increment: step; position: relative; padding-left: 36px; min-height: 26px; }
.help-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: .8rem;
  font-weight: 700;
}
.help-tips { margin-top: 12px; padding: 10px 12px; border-radius: 10px; background: var(--chip); font-size: .9rem; }
.help-tips ul { margin: 4px 0 0; }
.help-table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 8px 0; }
.help-table th, .help-table td { border-bottom: 1px solid var(--line); padding: 6px 4px; text-align: left; vertical-align: top; }
.help-dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; margin: 0; }
.help-dl dt { font-weight: 700; }
.help-dl dd { margin: 0; }
@media print {
  .help-article { border: 0; }
  .help-btn { display: none; }
}

/* Team dashboard: ageing bands from 0–30 days to over 2 years */
.age-0 { background: var(--b-current); }
.age-1 { background: var(--b-1-30); }
.age-2 { background: var(--b-31-60); }
.age-3 { background: var(--b-61-90); }
.age-4 { background: #b23a4c; }
.age-5 { background: var(--b-90); }
.age-6 { background: #5c0f1c; }
.report { width: 100%; border-collapse: collapse; margin-top: 8px; }
.report th { text-align: left; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 4px 0; border-bottom: 1px solid var(--line); }
.report th:last-child { text-align: right; }
.report td { padding: 5px 0; border-bottom: 1px solid var(--line); }
a.stat { color: inherit; text-decoration: none; }
#desk-date, #desk-under { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); max-width: 60vw; }
#assign-form select { flex: 1; font: inherit; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); }
#assign-form { gap: 8px; }

/* ID cards: the card's two sides, the crop frames (photo 4 : 5 with an oval for the face, signature 3 : 1), approvals */
.idc-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.idc-sides img { width: 100%; height: auto; aspect-ratio: 540 / 856; border-radius: 10px; background: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.idc-crop { position: relative; margin: 10px auto 6px; border-radius: 8px; overflow: hidden; background: #dde4ec; }
.idc-crop canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.idc-crop-photo { width: 240px; height: 300px; }
.idc-crop-sign { width: 300px; height: 100px; background: #fff; border: 1px solid var(--line); }
.idc-guide { position: absolute; left: 50%; top: 42%; width: 150px; height: 190px; transform: translate(-50%, -50%); border: 2px dashed rgba(255, 255, 255, .95); border-radius: 50%; box-shadow: 0 0 0 999px rgba(0, 0, 0, .18); pointer-events: none; }
.idc-now { text-align: center; margin: 6px 0; }
.idc-photo { width: 96px; height: 120px; object-fit: cover; border-radius: 6px; background: #dde4ec; }
.idc-sign { display: block; width: 150px; height: 50px; object-fit: contain; margin: 6px auto 0; background: #fff; border: 1px solid var(--line); border-radius: 4px; }
.idc-who { display: flex; gap: 12px; align-items: flex-start; }
.idc-who .idc-photo { flex: none; width: 72px; height: 90px; }
.idc-who .idc-sign { margin: 6px 0 0; }
.idc-req .form { margin-top: 10px; }

/* Settings: who is signed in, with their ID card photo */
.me-card { display: flex; gap: 14px; align-items: flex-start; }
.me-photo { width: 72px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line, #ddd); flex: none; background: #eee; }
.me-who { min-width: 0; flex: 1; }
.me-who .actions { margin-top: 8px; }

/* WhatsApp box: Mr or Ms, confirmed before a message that starts with it */
fieldset.wa-gender { border: 0; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
fieldset.wa-gender legend { font-size: .9rem; color: var(--muted); margin-bottom: 4px; padding: 0; }
fieldset.wa-gender .radio { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
fieldset.wa-gender .radio:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 10%, var(--bg)); }

/* EMIs from a lender's repayment schedule */
.tag-info { background: #e2edfb; color: #1c4f8f; }
.emi-box h2, .emi-card h2 { margin: 0 0 8px; font-size: 1rem; }
.emi-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.emi-stats .stat { text-align: center; padding: 8px 4px; }
.emi-stats .stat span { text-transform: none; letter-spacing: 0; font-size: .72rem; }
.emi-stats .stat strong { font-size: 1.2rem; }
.stat.bad strong { color: var(--bad, #b02a37); }
.stat.info strong { color: #1c5cab; }
.emi-card p { margin: 6px 0; }
@media (prefers-color-scheme: dark) { .tag-info { background: #1d3550; color: #b5d4f4; } .stat.info strong { color: #85b7eb; } }
/* My team: people by state */
table.by-state { width: 100%; border-collapse: collapse; font-size: .85rem; }
table.by-state th, table.by-state td { padding: 5px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.by-state .num { text-align: right; }
.chips + .chips { margin-top: 6px; }

/* Accounts: the Filters section (state list and chips), folded away by default */
details.filters { padding: 10px 12px; margin: 0 0 8px; }
details.filters > summary, details.fold > summary { display: flex; align-items: center; gap: 10px; list-style: none; font-weight: 600; }
details.filters > summary::-webkit-details-marker, details.fold > summary::-webkit-details-marker { display: none; }
details.filters > summary::after, details.fold > summary::after { content: '▾'; color: var(--muted); }
details.filters[open] > summary::after, details.fold[open] > summary::after { content: '▴'; }
details.filters[open] > summary, details.fold[open] > summary { margin-bottom: 10px; }
/* My team: a DC's districts, ticked from the districts of the accounts */
details.dist-fold { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
details.dist-fold fieldset.modes { margin-bottom: 10px; }
.dist-name { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; min-width: 0; }
.dist-name .warn-text { flex-basis: 100%; }
.filters-now { flex: 1; min-width: 0; text-align: right; font-weight: 400; font-size: .85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filters-now.on { color: var(--brand); font-weight: 600; }
details.filters .chips { flex-wrap: wrap; overflow: visible; padding-bottom: 0; }
details.filters .chips + .chips { margin-top: 8px; }
/* State and district side by side, then DC and agent; each with its name above */
.fsel-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 0 0 10px; }
.fsel { display: flex; flex-direction: column; gap: 3px; min-width: 0; font-size: .8rem; color: var(--muted); }
.fsel select { width: 100%; min-width: 0; }

/* State Heads: reports */
.rep-kinds { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); margin: 2px 0 4px; }
.rep-kinds a { flex: none; padding: 8px 10px; color: var(--muted); text-decoration: none; font-size: .88rem; border-bottom: 2px solid transparent; }
.rep-kinds a.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.rep-dates { gap: 8px; }
.rep-dates label { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rep-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.rep-row a { color: inherit; }
.rep-right { text-align: right; white-space: nowrap; }
.rep-scroll { overflow-x: auto; }
.rep-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.rep-table th, .rep-table td { padding: 6px 4px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rep-table th { color: var(--muted); font-weight: 600; font-size: .72rem; }
.rep-table th:first-child, .rep-table td:first-child { text-align: left; }
.rep-table tr.muted td { color: var(--muted); }
.rep-files .btn { flex: 1; }

/* A State Head's report saved as PDF: laid out for A4 in #print-report, and only that is printed while it is there */
#print-report { display: none; }
@media print {
  @page { size: A4; margin: 12mm 10mm; }
  body.print-report { background: #fff; padding: 0; }
  body.print-report > :not(#print-report) { display: none !important; }
  body.print-report #print-report { display: block; }
}
#print-report { color: #000; background: #fff; font: 9.5pt/1.35 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; }
#print-report .pr-head { border-bottom: 2px solid #0f5132; padding-bottom: 6px; margin-bottom: 8px; }
#print-report .pr-org { color: #0f5132; font-weight: 700; font-size: 8.5pt; letter-spacing: .04em; text-transform: uppercase; }
#print-report h1 { font-size: 16pt; margin: 2px 0 4px; }
#print-report h2 { font-size: 11pt; margin: 14px 0 4px; break-after: avoid; }
#print-report p { margin: 2px 0; }
#print-report .pr-small, #print-report .pr-note { color: #444; font-size: 8pt; }
#print-report .pr-note { margin-top: 8px; }
#print-report .pr-figs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 8px 0 4px; }
#print-report .pr-figs div { border: 1px solid #c8d3cd; border-radius: 4px; padding: 4px 6px; break-inside: avoid; }
#print-report .pr-figs span, #print-report .pr-figs small { display: block; font-size: 7.5pt; color: #444; }
#print-report .pr-figs strong { display: block; font-size: 12pt; }
#print-report table { width: 100%; border-collapse: collapse; font-size: 8.5pt; }
#print-report thead { display: table-header-group; }
#print-report th { text-align: left; background: #0f5132; color: #fff; padding: 3px 4px; font-weight: 600; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
#print-report td { padding: 2.5px 4px; border-bottom: 1px solid #d9e0dc; vertical-align: top; }
#print-report tr { break-inside: avoid; }
#print-report tbody tr:nth-child(even) td { background: #f2f6f4; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
#print-report .n { text-align: right; white-space: nowrap; }
#print-report table.pr-narrow { width: auto; min-width: 55%; }
#print-report table.pr-narrow th, #print-report table.pr-narrow td { padding-right: 18px; }
