/* Design system for dense financial data.
   Two rules drive every choice here:
   - Accuracy over polish. If a treatment makes a screen prettier but a number less
     traceable, the traceability wins.
   - The product lives in empty, partial and error states, so those are designed
     first-class rather than as an afterthought. */

:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f5f5f3;
  --surface-3: #ecebe7;
  --line: #e3e2dd;
  --line-strong: #cfcdc5;
  --ink: #1a1a18;
  --ink-2: #55534d;
  --ink-3: #85837b;
  --accent: #1c6b5a;
  --accent-soft: #e6f2ee;
  --pos: #16704f;
  --neg: #a8342a;
  --warn: #8a5a00;
  --warn-soft: #fdf3e0;
  --warn-line: #e6c88a;
  --crit: #9b2c20;
  --crit-soft: #fcefed;
  --crit-line: #e8b5ad;
  --contested: #5c4b8a;
  --contested-soft: #f0edf7;
  --radius: 7px;
  --radius-lg: 11px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --shadow: 0 1px 2px rgba(20,20,18,.05), 0 4px 16px rgba(20,20,18,.05);
  --shadow-lg: 0 8px 40px rgba(20,20,18,.14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131312; --surface: #1b1b1a; --surface-2: #222221; --surface-3: #2c2c2a;
    --line: #2e2e2b; --line-strong: #43423e;
    --ink: #eceae4; --ink-2: #a9a7a0; --ink-3: #78766f;
    --accent: #4fb89c; --accent-soft: #16302a;
    --pos: #4fb88c; --neg: #e2796c;
    --warn: #d9a441; --warn-soft: #2b2313; --warn-line: #55441f;
    --crit: #e8837a; --crit-soft: #2e1a18; --crit-line: #5c2f2a;
    --contested: #a996d8; --contested-soft: #211d2e;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,.5);
  }
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131312; --surface: #1b1b1a; --surface-2: #222221; --surface-3: #2c2c2a;
  --line: #2e2e2b; --line-strong: #43423e;
  --ink: #eceae4; --ink-2: #a9a7a0; --ink-3: #78766f;
  --accent: #4fb89c; --accent-soft: #16302a;
  --pos: #4fb88c; --neg: #e2796c;
  --warn: #d9a441; --warn-soft: #2b2313; --warn-line: #55441f;
  --crit: #e8837a; --crit-soft: #2e1a18; --crit-line: #5c2f2a;
  --contested: #a996d8; --contested-soft: #211d2e;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 40px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
button, select, input, textarea { font: inherit; color: inherit; }
/* Some platforms paint the dropdown list itself, not the closed control. */
option { background: var(--surface); color: var(--ink); }

/* ---------------------------------------------------------------- shell --- */
.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side {
  background: var(--surface-2); border-right: 1px solid var(--line);
  padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 14px; }
.brand b { font-size: 15px; letter-spacing: -.01em; }
.brand .mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  background: linear-gradient(140deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--ink)));
}
.navgroup { margin: 14px 0 4px; padding: 0 8px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.nav { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 6px 8px; border: 0; background: none; border-radius: var(--radius);
  cursor: pointer; color: var(--ink-2); font-size: 13.5px; }
.nav:hover { background: var(--surface-3); color: var(--ink); }
.nav[aria-current="true"] { background: var(--surface); color: var(--ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--line); }
.nav .pill { margin-left: auto; font-size: 10.5px; padding: 1px 6px; border-radius: 999px;
  background: var(--crit-soft); color: var(--crit); font-weight: 700; }
.nav .pill.muted { background: var(--surface-3); color: var(--ink-3); }

.main { min-width: 0; }
.switcher { display: inline-flex; align-items: center; gap: 8px; padding: 3px 4px 3px 10px; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.switcher .sel { border-color: transparent; font-weight: 500; }
.viewing-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 24px; background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid var(--warn-line); font-size: 13px;
}
.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 24px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  color: var(--ink);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 40;
}
.topbar .sel { max-width: 34vw; text-overflow: ellipsis; }
.topbar input[type="date"] { color: var(--ink); background: var(--surface); }
.page { padding: 22px 24px 80px; max-width: 1240px; }

