/* Kiran Gold Loan — counter interface. Vault ink, paper slips, a thread of gold. */
:root {
  --ink: #1d2a2e;
  --muted: #5d6b6e;
  --vault: #16323a;
  --vault-2: #21454f;
  --gold: #a67a26;
  --gold-soft: #f4ead6;
  --paper: #ffffff;
  --bg: #edf0ef;
  --line: #d5dbd9;
  --red: #b3261e; --red-soft: #fbe9e7;
  --green: #1d7348; --green-soft: #e3f3ea;
  --amber: #8a5d00; --amber-soft: #fdf1d6;
  --blue: #1f5c86; --blue-soft: #e4eef6;
  --radius: 6px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Tamil", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--ink); background: var(--bg); }
a { color: var(--blue); }
a:hover { color: var(--vault); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .75rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; font-weight: 650; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--paper); padding: .5rem 1rem; z-index: 50; }
.skip:focus { left: .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-line; }
.nowrap { white-space: nowrap; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--red); font-weight: 650; }
.lead { font-size: 1.05rem; color: var(--muted); margin-top: 0; }
.req { color: var(--red); }
.warn-text { display: block; color: var(--amber); font-weight: 600; margin-top: .25rem; }

/* Shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; background: var(--vault); color: #fff; }
.topbar a { color: #fff; text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.05rem; }
.brand-mark { width: 14px; height: 22px; border-radius: 3px; background: linear-gradient(160deg, #d9b25f, var(--gold) 60%, #7d5a17); box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.brand-lg { font-size: 1.35rem; color: var(--ink); }
.brand-lg .brand-mark { width: 16px; height: 26px; }
.topbar-user { margin-left: auto; display: flex; align-items: center; gap: .6rem; }
.topbar-user .user-name { font-weight: 600; }
.nav-toggle { display: none; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: var(--radius); padding: .35rem .7rem; font: inherit; }
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
.sidenav { background: var(--paper); border-right: 1px solid var(--line); padding: 1rem .75rem; }
.sidenav ul { list-style: none; margin: 0; padding: 0; }
.sidenav a { display: block; padding: .55rem .75rem; border-radius: var(--radius); color: var(--ink); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.sidenav a:hover { background: var(--bg); }
.sidenav a[aria-current="page"] { background: var(--gold-soft); border-left-color: var(--gold); font-weight: 650; }
.nav-note a { display: inline; padding: 0; border: 0; color: var(--amber); text-decoration: underline; font-weight: 650; }
.nav-note { margin: 1rem .5rem; padding: .6rem; font-size: .82rem; background: var(--amber-soft); border-radius: var(--radius); color: var(--amber); }
.main { padding: 1.5rem 1.75rem 4rem; max-width: 1280px; width: 100%; min-width: 0; }
.main:focus { outline: none; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }

/* Cards & grids */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.card.narrow { max-width: 460px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.grid-2 > .card, .grid-2 > .slip { margin-bottom: 0; }
.grid-2 + .card, .grid-2 + section { margin-top: 1.25rem; }
.empty { color: var(--muted); }
.card.empty { text-align: center; padding: 2rem 1rem; }

/* Stats: a ledger strip, not a card wall */
.stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 1.25rem; overflow: hidden; }
.stat { display: flex; flex-direction: column; padding: 1rem 1.1rem; text-decoration: none; color: var(--ink); border-right: 1px solid var(--line); min-width: 0; }
.stat:last-child { border-right: 0; }
.stat:hover { background: #f7f8f8; }
.stat-label { font-size: .85rem; color: var(--muted); }
.stat-value { font-size: clamp(1.1rem, 1.7vw, 1.45rem); font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stat-sub { font-size: .78rem; color: var(--muted); }
.stat-wide .stat-value { color: var(--vault); }
.stat-alert { background: var(--red-soft); }
.stat-alert .stat-value { color: var(--red); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; padding: .5rem .95rem; min-height: 40px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; line-height: 1.2; }
.btn:hover { border-color: var(--vault-2); color: var(--ink); }
.btn-primary { background: var(--vault); border-color: var(--vault); color: #fff; }
.btn-primary:hover { background: var(--vault-2); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue); }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { color: #fff; filter: brightness(1.08); }
.btn-wa { background: #1c7c4a; border-color: #1c7c4a; color: #fff; }
.btn-wa:hover { color: #fff; filter: brightness(1.08); }
.btn-sm { min-height: 32px; padding: .3rem .65rem; font-size: .85rem; }
.btn-block { width: 100%; margin-top: 1rem; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.page-head .actions, .report-head .actions { margin-top: 0; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--line); z-index: 5; }
.inline { display: inline; }
.row-actions { white-space: nowrap; text-align: right; }

/* Forms */
label, legend { display: block; font-weight: 600; font-size: .9rem; margin: .75rem 0 .3rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid #b9c3c1; border-radius: var(--radius); padding: .5rem .65rem; min-height: 40px; }
input[type="file"] { padding: .4rem; background: var(--bg); }
input:focus, select:focus, textarea:focus { border-color: var(--vault); outline: 2px solid rgba(166,122,38,.45); outline-offset: 0; }
.input-sm { min-height: 32px; padding: .25rem .4rem; width: 8rem; }
.help { font-size: .82rem; color: var(--muted); margin: .25rem 0 0; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1rem 1rem; margin: 0; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.span-2 { grid-column: 1 / -1; }
.field > label:first-child { margin-top: .75rem; }
.searchbar { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.searchbar input { flex: 1 1 280px; }
.searchbar select { flex: 0 0 auto; width: auto; }
.filters { display: flex; flex-wrap: wrap; gap: 0 1rem; align-items: flex-end; }
.filters .field { flex: 1 1 160px; }
.filters .actions { margin-top: .75rem; }
.inline-date { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; padding-bottom: .75rem; border-bottom: 1px dashed var(--line); margin-bottom: .25rem; }
.inline-date label { width: 100%; margin-bottom: 0; }
.inline-date input { flex: 1 1 150px; width: auto; }
.terms-note { background: var(--bg); border-radius: var(--radius); padding: .75rem 1rem; margin-top: 1rem; font-size: .88rem; }
.waiver { margin-top: 1rem; border-color: var(--gold); background: #fffcf6; }

/* Webcam */
.capture-row { display: grid; grid-template-columns: 260px 1fr; gap: 1rem; align-items: start; }
.capture-stage { width: 260px; aspect-ratio: 4 / 3; background: var(--bg); border: 1px dashed #b9c3c1; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; }
.capture-stage video, .capture-stage img { width: 100%; height: 100%; object-fit: cover; }
.capture-controls .btn { margin: 0 .4rem .4rem 0; }

/* Items */
.item-row { margin-bottom: 1rem; background: #fbfcfc; }
.item-row legend { margin: 0; padding: 0 .4rem; }
.item-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 1rem; }
.totals { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; margin: 1rem 0; padding: .75rem 1rem; background: var(--gold-soft); border-radius: var(--radius); font-variant-numeric: tabular-nums; }
.totals .over { color: var(--red); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card.table-wrap { padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { padding: .6rem .75rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { font-size: .8rem; color: var(--muted); font-weight: 650; background: #f6f8f7; white-space: nowrap; }
tfoot th { background: #f6f8f7; font-weight: 700; }
tbody tr:hover { background: #fafbfb; }
td a[href^="loan_view"], td a[href^="receipt"] { white-space: nowrap; }
.grid-2 > * { min-width: 0; }
tr.reversed td { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(179,38,30,.5); }
tr.reversed td:last-child, tr.reversed td:nth-child(3) { text-decoration: none; }
table.review th { font-weight: 500; color: var(--muted); border-bottom-style: dashed; }
table.review td { font-weight: 600; }
table.review tr.total th, table.review tr.total td { color: var(--ink); font-weight: 700; font-size: 1.05rem; border-top: 2px solid var(--ink); border-bottom: 0; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin: .75rem 0; }
.pager span { margin-right: auto; }

/* Badges & alerts */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 650; vertical-align: middle; white-space: nowrap; }
.b-blue { background: var(--blue-soft); color: var(--blue); }
.b-green { background: var(--green-soft); color: var(--green); }
.b-red { background: var(--red-soft); color: var(--red); }
.b-amber { background: var(--amber-soft); color: var(--amber); }
.b-grey { background: #e7eaea; color: #4d5a5c; }
.b-gold { background: var(--gold-soft); color: #7a5512; }
.alert { padding: .75rem 1rem; border-radius: var(--radius); margin: 0 0 1rem; border: 1px solid transparent; }
.alert ul { margin: .35rem 0 0; padding-left: 1.2rem; }
.alert-success { background: var(--green-soft); border-color: #b5dcc6; color: #14502f; }
.alert-error { background: var(--red-soft); border-color: #f0bdb8; color: #7d1a14; }
.alert-info { background: var(--blue-soft); border-color: #c3d8e9; color: #183f5c; }
.alert-warn { background: var(--amber-soft); border-color: #ecd49b; color: #5c3e00; }

/* The settlement slip — the one place gold is used at full strength */
.slip { background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; }
.slip-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.slip-head h3 { margin: 0 auto 0 0; font-size: 1.05rem; }
.figures { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; margin: 0; }
.figures div { display: flex; justify-content: space-between; gap: .75rem; padding: .4rem 0; border-bottom: 1px dotted var(--line); }
.figures dt { color: var(--muted); font-size: .88rem; }
.figures dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.slip-total { display: flex; justify-content: space-between; align-items: baseline; margin-top: .9rem; padding-top: .75rem; border-top: 2px dashed var(--gold); }
.slip-total strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.calc { margin-top: .75rem; font-size: .88rem; }
.calc summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.calc ol { padding-left: 1.2rem; margin: .5rem 0 0; color: var(--muted); }
.loan-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem; background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--vault); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; }

/* Profile & media */
.profile { display: grid; grid-template-columns: 140px 1fr; gap: 1.25rem; }
.avatar { width: 140px; height: 170px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.avatar-empty { display: grid; place-items: center; background: var(--bg); color: var(--muted); font-size: .85rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; }
.thumbs { display: flex; flex-wrap: wrap; gap: .6rem; }
.thumb { display: flex; flex-direction: column; width: 110px; text-decoration: none; color: var(--ink); }
.thumb img, .thumb .pdf { width: 110px; height: 85px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); background: var(--bg); }
.thumb .pdf { display: grid; place-items: center; font-weight: 700; color: var(--red); }
.thumb .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumbs-sm .thumb, .thumbs-sm .thumb img { width: 48px; height: 48px; }
.current-photo { width: 100%; height: 100%; object-fit: cover; }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: grid; grid-template-columns: 170px 1fr; gap: .75rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.activity .when { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.danger-zone { border-color: #f0bdb8; }
.inline-form summary { list-style: none; display: inline-flex; }
.inline-form summary::-webkit-details-marker { display: none; }
.inline-form form { margin-top: .5rem; min-width: 220px; }
.release-list { padding-left: 1.2rem; }
.tabs { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.tabs a { padding: .55rem .85rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--gold); }
.report-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; align-items: flex-start; }
code.details { font-size: .78rem; white-space: pre-wrap; word-break: break-word; color: var(--muted); display: block; max-width: 520px; }

/* Contact, dues, locator, tags */
.contact-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.contact-actions form { margin: 0; }
.btn-call { background: var(--blue-soft); border-color: #bcd3e6; color: var(--blue); }
.btn-call:hover { color: var(--blue); border-color: var(--blue); }
.phone-big { font-size: 1.5rem; font-weight: 700; margin: 0 0 .5rem; font-variant-numeric: tabular-nums; }
.tabs .count { display: inline-block; min-width: 1.6em; padding: 0 .4em; border-radius: 999px; background: #e7eaea; color: var(--ink); font-size: .78rem; text-align: center; }
.tabs .count-alert { background: var(--red); color: #fff; }
.due-list { display: grid; gap: .75rem; }
.due-card { background: var(--paper); border: 1px solid var(--line); border-left: 4px solid var(--amber); border-radius: var(--radius); padding: .85rem 1rem; }
.due-card.is-overdue { border-left-color: var(--red); }
.due-main { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.due-amount { text-align: right; display: flex; flex-direction: column; }
.due-amount strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.due-last { margin: .4rem 0; }
.due-actions { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.due-actions .contact-actions { margin: 0; }
.gold-location { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; background: var(--gold-soft); border-radius: var(--radius); padding: .75rem 1rem; margin: .75rem 0 1rem; }
.gold-location > div { display: flex; flex-direction: column; }
.packet-id { white-space: nowrap; font-size: 1.25rem; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.locate-card { border-top: 4px solid var(--gold); }
.locate-where { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; padding-bottom: .75rem; border-bottom: 1px dashed var(--line); margin-bottom: .75rem; }
.locate-where > div { display: flex; flex-direction: column; }
.locate-where .big { font-size: 1.6rem; line-height: 1.15; overflow-wrap: anywhere; }
.locate-where .packet-id { font-size: clamp(1.1rem, 4vw, 1.6rem); overflow-wrap: normal; }
.locate-who { display: flex; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.avatar-sm { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 1px solid var(--line); }
.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; margin: 0; }
.check { white-space: nowrap; }
.searchbar .check input, .check input { width: auto; min-height: 0; flex: 0 0 auto; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 170px 1fr; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.timeline .when { color: var(--muted); font-size: .85rem; }
.tags { display: grid; gap: 6mm; justify-content: center; padding: 1rem; }
.tag { width: 100mm; background: #fff; border: 1px dashed #777; padding: 4mm 5mm; font-size: 10pt; color: #000; break-inside: avoid; }
.tag header { display: flex; justify-content: space-between; font-weight: 700; border-bottom: 1px solid #000; padding-bottom: 1.5mm; margin-bottom: 2mm; }
.tag-code { text-align: center; }
.tag-code svg { max-width: 100%; height: 14mm; }
.tag-id { font-size: 18pt; font-weight: 800; letter-spacing: .04em; }
.tag dl { display: grid; grid-template-columns: max-content 1fr; gap: .5mm 3mm; margin: 2mm 0 0; }
.tag dt { font-weight: 600; }
.tag dd { margin: 0; }

/* Plain pages */
body.plain { display: grid; place-items: center; min-height: 100vh; padding: 1rem; }
.login-card, .error-box { width: 100%; max-width: 400px; background: var(--paper); border: 1px solid var(--line); border-top: 4px solid var(--gold); border-radius: var(--radius); padding: 2rem; }
.error-box { max-width: 560px; }

/* Receipts */
.receipt-page { background: var(--bg); }
.receipt-tools { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; max-width: 820px; margin: 1rem auto; padding: 0 1rem; }
.receipt-tools p { width: 100%; margin: 0; }
.receipt { position: relative; max-width: 820px; margin: 0 auto 2rem; background: var(--paper); border: 1px solid var(--line); border-top: 5px solid var(--gold); padding: 2rem; }
.r-head { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 2px solid var(--ink); padding-bottom: 1rem; margin-bottom: 1rem; }
.r-doc { text-align: right; }
.r-doc h1 { font-size: 1.2rem; margin: 0 0 .25rem; }
.r-grid { display: grid; grid-template-columns: 1fr auto; gap: 1rem; }
.r-photo { width: 150px; height: 120px; object-fit: cover; border: 1px solid var(--line); border-radius: 4px; }
.r-table { margin: 1rem 0; }
.r-table tr.sep td { border-top: 2px solid var(--line); }
.r-table tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
.r-sub { margin-top: 1.5rem; }
.r-foot { margin-top: 2rem; }
.sign { display: flex; justify-content: space-between; margin: 3rem 0 1rem; gap: 2rem; }
.sign span { flex: 1; border-top: 1px solid var(--ink); padding-top: .3rem; font-size: .85rem; }
.stamp { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) rotate(-18deg); font-size: 4rem; font-weight: 800; color: rgba(179,38,30,.18); border: 6px solid rgba(179,38,30,.18); padding: .25rem 1.5rem; pointer-events: none; }

/* Responsive */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat:nth-child(3n) { border-right: 0; }
  .stat:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .nav-toggle { display: inline-block; }
  .shell { grid-template-columns: 1fr; }
  .sidenav { display: none; position: fixed; inset: 52px 0 auto 0; z-index: 15; border-bottom: 1px solid var(--line); box-shadow: 0 8px 20px rgba(22,50,58,.15); max-height: calc(100vh - 52px); overflow-y: auto; }
  .sidenav.open { display: block; }
  .main { padding: 1rem 1rem 4rem; }
  .grid-2, .form-grid { grid-template-columns: 1fr; }
  .topbar-user .badge, .topbar-user .user-name { display: none; }
  .capture-row { grid-template-columns: 1fr; }
  .profile { grid-template-columns: 1fr; }
  .activity li, .timeline li { grid-template-columns: 1fr; gap: 0; }
  .locate-where { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { font-size: 1.05rem; }
  .stat { border-right: 1px solid var(--line) !important; border-bottom: 1px solid var(--line); }
  .stat:nth-child(2n) { border-right: 0 !important; }
  .figures { grid-template-columns: 1fr; }
  .item-grid { grid-template-columns: 1fr 1fr; }
  .item-grid .span-2 { grid-column: 1 / -1; }
  .receipt { padding: 1rem; }
  .r-head, .r-grid { flex-direction: column; grid-template-columns: 1fr; }
  .r-doc { text-align: left; }
  .due-main { flex-direction: column; gap: .25rem; }
  .due-amount { text-align: left; }
  .due-actions .btn, .contact-actions .btn { flex: 1 1 auto; min-height: 42px; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Print */
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11pt; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .sidenav, .no-print, .receipt-tools, .skip, .pager, .tabs { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; max-width: none; }
  .card, .receipt, .slip { border: 0; padding: 0; margin: 0 0 1rem; box-shadow: none; }
  .receipt { border-top: 4px solid var(--gold); padding-top: .5rem; }
  .tags { padding: 0; display: block; }
  .tag { border: 1px solid #000; margin: 0 0 5mm; }
  .table-wrap { overflow: visible; }
  a { color: inherit; text-decoration: none; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
}

/* ---------- Version 3: loan form, camera, approvals ---------- */
.calc-out { display: flex; align-items: center; min-height: 40px; padding: .5rem .65rem; border-radius: var(--radius); background: var(--gold-soft); font-weight: 700; font-variant-numeric: tabular-nums; }
.item-grid .help { display: block; }
input[readonly] { background: #f3f5f4; color: var(--ink); }
input.over { border-color: var(--red); outline: 2px solid rgba(179,38,30,.25); }
.photo-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.photo-actions input[type="file"] { flex: 1 1 220px; }
.cam-shots { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.cam-shot { margin: 0; display: flex; flex-direction: column; align-items: center; width: 96px; }
.cam-shot img { width: 96px; height: 72px; object-fit: cover; border-radius: 4px; border: 1px solid var(--line); }
.cam-dialog { border: 0; border-radius: 10px; padding: 1.25rem; width: min(680px, 96vw); box-shadow: 0 20px 60px rgba(22,50,58,.35); }
.cam-dialog::backdrop { background: rgba(22,50,58,.6); }
.cam-stage { background: #000; border-radius: 6px; overflow: hidden; aspect-ratio: 4 / 3; }
.cam-stage video { width: 100%; height: 100%; object-fit: contain; }
.nav-count { display: inline-block; min-width: 1.5em; padding: 0 .4em; border-radius: 999px; background: var(--red); color: #fff; font-size: .75rem; text-align: center; }
.approval-panel { border-left: 4px solid var(--amber); background: #fffcf4; }
.input-num { width: 9rem; text-align: right; }

/* ---------- Printed documents: A4 sheet = two A5 copies ---------- */
.sheet-wrap { overflow-x: auto; padding: 0 1rem 2rem; }
.sheet { width: 210mm; margin: 0 auto; background: #fff; box-shadow: 0 2px 14px rgba(22,50,58,.18); color: #111; font: 8.6pt/1.35 var(--font); }
.sheet .copy { height: 148mm; padding: 6mm 9mm 5mm; overflow: hidden; position: relative; }
.sheet.single .copy { height: auto; }
.cut { height: 0; border-top: 1px dashed #888; position: relative; }
.cut span { position: absolute; left: 50%; top: -0.7em; transform: translateX(-50%); background: #fff; padding: 0 2mm; font-size: 7pt; color: #777; }
.doc { position: relative; height: 100%; display: flex; flex-direction: column; gap: 2.2mm; }
.d-head { display: flex; justify-content: space-between; gap: 4mm; border-bottom: 1.5px solid #111; padding-bottom: 1.8mm; }
.d-co { display: flex; align-items: center; gap: 2mm; font-size: 12.5pt; font-weight: 800; }
.d-co .brand-mark { width: 8px; height: 13px; }
.d-addr { font-size: 7.4pt; color: #444; max-width: 105mm; }
.d-title { text-align: right; }
.d-title h1 { font-size: 11pt; margin: .3mm 0; text-transform: uppercase; letter-spacing: .04em; }
.d-copy { display: inline-block; font-size: 7pt; font-weight: 800; letter-spacing: .12em; border: 1px solid #111; padding: .3mm 1.8mm; }
.d-top { display: flex; gap: 3mm; align-items: flex-start; }
.d-photo { width: 25mm; height: 30mm; object-fit: cover; border: 1px solid #999; border-radius: 1.5mm; flex: 0 0 auto; }
.d-nophoto { display: grid; place-items: center; text-align: center; font-size: 6.5pt; color: #888; background: #f4f4f4; }
.d-kv { flex: 1; display: grid; grid-template-columns: max-content 1fr; gap: .4mm 3mm; margin: 0; }
.d-kv dt { color: #555; }
.d-kv dd { margin: 0; }
.d-table { width: 100%; border-collapse: collapse; font-size: 8pt; }
.d-table th, .d-table td { border: 1px solid #bbb; padding: .7mm 1.4mm; vertical-align: top; }
.d-table thead th { background: #f1f1ee; color: #222; font-size: 7.4pt; white-space: nowrap; }
.d-table tfoot th, .d-table .d-total td { font-weight: 800; background: #faf7ef; }
.d-muted { color: #666; font-size: 7.2pt; }
.d-loan { display: flex; gap: 4mm; align-items: stretch; }
.d-amount { flex: 0 0 72mm; border: 1.5px solid #111; border-radius: 1.5mm; padding: 1.5mm 2.5mm; display: flex; flex-direction: column; }
.d-amount span { font-size: 7.4pt; color: #444; }
.d-amount strong { font-size: 15pt; }
.d-amount em { font-style: normal; font-size: 7.2pt; }
.d-terms { align-content: center; }
.d-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; }
.d-words { margin: 0; font-weight: 600; }
.d-note { margin: 0; font-size: 7.2pt; color: #444; }
.d-alert { margin: 0; color: #a01d17; font-weight: 700; }
.d-sign { margin-top: auto; display: flex; justify-content: space-between; gap: 10mm; padding-top: 7mm; }
.d-sign span { flex: 1; border-top: 1px solid #111; padding-top: .8mm; font-size: 7.2pt; text-align: center; }
.doc.dense { gap: 1.4mm; }
.doc.dense .d-table { font-size: 7.2pt; }
.doc.dense .d-table th, .doc.dense .d-table td { padding: .35mm 1.2mm; }
.doc.dense .d-photo { width: 21mm; height: 25mm; }
.doc.dense .d-sign { padding-top: 5mm; }
.doc .stamp { font-size: 3rem; top: 50%; }
@media print {
  .sheet-wrap { padding: 0; overflow: visible; }
  .sheet { box-shadow: none; margin: 0; width: 210mm; }
  .sheet .copy { height: 148mm; }
  .sheet.single .copy { height: auto; }
}
@media (max-width: 860px) { .sheet-wrap { padding: 0 .25rem 1rem; } }

.rule-box { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; background: var(--gold-soft); border-radius: var(--radius); padding: .75rem 1rem; margin-bottom: 1rem; font-weight: 600; }
.rule-box label { margin: 0; }
.rule-box .input-num { width: 6rem; }
