/* A party's khata (khata-view.js): the page a link opens (khata.html, body.kpage) and My khatas in
   the Tulan app (app.js). Every class starts kv-, so the app's own styles never reach into it.
   The colours are the app's own tokens: the page sets them here, light; inside the app they are
   the app's, so the view follows its light or dark theme. */

.kpage {
  --paper: #f5f6fa; --surface: #ffffff; --surface-2: #eceef6; --surface-3: #dde0ee;
  --ink: #12141f; --body: #3d4256; --muted: #646b85; --faint: #8990a5;
  --brand: #2d3561; --brand-lt: #4f5bd5; --brand-tint: #e8eaf8; --on-brand: #f4f5fc;
  --green: #14805a; --red: #c4362f; --red-tint: #fceceb; --gold: #8a5a00;
  --rule: #dfe2ee; --rule-soft: #ebedf5;
  --shadow: 0 1px 2px rgba(18,20,31,.06), 0 2px 8px rgba(18,20,31,.05);
  --sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
  margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.4 var(--sans);
  -webkit-text-size-adjust: 100%;
}
.kpage * { box-sizing: border-box; }
.kpage main { max-width: 34rem; margin: 0 auto; min-height: 100vh; }

.kv { color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.4; }
.kv button, .kv input { font: inherit; }
.kv-wait, .kv-msg { padding: 30vh 24px 0; text-align: center; color: var(--body); }
.kv-msg b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.kv-msg .kv-btn { margin: 16px auto 0; display: inline-flex; }
.kv-spin { display: inline-block; width: 22px; height: 22px; border: 2.5px solid var(--surface-3);
  border-top-color: var(--brand-lt); border-radius: 50%; animation: kvsp .8s linear infinite; }
@keyframes kvsp { to { transform: rotate(360deg); } }

/* The business, and the two tabs */
.kv-top { background: var(--surface); padding: 18px 16px 0; border-bottom: 1px solid var(--rule); }
.kv-who { display: flex; align-items: center; gap: 12px; }
.kv-av { width: 44px; height: 44px; border-radius: 10px; background: var(--brand); color: var(--on-brand);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; flex-shrink: 0; }
.kv-t { min-width: 0; flex: 1; }
.kv-firm { font-size: 19px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.kv-of { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.kv-lang { border: 1px solid var(--surface-3); background: var(--surface); color: var(--brand-lt); border-radius: 8px;
  height: 32px; padding: 0 10px; font-size: 13px; font-weight: 600; flex-shrink: 0; cursor: pointer; }
.kv-tabs { display: flex; gap: 4px; margin-top: 14px; }
.kv-tabs button { flex: 1; height: 44px; border: 0; background: none; color: var(--muted); font-weight: 500;
  border-bottom: 3px solid transparent; cursor: pointer; }
.kv-tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand-lt); }
.kv-gap { height: 14px; }

/* How to keep it in the Tulan app (the page only) */
.kv-keep { background: var(--brand-tint); padding: 10px 16px; font-size: 13px; color: var(--brand); }
.kv-keeprow { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kv-steps { margin: 10px 0 4px; padding-left: 20px; line-height: 1.6; color: var(--body); }
.kv-steps a { color: var(--brand-lt); font-weight: 600; }
.kv-steps .kv-sm { margin-top: 6px; }
.kv-web { display: inline-block; margin: 4px 0 2px; color: var(--brand-lt); font-weight: 600; }

.kv-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.kv-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); }

/* What is owed, and paying it */
.kv-owe { padding: 18px 16px 16px; display: flex; flex-direction: column; gap: 12px; }
.kv-l { font-size: 14px; color: var(--muted); }
.kv-n { font: 600 34px/1.1 var(--mono); letter-spacing: -0.01em; }
.kv-n.kv-fav { color: var(--green); }
.kv-n.kv-due { color: var(--red); }
.kv-asof { font-size: 13px; color: var(--muted); }
.kv-btn { height: 52px; border-radius: 12px; border: 0; background: var(--brand); color: var(--on-brand);
  font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: none; display: flex;
  align-items: center; justify-content: center; padding: 0 16px; }
