:root {
  --green: #1d5c3a;
  --green-d: #15502f;
  --green-l: #2a7a4e;
  --green-50: #e6f1ea;
  --gold: #e9b949;
  --gold-d: #b98a1c;
  --gold-50: #fcf3dc;
  --cream: #f6f1e4;
  --ink: #1f2a24;
  --muted: #66736b;
  --line: #e6e0cf;
  --card: #ffffff;
  --red: #c8443d;
  --red-50: #fcebea;
  --blue: #2f6db0;
  --blue-50: #e8f0fa;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(31,42,36,.05), 0 6px 18px rgba(31,42,36,.06);
  --shadow-lg: 0 18px 44px rgba(31,42,36,.16);
  --tab-h: 66px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--cream); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.wrap { max-width: 820px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.urdu { font-family: "Noto Nastaliq Urdu", serif; font-weight: 500; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Lock screen ---------- */
.lock { position: fixed; inset: 0; z-index: 200; background: radial-gradient(120% 80% at 50% 0%, #2a7a4e 0%, #15502f 55%, #0f3d24 100%); color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px 24px calc(24px + env(safe-area-inset-bottom)); text-align: center; overflow: auto; }
.lock img { width: 108px; height: 108px; filter: drop-shadow(0 10px 24px rgba(0,0,0,.3)); }
.lock h1 { font-size: 1.55rem; letter-spacing: -.02em; line-height: 1.2; }
.lock h1 small { display: block; font-family: "Noto Nastaliq Urdu", serif; font-size: 1rem; font-weight: 500; color: var(--gold); margin-top: 6px; }
.lock p { color: rgba(255,255,255,.75); font-size: .92rem; }
.dots { display: flex; gap: 14px; margin: 4px 0 6px; }
.dots i { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.7); transition: all .15s; }
.dots i.on { background: var(--gold); border-color: var(--gold); transform: scale(1.1); }
.dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }
.lock .err { color: #ffd2cc; min-height: 1.4em; font-weight: 600; font-size: .9rem; }
.keypad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px 22px; }
.keypad button { width: 76px; height: 76px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 1.7rem; font-weight: 600; cursor: pointer; transition: background .12s, transform .08s; }
.keypad button:active { background: rgba(255,255,255,.28); transform: scale(.94); }
.keypad button.ghost { background: transparent; font-size: 1rem; font-weight: 700; }
.keypad button[disabled] { opacity: .4; }

/* ---------- Shell ---------- */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--green-d); color: #fff; padding-top: env(safe-area-inset-top); box-shadow: 0 2px 10px rgba(0,0,0,.12); }
.topbar-inner { display: flex; align-items: center; gap: 12px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 1.05rem; letter-spacing: -.01em; line-height: 1.1; }
.brand b { color: var(--gold); font-weight: 800; }
.brand small { display: block; font-family: "Noto Nastaliq Urdu", serif; font-size: .7rem; color: rgba(255,255,255,.75); margin-top: 3px; font-weight: 500; }
.top-icon { margin-left: auto; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.1); }
.top-icon svg { width: 21px; height: 21px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
main { padding: 16px 0 calc(var(--tab-h) + 96px + env(safe-area-inset-bottom)); outline: none; }
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: .72rem; font-weight: 700; color: var(--muted); }
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a.on { color: var(--green); }
.tabbar a.on svg { stroke-width: 2.3; }
.fab { position: fixed; right: max(18px, calc(50% - 410px + 18px)); bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom)); z-index: 55; width: 60px; height: 60px; border-radius: 20px;
  background: var(--gold); color: #2b2005; font-size: 2.1rem; font-weight: 500; display: grid; place-items: center; box-shadow: 0 12px 28px rgba(185,138,28,.45); line-height: 1; }
.fab:active { transform: scale(.95); }

