/* app.css - Mizan ka poora look. Rang aur font sirf :root ke variables se.
   Theme badalni ho to sirf :root badlein. Mobile-first, 360px se shuru. */

:root {
    --c-primary:      #0f6e56;
    --c-primary-dark: #0a5241;
    --c-primary-text: #ffffff;
    --c-bg:           #f4f6f5;
    --c-surface:      #ffffff;
    --c-text:         #1c2421;
    --c-muted:        #5f6b66;
    --c-border:       #cfd8d4;
    --c-focus:        #2d9b7c;

    --c-ok-bg:        #e3f5ec;
    --c-ok-text:      #13603f;
    --c-error-bg:     #fdecea;
    --c-error-text:   #a1261b;
    --c-warn-bg:      #ffe98a;
    --c-warn-text:    #5a4500;

    --font:           system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
    --fs-base:        17px;
    --fs-small:       14px;
    --fs-big:         32px;

    --c-pos:          #13603f;   /* lena hai */
    --c-neg:          #a1261b;   /* dena hai */
    --c-sale:         #0f6e56;
    --c-purchase:     #1d5fa8;
    --c-receipt:      #2e7d32;
    --c-payment:      #b3541e;
    --c-expense:      #6a4c93;

    --fs-huge:        40px;

    --radius:         12px;
    --gap:            16px;
    --tap:            48px;   /* ungli se dabane ki kam az kam oonchai */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-base);
    line-height: 1.45;
    color: var(--c-text);
    background: var(--c-bg);
}

h1, h2 { margin: 0 0 8px; line-height: 1.2; }
h2 { font-size: 20px; }
a { color: var(--c-primary); }
.muted { color: var(--c-muted); font-size: var(--fs-small); }

/* ---- Top bar ---- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px var(--gap);
    background: var(--c-primary);
    color: var(--c-primary-text);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-text { min-width: 0; }
.topbar .biz {
    font-weight: 700;
    font-size: 18px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar .user { font-size: var(--fs-small); opacity: .85; }
.topbar-logout { margin: 0; flex-shrink: 0; }

.readonly-bar {
    background: var(--c-warn-bg);
    color: var(--c-warn-text);
    padding: 10px var(--gap);
    font-weight: 600;
    font-size: 15px;
}

.content {
    max-width: 560px;
    margin: 0 auto;
    padding: var(--gap);
}

.card {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: var(--gap);
    margin-bottom: var(--gap);
}
.amount { font-size: var(--fs-big); font-weight: 700; }

/* ---- Paanch bare buttons ka grid ---- */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.action-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--c-primary);
    color: var(--c-primary-text);
    font-size: 19px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}
.action-btn small { font-size: 12px; font-weight: 400; opacity: .8; }
.action-btn.is-disabled { background: var(--c-border); color: var(--c-muted); }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 20px;
    border: 0;
    border-radius: var(--radius);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}
.btn-primary { background: var(--c-primary); color: var(--c-primary-text); }
.btn-primary:active { background: var(--c-primary-dark); }
.btn-ghost {
    background: transparent;
    color: var(--c-primary-text);
    border: 1px solid rgba(255, 255, 255, .5);
    min-height: 40px;
    padding: 0 14px;
    font-size: 15px;
}
.btn-block { display: flex; width: 100%; margin-top: 8px; }

/* ---- Forms ---- */
label {
    display: block;
    font-weight: 600;
    margin: 14px 0 6px;
}
input, select, textarea {
    display: block;
    width: 100%;
    min-height: 52px;
    padding: 12px 14px;
    font: inherit;
    font-size: 18px;   /* 16px se kam par iPhone zoom karta hai */
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
}
input:focus, select:focus, textarea:focus {
    outline: 3px solid var(--c-focus);
    outline-offset: 1px;
    border-color: var(--c-focus);
}
input.pin { letter-spacing: .5em; font-size: 24px; text-align: center; }
form .btn-block { margin-top: 22px; }

/* ---- Messages ---- */
.ok, .error {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin: 12px 0;
    font-weight: 600;
}
.ok    { background: var(--c-ok-bg);    color: var(--c-ok-text); }
.error { background: var(--c-error-bg); color: var(--c-error-text); }