.kv-btn.kv-line { background: var(--surface); color: var(--brand-lt); border: 1px solid var(--brand-lt); height: 44px; font-size: 15px; gap: 8px; }
.kv-wa { flex-shrink: 0; }
.kv-payrow { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.kv-lnk { border: 0; background: none; color: var(--brand-lt); font-weight: 600; font-size: 14px; padding: 6px 0; cursor: pointer; }
.kv-upi { display: flex; align-items: center; gap: 8px; min-width: 0; padding-top: 10px; border-top: 1px solid var(--rule-soft); }
.kv-upi .kv-upil { font: 500 12px var(--sans); color: var(--muted); flex-shrink: 0; }
.kv-upi .kv-upiv { flex: 1; min-width: 0; font: 500 14px var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.kv-owe > .kv-lnk { align-self: flex-start; }
.kv-back { width: 40px; height: 40px; margin-left: -8px; border: 0; border-radius: 50%; background: transparent; color: var(--ink);
  font-size: 22px; line-height: 1; flex-shrink: 0; cursor: pointer; }
.kv-more { width: 100%; height: 44px; border: 0; border-bottom: 1px solid var(--rule-soft); background: none; color: var(--brand-lt);
  font: 600 14px var(--sans); cursor: pointer; }
.kv-rows > .kv-more:last-child { border-bottom: 0; }
.kv-sm { height: 32px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--surface-3); background: var(--surface);
  color: var(--brand-lt); font-size: 13px; font-weight: 500; cursor: pointer; flex-shrink: 0; }
.kv-other { display: flex; gap: 8px; }
.kv-other input { flex: 1; min-width: 0; height: 48px; border: 1px solid var(--surface-3); border-radius: 10px; padding: 0 12px;
  font: 500 17px var(--mono); background: var(--paper); color: var(--ink); }
.kv-other .kv-btn { height: 48px; font-size: 15px; }
.kv-note { font-size: 12px; color: var(--muted); }
/* On an iPhone: which UPI app pays */
.kv-pick { display: flex; flex-direction: column; gap: 10px; }
.kv-pick > .kv-lnk { align-self: flex-start; }
.kv-apps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.kv-app { height: 48px; border-radius: 12px; border: 1px solid var(--surface-3); background: var(--surface-2); color: var(--ink);
  font-weight: 600; font-size: 15px; text-decoration: none; display: flex; align-items: center; justify-content: center;
  padding: 0 8px; text-align: center; }
.kv-app:active { background: var(--surface-3); }
/* Each app's own icon beside its name (khata-view.js UPI_APPS), rounded as a phone shows it. */
.kv-app { justify-content: flex-start; gap: 10px; padding: 0 10px; }
.kv-app span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv-appic { flex: none; width: 28px; height: 28px; border-radius: 7px; }
.kv-wait2 { padding: 12px 0; text-align: center; }

/* Lists */
.kv-sec { display: flex; justify-content: space-between; align-items: baseline; padding: 0 4px; gap: 8px; }
.kv-sec b { font-size: 15px; }
.kv-sec span { font-size: 13px; color: var(--muted); }
.kv-rows > div { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--rule-soft); }
.kv-rows > div:last-child { border-bottom: 0; }
.kv-m { flex: 1; min-width: 0; }
.kv-p { font-size: 15px; overflow-wrap: anywhere; }
.kv-s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.kv-n2 { font-style: italic; overflow-wrap: anywhere; }
.kv-r { text-align: right; flex-shrink: 0; }
.kv-amt { font: 500 15px var(--mono); }
/* Under a balance: whose side it is on - "in your favour", "due" (balTwo). */
.kv-bw { font-size: 12.5px; font-weight: 500; margin-top: 2px; white-space: nowrap; }
.kv-amt.kv-b { font-weight: 600; }
.kv-amt.kv-paid { color: var(--green); }
.kv-bal { font: 500 12px var(--mono); color: var(--muted); margin-top: 2px; }
.kv-tag { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; margin-top: 4px; }
.kv-tag.kv-od { color: var(--red); background: var(--red-tint); }
.kv-tag.kv-due { color: var(--muted); padding-left: 0; padding-right: 0; font-weight: 500; }
.kv-tag.kv-ok { color: var(--green); background: rgba(20, 128, 90, .12); }
.kv-tag.kv-out { color: var(--muted); background: var(--surface-2); }
/* Out of stock in red, as on the owner's own khata rate list (Vishal, 25 Oct 26). */
.kv-tag.kv-oos { color: var(--red); background: var(--red-tint); }
.kv-rows .kv-tot { background: var(--surface-2); border-radius: 0 0 14px 14px; }
.kv-rows .kv-tot.kv-tot1 { border-radius: 14px 14px 0 0; }
.kv-rows .kv-tot .kv-p, .kv-rows .kv-tot .kv-amt { font-weight: 600; }
/* The open bills' total and its interest (khata-view.js billsCard): the same band as the total, quieter. */
.kv-rows .kv-bsum { background: var(--surface-2); padding-top: 10px; padding-bottom: 6px; border-bottom: 0; }
.kv-rows .kv-bsum + .kv-bsum { padding-top: 0; }
.kv-rows .kv-bsum .kv-p { font-size: 14px; color: var(--muted); }
.kv-rows .kv-bsum .kv-amt { font-size: 14px; }
/* A bill's lines under its figure: what it was raised at, its interest - in the figures' own face, as the
   business's Outstanding screen sets them. In the small text face the same gold read dull beside the
   business's (Vishal, 26 Oct 26: "Interest color not matching"). */
