/* Layout: survey-office console. Slim top bar with section tabs; insight pages are a single reading column of
   cards (two-up on wide screens); the map view keeps a search sidebar beside a full-height map. */
:root {
  --bg: #e9edee;            /* slate paper */
  --panel: #fbfcfc;
  --ink: #1b2428;
  --ink-2: #3d4a50;
  --muted: #5a686e;
  --line: #d3dbde;
  --grid: #e3e8ea;
  --accent: #a9532a;        /* copper ore */
  --accent-ink: #ffffff;
  --soft: #f3e6df;
  --ok: #2f7d4f;  --ok-bg: #e2f1e7;
  --warn: #9a6608; --warn-bg: #f8eccf;
  --bad: #b23a2e; --bad-bg: #f8e1de;
  --s1: #2a78d6;            /* series 1: approved */
  --s2: #eb6834;            /* series 2: under process */
  --s3: #8c979c;            /* inactive (neutral) */
  --font-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --bar: #1b2428;          /* top bar stays dark in both themes, like the app icon */
  --bar-ink: #f3f6f7;
  --panel-w: 400px;
  --bar-h: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1416; --panel: #161d20; --ink: #e2e8ea; --ink-2: #c3ccd0; --muted: #94a3a9; --line: #29343a; --grid: #222b30;
    --accent: #e0895a; --accent-ink: #1a0f09; --soft: #3a2519;
    --ok: #6cc290; --ok-bg: #173225; --warn: #e2b04a; --warn-bg: #3a2c0c; --bad: #f07a6c; --bad-bg: #3e1a16;
    --s1: #3987e5; --s2: #d95926; --s3: #6d7a80; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1416; --panel: #161d20; --ink: #e2e8ea; --ink-2: #c3ccd0; --muted: #94a3a9; --line: #29343a; --grid: #222b30;
  --accent: #e0895a; --accent-ink: #1a0f09; --soft: #3a2519;
  --ok: #6cc290; --ok-bg: #173225; --warn: #e2b04a; --warn-bg: #3a2c0c; --bad: #f07a6c; --bad-bg: #3e1a16;
  --s1: #3987e5; --s2: #d95926; --s3: #6d7a80; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-body); display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.mono { font-family: var(--font-mono); font-size: 12.5px; font-variant-numeric: tabular-nums; }
h1, h2, h3 { text-wrap: balance; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 1000; flex: none;
  display: flex; align-items: center; gap: 20px; min-height: var(--bar-h);
  background: var(--bar); color: var(--bar-ink); border-bottom: 1px solid var(--line);
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bar); }
.logo { font-family: var(--font-display); font-stretch: 78%; font-weight: 800; font-size: 22px; color: inherit; text-decoration: none; letter-spacing: 0.01em; white-space: nowrap; }
.tabs { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; min-width: 0; }
.tabs a { color: inherit; opacity: 0.72; text-decoration: none; padding: 15px 12px 13px; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs a:hover { opacity: 1; }
.tabs a[aria-current="page"] { opacity: 1; border-bottom-color: var(--accent); }
.asof { margin-left: auto; opacity: 0.7; font-size: 12px; white-space: nowrap; }

/* ---------- pages ---------- */
.page {
  width: 100%; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 26px 36px;
}
.intro h1 { font-family: var(--font-display); font-stretch: 80%; font-weight: 800; font-size: clamp(26px, 4vw, 36px); line-height: 1.05; margin: 0 0 8px; }
.lede { margin: 0; max-width: 68ch; color: var(--ink-2); font-size: 15px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.card h2 { font-family: var(--font-display); font-stretch: 85%; font-weight: 700; font-size: 18px; margin: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.note { margin: 0; color: var(--muted); font-size: 12.5px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.page-foot { padding: 14px max(16px, env(safe-area-inset-right, 0px)) 18px max(16px, env(safe-area-inset-left, 0px)); font-size: 12px; color: var(--muted); text-align: center; }

.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--accent-ink); border-radius: 8px; padding: 9px 16px; cursor: pointer; font-weight: 600; white-space: nowrap; }
.btn.ghost, .ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover, .ghost:hover { border-color: var(--accent); color: var(--accent); }
.ghost { border-radius: 6px; padding: 3px 9px; font-size: 12.5px; cursor: pointer; }
.searchrow { display: flex; gap: 8px; margin-top: 14px; max-width: 640px; flex-wrap: wrap; }
.searchrow input, .searchrow select { flex: 1 1 260px; min-width: 0; }
input[type="search"], select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
input[type="search"]:focus, select:focus { border-color: var(--accent); outline: none; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .v { font-family: var(--font-display); font-stretch: 85%; font-weight: 800; font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.kpi .k { font-weight: 600; font-size: 13.5px; }
.kpi .d { color: var(--muted); font-size: 12px; }
.kpi.warn .v { color: var(--warn); }
.kpi.bad .v { color: var(--bad); }
.kpi a { color: inherit; text-decoration: none; }
.kpi:has(a):hover { border-color: var(--accent); }

.findings ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; max-width: 90ch; }
.findings b { font-variant-numeric: tabular-nums; }

/* ---------- charts (HTML bars) ---------- */
.legend-inline { display: inline-flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend-inline i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 4px; }
.hb { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 10px; padding: 3px 4px; border-radius: 6px; background: transparent; border: 0; text-align: left; width: 100%; }
button.hb { cursor: pointer; }
button.hb:hover { background: var(--bg); }
.hb .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb .track { display: flex; gap: 2px; height: 14px; }
.hb .seg { height: 100%; min-width: 2px; }
.hb .seg:last-child { border-radius: 0 4px 4px 0; }
.hb .val { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); min-width: 3ch; text-align: right; }

.cols { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; align-items: end; height: 190px; padding-top: 18px; border-bottom: 1px solid var(--line); position: relative; }
.col { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; position: relative; min-width: 0; }
.col .bar { width: 72%; max-width: 30px; background: var(--s1); border-radius: 4px 4px 0 0; min-height: 1px; }
.col .bar.partial { background: repeating-linear-gradient(135deg, var(--s1) 0 4px, transparent 4px 7px); border: 1.5px solid var(--s1); border-bottom: 0; }
.col .bar.hi { background: var(--accent); }
.col .n { font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); margin-bottom: 3px; }
.col-labels { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); text-align: center; }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--grid); vertical-align: top; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--bg); }
.tbl .sub { color: var(--muted); font-size: 12px; }