/* ---- Login ---- */
.login-page { display: flex; min-height: 100vh; align-items: flex-start; }
.login-box {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    padding: 40px var(--gap) var(--gap);
}
.login-box .brand { color: var(--c-primary); font-size: 34px; }

/* ---- Step 2: home ---- */
.topbar .biz a { color: inherit; text-decoration: none; }
.action-btn { min-height: 88px; gap: 4px; }
.action-icon { font-size: 30px; line-height: 1; }
.a-sale     { background: var(--c-sale); }
.a-purchase { background: var(--c-purchase); }
.a-receipt  { background: var(--c-receipt); }
.a-payment  { background: var(--c-payment); }
.a-expense  { background: var(--c-expense); }

.tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 20px;
}
.tile {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    padding: 12px;
    min-width: 0;
}
.tile-label { font-size: var(--fs-small); color: var(--c-muted); }
.tile-val { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }

.bal-pos  { color: var(--c-pos); }
.bal-neg  { color: var(--c-neg); }
.bal-zero { color: var(--c-muted); }

/* ---- Step 2: wizard ---- */
.wiz-head {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}
.wiz-head form { margin: 0; }
.wiz-name { font-weight: 700; font-size: 20px; }
.q { font-size: 22px; margin: 8px 0 12px; display: block; }

.btn-light {
    background: var(--c-surface);
    color: var(--c-text);
    border: 1px solid var(--c-border);
}
.btn-outline {
    background: transparent;
    color: var(--c-primary);
    border: 2px dashed var(--c-primary);
}
.btn-big { min-height: 60px; font-size: 20px; }
.btn-block + .btn-block { margin-top: 10px; }

.list-search { margin-bottom: 10px; }
.pick-list {
    max-height: 55vh;
    overflow-y: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    margin-bottom: 12px;
}
.pick-list .empty-msg { padding: 12px 14px; margin: 0; }
.pick-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 56px;
    padding: 10px 14px;
    border: 0;
    border-bottom: 1px solid var(--c-border);
    background: transparent;
    font: inherit;
    text-align: left;
    color: var(--c-text);
    cursor: pointer;
}
.pick-item:last-of-type { border-bottom: 0; }
.pick-item:active { background: var(--c-bg); }
.pick-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.pick-meta { font-size: var(--fs-small); white-space: nowrap; }

.add-new { margin: 12px 0; }
.add-new summary { list-style: none; }
.add-new summary::-webkit-details-marker { display: none; }
.add-new[open] summary { margin-bottom: 10px; }

.tap-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.tap-btn {
    min-height: 64px;
    padding: 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    font: inherit;
    font-weight: 600;
    color: var(--c-text);
    cursor: pointer;
}
.tap-btn:active { background: var(--c-ok-bg); border-color: var(--c-primary); }

.lines {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    margin-bottom: 12px;
}
.lines-confirm { border: 0; margin: 10px 0; }
.line {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--c-border);
}
.line:last-child { border-bottom: 0; }
.line form { margin: 0; }
.line-main { flex: 1; min-width: 0; }
.line-name { font-weight: 600; overflow-wrap: anywhere; }
.line-amt { font-weight: 700; white-space: nowrap; }
.btn-x {
    width: var(--tap);
    height: var(--tap);
    border: 0;
    border-radius: 50%;
    background: var(--c-error-bg);
    color: var(--c-error-text);
    font-size: 24px;
    cursor: pointer;
}
.line-preview { margin-top: 10px; }

.total-bar {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
    padding: 14px 4px;
    margin: 8px 0;
    border-top: 2px solid var(--c-border);
}
.total-big { font-size: 30px; font-weight: 800; overflow-wrap: anywhere; text-align: right; }

.choices { display: grid; gap: 10px; }
.choices-row { grid-template-columns: 1fr 1fr; }
.choice { margin: 0; font-weight: 600; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.choice span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    padding: 10px;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    text-align: center;
}
.choice input:checked + span {
    border-color: var(--c-primary);
    background: var(--c-ok-bg);
    color: var(--c-primary-dark);
}
.choice input:focus-visible + span { outline: 3px solid var(--c-focus); outline-offset: 1px; }
.sub-q { margin-top: 16px; }
.sub-q .label { font-weight: 600; margin-bottom: 6px; }
.input-big { font-size: 30px; min-height: 64px; font-weight: 700; }