.kv-r .kv-s { white-space: nowrap; }
.kv-r .kv-bfig { font: 500 14px var(--mono); margin-top: 3px; }
/* That screen: the bill and its interest, then each stretch with the sum that makes it. */
.kv-ihead { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.kv-ihead .kv-amt { font-size: 22px; font-weight: 600; }
.kv-isum { font: 500 12.5px var(--mono); color: var(--body); margin-top: 3px; }
.kv-ihow { font-size: 13px; color: var(--muted); }

/* The open bills, a tap away from the khata */
.kv-go { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px 16px; border: 0; text-align: left;
  color: var(--ink); cursor: pointer; }
.kv-go .kv-m, .kv-go .kv-p, .kv-go .kv-s { display: block; }
.kv-go .kv-tag { margin-top: 6px; }
.kv-chev { font-size: 26px; line-height: 1; color: var(--faint); flex-shrink: 0; }

/* The row of actions under what is owed: Statement · WhatsApp · Call · My entry */
.kv-acts { display: flex; justify-content: space-around; padding: 10px 4px; }
.kv-act { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 2px; border: 0;
  background: none; color: var(--brand-lt); font: 500 12px var(--sans); text-decoration: none; cursor: pointer; min-width: 0; }
.kv-acts .kv-act { font: 500 12px var(--sans); }   /* over ".kv button { font: inherit }": one size for all four */
.kv-act svg { width: 24px; height: 24px; }
.kv-act span { color: var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.kv-act:disabled { opacity: .5; }

/* The statement: one amount, red for what the customer got, green for what they paid */
.kv-cgot { color: var(--red); }
.kv-cgave { color: var(--green); }
/* Interest in gold, as the business's own app has it (app.css .int). */
.kv-cint { color: var(--gold, #8a5a00); }
.kv-mine { margin-left: 6px; }

/* The customer's own entries, and the form for one */
.kv-nacts { display: flex; gap: 6px; flex-shrink: 0; }
.kv-del { color: var(--red); }
.kv-form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.kv-fld { display: flex; flex-direction: column; gap: 4px; }
.kv-fld span { font-size: 13px; color: var(--muted); }
.kv-fld input, .kv-fld select { height: 46px; border: 1px solid var(--surface-3); border-radius: 10px; padding: 0 12px;
  font: 16px var(--sans); background: var(--paper); color: var(--ink); width: 100%; box-sizing: border-box; }
/* iPHONE'S DATE BOX (Vishal's iPhone, 25 Oct 26: wider than the card, its date centred): it keeps a
   width of its own and centres its value unless told otherwise. */
.kv-fld input[type="date"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%;
  text-align: left; line-height: 44px; }
.kv-fld input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.kv-chk { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--body); }
.kv-chk input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--brand-lt); flex-shrink: 0; }
.kv-err { color: var(--red); font-size: 14px; }

/* One entry on its own screen */
.kv-rows > .kv-tap { cursor: pointer; padding-right: 10px; }
.kv-chev-sm { font-size: 22px; margin-left: -4px; }
.kv-rows > .kv-tap:active { background: var(--surface-2); }
.kv-kv { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-top: 10px;
  border-top: 1px solid var(--rule-soft); font-size: 14px; color: var(--muted); }
.kv-kv b { color: var(--ink); font-weight: 600; text-align: right; }
.kv-mono { font-family: var(--mono); font-weight: 500; }
.kv-note2 { padding: 14px 16px; color: var(--body); white-space: pre-wrap; overflow-wrap: anywhere; }

/* The rate list */
.kv-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.kv-chips button { height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--surface-3); background: var(--surface);
  color: var(--body); font-size: 14px; font-weight: 500; cursor: pointer; }
.kv-chips button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); border-color: var(--brand); font-weight: 600; }
.kv-ph { width: 64px; height: 64px; border-radius: 10px; background: var(--surface-3); flex-shrink: 0; object-fit: cover;
  display: flex; align-items: center; justify-content: center; color: var(--muted); }