/* ---------- Common ---------- */
.page { display: flex; flex-direction: column; gap: 16px; }
.h1 { font-size: 1.45rem; letter-spacing: -.025em; line-height: 1.2; }
.h1 small { display: block; font-size: .88rem; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-top: 2px; }
.h2 { font-size: 1.05rem; letter-spacing: -.01em; }
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.pad { padding: 18px; }
.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--muted); font-size: .92rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: 14px; padding: 11px 18px; font-weight: 700; cursor: pointer; white-space: nowrap; font-size: .93rem; transition: transform .08s, background .15s; }
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--green); color: #fff; }
.btn-gold { background: var(--gold); color: #2b2005; }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-danger { background: #fff; border-color: #f0c9c6; color: var(--red); }
.btn-sm { padding: 8px 13px; font-size: .84rem; border-radius: 11px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .6; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .74rem; font-weight: 700; background: var(--green-50); color: var(--green); white-space: nowrap; }
.pill.gold { background: var(--gold-50); color: #855f08; }
.pill.red { background: var(--red-50); color: var(--red); }
.pill.blue { background: var(--blue-50); color: var(--blue); }
.pill.grey { background: #eeece4; color: var(--muted); }
.tag { display: inline-flex; align-items: center; gap: 4px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; font-size: .76rem; padding: 3px 8px; border-radius: 7px; background: #fff7d9; color: #6b4d05; border: 1px solid #f0dc9c; letter-spacing: .02em; }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--gold-d); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-weight: 700; font-size: .84rem; }
.input { width: 100%; border: 1.5px solid var(--line); background: #fff; border-radius: 13px; padding: 12px 13px; outline: none; font-size: 16px; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,92,58,.12); }
textarea.input { resize: vertical; min-height: 84px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid2 .full { grid-column: 1 / -1; }
.hint { font-size: .8rem; color: var(--muted); }
.err { color: var(--red); font-size: .86rem; font-weight: 600; min-height: 1.2em; }
.money { position: relative; }
.money span { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; font-size: .9rem; }
.money .input { padding-left: 40px; }
.unit { position: relative; }
.unit span { position: absolute; right: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 700; font-size: .88rem; }
.unit .input { padding-right: 44px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { position: relative; cursor: pointer; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 13px; border: 1.5px solid var(--line); border-radius: 999px; background: #fff; font-size: .86rem; font-weight: 700; color: var(--muted); }
.opt span i { width: 9px; height: 9px; border-radius: 50%; }
.opt input:checked + span { border-color: var(--green); background: var(--green-50); color: var(--green); }

/* ---------- Home ---------- */
.hello { background: linear-gradient(135deg, var(--green) 0%, var(--green-l) 100%); color: #fff; border-radius: 22px; padding: 20px; position: relative; overflow: hidden; }
.hello::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px; border-radius: 50%; border: 22px solid rgba(233,185,73,.18); }
.hello h1 { font-size: 1.35rem; letter-spacing: -.02em; }
.hello p { color: rgba(255,255,255,.8); font-size: .9rem; }
.hello .stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; position: relative; z-index: 1; }
.hello .stats div { background: rgba(255,255,255,.12); border-radius: 14px; padding: 10px 12px; }
.hello .stats small { display: block; font-size: .7rem; color: rgba(255,255,255,.75); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.hello .stats b { font-size: 1.05rem; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { padding: 16px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; transition: transform .15s; }
.tile:active { transform: scale(.98); }
.tile .emo { font-size: 1.9rem; line-height: 1; }
.tile b.big { font-size: 1.55rem; letter-spacing: -.02em; line-height: 1.1; }
.tile .t { font-weight: 800; font-size: .95rem; }
.tile .u { font-family: "Noto Nastaliq Urdu", serif; color: var(--muted); font-size: .72rem; line-height: 1.8; }
.tile .s { font-size: .8rem; color: var(--muted); }
.tile .corner { position: absolute; right: 14px; top: 14px; }
.eid { display: flex; align-items: center; gap: 14px; padding: 16px; background: linear-gradient(120deg, var(--gold-50), #fff); border-color: #f0dc9c; }
.eid .d { width: 62px; height: 62px; border-radius: 16px; background: var(--gold); color: #2b2005; display: grid; place-items: center; text-align: center; line-height: 1; flex: none; }
.eid .d b { font-size: 1.4rem; display: block; }
.eid .d small { font-size: .62rem; font-weight: 700; text-transform: uppercase; }

/* ---------- Progress / overflow bars ---------- */
.pbar { position: relative; height: 12px; border-radius: 999px; background: #ede8da; overflow: visible; display: flex; }
.pbar i { display: block; height: 100%; }
.pbar i.fill { background: linear-gradient(90deg, #3c9a68, var(--green)); border-radius: 999px 0 0 999px; }
.pbar i.fill.full { border-radius: 999px 0 0 999px; }
.pbar i.fill.only { border-radius: 999px; }
.pbar i.over { background: repeating-linear-gradient(135deg, #e06a5f 0 6px, var(--red) 6px 12px); border-radius: 0 999px 999px 0; }
.pbar .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 2px; opacity: .55; }
.pbar.sm { height: 8px; }
.pbar-label { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; margin-bottom: 6px; }
.pct { font-weight: 800; }
.pct.over { color: var(--red); }
.pct.full { color: var(--green); }
.stack { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: #ede8da; }
.stack i { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 10px; font-size: .83rem; }
.legend span { display: flex; align-items: center; gap: 7px; min-width: 0; }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-left: auto; white-space: nowrap; }

/* ---------- Animals ---------- */
.sections { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.sections::-webkit-scrollbar { display: none; }
.sections a { flex: none; display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px; background: #fff; border: 1.5px solid var(--line); font-weight: 700; font-size: .88rem; color: var(--muted); }
.sections a.on { background: var(--green); border-color: var(--green); color: #fff; }
.sections a b { font-size: .75rem; background: rgba(0,0,0,.08); padding: 1px 7px; border-radius: 999px; }
.sections a.on b { background: rgba(255,255,255,.2); }
.epd { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--gold-50); border-color: #f0dc9c; }
.epd .ico { font-size: 1.5rem; }
.epd b { font-size: 1.1rem; }
.search { position: relative; flex: 1; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; }
.search .input { padding-left: 40px; border-radius: 14px; }
.seg { display: inline-flex; background: #ebe5d5; border-radius: 12px; padding: 3px; gap: 2px; flex: none; }
.seg button { border: 0; background: none; padding: 8px 12px; border-radius: 10px; font-weight: 700; font-size: .82rem; color: var(--muted); cursor: pointer; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow); }
.alist { display: flex; flex-direction: column; gap: 10px; }
.acard { display: flex; gap: 14px; padding: 12px; align-items: center; transition: transform .1s; }
.acard:active { transform: scale(.99); }
.avatar { width: 64px; height: 64px; border-radius: 16px; flex: none; overflow: hidden; background: var(--green-50); display: grid; place-items: center; font-size: 2rem; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.acard .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.acard .name { font-weight: 800; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acard .sub { font-size: .8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acard .right { text-align: right; flex: none; display: flex; flex-direction: column; gap: 2px; align-items: flex-end; }
.acard .right b { font-size: 1rem; }
.acard .right small { font-size: .72rem; color: var(--muted); }
.acard.sold { opacity: .7; }

.profile-hero { overflow: hidden; }
.profile-hero .ph { height: 220px; background: linear-gradient(135deg, var(--green-50), var(--gold-50)); display: grid; place-items: center; font-size: 5rem; }
.profile-hero .ph img { width: 100%; height: 100%; object-fit: cover; }
.profile-hero .body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.profile-hero h1 { font-size: 1.5rem; letter-spacing: -.02em; }
.value-card { background: linear-gradient(135deg, #15502f, #2a7a4e); color: #fff; border: 0; padding: 18px; }
.value-card small { color: rgba(255,255,255,.75); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.value-card .big { font-size: 2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; color: var(--gold); }
.calc { margin-top: 12px; background: rgba(255,255,255,.1); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; font-size: .9rem; }
.calc div { display: flex; justify-content: space-between; gap: 10px; }
.calc .tot { border-top: 1px dashed rgba(255,255,255,.35); padding-top: 8px; font-weight: 800; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 12px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; }
.kv dd a { color: var(--green); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions .btn { flex: 1; }

/* ---------- Labour ---------- */
.lcard { padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.lcard .top { display: flex; gap: 12px; align-items: center; }
.lav { width: 50px; height: 50px; border-radius: 15px; background: var(--gold-50); color: #855f08; display: grid; place-items: center; font-weight: 800; font-size: 1.05rem; flex: none; overflow: hidden; }
.lav img { width: 100%; height: 100%; object-fit: cover; }
.lav.lg { width: 76px; height: 76px; border-radius: 22px; font-size: 1.5rem; }
.month-card { padding: 18px; border: 2px solid var(--green); }
.month-card .amt { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.month-card .amt div { background: #f8f5ec; border-radius: 12px; padding: 10px; }
.month-card .amt small { display: block; font-size: .7rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.month-card .amt b { font-size: .98rem; }
.lines { display: flex; flex-direction: column; }
.line { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 1.05rem; }
.line .grow { flex: 1; min-width: 0; }
.line .grow b { display: block; font-size: .92rem; }
.line .grow span { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line .a { font-weight: 800; white-space: nowrap; }
.line.tap { cursor: pointer; }
.months { display: flex; flex-direction: column; gap: 8px; }
.mrow { border: 1px solid var(--line); border-radius: 14px; background: #fff; overflow: hidden; }
.mrow summary { list-style: none; cursor: pointer; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.mrow summary::-webkit-details-marker { display: none; }
.mrow summary .between b { font-size: .95rem; }
.mrow summary .chev { transition: transform .15s; color: var(--muted); }
.mrow[open] summary .chev { transform: rotate(180deg); }
.mrow .inner { padding: 0 14px 12px; }
.empty { text-align: center; padding: 34px 16px; display: flex; flex-direction: column; gap: 8px; align-items: center; color: var(--muted); }
.empty .big { font-size: 2.6rem; }
.empty-sm { text-align: center; color: var(--muted); padding: 16px 8px; font-size: .9rem; }

/* ---------- Expenses ---------- */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.month-nav button { width: 42px; height: 42px; border-radius: 13px; border: 1.5px solid var(--line); background: #fff; font-size: 1.2rem; cursor: pointer; }
.month-nav button[disabled] { opacity: .35; }
.month-nav h1 { text-align: center; }
.total-card { padding: 18px; }
.total-card .big { font-size: 1.9rem; font-weight: 800; letter-spacing: -.02em; }
.day-head { font-size: .78rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 6px 2px -4px; }

/* ---------- Photo picker ---------- */
.photo-pick { display: flex; gap: 14px; align-items: center; }
.photo-pick .pv { width: 88px; height: 88px; border-radius: 20px; background: var(--green-50); display: grid; place-items: center; overflow: hidden; border: 2px dashed #cfd9cf; font-size: 2.2rem; flex: none; cursor: pointer; }
.photo-pick .pv img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- Modal, toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(12,30,20,.5); z-index: 150; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 560px; border-radius: 24px 24px 0 0; padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 14px; animation: up .22s ease-out; }
.modal::before { content: ""; width: 42px; height: 5px; border-radius: 9px; background: #ddd7c6; align-self: center; margin-bottom: 4px; }
.modal h3 { font-size: 1.2rem; }
.modal .foot { display: flex; gap: 10px; }
.modal .foot .btn { flex: 1; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: .9rem; opacity: 0; pointer-events: none; transition: all .22s; z-index: 300; max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.loader { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--green-50); border-top-color: var(--green); animation: spin .8s linear infinite; margin: 60px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 700px) {
  main { padding-top: 22px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: 24px; padding-top: 22px; }
  .modal::before { display: none; }
  .profile-hero .ph { height: 300px; }
}
@media (max-width: 380px) {
  .keypad { grid-template-columns: repeat(3, 68px); gap: 12px 18px; }
  .keypad button { width: 68px; height: 68px; }
  .hello .stats b { font-size: .92rem; }
  .grid2 { grid-template-columns: 1fr; }
}
