/* ============================================================
   Lekha AI — Credit Note Ingestion · design tokens + components
   Visual DNA derived from the Tally Bridge screenshot.
   ============================================================ */

:root {
  /* brand */
  --lime: #c5e063;
  --lime-deep: #aacf3f;
  --lime-ink: #2c3a08;
  --ink: #0c0c0d;
  --header: #0c0c0d;

  /* surfaces */
  --bg: #f3f1ea;
  --bg-warm: #efece3;
  --card: #ffffff;
  --line: #e7e3d9;
  --line-soft: #eeebe2;

  /* text */
  --text: #1a1a17;
  --text-2: #57564f;
  --text-3: #8d8b81;

  /* status tints */
  --green-bg: #dcefce;  --green-fg: #4d7a2a;
  --red-bg:   #f9dad4;  --red-fg:   #c0392b;
  --amber-bg: #f6e7d0;  --amber-fg: #9a6b2f;
  --blue-bg:  #dce8f5;  --blue-fg:  #2f5f9a;
  --gray-bg:  #eae7df;  --gray-fg:  #6b6a61;
  --teal-bg:  #d6ece6;  --teal-fg:  #2c7a68;

  --shadow-sm: 0 1px 2px rgba(20,18,10,.05), 0 1px 1px rgba(20,18,10,.04);
  --shadow:    0 6px 24px rgba(28,24,12,.07), 0 1px 3px rgba(28,24,12,.05);
  --shadow-lg: 0 24px 60px rgba(24,20,8,.18), 0 6px 16px rgba(24,20,8,.10);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-pill: 999px;

  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --sans: "Hanken Grotesk", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background: #1b1b1c;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
::selection { background: var(--lime); color: var(--lime-ink); }

/* ---------- prototype chrome ---------- */
.stage {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.proto-bar {
  height: 44px;
  flex: 0 0 44px;
  background: #161617;
  border-bottom: 1px solid #000;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  color: #cfcdc6;
  font-size: 12.5px;
}
.proto-bar .pb-title {
  letter-spacing: .02em;
  color: #9b998f;
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}
.proto-bar .pb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(197,224,99,.18); }
.proto-bar .spacer { flex: 1; }
.seg {
  display: inline-flex;
  background: #0c0c0d;
  border: 1px solid #2a2a2b;
  border-radius: var(--r-pill);
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  color: #b7b5ac;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all .16s ease;
  letter-spacing: .01em;
  white-space: nowrap;
}
.seg button .role-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .55; }
.seg button:hover { color: #f2f0e7; }
.seg button.on { background: var(--lime); color: var(--lime-ink); }
.seg button.on .role-dot { opacity: 1; }
.pb-reset {
  border: 1px solid #2f2f30;
  background: transparent;
  color: #9b998f;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s ease;
}
.pb-reset:hover { color: #f2f0e7; border-color: #4a4a4b; }

/* ---- Account menu (top-bar identity chip + dropdown) ---- */
.am-wrap { position: relative; display: inline-flex; }
.am-chip {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid #2f2f30; background: transparent; color: #cfcdc6;
  padding: 4px 10px 4px 4px; border-radius: var(--r-pill);
  font-size: 12.5px; font-weight: 600; transition: all .15s ease;
}
.am-chip:hover { border-color: #4a4a4b; color: #f2f0e7; }
.am-av {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--lime); color: var(--lime-ink);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 800; letter-spacing: .02em;
}
.am-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 60;
  min-width: 214px; background: #1c1c1d; border: 1px solid #333;
  border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.45);
  padding: 6px; overflow: hidden;
}
.am-head { padding: 8px 10px 10px; border-bottom: 1px solid #2a2a2b; margin-bottom: 4px; }
.am-head-name { color: #f2f0e7; font-weight: 700; font-size: 13px; }
.am-head-sub { color: #9b998f; font-size: 11.5px; margin-top: 1px; }
.am-head-role { color: var(--lime); font-size: 11px; margin-top: 3px; font-weight: 600; }
.am-item {
  display: block; width: 100%; text-align: left;
  background: transparent; border: 0; color: #d7d5cc;
  font-size: 12.5px; font-weight: 600; padding: 8px 10px; border-radius: 8px;
  transition: background .12s ease;
}
.am-item:hover { background: #2a2a2b; color: #f2f0e7; }
.am-div { height: 1px; background: #2a2a2b; margin: 4px 0; }
.am-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 20px;
}

/* ---- Review: debit note (left) vs credit note (right) split ---- */
.dn-cn-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .dn-cn-split { grid-template-columns: 1fr; } }

/* ---------- product header ---------- */
.app { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.appHeader {
  background: var(--header);
  padding: 20px 32px 18px;
  display: flex;
  align-items: center;
  gap: 22px;
}
.brand { display: flex; align-items: baseline; gap: 16px; }
.brand .logo {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 30px;
  letter-spacing: .01em;
  color: var(--lime);
  line-height: 1;
  white-space: nowrap;
}
.brand .sub { white-space: nowrap; }
.brand .sub {
  color: #8e8d86;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: .005em;
}
.appHeader .spacer { flex: 1; }
.who {
  display: flex; align-items: center; gap: 10px;
  color: #cfcdc6; font-size: 13px;
}
.who .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  color: var(--lime-ink); background: var(--lime);
}
.who .who-meta { line-height: 1.25; }
.who .who-meta b { color: #f2f0e7; font-weight: 600; display: block; font-size: 13px; }
.who .who-meta span { color: #87867e; font-size: 11.5px; }

/* ---------- tabs ---------- */
.tabs {
  background: var(--card);
  padding: 0 32px;
  display: flex;
  gap: 30px;
  border-bottom: 1px solid var(--line);
}
.tabs .tab {
  border: 0; background: transparent;
  padding: 16px 2px 14px;
  font-size: 15px; font-weight: 500;
  color: var(--text-3);
  position: relative;
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s ease;
}
.tabs .tab:hover { color: var(--text-2); }
.tabs .tab.on { color: var(--text); font-weight: 600; }
.tabs .tab.on::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2.5px;
  background: var(--lime-deep); border-radius: 3px 3px 0 0;
}
.tabs .tab .tcount {
  font-size: 11.5px; font-weight: 700;
  background: var(--gray-bg); color: var(--text-2);
  padding: 1px 8px; border-radius: var(--r-pill);
}
.tabs .tab.on .tcount { background: var(--lime); color: var(--lime-ink); }

/* ---------- main scroll area ---------- */
.main { flex: 1; overflow: auto; }
.container { max-width: 1240px; margin: 0 auto; padding: 26px 32px 60px; }
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; }
.page-head .ph-title { font-family: var(--serif); font-size: 25px; font-weight: 700; letter-spacing: .005em; }
.page-head .ph-sub { color: var(--text-3); font-size: 14px; margin-top: 3px; }
.page-head .spacer { flex: 1; }

/* ---------- controls ---------- */
.select, .input {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  font-size: 14px; font-weight: 500; color: var(--text);
  box-shadow: var(--shadow-sm);
  font-family: inherit;
}
.select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5L6 8l3.5-3.5' stroke='%237a786f' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  cursor: pointer;
}
.select:focus, .input:focus { outline: none; border-color: var(--lime-deep); box-shadow: 0 0 0 3px rgba(170,207,63,.22); }
.input::placeholder { color: var(--text-3); }
.field-label { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .06em; }

.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; gap: 8px;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: #d6d2c6; background: #faf9f4; }
.btn:active { transform: translateY(.5px); }
.btn-primary { background: var(--lime); border-color: var(--lime-deep); color: var(--lime-ink); }
.btn-primary:hover { background: #cde774; border-color: var(--lime-deep); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #f2f0e7; }
.btn-dark:hover { background: #25251f; border-color: #25251f; }
.btn-danger { background: #fff; color: var(--red-fg); border-color: #f0cfc9; }
.btn-danger:hover { background: #fdf3f1; border-color: var(--red-fg); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: rgba(0,0,0,.04); border-color: transparent; }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-lg { padding: 13px 22px; font-size: 15px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ---------- card ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card-pad { padding: 22px 24px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-sm); }

/* ---------- table ---------- */
.tbl-wrap { overflow: hidden; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl thead th {
  text-align: left; padding: 15px 20px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  background: #fbfaf6;
  white-space: nowrap;
}
.tbl tbody td { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background .12s ease; cursor: pointer; }
.tbl tbody tr:hover { background: #faf9f3; }
.tbl .doc-no { font-weight: 700; color: var(--text); letter-spacing: .005em; }
.tbl .muted { color: var(--text-3); }
.tbl .amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.tbl .type-chip {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  color: var(--text-2); background: var(--bg-warm); padding: 3px 9px; border-radius: 6px;
}
.row-arrow { color: var(--text-3); opacity: 0; transition: all .15s ease; }
.tbl tbody tr:hover .row-arrow { opacity: 1; transform: translateX(2px); }

/* ---------- badge / status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 5px 11px; border-radius: var(--r-pill);
  white-space: nowrap;
}
.badge .b-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-bg); color: var(--green-fg); }
.badge.red   { background: var(--red-bg);   color: var(--red-fg); }
.badge.amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge.blue  { background: var(--blue-bg);  color: var(--blue-fg); }
.badge.gray  { background: var(--gray-bg);  color: var(--gray-fg); }
.badge.teal  { background: var(--teal-bg);  color: var(--teal-fg); }
.badge.spin .b-dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ---------- toggle switch ---------- */
.switch { position: relative; width: 46px; height: 26px; flex: 0 0 46px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--r-pill);
  background: #d8d4c8; transition: background .2s ease; cursor: pointer;
}
.switch .knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s ease;
}
.switch input:checked + .track { background: var(--lime-deep); }
.switch input:checked + .track .knob { transform: translateX(20px); }

/* ---------- pipeline tracker ---------- */
.pipe { display: flex; align-items: flex-start; gap: 0; }
.pipe .node { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; min-width: 0; }
/* equal-width nodes so the connecting bar never breaks before/after the wide node */
.pipe .node.wide { flex: 1; }
.pipe .node .lbl.lbl-wide { max-width: 120px; font-weight: 700; color: var(--text); }
.pipe .node.wide.active .lbl.lbl-wide { color: var(--lime-ink); }
.pipe .node .ring {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; z-index: 2;
  background: #fff; border: 2px solid var(--line);
  color: var(--text-3); font-size: 13px; font-weight: 700;
  transition: box-shadow .3s ease, border-color .25s ease, color .2s ease;
}
.pipe .node.done .ring { background: var(--green-fg); border-color: var(--green-fg); color: #fff; }
.pipe .node.active .ring { background: var(--lime); border-color: var(--lime-deep); color: var(--lime-ink); box-shadow: 0 0 0 4px rgba(197,224,99,.3); }
.pipe .node.fail .ring { background: var(--red-fg); border-color: var(--red-fg); color: #fff; }
.pipe .node .lbl { font-size: 11px; font-weight: 600; color: var(--text-3); margin-top: 8px; text-align: center; line-height: 1.25; max-width: 84px; }
.pipe .node.done .lbl, .pipe .node.active .lbl { color: var(--text); }
.pipe .node .bar { position: absolute; top: 14px; left: 50%; width: 100%; height: 2.5px; background: var(--line); z-index: 1; }
.pipe .node.done .bar { background: var(--green-fg); }
.pipe .node:last-child .bar { display: none; }
.pipe.busy .node.active .ring { animation: ringspin 1.1s linear infinite; }
@keyframes ringspin { to { box-shadow: 0 0 0 4px rgba(197,224,99,0); } }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.kpi .k-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .k-label { font-size: 12.5px; font-weight: 600; color: var(--text-3); }
.kpi .k-val { font-size: 30px; font-weight: 700; font-family: var(--serif); margin-top: 8px; letter-spacing: .01em; }
.kpi .k-foot { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.kpi .k-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(18,16,8,.5); z-index: 40; opacity: 0; animation: fade .2s ease forwards; }
@keyframes fade { to { opacity: 1; } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 94vw);
  background: var(--bg); z-index: 41; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%); animation: slidein .28s cubic-bezier(.22,1,.36,1) forwards;
  border-left: 1px solid var(--line);
}
@keyframes slidein { to { transform: translateX(0); } }
/* Centered modal variant — used by the internal ops-console doc preview so it
   reads like the brand-finance review, not a cramped right rail. */
.drawer.drawer-center {
  top: 4vh; bottom: auto; right: auto; left: 50%; max-height: 92vh;
  width: min(920px, 94vw); border: 1px solid var(--line); border-radius: 16px;
  border-left: 1px solid var(--line); overflow: hidden;
  transform: translate(-50%, 14px); opacity: 0;
  animation: popin .26s cubic-bezier(.22,1,.36,1) forwards;
}
@keyframes popin { to { transform: translate(-50%, 0); opacity: 1; } }
.drawer.drawer-center .dr-body { max-height: calc(92vh - 82px); }

/* ---- Tally-like credit-note voucher preview (CNPreview) ------------------ */
.tally-vch { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); font-size: 13px; }
.tv-block { display: flex; gap: 8px; align-items: flex-start; padding: 10px 16px; font-size: 12.5px;
  color: var(--amber-fg); background: var(--amber-bg); border-bottom: 1px solid var(--line); }
.tv-head { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--blue-bg); border-bottom: 1px solid var(--line); }
.tv-badge { font-family: var(--serif); font-weight: 700; font-size: 15px; color: var(--blue-fg);
  background: var(--card); border: 1px solid var(--line); padding: 3px 12px; border-radius: 6px; }
.tv-no { font-weight: 700; font-size: 13.5px; }
.tv-date { font-weight: 600; color: var(--text-3); white-space: nowrap; }
.tv-party { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tv-k { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); font-weight: 700; margin-bottom: 2px; }
.tv-party-name { font-weight: 700; font-size: 14px; }
.tv-grid { display: grid; grid-template-columns: 1.5fr 1fr; }
.tv-col { padding: 12px 16px; min-width: 0; }
.tv-col + .tv-col { border-left: 1px solid var(--line); }
.tv-tbl { width: 100%; border-collapse: collapse; }
.tv-tbl th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); font-weight: 700; padding: 6px 8px; border-bottom: 1.5px solid var(--line); }
.tv-tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tv-tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tv-item-name { font-size: 12px; max-width: 260px; word-break: break-word; }
.tv-tax td { color: var(--text-3); font-style: italic; }
.tv-tbl tfoot td { padding: 9px 8px; border-top: 1.5px solid var(--line); border-bottom: 0; }
/* footer symmetry: both columns are equal height (grid stretch); make each table fill it
   and let an empty filler row absorb the slack so the Total row and the ledger's Balanced
   row line up at the very bottom. */
.tv-grid { align-items: stretch; }
.tv-grid .tv-tbl { height: 100%; }
.tv-tbl tr.tv-fill { height: 100%; }
.tv-tbl tr.tv-fill td { border: 0; padding: 0; }
.tv-total-k { font-weight: 700; white-space: nowrap; }
.tv-total-v { font-weight: 700; font-size: 14px; }
.tv-kv { width: 100%; border-collapse: collapse; }
.tv-kv td { padding: 5px 8px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.tv-kv td:first-child { width: 44%; }
.tv-kv td:last-child { text-align: right; }
.tv-kv .num { font-variant-numeric: tabular-nums; }
/* fixed layout so Dr/Cr are always reserved and the ledger dropdown fills the rest
   (a long ledger name / editable <select> can't push the amounts off the card) */
.tv-ledger { margin-top: 0; table-layout: fixed; }
.tv-ledger th:nth-child(2), .tv-ledger th:nth-child(3),
.tv-ledger td:nth-child(2), .tv-ledger td:nth-child(3) { width: 74px; }
.tv-ledger td:first-child { overflow: hidden; text-overflow: ellipsis; }
.tv-leg-cc { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }
.tv-narr { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 12.5px;
  color: var(--text); background: var(--bg); line-height: 1.6; }
.tv-edit-bar { display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 6px 16px; font-size: 11.5px; color: var(--muted); background: var(--bg);
  border-bottom: 1px solid var(--line); }
.tv-edit-err { color: var(--red-fg); font-weight: 600; }
.tv-edit-inp { font: inherit; color: var(--text); background: var(--panel, #fff);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; width: 100%;
  max-width: 100%; box-sizing: border-box; }
.tv-edit-inp:focus { outline: none; border-color: var(--blue-fg); }
.tv-no-inp { width: 150px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.tv-edit-sel { font: inherit; color: var(--text); background: var(--panel, #fff);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px;
  width: 100%; max-width: 100%; box-sizing: border-box; cursor: pointer; }
.tv-edit-sel:focus { outline: none; border-color: var(--blue-fg); }
.tv-narr-note { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.tv-xml { border-top: 1px solid var(--line); background: var(--bg); }
.tv-xml > summary { padding: 10px 16px; font-size: 12px; color: var(--muted);
  cursor: pointer; user-select: none; }
.tv-xml > summary:hover { color: var(--text); }
.tv-xml-pre { margin: 0; padding: 12px 16px; max-height: 320px; overflow: auto;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
  line-height: 1.5; color: var(--text); background: var(--panel, var(--bg));
  white-space: pre-wrap; word-break: break-all; border-top: 1px solid var(--line); }
@media (max-width: 720px) {
  .tv-grid { grid-template-columns: 1fr; }
  .tv-col + .tv-col { border-left: 0; border-top: 1px solid var(--line); }
}
.drawer .dr-head { padding: 20px 24px 16px; border-bottom: 1px solid var(--line); background: var(--card); }
.drawer .dr-body { flex: 1; overflow: auto; padding: 22px 24px; }
.drawer .dr-foot { padding: 16px 24px; border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 10px; }
.icon-btn { border: 0; background: transparent; color: var(--text-3); padding: 6px; border-radius: 8px; display: grid; place-items: center; transition: all .15s ease; }
.icon-btn:hover { background: rgba(0,0,0,.05); color: var(--text); }

/* ---------- focused review (finance) ---------- */
.review { display: grid; grid-template-columns: 1.35fr 1fr; gap: 22px; align-items: start; }

/* ---- Review screen: full-width + symmetric 2x2 grid (DN | CN / Downstream | Reconciled) ---- */
.review-wide { max-width: 1640px; }
.review-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: stretch; }
.review-cell { height: 64vh; display: flex; flex-direction: column; overflow: hidden; }
.review-cell > .review-scroll { flex: 1; overflow-y: auto; overflow-x: auto; min-height: 0; }
.review-cell iframe { flex: 1; min-height: 0; }
.review-cell .review-head { flex: 0 0 auto; }
@media (max-width: 980px) {
  .review-grid { grid-template-columns: 1fr; }
  .review-cell { height: auto; }
  .review-cell iframe { height: 58vh; }
}
/* tasteful staggered entrance — the review reads as one composed board, not a reflow */
@keyframes reviewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.review-grid > .card { animation: reviewIn .38s cubic-bezier(.22,1,.36,1) both; }
.review-grid > .card:nth-child(2) { animation-delay: .05s; }
.review-grid > .card:nth-child(3) { animation-delay: .10s; }
.review-grid > .card:nth-child(4) { animation-delay: .15s; }
.review-cell { transition: box-shadow .2s ease; }
.review-cell:hover { box-shadow: var(--shadow-lg, 0 12px 32px rgba(0,0,0,.10)); }

/* confidence ring gauge */
.conf-ring { display: inline-flex; align-items: center; gap: 8px; }
.conf-ring-svg { position: relative; display: inline-grid; place-items: center; }
.conf-ring-num { position: absolute; font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* amounts-match affirmation */
.amt-match {
  display: flex; align-items: center; gap: 8px; margin-top: 14px;
  color: var(--green-fg); font-size: 13px; font-weight: 600;
  background: var(--green-bg); border-radius: 10px; padding: 10px 14px;
  animation: amtMatchIn .5s cubic-bezier(.22,1,.36,1) both;
}
.amt-match svg { flex: 0 0 16px; }
@keyframes amtMatchIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

/* sticky decision bar — the primary action stays reachable on a tall voucher */
.review-decision { position: sticky; bottom: 14px; z-index: 6; }
.kbd-hint { display: flex; justify-content: center; gap: 14px; margin-top: 10px; color: var(--text-3); font-size: 11.5px; }
.kbd-hint kbd {
  font-family: var(--mono, monospace); font-size: 11px; background: var(--card);
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  padding: 1px 6px; margin-right: 4px; color: var(--text-2);
}

/* one-shot confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 90; }
.confetti-bit {
  position: absolute; top: -14px; border-radius: 2px; opacity: 0;
  animation-name: confettiFall; animation-timing-function: cubic-bezier(.35,.6,.55,1);
  animation-fill-mode: forwards;
}
@keyframes confettiFall {
  0% { opacity: 0; top: -14px; transform: rotate(0) translateX(0); }
  10% { opacity: 1; }
  100% { opacity: 0; top: 102%; transform: rotate(var(--rot)) translateX(24px); }
}
@media (prefers-reduced-motion: reduce) {
  .confetti { display: none; }
  .review-grid > .card, .amt-match { animation: none; }
}
.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: 14px; }
.kv dt { color: var(--text-3); font-weight: 500; }
.kv dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.compare { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: stretch; }
.compare .arrow-mid { display: grid; place-items: center; color: var(--lime-deep); }

.li-tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.li-tbl th { text-align: left; padding: 9px 12px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); border-bottom: 1px solid var(--line); font-weight: 700; }
.li-tbl td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-variant-numeric: tabular-nums; }
.li-tbl tr:last-child td { border-bottom: 0; }
.li-tbl .num { text-align: right; }
.li-tbl tfoot td { font-weight: 700; border-top: 2px solid var(--line); border-bottom: 0; padding-top: 12px; }

.match-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--green-fg); background: var(--green-bg); padding: 4px 10px; border-radius: var(--r-pill); }

/* ---------- timeline ---------- */
.timeline { position: relative; padding-left: 6px; }
.tl-item { display: flex; gap: 14px; padding-bottom: 18px; position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item .tl-rail { position: relative; display: flex; flex-direction: column; align-items: center; }
.tl-item .tl-dot { width: 13px; height: 13px; border-radius: 50%; background: var(--green-fg); border: 2.5px solid #fff; box-shadow: 0 0 0 1.5px var(--green-fg); z-index: 2; margin-top: 2px; }
.tl-item.pending .tl-dot { background: #fff; box-shadow: 0 0 0 1.5px var(--line); }
.tl-item.active .tl-dot { background: var(--lime); box-shadow: 0 0 0 1.5px var(--lime-deep); }
.tl-item .tl-line { position: absolute; top: 14px; bottom: -8px; width: 2px; background: var(--line); }
.tl-item:last-child .tl-line { display: none; }
.tl-item .tl-body { flex: 1; }
.tl-item .tl-t { font-size: 13.5px; font-weight: 600; }
.tl-item.pending .tl-t { color: var(--text-3); font-weight: 500; }
.tl-item .tl-meta { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  background: var(--ink); color: #f4f2ea; padding: 13px 18px; border-radius: var(--r);
  box-shadow: var(--shadow-lg); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 12px; min-width: 280px;
  animation: toastin .3s cubic-bezier(.22,1,.36,1);
}
@keyframes toastin { from { opacity: 0; transform: translateY(14px); } }
.toast .t-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 22px; }
.toast .t-ic.ok { background: var(--lime); color: var(--lime-ink); }
.toast .t-ic.bad { background: var(--red-fg); color: #fff; }
.toast .t-ic.info { background: var(--blue-fg); color: #fff; }

/* ---------- misc ---------- */
.hint { background: var(--amber-bg); border: 1px solid #ecd3aa; color: var(--amber-fg); border-radius: var(--r); padding: 12px 16px; font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; }
.hint.info { background: var(--blue-bg); border-color: #c4d8ee; color: var(--blue-fg); }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin: 0 0 12px; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }
.empty { text-align: center; padding: 60px 20px; color: var(--text-3); }
.empty .e-ic { width: 56px; height: 56px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; margin: 0 auto 16px; box-shadow: var(--shadow-sm); }
.empty .e-t { font-size: 16px; font-weight: 600; color: var(--text-2); }
.empty .e-s { font-size: 13.5px; margin-top: 4px; }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap6 { gap: 6px; } .gap8 { gap: 8px; } .gap10 { gap: 10px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb20 { margin-bottom: 20px; }
.tiny { font-size: 12px; color: var(--text-3); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.grow { flex: 1; }
.bizdot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }

.conf-bar { height: 6px; border-radius: 4px; background: var(--gray-bg); overflow: hidden; width: 110px; }
.conf-bar > i { display: block; height: 100%; border-radius: 4px; }

.biz-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); transition: background .12s ease; }
.biz-card:last-child { border-bottom: 0; }
.biz-card:hover { background: #faf9f3; }
.biz-card .biz-name { font-weight: 600; font-size: 14.5px; }
.biz-card .biz-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.email-input { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

@media (max-width: 880px) {
  .review { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2,1fr); }
  .compare { grid-template-columns: 1fr; }
  .compare .arrow-mid { transform: rotate(90deg); }
}

/* ---- admin verify gate: split-screen (PDF | editable fields) ------------- */
.gate-modal {
  position: fixed; inset: 0; z-index: 41; background: var(--bg);
  display: flex; flex-direction: column;
  animation: fade .2s ease forwards;
}
.gate-modal .gm-head { padding: 16px 24px; border-bottom: 1px solid var(--line); background: var(--card); display: flex; align-items: center; gap: 14px; }
.gate-split { flex: 1; display: grid; grid-template-columns: 1fr 1fr; min-height: 0; }
.gate-split .gp-doc { background: #5b5b5b; min-height: 0; border-right: 1px solid var(--line); }
.gate-split .gp-doc iframe { width: 100%; height: 100%; border: 0; display: block; }
.gate-split .gp-fields { overflow: auto; padding: 24px; min-height: 0; }
.gate-modal .gm-foot { padding: 14px 24px; border-top: 1px solid var(--line); background: var(--card); display: flex; gap: 10px; justify-content: flex-end; }
@media (max-width: 980px) {
  .gate-split { grid-template-columns: 1fr; grid-template-rows: 40vh 1fr; }
  .gate-split .gp-doc { border-right: 0; border-bottom: 1px solid var(--line); }
}

/* ---- accordion (FAQ-style settings) -------------------------------------- */
.acc { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--card); }
.acc + .acc { margin-top: 14px; }
.acc-head { width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer;
  padding: 18px 20px; display: flex; align-items: center; gap: 14px; font: inherit; }
.acc-head:hover { background: #faf9f3; }
.acc-head .acc-ic { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 36px; }
.acc-head .acc-tt { font-weight: 700; font-size: 15px; }
.acc-head .acc-sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.acc-head .acc-chev { margin-left: auto; transition: transform .2s ease; color: var(--text-3); flex: 0 0 auto; }
.acc.open .acc-head .acc-chev { transform: rotate(90deg); }
.acc-body { padding: 4px 20px 20px; border-top: 1px solid var(--line); }