.kv-rate { font: 600 17px var(--mono); }
.kv-per { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kv-dim .kv-p, .kv-dim .kv-rate { color: var(--muted); }
.kv-ri .kv-ph { width: 52px; height: 52px; font-weight: 700; font-size: 15px; }
.kv-ri .kv-tag { margin-right: 6px; }
.kv-tag.kv-new { color: var(--brand-lt); background: var(--brand-tint); }
.kv-mv { font: 600 12px var(--mono); margin-top: 2px; }
.kv-mv.kv-up { color: var(--red); }
.kv-mv.kv-down { color: var(--green); }
.kv-find { width: 100%; height: 44px; border: 1px solid var(--surface-3); border-radius: 12px; padding: 0 14px;
  font: 15px var(--sans); background: var(--surface); color: var(--ink); }
.kv-find:focus { outline: 2px solid var(--brand-lt); outline-offset: 0; border-color: transparent; }
/* The statement's period (khata-view.js periodBar, 25 Oct 26): ‹ This Year · its dates ▾ ›, the
   native picker laid over the words; two dates below it for Custom. */
/* AS THE BUSINESS'S OWN STATEMENT HAS IT (app.css .periodbar, Vishal 25 Oct 26: "same size as in
   business user and also reduce gap"): bare chevrons, a thin bar with a hairline under it, small
   words - and the search and the lines close beneath, not a section's gap apart. */
/* kv-pbar, NOT kv-per: that name is the rate list's "per 70 Kg" line (above), which this bar's rules
   pulled up over its rate (Vishal's iPhone, 26 Oct 26). */
.kv-pbar { display: flex; align-items: center; border-bottom: 1px solid var(--rule-soft); margin: -12px 0 -6px; padding: 0 2px; }
.kv-perstep { flex: none; width: 2.75rem; height: 2.25rem; font-size: 1.2rem; line-height: 1; padding: 0;
  color: var(--muted); background: none; border: 0; border-radius: 8px; }
.kv-perstep:active { background: var(--surface-2); }
.kv-perstep:disabled { opacity: .3; }
.kv-perpick { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center;
  gap: 8px; flex-wrap: wrap; padding: 0 8px; font-size: 13px; color: var(--faint); letter-spacing: .03em; }
.kv-perpick b { color: var(--ink); font-weight: 600; white-space: nowrap; }
.kv-perpick span { color: var(--faint); white-space: nowrap; }
.kv-perpick::after { content: '▾'; font-size: .7rem; line-height: 1; color: var(--faint); }
.kv-perpick:active { opacity: .6; }
.kv-perpick select { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; border: 0; font-size: 16px;
  -webkit-appearance: none; appearance: none; }
.kv-perdates { display: flex; gap: 10px; margin-top: -6px; }
.kv-perdates .kv-fld { flex: 1; min-width: 0; }
[data-kv="stmtrows"] { margin-top: -6px; }
/* The dues statement's screen (khata-view.js duesScreen): its sentences, and what is left on the bills. */
.kv-dnote { margin: -6px 4px 0; font-size: 14px; line-height: 1.5; color: var(--body); }
.kv-dfoot .kv-amt { font-size: 18px; }
/* How many pending bills it shows (duesPicker), as the business's own screen picks them. */
.kv-dpend { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.kv-dpend .kv-m { display: flex; flex-direction: column; gap: 2px; }
.kv-dpend b { font-size: 15px; font-weight: 600; color: var(--ink); }
.kv-dpend .kv-m span { font-size: 13px; color: var(--muted); }
.kv-dpend select { flex: none; max-width: 55%; height: 42px; border: 1px solid var(--surface-3); border-radius: 10px;
  padding: 0 12px; font: 16px var(--sans); background: var(--paper); color: var(--ink); }
.kv-rl { display: flex; flex-direction: column; gap: 10px; }
.kv-grp { font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 4px 0; text-transform: uppercase; letter-spacing: .04em; }
/* One item */
.kv-item { overflow: hidden; }
.kv-big { display: block; width: 100%; max-height: 60vh; object-fit: contain; background: var(--surface-2); }
.kv-itxt { padding: 16px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.kv-iname { font-size: 20px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
.kv-irate { font: 600 28px/1.15 var(--mono); margin-top: 4px; }
.kv-irate span { font: 500 14px var(--sans); color: var(--muted); }
.kv-irate.kv-ask { font: 600 17px var(--sans); color: var(--muted); }

.kv-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 8px 0 28px; text-align: center; }
.kv-q { font-size: 14px; color: var(--body); }
.kv-made { font-size: 13px; color: var(--muted); padding-top: 6px; }
.kv-made a { color: var(--brand-lt); font-weight: 600; text-decoration: none; }
.kv-empty { padding: 20px 16px; color: var(--muted); text-align: center; }
.kv-toast { position: fixed; left: 16px; right: 16px; bottom: 24px; margin: 0 auto; max-width: 30rem; background: #12141f; color: #fff;
  padding: 12px 16px; border-radius: 10px; font-size: 14px; text-align: center; z-index: 50; }