/* --------------------------------------------------------------- inputs --- */
.sel, .btn, .inp {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius); padding: 5px 9px; font-size: 13px; cursor: pointer;
}
.sel:focus-visible, .btn:focus-visible, .inp:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.inp { cursor: text; }
.btn:hover, .sel:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #08110e; }
.btn.ghost { background: none; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn.sm { padding: 3px 7px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------------------------------------------------------------- cards --- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card + .card { margin-top: 14px; }
.card > header { padding: 13px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.card > header h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.005em; }
.card > header .sub { font-size: 12.5px; color: var(--ink-3); }
.card > header .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.card .body { padding: 14px 16px; }
.card .body.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

h1 { font-size: 21px; margin: 0 0 3px; letter-spacing: -.015em; }
.lede { color: var(--ink-2); margin: 0 0 18px; max-width: 74ch; }
h3 { font-size: 13px; margin: 20px 0 8px; font-weight: 650; }

/* ----------------------------------------------------------- statistics --- */
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat .k { font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat .v { font-size: 25px; font-weight: 600; letter-spacing: -.02em; line-height: 1.15; }
.stat .v.sm { font-size: 19px; }
.stat .n { font-size: 12.5px; color: var(--ink-3); }
.pos { color: var(--pos); } .neg { color: var(--neg); }
.num { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- tables --- */
.tw { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 600; font-size: 11px; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
thead th { position: sticky; top: 0; z-index: 2; }
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); background: var(--surface-2); }
th.sortable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
th.sorted { color: var(--ink); }
.sortarrow { margin-left: 4px; font-size: 9.5px; opacity: .35; }
th.sortable:hover .sortarrow { opacity: .7; }
th.sorted .sortarrow { opacity: 1; color: var(--accent); }

tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--surface-2); }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: var(--mono); font-size: 12px; }
tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); background: var(--surface-2); }
.sub2 { font-size: 11.5px; color: var(--ink-3); display: block; margin-top: 1px; }

/* -------------------------------------------------------------- markers --- */
/* Hard problem #2: three kinds of certainty on one screen. Exact figures carry no
   ornament at all — the marker is the exception, so it keeps its meaning. */
.c-est { border-bottom: 1.5px dotted var(--warn); cursor: help; }
.c-con { border-bottom: 1.5px dashed var(--contested); cursor: help; }
.dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; vertical-align: 1px; }
.dot.est { background: var(--warn); } .dot.con { background: var(--contested); } .dot.ok { background: var(--pos); }

.tag { display: inline-block; font-size: 10.5px; font-weight: 650; padding: 1.5px 6px;
  border-radius: 4px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
  letter-spacing: .01em; }
.tag.lt { background: var(--accent-soft); color: var(--accent); }
.tag.st { background: var(--warn-soft); color: var(--warn); }
.tag.est { background: var(--warn-soft); color: var(--warn); }
.tag.con { background: var(--contested-soft); color: var(--contested); }
.tag.crit { background: var(--crit-soft); color: var(--crit); }
.tag.ok { background: var(--accent-soft); color: var(--accent); }
.tag.xb { background: var(--contested-soft); color: var(--contested); }

.note { border-radius: var(--radius); padding: 11px 13px; font-size: 13px; line-height: 1.55; }
.note.warn { background: var(--warn-soft); border: 1px solid var(--warn-line); }
.note.crit { background: var(--crit-soft); border: 1px solid var(--crit-line); }
.note.info { background: var(--surface-2); border: 1px solid var(--line); }
.note.ok   { background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent); }
.note b { font-weight: 650; }
.note + .note { margin-top: 8px; }

.rule { font-size: 12px; color: var(--ink-3); }
.cite { font-family: var(--mono); font-size: 11.5px; color: var(--ink-3);
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px; white-space: nowrap; }
.cite.verify { border-bottom: 1.5px dotted var(--warn); }

/* ---------------------------------------------------------------- drill --- */
/* The descent from "you owe ₹4.2 lakh" to "these 37 lots". A pushed stack with a
   breadcrumb, so getting back out is one click and the path is never a mystery.
   On a phone it becomes a full-height sheet rather than a shrunken desktop panel. */
.scrim { position: fixed; inset: 0; background: rgba(15,15,14,.35); z-index: 90;
  animation: fade .16s ease; }
.drill { position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 94vw);
  background: var(--surface); border-left: 1px solid var(--line); z-index: 91;
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg);
  animation: slide .2s cubic-bezier(.2,.8,.2,1); }
@keyframes slide { from { transform: translateX(22px); opacity: .4 } }
@keyframes fade { from { opacity: 0 } }
.drill > header { padding: 11px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 8px; }
.crumbs { display: flex; align-items: center; gap: 4px; font-size: 12.5px;
  color: var(--ink-3); flex-wrap: wrap; min-width: 0; }
