:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --text: #1a1f1c;
  --muted: #5f6b64;
  --border: #e1e5df;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f0;
  --warn: #b45309;
  --warn-soft: #fdf1e1;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --ok: #15803d;
  --ok-soft: #e5f5ea;
  --shadow: 0 1px 2px rgba(16,24,20,.06), 0 4px 16px rgba(16,24,20,.05);
  --radius: 18px;
  --nav-h: 68px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1311; --surface: #171c19; --surface-2: #1f2622; --text: #eef2ef; --muted: #9aa69f;
    --border: #2a332e; --accent: #2bb3a3; --accent-ink: #062621; --accent-soft: #123a35;
    --warn: #f0a44b; --warn-soft: #3a2a12; --danger: #f2877d; --danger-soft: #3d1a17;
    --ok: #5ccf86; --ok-soft: #133222; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 17px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body.ur { font-family: "Noto Nastaliq Urdu", Inter, system-ui, sans-serif; line-height: 1.9; }
button, input, select, textarea { font: inherit; color: inherit; }
.urdu { font-family: "Noto Nastaliq Urdu", serif; direction: rtl; text-align: right; line-height: 2.1; font-size: 17px; white-space: pre-wrap; }

/* layout */
.app { max-width: 640px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 96px); }
header.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
header.top h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { padding: 4px 16px 16px; }
h2.section { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 24px 4px 10px; }
body.ur h2.section { text-transform: none; letter-spacing: 0; font-size: 16px; }

/* pills & chips */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.chip.late { background: var(--danger-soft); color: var(--danger); }
.chip.soon { background: var(--warn-soft); color: var(--warn); }
.chip.st-active { background: var(--accent-soft); color: var(--accent); }
.chip.st-replied { background: var(--warn-soft); color: var(--warn); }
.chip.st-call { background: var(--danger-soft); color: var(--danger); }
.chip.st-paid { background: var(--ok-soft); color: var(--ok); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.card.hero { display: grid; gap: 12px; }
.stat-row { display: flex; gap: 10px; }
.stat { flex: 1; background: var(--surface-2); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.hint { color: var(--muted); font-size: 15px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.name { font-size: 19px; font-weight: 700; margin: 0; }
.amount { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.msg { background: var(--surface-2); border-radius: 14px; padding: 10px 14px; margin: 12px 0; }
.msg.collapsed { max-height: 9.2em; overflow: hidden; position: relative; }
.msg.collapsed::after { content: ""; position: absolute; inset: auto 0 0 0; height: 2.4em; background: linear-gradient(transparent, var(--surface-2)); }
.linkish { background: none; border: 0; padding: 6px 0; color: var(--accent); font-weight: 600; font-size: 15px; cursor: pointer; }
.state-line { font-size: 15px; font-weight: 600; margin-top: 8px; }
.state-line.approved { color: var(--accent); } .state-line.sent { color: var(--ok); } .state-line.skipped, .state-line.cancelled, .state-line.expired { color: var(--muted); } .state-line.failed { color: var(--danger); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); font-weight: 600; font-size: 16px; cursor: pointer; transition: transform .06s; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btns .wide { grid-column: 1 / -1; }
.sticky-cta { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 10px 16px; z-index: 4;
  background: linear-gradient(transparent, var(--bg) 30%); }
.sticky-cta .btn { max-width: 608px; margin: 0 auto; display: flex; width: 100%; min-height: 58px; font-size: 18px; box-shadow: 0 6px 20px rgba(15,118,110,.3); }

/* bottom nav */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--border);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { height: var(--nav-h); background: none; border: 0; display: grid; place-items: center; gap: 2px; font-size: 13px; font-weight: 600; color: var(--muted); position: relative; cursor: pointer; }
nav.tabs button svg { width: 26px; height: 26px; }
nav.tabs button.on { color: var(--accent); }
.badge { position: absolute; top: 8px; left: calc(50% + 6px); min-width: 20px; height: 20px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 12px; display: grid; place-items: center; padding: 0 5px; }

/* forms */
label.f { display: grid; gap: 6px; margin-bottom: 14px; font-size: 15px; font-weight: 600; color: var(--muted); }
input.in, select.in, textarea.in { width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 17px; color: var(--text); }
textarea.in { min-height: 180px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search { position: sticky; top: 64px; z-index: 3; background: var(--bg); padding: 4px 0 8px; }
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.filters button { flex: none; min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); font-size: 15px; font-weight: 600; cursor: pointer; }
.filters button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; margin-bottom: 8px; width: 100%; text-align: start; cursor: pointer; }
.list-item .sub { font-size: 14px; color: var(--muted); }
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); width: 60px; height: 60px; border-radius: 20px;
  background: var(--accent); color: var(--accent-ink); border: 0; font-size: 30px; box-shadow: 0 6px 20px rgba(15,118,110,.35); z-index: 4; cursor: pointer; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 44px; margin-bottom: 8px; }

/* sheet (modal) */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 20; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 4px; font-size: 22px; }
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@keyframes fade { from { opacity: 0; } }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .box { width: 100%; max-width: 340px; text-align: center; }
.dots { display: flex; justify-content: center; gap: 14px; margin: 24px 0; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); }
.dots i.f { background: var(--accent); border-color: var(--accent); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.pad button { height: 70px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface); font-size: 28px; font-weight: 600; cursor: pointer; }
.pad button:active { background: var(--surface-2); }
.err { color: var(--danger); min-height: 1.5em; font-weight: 600; }

.qr { display: block; margin: 12px auto; width: 260px; max-width: 100%; border-radius: 12px; background: #fff; padding: 8px; }
.log { font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); padding: 8px 0; }
.log.error { color: var(--danger); }
.bubble { padding: 10px 14px; border-radius: 14px; margin: 8px 0; max-width: 92%; }
.bubble.in { background: var(--surface); border: 1px solid var(--border); }
.bubble.out { background: var(--accent-soft); margin-left: auto; }
.bubble small { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; direction: ltr; text-align: left; font-family: Inter, sans-serif; }
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 90px); transform: translateX(-50%) translateY(20px); opacity: 0; background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 12px; font-weight: 600; transition: .2s; z-index: 30; pointer-events: none; max-width: calc(100% - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }
.banner { background: var(--warn-soft); color: var(--warn); padding: 12px 14px; border-radius: 14px; font-weight: 600; font-size: 15px; margin-bottom: 12px; }
.banner.bad { background: var(--danger-soft); color: var(--danger); }
.toggle-lang { min-height: 40px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-weight: 600; cursor: pointer; }