/* ---------- pills / status ---------- */
.pill { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; display: inline-block; line-height: 1.5; }
.pill.in { color: var(--accent); background: var(--soft); border-color: transparent; font-weight: 600; }
.pill.st-Approved { color: var(--ok); }
.pill.st-Under { color: var(--warn); }
.pill.st-Inactive { color: var(--muted); }
.pill.exp { color: var(--bad); }
.pill.soon { color: var(--warn); }
.pill.type { color: var(--ink-2); border-color: var(--line); }
.pill.same { color: var(--accent); }

/* ---------- bottom tab bar (phones) ---------- */
.bottomnav { display: none; }
.bottomnav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- saved licences ---------- */
.saved { border-color: var(--accent); }
.save { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; white-space: nowrap; color: var(--ink); min-height: 36px; }
.save[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--soft); }
.pc-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.days { font-family: var(--font-display); font-stretch: 85%; font-weight: 800; font-size: 16px; white-space: nowrap; }
.days.ok { color: var(--ok); } .days.warn { color: var(--warn); } .days.bad { color: var(--bad); } .days.none { color: var(--muted); font-size: 13px; }

/* ---------- licence check ---------- */
.lic-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.lic-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.lic-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.nlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.nlist a { display: flex; flex-direction: column; gap: 2px; padding: 9px 4px; border-bottom: 1px solid var(--grid); color: var(--ink); text-decoration: none; font-size: 13px; }
.nlist a:hover { background: var(--bg); }
.nlist .top { display: flex; justify-content: space-between; gap: 8px; }
.nlist .no { font-family: var(--font-mono); font-size: 13px; overflow-wrap: anywhere; }
.nlist .meta { color: var(--muted); font-size: 12.5px; }
.lic-title { display: flex; flex-direction: column; gap: 6px; }
.lic-title .min { font-family: var(--font-display); font-stretch: 80%; font-weight: 800; font-size: 32px; line-height: 1; }
.lic-title .no { font-family: var(--font-mono); font-size: 15px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.term { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; align-items: center; }
.term .big { font-family: var(--font-display); font-stretch: 85%; font-weight: 800; font-size: 44px; line-height: 1; font-variant-numeric: tabular-nums; grid-row: span 2; }
.term .big.ok { color: var(--ok); } .term .big.warn { color: var(--warn); } .term .big.bad { color: var(--bad); } .term .big.none { color: var(--muted); font-size: 26px; }
.progress { height: 8px; background: var(--grid); border-radius: 99px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--s1); border-radius: 99px; }
.progress.warn i { background: var(--warn); } .progress.bad i { background: var(--bad); }
.dates { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.checks li { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; font-size: 13.5px; }
.checks .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.checks .ok .ic { background: var(--ok-bg); color: var(--ok); }
.checks .warn .ic { background: var(--warn-bg); color: var(--warn); }
.checks .bad .ic { background: var(--bad-bg); color: var(--bad); }
.checks small { display: block; color: var(--muted); font-size: 12px; }
.nstats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.nstats div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.nstats b { display: block; font-family: var(--font-display); font-stretch: 85%; font-size: 24px; font-weight: 800; line-height: 1.1; }
.nstats span { font-size: 12px; color: var(--muted); }
.rowbtns { display: flex; flex-wrap: wrap; gap: 8px; }
.example { font-size: 12px; color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.portfolio { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.pcard { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pcard:hover { border-color: var(--accent); }
a.pcard, a.btn { color: var(--ink); text-decoration: none; }
a.btn:not(.ghost) { color: var(--accent-ink); }
.pcard .no { font-family: var(--font-mono); font-size: 13px; overflow-wrap: anywhere; }
.pcard .min { font-weight: 600; }
.pcard .meta { color: var(--muted); font-size: 12.5px; }

/* ---------- law ---------- */
.law-topics { display: flex; flex-direction: column; gap: 24px; }
.law-topic { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: calc(var(--bar-h) + 12px); }
.law-topic > h2 { font-family: var(--font-display); font-stretch: 85%; font-weight: 800; font-size: 22px; margin: 0; }
.law-item { scroll-margin-top: calc(var(--bar-h) + 12px); }
.law-item h3 { margin: 0; font-size: 16px; font-weight: 600; }
.law-item p { margin: 0; max-width: 78ch; }
.law-item .when { color: var(--ink-2); }
.law-item .fees { font-size: 13px; color: var(--ink-2); background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.law-item.focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--soft); }
.law-status { max-width: 90ch; }
.refs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.ref { font-family: var(--font-mono); font-size: 11.5px; border: 1px solid var(--line); border-radius: 6px; padding: 1px 7px; color: var(--ink-2); text-decoration: none; background: var(--panel); }
.ref:hover { border-color: var(--accent); color: var(--accent); }
.ifnot { background: var(--bad-bg); color: var(--ink); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; display: flex; flex-direction: column; gap: 6px; }
.ifnot b { color: var(--bad); }
.datelist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.datelist li { display: grid; grid-template-columns: minmax(170px, auto) 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--grid); align-items: start; }
.datelist .when b { font-family: var(--font-display); font-stretch: 85%; font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.datelist small { display: block; color: var(--muted); font-size: 12px; }
.datelist li.warn .when b { color: var(--warn); }
.sources { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.sources .note { display: block; }
.checks .info .ic { background: var(--bg); color: var(--s1); }
.checks .refs { margin-top: 5px; }
.checks small a { white-space: nowrap; }

/* ---------- account and hisab ---------- */
.acc-link { margin-left: 12px; color: var(--bar-ink); text-decoration: none; font-weight: 600; font-size: 13px; white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 999px; padding: 5px 12px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.acc-link.signed { background: var(--accent); border-color: var(--accent); color: #fff; }
.form { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
.form label, .grid-form label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.form input:not([type="checkbox"]), .form select, .searchrow.inline input, .searchrow.inline select, .hisab-head select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }
.form input:focus, .form select:focus { border-color: var(--accent); outline: none; }
.form .btn { align-self: flex-start; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; max-width: none; }
.grid-form > div { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.grid-form .wide { grid-column: 1 / -1; }
.calc { background: var(--bg); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; }
.calc .bad, .msg.bad { color: var(--bad); }
.msg { margin: 0; font-size: 13.5px; color: var(--ok); }
.linkbtn { background: none; border: 0; padding: 4px 0; color: var(--accent); cursor: pointer; font: inherit; font-size: 13px; text-decoration: underline; }
.auth-card { max-width: 520px; }
.auth-alt { display: flex; gap: 16px; flex-wrap: wrap; }
.userbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); }
.userbar select { width: auto; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); }
.userbar .ghost { margin-left: auto; }
.searchrow.inline { margin-top: 0; max-width: 640px; }
.pwrap { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.team { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.team li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--grid); flex-wrap: wrap; }
.team li > span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.hisab-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.hisab-head h2 { font-family: var(--font-display); font-stretch: 85%; font-weight: 800; font-size: 22px; margin: 0; }
.hisab-head select { width: auto; }
.hisab-tabs { grid-template-columns: repeat(5, 1fr); }
.warnbox { border-color: var(--bad); }
.kpi .v { overflow-wrap: anywhere; }
#hisab-out { display: flex; flex-direction: column; gap: 14px; }
#hb-body { display: flex; flex-direction: column; gap: 14px; }
#acc-out { display: flex; flex-direction: column; gap: 14px; }
/* ---------- khata (hisab) ---------- */
.np { font-size: 0.82em; color: var(--muted); font-weight: 500; }
.t-recv { color: var(--ok); }
.t-pay { color: var(--bad); }
.hb-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.hb-tabs .chip { flex: none; font-size: 13.5px; padding: 6px 12px; }
.khata-top { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.khata-top.single { grid-template-columns: minmax(0, 320px); }
.khata-card { display: flex; flex-direction: column; gap: 2px; text-align: left; border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; min-width: 0; }
div.khata-card { cursor: default; }
.khata-card .np { font-size: 14px; font-weight: 600; }
.khata-card .lbl { font-size: 12.5px; color: var(--muted); }
.khata-card b { font-family: var(--font-display); font-stretch: 85%; font-size: 28px; font-weight: 800; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.khata-card.recv { border-color: var(--ok); background: var(--ok-bg); } .khata-card.recv b, .khata-card.recv .np { color: var(--ok); }
.khata-card.pay { border-color: var(--bad); background: var(--bad-bg); } .khata-card.pay b, .khata-card.pay .np { color: var(--bad); }
.quick { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.qbtn { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 10px; padding: 10px 4px; cursor: pointer; font: inherit; font-size: 12.5px; font-weight: 600; min-height: 60px; justify-content: center; }
.qbtn .np { font-size: 13px; }
.qbtn:hover { border-color: var(--accent); }
.q-sale, .q-payment_in { border-bottom: 3px solid var(--ok); }
.q-purchase, .q-expense, .q-payment_out { border-bottom: 3px solid var(--bad); }
.q-prod { border-bottom: 3px solid var(--s1); }
.kpis.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg.entry-kinds { grid-template-columns: repeat(5, 1fr); margin-bottom: 4px; }
.entry-kinds .seg-btn { display: flex; flex-direction: column; align-items: center; line-height: 1.2; padding: 7px 2px; }
.entry-kinds .seg-btn small { font-size: 11px; opacity: 0.8; }
.newparty { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; background: var(--bg); border-radius: 8px; padding: 10px; }
.newparty > div { display: flex; flex-direction: column; gap: 4px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters select { width: auto; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; }
.daybook { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.db-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; grid-template-areas: "date main amt" "date main act"; gap: 2px 10px;
  padding: 10px 0; border-bottom: 1px solid var(--grid); align-items: start; }
.db-date { grid-area: date; font-family: var(--font-mono); font-size: 13px; font-weight: 500; display: flex; flex-direction: column; }
.db-date small { color: var(--muted); font-size: 11px; }
.db-main { grid-area: main; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; min-width: 0; }
.db-main .sub { flex-basis: 100%; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.db-amt { grid-area: amt; font-family: var(--font-mono); font-weight: 500; text-align: right; white-space: nowrap; }
.db-act { grid-area: act; display: flex; gap: 10px; justify-content: flex-end; }
.kpill { border-color: transparent; background: var(--bg); color: var(--ink-2); }
.k-sale .kpill, .k-payment_in .kpill { background: var(--ok-bg); color: var(--ok); }
.k-purchase .kpill, .k-expense .kpill, .k-payment_out .kpill { background: var(--bad-bg); color: var(--bad); }
.parties { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.party-row { width: 100%; display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 4px; border: 0;
  border-bottom: 1px solid var(--grid); background: transparent; color: var(--ink); cursor: pointer; font: inherit; text-align: left; }
.party-row:hover { background: var(--bg); }
.pr-name { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.pr-name small, .pr-bal small { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.pr-bal { display: flex; flex-direction: column; align-items: flex-end; font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.stockchips { display: flex; flex-wrap: wrap; gap: 8px; }
.stockchip { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 120px; }
.stockchip b { font-family: var(--font-display); font-stretch: 85%; font-size: 18px; }
.linkbtn.danger { color: var(--bad); }
.tbl tr.total td { border-top: 2px solid var(--line); }
#print-area { display: none; }
@media print {
  body.printing > *:not(#print-area) { display: none !important; }
  body.printing #print-area { display: block; }
  body { background: #fff !important; color: #000 !important; padding: 0 !important; }
}
.bill { font: 13px/1.5 var(--font-body); color: #000; max-width: 720px; margin: 0 auto; padding: 24px; }
.bill-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
.bill h1 { font-family: var(--font-display); font-size: 24px; margin: 0; }
.bill-head p { margin: 2px 0 0; }
.bill-meta { text-align: right; }
.bill table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.bill th, .bill td { border-bottom: 1px solid #999; padding: 6px 4px; text-align: left; }
.bill .num { text-align: right; }
.bill-foot { margin-top: 30px; font-size: 11px; color: #555; }

/* ---------- map view ---------- */
body.is-map { height: 100%; overflow: hidden; }
body.is-map .page-foot { display: none; }
.mapview { display: grid; grid-template-columns: var(--panel-w) 1fr; flex: 1; min-height: 0; }
.mapview[hidden] { display: none; }
.panel {
  background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 16px; padding-block: 6px 20px;
}
.mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--bg); }
.block { display: flex; flex-direction: column; gap: 10px; padding-block: 14px; border-top: 1px solid var(--line); }
.panel > .block:first-child { border-top: 0; }
.label { font-family: var(--font-display); font-stretch: 85%; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0; }
.small { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.panel input[type="search"], .panel select { background: var(--bg); }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg-btn { background: transparent; border: 0; padding: 7px 4px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 13px; }
.seg-btn + .seg-btn { border-left: 1px solid var(--line); }
.seg-btn.on { background: var(--ink); color: var(--panel); }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choices button { border: 1px solid var(--accent); color: var(--accent); background: transparent; border-radius: 999px; padding: 3px 10px; cursor: pointer; font-size: 13px; }
.radius { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }
.radius label { grid-column: 1 / -1; font-size: 12px; color: var(--muted); }
.radius input { width: 100%; accent-color: var(--accent); }
.radius output { min-width: 4.5em; text-align: right; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 10px; cursor: pointer; font-size: 12.5px; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); background: var(--bg); }
.chip .sw { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.chip .n { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row2 > div { min-width: 0; }
.res-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions { display: flex; gap: 6px; }
.summary { margin: 0; font-size: 15px; }
.summary strong { font-family: var(--font-display); font-stretch: 85%; font-size: 22px; font-weight: 800; color: var(--accent); margin-right: 2px; }
.bytype { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.bytype span { display: inline-flex; align-items: center; gap: 5px; }
.bytype i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: 4px 1fr; gap: 10px; padding: 10px 6px 10px 0; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; text-align: left; background: transparent; width: 100%; }
.item:hover, .item.sel { background: var(--bg); }
.item .bar { border-radius: 2px; }
.item .body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item .top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.item .no { font-family: var(--font-mono); font-weight: 500; font-size: 13px; overflow-wrap: anywhere; }
.item .min { font-weight: 600; }
.item .meta { color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.item .tags { display: flex; flex-wrap: wrap; gap: 4px; }
.dist { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }
.layers summary { cursor: pointer; list-style: none; }
.layers summary::after { content: " +"; }
.layers[open] summary::after { content: " –"; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; }
.check input { accent-color: var(--accent); }
.legend { position: absolute; z-index: 500; right: max(10px, env(safe-area-inset-right, 0px)); bottom: 24px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; max-width: 220px; }
.legend .r { display: flex; align-items: center; gap: 7px; }
.legend .ln { width: 18px; height: 0; border-top-width: 2px; border-top-style: solid; }
.legend .sq { width: 12px; height: 9px; border-width: 1.5px; border-style: solid; border-radius: 1px; }

/* ---------- floating ---------- */
.tip { position: fixed; z-index: 2000; pointer-events: none; background: var(--ink); color: var(--panel); padding: 6px 9px; border-radius: 6px; font-size: 12px; max-width: 260px; }
.tip b { font-family: var(--font-mono); font-weight: 500; }
.toast { position: fixed; z-index: 2000; left: 50%; transform: translateX(-50%); top: calc(var(--bar-h) + 12px + env(safe-area-inset-top, 0px)); background: var(--ink); color: var(--panel); padding: 7px 14px; border-radius: 8px; font-size: 13px; }

/* Leaflet in theme */
.leaflet-container { font: inherit; background: var(--bg); }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--ink); border-radius: 8px; }
.leaflet-popup-content { margin: 12px 14px; min-width: 240px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-bar a { background: var(--panel); color: var(--ink); border-color: var(--line); }
.pop h3 { margin: 0 0 2px; font-family: var(--font-mono); font-size: 14px; font-weight: 500; }
.pop .min { font-family: var(--font-display); font-stretch: 85%; font-size: 18px; font-weight: 700; }
.pop .tags { margin: 6px 0 8px; }
.pop dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12.5px; }
.pop dt { color: var(--muted); }
.pop dd { margin: 0; overflow-wrap: anywhere; }
.pop .links { margin-top: 8px; font-size: 12.5px; display: flex; gap: 10px; flex-wrap: wrap; }
.lbl-tip { background: var(--panel); color: var(--ink); border: 1px solid var(--line); box-shadow: none; font-size: 12px; padding: 1px 6px; }
.lbl-tip::before { display: none; }

/* ---------- narrow ---------- */
@media (max-width: 900px) {
  .grid2, .lic-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .asof { display: none; }
}
@media (max-width: 760px) {
  /* thumb-reach navigation: tabs move to a fixed bar at the bottom */
  .tabs { display: none; }
  .topbar { gap: 10px; min-height: 48px; }
  .logo { font-size: 20px; }
  .asof { display: none; }
  .acc-link { margin-left: auto; }
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .khata-card b { font-size: 22px; }
  .entry-kinds .seg-btn { font-size: 11.5px; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
    background: var(--panel); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px);
  }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11.5px; font-weight: 500; color: var(--muted); text-decoration: none; min-height: 56px; }
  .bottomnav a[aria-current="page"] { color: var(--accent); }
  body { padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)); }
  .page { padding-block: 18px 24px; gap: 14px; }
  .card { padding: 14px; }
  .hide-sm { display: none; }
  .searchrow input, .searchrow select { flex-basis: 0; flex-grow: 1; font-size: 16px; } /* 16px stops iOS zooming in */
  .panel input[type="search"], .panel select { font-size: 16px; }
  .btn { padding: 11px 16px; }
  .rowbtns .btn { flex: 1 1 auto; text-align: center; }
  /* licence page: days left, then risks, details, neighbours, portfolio */
  .lic-grid { display: flex; flex-direction: column; align-items: stretch; gap: 14px; }
  .lic-col { display: contents; }
  .o1 { order: 1; } .o2, .o2b { order: 2; } .o3 { order: 3; } .o4 { order: 4; } .o5 { order: 5; }
  .datelist li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .lic-title .min { font-size: 28px; }
  .portfolio { grid-template-columns: minmax(0, 1fr); }
  .findings ul { padding-left: 18px; }
  .hb { grid-template-columns: minmax(70px, 34%) 1fr auto; }
  body.is-map { height: auto; overflow: auto; }
  body.is-map .page-foot { display: block; }
  .mapview { display: flex; flex-direction: column-reverse; }
  .mapwrap { height: 50vh; flex: none; }
  .panel { border-right: 0; overflow: visible; padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .legend { display: none; }
  .kpi .v { font-size: 28px; }
  .term { grid-template-columns: minmax(0, 1fr); }
  .term .big { font-size: 36px; grid-row: auto; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