.crumbs button { border: 0; background: none; padding: 2px 5px; border-radius: 5px;
  cursor: pointer; color: var(--ink-2); font-size: 12.5px; }
.crumbs button:hover { background: var(--surface-3); color: var(--ink); }
.crumbs .sep { color: var(--ink-3); opacity: .6; }
.crumbs .now { color: var(--ink); font-weight: 600; padding: 2px 5px; }
.drill .content { overflow-y: auto; padding: 16px; flex: 1; }
.drill h3:first-child { margin-top: 0; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 5px 16px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

.lot { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.lot + .lot { margin-top: 7px; }
.lot.hi { border-color: var(--accent); background: var(--accent-soft); }
.lot header { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.lot header .n { font-family: var(--mono); font-size: 11px; color: var(--ink-3);
  background: var(--surface-2); border-radius: 4px; padding: 1px 5px; }

.chain { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.chain .arrow { color: var(--ink-3); }

/* ------------------------------------------------------------- progress --- */
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); }
.meter.warn > i { background: var(--warn); }
.meter.crit > i { background: var(--crit); }
.bars { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 1.5px; }
.bars > i { display: block; }

.tracerow {
  display: flex; align-items: flex-start; gap: 10px; width: 100%;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; text-align: left;
}
.tracerow:hover { background: var(--surface-2); border-color: var(--line-strong); }
.tracerow[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tracerow .dot { margin-top: 5px; flex: none; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.empty .big { font-size: 15px; color: var(--ink-2); margin-bottom: 5px; }

.steps { counter-reset: s; }
.step { display: grid; grid-template-columns: 26px 1fr; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .i { counter-increment: s; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-3); color: var(--ink-2); font-size: 11.5px; font-weight: 700;
  display: grid; place-items: center; }
.step .i::before { content: counter(s); }
.step.done .i { background: var(--accent); color: #fff; }
.step.done .i::before { content: "✓"; }
.step b { display: block; font-weight: 620; margin-bottom: 2px; }

.list-reset { margin: 6px 0 0; padding-left: 18px; }
.list-reset li { margin: 3px 0; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.hr { height: 1px; background: var(--line); margin: 14px 0; }

.switcher { display: flex; gap: 2px; background: var(--surface-3); padding: 2px; border-radius: 8px; }
.switcher button { border: 0; background: none; padding: 4px 10px; border-radius: 6px;
  cursor: pointer; font-size: 12.5px; color: var(--ink-2); }
.switcher button[aria-pressed="true"] { background: var(--surface); color: var(--ink);
  font-weight: 600; box-shadow: var(--shadow); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 15px; border-radius: 999px;
  font-size: 13px; z-index: 200; box-shadow: var(--shadow-lg); }

/* ------------------------------------------------------------- mobile ----- */
/* Mobile-complete, not mobile-viewable: every flow — import, correction, drill-down,
   filing handoff — has to finish on a phone. */
.mobnav { display: none; }
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  .side.open { display: block; position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 100; }
  .mobnav { display: inline-flex; }
  .page { padding: 16px 14px 90px; }
  .topbar { padding: 8px 14px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .drill { width: 100%; top: 6vh; border-radius: 14px 14px 0 0; border-left: 0; border-top: 1px solid var(--line); }
  .stat .v { font-size: 21px; }
  table { font-size: 12.5px; }
  th, td { padding: 7px 9px; }
  /* Wide tables scroll inside their own container; the page body never does. */
  .tw { margin: 0 -2px; }
}
@media (min-width: 881px) { .only-mobile { display: none !important; } }

/* ---------------------------------------------------------------- sign-in --- */
.authwrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.authcard { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: 26px; box-shadow: var(--shadow); }
.authfoot { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2); }
.inp.otp { font-family: var(--mono); font-size: 22px; letter-spacing: .34em; text-align: center; padding: 10px; }
.authcard .btn { padding: 8px 12px; }

/* ------------------------------------------------------------------ admin --- */
.q-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: start; }
.pre { font-family: var(--mono); font-size: 11.5px; line-height: 1.55; white-space: pre-wrap;
  word-break: break-word; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px; max-height: 340px; overflow: auto; }
.sla { font-variant-numeric: tabular-nums; }
.sla.late { color: var(--crit); font-weight: 650; }