.confirm .kv {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
}
.confirm .kv > :last-child { text-align: right; overflow-wrap: anywhere; }
.confirm-total {
    text-align: center;
    padding: 14px 0;
    margin: 6px 0;
    border-top: 1px solid var(--c-border);
    border-bottom: 1px solid var(--c-border);
}
.amount-huge { font-size: var(--fs-huge); font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.after-bal {
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--c-bg);
    border-radius: var(--radius);
}

.done { text-align: center; }
.done-tick {
    width: 64px;
    height: 64px;
    margin: 4px auto 10px;
    border-radius: 50%;
    background: var(--c-ok-bg);
    color: var(--c-ok-text);
    font-size: 36px;
    line-height: 64px;
}

/* ---- Step 3: reports ---- */
.content { padding-bottom: 96px; }   /* bottom bar ke neechay content na chhupe */

.bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-bar a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60px;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-muted);
    text-decoration: none;
}
.bottom-bar a.is-on { color: var(--c-primary); background: var(--c-ok-bg); }
.bb-icon { font-size: 22px; line-height: 1.2; }

.seg {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}
.seg-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 4px 6px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    color: var(--c-text);
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
}
.seg-btn.is-on { background: var(--c-primary); border-color: var(--c-primary); color: var(--c-primary-text); }
.seg-big .seg-btn { min-height: 56px; font-size: 18px; }

.range-custom summary {
    cursor: pointer;
    color: var(--c-primary);
    font-weight: 600;
    min-height: 40px;
    display: flex;
    align-items: center;
}
.range-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.range-dates label { margin: 6px 0 0; }
.range-dates input { font-size: 16px; padding: 8px; }
.range-text { font-weight: 700; margin: 6px 0 10px; }

.rep-head { margin-bottom: 12px; }
.rep-head .btn { margin-bottom: 8px; }
.rep-title { font-size: 26px; margin: 4px 0; overflow-wrap: anywhere; }
.big-bal { font-size: 28px; font-weight: 800; margin-top: 6px; }
.legend { margin: 4px 0 8px; }
.print-only { display: none; }

.rep-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }

.strip {
    background: var(--c-ok-bg);
    color: var(--c-ok-text);
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 18px;
}

.rows {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    overflow: hidden;
}
.row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-text);
    text-decoration: none;
}
a.row:active { background: var(--c-bg); }
.row:last-child { border-bottom: 0; }
.row-left { flex: 1; min-width: 0; }
.row-right { text-align: right; white-space: nowrap; font-weight: 700; }
.row-date { font-size: var(--fs-small); color: var(--c-muted); }
.row-title { font-weight: 600; overflow-wrap: anywhere; }
.row-amt { font-size: 18px; font-weight: 700; }
.row-bal { font-size: var(--fs-small); font-weight: 600; color: var(--c-muted); }
.row-bal.bal-pos { color: var(--c-pos); }
.row-bal.bal-neg { color: var(--c-neg); }
.row-qty { font-size: 18px; }
.row-sum { background: var(--c-bg); }
.row-close .row-title { font-size: 18px; }
.row-right.big { font-size: 22px; }
.row-bad { background: var(--c-error-bg); }
.row-bad .row-title, .row-bad .row-qty { color: var(--c-error-text); }
.rows > .btn { border-radius: 0; margin: 0; }
.rows > .empty-msg { padding: 12px 14px; margin: 0; }
.tag {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 99px;
    background: var(--c-warn-bg);
    color: var(--c-warn-text);
}

