:root {
  --bg: #f5f4fa; --surface: #fff; --text: #1c1838; --muted: #625d7d; --line: #e2dfef;
  --brand: #6d3fd6; --brand-2: #2563eb; --ok: #157a46; --bad: #b42323; --warn: #a15c07;
  --code-bg: #efecf8;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0d1f; --surface: #1a1730; --text: #ece9fb; --muted: #a7a2c6; --line: #2d2950;
    --brand: #a78bfa; --brand-2: #60a5fa; --ok: #4ade80; --bad: #f87171; --warn: #fbbf24; --code-bg: #26224a; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
h1, h2, h3 { line-height: 1.25; }
h3 { margin: 18px 0 8px; font-size: 15px; }

.bar { position: sticky; top: 0; z-index: 5; background: linear-gradient(110deg, #2563eb, #6d3fd6 60%, #a21caf); color: #fff; }
.bar-in { display: flex; align-items: center; gap: 16px; padding: 10px 16px; max-width: 1400px; margin: 0 auto; flex-wrap: wrap; }
.bar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.bar nav button { background: transparent; color: #fff; border: 0; padding: 8px 12px; border-radius: 8px; font: inherit; cursor: pointer; opacity: .85; }
.bar nav button.on, .bar nav button:hover { background: rgba(255,255,255,.18); opacity: 1; }
.who { margin-left: auto; opacity: .9; }
.bar .ghost { color: #fff; border-color: rgba(255,255,255,.5); }

main { max-width: 1400px; margin: 0 auto; padding: 20px 16px 60px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }

button, select, input, textarea { font: inherit; color: var(--text); }
button { cursor: pointer; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 8px 14px; min-height: 38px; }
button:hover { border-color: var(--brand); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.bad { background: transparent; border-color: var(--bad); color: var(--bad); }
button.ghost { background: transparent; }
@media (prefers-color-scheme: dark) { button.primary, button.ok { color: #0f0d1f; } }
select, input, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
textarea { width: 100%; resize: vertical; margin: 8px 0; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.login { max-width: 380px; margin: 60px auto; }
.login h1 { margin-top: 0; }
.login label { display: flex; flex-direction: column; gap: 4px; margin: 0 0 12px; font-weight: 600; }
.login button { width: 100%; }
.msg { margin: 8px 0; }
.msg.err { color: var(--bad); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 14px; }
.filters input { flex: 1 1 240px; }
.count { color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 460px; gap: 16px; align-items: start; }
.split:has(.detail[hidden]) { grid-template-columns: 1fr; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.grid { width: 100%; border-collapse: collapse; }
.grid th, .grid td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid th { position: sticky; top: 0; background: var(--surface); color: var(--muted); font-weight: 600; font-size: 13px; }
.grid tbody tr { cursor: pointer; }
.grid tbody tr:hover, .grid tbody tr:focus { background: var(--code-bg); outline: none; }
.grid td.num { text-align: right; font-variant-numeric: tabular-nums; }
.grid td.trunc { max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.grid td.actions { display: flex; gap: 6px; }
.empty { padding: 20px; color: var(--muted); margin: 0; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--code-bg); }
.kyc-verified, .st-approved, .st-paid { color: var(--ok); }
.kyc-failed, .st-rejected, .st-cancelled { color: var(--bad); }
.st-batched, .st-submitted { color: var(--brand-2); }
.kyc-unchecked, .st-pending, .st-draft { color: var(--warn); }

.detail { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow-y: auto; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.detail-head h2 { margin: 0; font-size: 18px; }
.kvs { margin: 12px 0; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { overflow-wrap: anywhere; }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.doc { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; }
.doc small { color: var(--muted); }
.doc img { width: 100%; border-radius: 6px; cursor: zoom-in; }
.doc img:hover { position: relative; z-index: 3; transform: scale(2.2); transform-origin: top left; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.row input { width: 140px; }
.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; color: var(--muted); }
.hist li { padding: 3px 0; }

.totals { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 0 0 16px; }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 14px; }
.stat span { color: var(--muted); font-size: 13px; }
.totals .stat:first-child { grid-column: 1 / -1; }
.pillar-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.pillar h3 { margin: 0 0 10px; font-size: 18px; }
.meter { height: 8px; border-radius: 999px; background: var(--code-bg); overflow: hidden; margin: 0 0 10px; }
.meter span { display: block; height: 100%; background: var(--c, var(--brand)); }
.p-employment { --c: #2b6de0; } .p-food { --c: #1f9d55; } .p-healthcare { --c: #d63a3a; } .p-housing { --c: #e07a1f; }
.p-education { --c: #7c3aed; } .p-judicial { --c: #0e8f9a; } .p-safety { --c: #c0267d; }
.pillar { border-top: 4px solid var(--c); }

#tab-batches .card { margin: 0 0 16px; }
#tab-batches h2 { margin-top: 0; }

.toast { position: fixed; right: 16px; bottom: 16px; z-index: 20; max-width: 420px; padding: 12px 16px; border-radius: 10px; background: #1c1838; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }

@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
}