/* Din ki closing - sab se bara aur saaf */
.day-nav { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.day-nav .btn { min-width: var(--tap); padding: 0 12px; font-size: 22px; }
.day-nav .is-disabled { opacity: .35; }
.day-form { flex: 1; margin: 0; }
.day-form input { text-align: center; }
.day-title { font-size: 28px; }
.tiles-3 { margin-top: 10px; }
.tile-big { padding: 14px; }
.tile-big .tile-label { font-size: 15px; font-weight: 600; }
.tile-big .tile-val { font-size: 24px; }
.tile-cash { background: var(--c-ok-bg); border-color: var(--c-primary); }
@media (min-width: 480px) {
    .tiles-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ---- Print: menu aur buttons chhup jayein ---- */
@media print {
    body { background: #fff; font-size: 12pt; }
    .no-print, .bottom-bar, .topbar-logout, .readonly-bar, .list-search, .rep-actions, .soon-msg { display: none !important; }
    .print-only { display: block; }
    .topbar { position: static; background: none; color: #000; padding: 0 0 8px; border-bottom: 2px solid #000; }
    .content { max-width: none; padding: 8px 0; }
    .rows, .tile, .card { border-color: #999; }
    .row { break-inside: avoid; padding: 6px 4px; }
    a { color: #000; text-decoration: none; }
    .bal-pos, .bal-neg, .row-bad .row-title { color: #000 !important; }
    .row-bad { background: none; border-left: 4px solid #000; }
}

/* ---- Step 3b: settings ---- */
.topbar-text { flex: 1; }
.topbar-set { font-size: 20px; padding: 0 12px; text-decoration: none; }
.style-pick {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 84px;
    border: 2px solid var(--c-border);
    border-radius: var(--radius);
    background: var(--c-surface);
    font: inherit;
    font-weight: 600;
    color: var(--c-text);
    cursor: pointer;
}
.style-pick .ur { font-size: 24px; line-height: 1.6; }
.style-pick .style-icon { font-size: 24px; }
.style-pick.is-on { border-color: var(--c-primary); background: var(--c-ok-bg); color: var(--c-primary-dark); }
.style-pick:disabled { cursor: not-allowed; opacity: .7; }


/* ---- KHATA: asal dukaan wale register jaisa (right-to-left) ----
   تاریخ | تفصیل | صفحہ | نام (روپیہ|پیسہ) | جمع (روپیہ|پیسہ) | نام یا جمع | بقایا (روپیہ|پیسہ)
   Urdu: Nastaleeq. RAQAM: hamesha saaf tabular font, gehra kaala. */
:root {
    --k-paper:   #fffefa;
    --k-red:     #e0605a;    /* register ki laal lakeer */
    --k-red-dk:  #c0392b;
    --k-dot:     #8a97b3;    /* dotted aari lakeer */
    --k-ink:     #1a1a1a;
    --k-num:     #111111;
    --k-pos:     #0b5d2a;    /* نام - lena - gehra sabz */
    --k-neg:     #9e1b12;    /* جمع - dena - gehra laal */
    --k-open:    #f6f0de;
    --k-urdu:    "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", "Gulzar", "Urdu Typesetting", serif;
    --k-hand:    "Caveat", "Segoe Print", cursive;
    --k-numfont: system-ui, -apple-system, "Segoe UI", Roboto, "Roboto Mono", sans-serif;
    --topbar-h:  62px;
}

.content:has(.khata) { max-width: 900px; }
.k-tools { margin-bottom: 12px; }
.k-tools > .btn { margin-bottom: 8px; }

.khata {
    background: var(--k-paper);
    color: var(--k-ink);
    border: 1px solid #ddd6c6;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .08);
    padding: 12px 10px 16px;
    font-family: var(--k-urdu);
    margin: 0 -6px;
}

/* Sar-nama: "کھاتہ بنام ______" */
.k-top { padding: 0 4px 6px; }
.k-heading {
    display: flex;
    align-items: baseline;
    gap: 10px;
    border-bottom: 0;
}
.k-heading-ur { font-size: 26px; font-weight: 700; line-height: 2.1; white-space: nowrap; }
.k-name {
    flex: 1;
    min-width: 0;
    border-bottom: 1.5px solid #555;      /* naam ki lakeer */
    font-family: var(--k-hand), var(--k-urdu);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.5;
    color: #1d2d5a;                        /* neeli siyahi */
    padding: 0 6px;
    overflow-wrap: anywhere;
}
.k-sub { font-family: var(--k-numfont); font-size: 12px; color: #555; margin-top: 4px; text-align: left; }

/* ---- Grid: chauri screen / A4 par das khane ---- */
.k-grid { display: grid; }
.k-row {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted var(--k-dot);
}
a.k-row:active { background: rgba(138, 151, 179, .12); }
.k-row > div { padding: 5px 6px; min-width: 0; }

/* HAR RAQAM - saaf, tabular, gehra kaala; register ki tarah paisa ke saath chipka */
.c-rs, .c-ps, .c-date, .c-page {
    font-family: var(--k-numfont);
    font-variant-numeric: tabular-nums;
    direction: ltr;
    unicode-bidi: isolate;
}
.c-rs { font-size: 17px; font-weight: 700; color: var(--k-num); text-align: left; white-space: nowrap; }
.c-ps { font-size: 13px; font-weight: 600; color: #333; text-align: center; }
.c-date { font-size: 13px; color: #333; text-align: center; }
.c-page { font-size: 13px; color: #333; text-align: center; }
.c-desc { font-size: 17px; line-height: 2; }
.c-side { font-size: 14px; text-align: center; line-height: 1.8; }
.k-note { font-family: var(--font); font-size: 12px; color: #555; line-height: 1.3; }
.ps-inline { display: none; }
.k-pos  { color: var(--k-pos) !important; }
.k-neg  { color: var(--k-neg) !important; }
.k-zero { color: #777 !important; }

.k-head {
    position: sticky;
    top: var(--topbar-h);
    z-index: 5;
    background: var(--k-paper);
    border-top: 2px solid var(--k-red);
    border-bottom: 4px double var(--k-red);
    text-align: center;
    font-size: 15px;
    line-height: 1.9;
}
.k-head small { font-family: var(--font); font-size: 10px; color: #777; }
.k-head .h-desc { font-size: 20px; }
.k-head .h-side { font-size: 11px; line-height: 1.5; }
.k-head .h-rs, .k-head .h-ps { font-size: 12px; border-top: 1px solid var(--k-red); }

.k-open { background: var(--k-open); }
.k-open .c-desc { font-weight: 700; }
.k-close {
    border-top: 3px double var(--k-red);
    border-bottom: 0;
    margin-top: 2px;
    align-items: center;
}
.k-close .c-desc { font-size: 22px; font-weight: 700; }
.k-close .c-rs { font-size: 26px; font-weight: 800; }
.k-empty .c-desc { font-size: 15px; color: #777; }
.khata > .btn { margin: 8px 0; }

@media (min-width: 700px) {
    .khata { margin: 0; padding: 16px 18px 20px; }
    .k-grid { grid-template-columns: 70px minmax(0, 1fr) 44px 96px 30px 96px 30px 34px 104px 30px; }
    .khata.k-noside .k-grid { grid-template-columns: 70px minmax(0, 1fr) 44px 96px 30px 96px 30px 104px 30px; }

    /* laal khari lakeerein - har khane ke bayein (RTL mein aglay khane se pehle) */
    .k-grid > div { border-left: 1px solid var(--k-red); }
    .k-grid > div:last-child { border-left: 0; }

    /* unwan: do manzil */
    .h-date  { grid-column: 1;      grid-row: 1 / 3; align-self: stretch; display: flex; align-items: center; justify-content: center; }
    .h-desc  { grid-column: 2;      grid-row: 1 / 3; display: flex; align-items: center; justify-content: center; }
    .h-page  { grid-column: 3;      grid-row: 1 / 3; display: flex; align-items: center; justify-content: center; }
    .h-a     { grid-column: 4 / 6;  grid-row: 1; }
    .h-b     { grid-column: 6 / 8;  grid-row: 1; }
    .h-side  { grid-column: 8;      grid-row: 1 / 3; }
    .h-bal   { grid-column: 9 / 11; grid-row: 1; font-size: 18px; }
    .h-a-rs { grid-column: 4; grid-row: 2; }  .h-a-ps { grid-column: 5; grid-row: 2; }
    .h-b-rs { grid-column: 6; grid-row: 2; }  .h-b-ps { grid-column: 7; grid-row: 2; }
    .h-bal-rs { grid-column: 9; grid-row: 2; } .h-bal-ps { grid-column: 10; grid-row: 2; border-left: 0; }
    .k-noside .h-bal    { grid-column: 8 / 10; }
    .k-noside .h-bal-rs { grid-column: 8; }
    .k-noside .h-bal-ps { grid-column: 9; }
    .h-m-right, .h-m-left { display: none; }

    .k-close .c-desc { grid-column: 1 / 8; text-align: center; }
    .k-noside .k-close .c-desc { grid-column: 1 / 8; }
    .k-empty .c-desc { grid-column: 1 / -1; text-align: center; }
}

/* ---- Mobile: do hisse - dayein tareekh/tafseel, bayein raqam/bakaya ---- */
@media (max-width: 699.98px) {
    .k-grid { grid-template-columns: minmax(0, 1fr) 132px;  /* sab rows mein ek hi chaudai - laal lakeer seedhi */ }
    .k-head > div:not(.h-m-right):not(.h-m-left) { display: none; }
    .h-m-right, .h-m-left { font-size: 14px; }
    .h-m-left { border-right: 1px solid var(--k-red); }

    .k-row .c-date { grid-column: 1; grid-row: 1; text-align: right; padding-bottom: 0; }
    .k-row .c-desc { grid-column: 1; grid-row: 2; }
    .k-row .c-page, .k-row .c-ps, .k-row .c-side { display: none; }
    .k-row .c-rs {
        grid-column: 2;
        border-right: 1px solid var(--k-red);    /* amoodi laal lakeer */
        text-align: left;
    }
    .k-row .c-a, .k-row .c-b { grid-row: 1; }
    .k-row .c-rs.c-a:empty, .k-row .c-rs.c-b:empty { display: none; }
    .k-row .c-bal { grid-row: 2; font-size: 14px; }
    .ps-inline { display: inline; }
    .c-rs.c-a:not(:empty)::before { content: var(--la) " "; }
    .c-rs.c-b:not(:empty)::before { content: var(--lb) " "; }
    .c-rs.c-a::before, .c-rs.c-b::before, .c-bal[data-w]::before {
        font-family: var(--k-urdu);
        font-size: 12px;
        font-weight: 400;
        color: #555;
    }
    .c-bal[data-w]:not([data-w=""])::before { content: attr(data-w) " "; }
    .k-open .c-desc { grid-row: 1 / 3; }
    .k-close .c-desc { grid-column: 1; grid-row: 1; }
    .k-close .c-bal { grid-row: 1; border-right: 0; font-size: 24px; font-weight: 800; }  /* aaj ka bakaya - sab se bara */
}

/* ---- Print: A4, lakeerein aur rang rahein ---- */
@media print {
    @page { size: A4; margin: 10mm; }
    .khata, .khata * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .khata { margin: 0; box-shadow: none; border: 0; padding: 0; }
    .k-head { position: static; }
    .k-row { break-inside: avoid; }
    .topbar-set { display: none !important; }
}

/* ---- Step 4: opening wizard, lists, users ---- */
.setup-banner {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    margin-bottom: 14px;
    border-radius: var(--radius);
    background: var(--c-warn-bg);
    color: var(--c-warn-text);
    text-decoration: none;
}
.setup-banner strong { font-size: 18px; }
.setup-go { font-weight: 700; }

.steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin: 12px 0;
}
.steps a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    border-radius: var(--radius);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    color: var(--c-muted);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
}
.steps a span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--c-border);
    color: var(--c-text);
}
.steps a.is-on { border-color: var(--c-primary); color: var(--c-primary); background: var(--c-ok-bg); }
.steps a.is-on span { background: var(--c-primary); color: var(--c-primary-text); }

.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 500; margin-top: 16px; }
.check input { width: 24px; min-height: 24px; height: 24px; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.csv-help { padding-left: 20px; margin: 8px 0; }
input[type="file"] { min-height: 0; padding: 10px; font-size: 15px; margin: 10px 0; }
.hub { margin-bottom: 16px; }
.hub .row-right { font-size: 24px; color: var(--c-muted); }
.choice .ur { font-family: "Noto Nastaliq Urdu", "Jameel Noori Nastaleeq", serif; font-size: 14px; }
.card > h2 { margin-bottom: 4px; }

/* ---- Report buttons: WhatsApp (wa.me) + PDF (print) ---- */
.btn-wa { background: #25d366; color: #fff; border-color: #25d366; text-decoration: none; }
.btn-wa:active { background: #1da851; }
.rep-hint { font-size: 12px; margin: -2px 0 10px; }
