/* Hisab v2 design system. One look for every screen: green band header, white cards on a soft
   ground, money colours that always come with a sign and a word, 44px+ touch targets.
   Motion has a job (an entry lands, a sheet rises, money moves) and is off for reduced motion. */
:root {
  --bg: #F2F4F1; --surface: #FFFFFF; --surface-2: #F1F4F1; --line: #DDE3DE; --line-strong: #CBD3CD;
  --fg: #15201B; --muted: #5B6B63; --brand: #0E5E4A; --brand-2: #0A4537; --on-brand: #FFFFFF;
  --in: #0B7A45; --in-soft: #E7F3EC; --in-ink: #1F5A3A; --out: #B23E0B; --out-soft: #FBEDE6; --out-ink: #7A3B1C;
  --warn: #7A4F00; --warn-soft: #FFF4D6; --danger: #B42318; --focus: #F2B705; --chart-out: #D9733F;
  --overlay: rgba(10,25,19,.45); --shadow: 0 10px 28px rgba(14,94,74,.12);
  --font: Inter, "Noto Sans Devanagari", system-ui, sans-serif;
  --ease: cubic-bezier(.2,.8,.2,1);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1512; --surface: #16201B; --surface-2: #1B2621; --line: #26332D; --line-strong: #34443C;
  --fg: #E8EFEB; --muted: #A3B3AA; --brand: #124F3F; --brand-2: #0C3B2F;
  --in: #4CC38A; --in-soft: #17342A; --in-ink: #9BE0BD; --out: #F2925F; --out-soft: #3A2419; --out-ink: #F6C1A4;
  --warn: #F3CF73; --warn-soft: #3A3014; --danger: #F97066; --chart-out: #E8915F;
  --overlay: rgba(0,0,0,.6); --shadow: 0 10px 28px rgba(0,0,0,.4); color-scheme: dark;
}
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] {
  --bg: #0E1512; --surface: #16201B; --surface-2: #1B2621; --line: #26332D; --line-strong: #34443C;
  --fg: #E8EFEB; --muted: #A3B3AA; --brand: #124F3F; --brand-2: #0C3B2F;
  --in: #4CC38A; --in-soft: #17342A; --in-ink: #9BE0BD; --out: #F2925F; --out-soft: #3A2419; --out-ink: #F6C1A4;
  --warn: #F3CF73; --warn-soft: #3A3014; --danger: #F97066; --chart-out: #E8915F;
  --overlay: rgba(0,0,0,.6); --shadow: 0 10px 28px rgba(0,0,0,.4); color-scheme: dark; } }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.4; -webkit-tap-highlight-color: transparent; }
body { overflow-x: clip; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--brand); }
:root[data-theme="dark"] a { color: var(--in); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- frame ---------- */
#app { max-width: 560px; margin: 0 auto; min-height: 100dvh; position: relative; display: flex; flex-direction: column; padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
#app.no-tabs { padding-bottom: 24px; }
.band { background: var(--brand); color: var(--on-brand); padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.band.tall { padding-bottom: 72px; }
.band-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.band h1 { margin: 0; font-size: 20px; font-weight: 600; }
.band small, .band .sub { font-size: 13px; opacity: .92; }
.band .back { min-height: 44px; display: inline-flex; align-items: center; gap: 6px; color: var(--on-brand); text-decoration: none; background: none; border: 0; padding: 0; font-weight: 500; font-size: 14px; align-self: flex-start; }
.band .ghost { min-height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid rgba(255,255,255,.6); color: var(--on-brand); background: transparent; font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.band .icon-btn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255,255,255,.14); color: var(--on-brand); display: inline-flex; align-items: center; justify-content: center; }
.band .seg button { color: var(--on-brand); border-color: rgba(255,255,255,.6); background: transparent; }
.band .seg button[aria-pressed="true"] { background: #FFFFFF; color: var(--brand); border-color: #FFFFFF; }
.wrap { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }
.sect { padding: 10px 4px 0; font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- cards, rows, lists ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card h2 { margin: 0; font-size: 16px; font-weight: 600; }
.card p { margin: 0; line-height: 1.5; }
.card.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.card.bad { border: 2px solid var(--danger); }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; width: 100%; text-align: left; color: var(--fg); text-decoration: none; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row .grow b { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.row .grow small { font-size: 12px; color: var(--muted); }
.row .end { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; text-align: right; }
.row .end small { font-size: 12px; color: var(--muted); }
.list { display: flex; flex-direction: column; gap: 8px; }
.menu { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.menu > * { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
.menu > *:last-child { border-bottom: 0; }
.menu .row { border-radius: 0; border-left: 0; border-right: 0; border-top: 0; }
.badge { width: 40px; height: 40px; border-radius: 12px; flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.badge.in { background: var(--in-soft); color: var(--in); }
.badge.out { background: var(--out-soft); color: var(--out); }
.badge.mv { background: var(--surface-2); color: var(--muted); }
.badge.br { background: var(--in-soft); color: var(--brand); }
.pill { align-self: flex-start; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 10px; }
.pill.late, .pill.low { background: var(--warn-soft); color: var(--warn); }
.pill.out { background: var(--out-soft); color: var(--out-ink); }
.pill.ok { background: var(--in-soft); color: var(--in-ink); }
.pill.soon { background: var(--surface-2); color: var(--muted); }
.amt-in { color: var(--in); font-weight: 700; }
.amt-out { color: var(--out); font-weight: 700; }
.empty { padding: 36px 12px; text-align: center; color: var(--muted); line-height: 1.5; }

/* ---------- controls ---------- */
.btn { min-height: 48px; padding: 0 18px; border-radius: 14px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; transition: transform 120ms ease-out; }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.btn.in { background: var(--in); color: #FFFFFF; border-color: var(--in); }
.btn.out { background: var(--out); color: #FFFFFF; border-color: var(--out); }
:root[data-theme="dark"] .btn.in, :root[data-theme="dark"] .btn.out { color: #0E1512; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.link { border: 0; background: none; color: var(--brand); text-decoration: underline; padding: 0 6px; min-height: 44px; }
.btn.big { min-height: 56px; font-size: 17px; border-radius: 16px; width: 100%; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btns.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg.fill { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.seg button, .chip { min-height: 44px; padding: 0 14px; border-radius: 22px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--fg); font-weight: 500; font-size: 14px; }
.seg button[aria-pressed="true"], .chip[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.seg.in button[aria-pressed="true"] { background: var(--in); border-color: var(--in); color: #FFFFFF; }
.seg.out button[aria-pressed="true"] { background: var(--out); border-color: var(--out); color: #FFFFFF; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field .hint { font-weight: 400; color: var(--muted); }
.field input, .field select, .field textarea, .input { height: 52px; border: 1px solid var(--line-strong); border-radius: 14px; background: var(--surface); padding: 0 14px; font-size: 16px; font-weight: 400; width: 100%; }
.field textarea { height: auto; min-height: 80px; padding: 12px 14px; }
.field.bad input { border-color: var(--danger); }
.err { color: var(--danger); font-size: 14px; font-weight: 600; margin: 0; }
.search { position: relative; }
.search svg { position: absolute; left: 14px; top: 15px; color: var(--muted); }
.search input { padding-left: 42px; height: 48px; }
.amount-box { display: flex; align-items: baseline; gap: 8px; padding: 10px 14px; border-radius: 16px; }
.amount-box.in { background: var(--in-soft); color: var(--in); }
.amount-box.out { background: var(--out-soft); color: var(--out); }
.amount-box.br { background: var(--surface-2); color: var(--fg); }
.amount-box input { border: 0; background: transparent; font-size: 36px; font-weight: 700; width: 100%; color: inherit; padding: 0; height: 52px; }
.switch { width: 52px; height: 32px; border-radius: 16px; border: 0; padding: 0; flex: none; position: relative; background: #8A978F; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 12px; background: #FFFFFF; transition: transform 180ms var(--ease); }
.switch[aria-checked="true"] { background: var(--in); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }

/* ---------- Day Book ---------- */
.date-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.date-strip button { width: 44px; height: 44px; border-radius: 22px; border: 0; background: rgba(255,255,255,.14); color: var(--on-brand); display: inline-flex; align-items: center; justify-content: center; }
.date-strip .mid { text-align: center; display: flex; flex-direction: column; }
.hero { margin: -60px 16px 0; perspective: 900px; position: relative; z-index: 2; }
.hero-card { background: var(--surface); border-radius: 22px; padding: 18px; box-shadow: 0 22px 40px rgba(14,94,74,.18); transform-style: preserve-3d; transition: transform 220ms var(--ease); will-change: transform; }
.hero-card .lift { transform: translateZ(30px); }
.hero-card .big { font-size: 34px; font-weight: 700; letter-spacing: -.5px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; }
.tile span { font-size: 12px; }
.tile b { font-size: 17px; }
.tile.in { background: var(--in-soft); } .tile.in span { color: var(--in-ink); } .tile.in b { color: var(--in); }
.tile.out { background: var(--out-soft); } .tile.out span { color: var(--out-ink); } .tile.out b { color: var(--out); }
.places { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 6px; perspective: 700px; scroll-snap-type: x mandatory; }
.place { flex: 1 0 104px; scroll-snap-align: start; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 4px; box-shadow: 0 6px 14px rgba(14,94,74,.08); transition: transform 220ms var(--ease); }
.place:hover { transform: translateY(-3px) rotateX(8deg); }
.place span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.place i { width: 8px; height: 8px; border-radius: 4px; display: inline-block; }
.place b { font-size: 15px; }
.limit-bar { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.limit-bar div { height: 100%; border-radius: 4px; background: var(--in); transform-origin: left; animation: growX 320ms var(--ease) both; }
.limit-bar.over div { background: var(--out); }
.actions { position: fixed; left: 50%; transform: translateX(-50%); width: min(560px, 100%); bottom: calc(68px + env(safe-area-inset-bottom, 0px)); padding: 12px 16px 10px; background: linear-gradient(rgba(242,244,241,0), var(--bg) 30%); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; z-index: 20; }
#app.has-actions { padding-bottom: calc(150px + env(safe-area-inset-bottom, 0px)); }
.tag { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 8px; margin-left: 6px; }
.tag.saving { background: var(--surface-2); color: var(--muted); }
.tag.failed { background: var(--out-soft); color: var(--danger); }

/* ---------- tab bar ---------- */
.tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(560px, 100%); background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding-bottom: env(safe-area-inset-bottom, 0px); z-index: 25; }
.tabs button { height: 68px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 500; color: var(--muted); }
.tabs button[aria-current="page"] { color: var(--brand); font-weight: 600; box-shadow: inset 0 3px 0 var(--brand); }
:root[data-theme="dark"] .tabs button[aria-current="page"] { color: var(--in); box-shadow: inset 0 3px 0 var(--in); }

/* ---------- Sell / Stock ---------- */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.item { position: relative; min-height: 104px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 6px; text-align: left; box-shadow: 0 4px 12px rgba(14,94,74,.07); transition: transform 120ms ease-out; }
.item:active:not(:disabled) { transform: scale(.97); }
.item[aria-pressed="true"] { border-color: var(--in); box-shadow: 0 0 0 1px var(--in); }
.item:disabled { background: var(--surface-2); box-shadow: none; opacity: 1; }
.item .name { font-size: 15px; font-weight: 600; padding-right: 30px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .qty { position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--in); color: #FFFFFF; font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; animation: pop 180ms var(--ease) both; }
.cartbar { position: fixed; left: 50%; transform: translateX(-50%); width: min(560px, 100%); bottom: calc(68px + env(safe-area-inset-bottom, 0px)); padding: 12px 16px; background: var(--bg); box-shadow: 0 -8px 20px rgba(21,32,27,.08); z-index: 20; animation: up 260ms var(--ease) both; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--line-strong); background: var(--surface); font-size: 20px; font-weight: 600; }

/* ---------- charts ---------- */
.bars { height: 140px; display: flex; align-items: flex-end; gap: 6px; border-bottom: 1px solid var(--line-strong); }
.bars .g { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.bars .b { width: 12px; max-width: 40%; border-radius: 3px 3px 0 0; transform-origin: bottom; animation: growY 320ms var(--ease) both; }
.bars .b.in { background: var(--in); } .bars .b.out { background: var(--chart-out); }
.bar-labels { display: flex; gap: 6px; } .bar-labels span { flex: 1; min-width: 0; text-align: center; font-size: 11px; color: var(--muted); }
.hbar { height: 8px; border-radius: 4px; background: var(--surface-2); } .hbar div { height: 100%; border-radius: 4px; background: var(--brand); transform-origin: left; animation: growX 320ms var(--ease) both; }
:root[data-theme="dark"] .hbar div { background: var(--in); }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); } .legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 4px; vertical-align: -1px; }

/* ---------- sheets and toasts ---------- */
.veil { position: fixed; inset: 0; background: var(--overlay); z-index: 40; animation: fade 200ms linear both; }
.sheet { position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(560px, 100%); max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 14px; z-index: 41; animation: sheetUp 260ms var(--ease) both; }
.sheet-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.sheet-h h2 { margin: 0; font-size: 18px; }
.x { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.toast { position: fixed; left: 50%; bottom: calc(160px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); max-width: calc(100% - 32px); min-height: 48px; padding: 8px 18px; border-radius: 24px; background: #15201B; color: #FFFFFF; display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; box-shadow: 0 10px 24px rgba(0,0,0,.25); z-index: 60; animation: toastIn 220ms var(--ease) both; }
.toast button { background: none; border: 0; color: #9BE0BD; font-weight: 700; min-height: 44px; padding: 0 6px; }
.toast .check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: draw 300ms ease-out 120ms forwards; }
.gate { max-width: 520px; margin: 0 auto; }
.logo { width: 48px; height: 48px; border-radius: 14px; background: #FFFFFF; display: inline-flex; align-items: center; justify-content: center; }
.logo path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw 700ms var(--ease) 150ms forwards; }

/* ---------- motion ---------- */
.rise { animation: rise 320ms var(--ease) both; }
.drop { animation: drop 380ms var(--ease) both; }
.enter { animation: enter 420ms var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes drop { from { opacity: 0; transform: translateY(-40px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes enter { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes up { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes pop { from { opacity: 0; transform: scale(.7); } to { opacity: 1; transform: none; } }
@keyframes growX { from { transform: scaleX(0); } to { transform: none; } }
@keyframes growY { from { transform: scaleY(0); } to { transform: none; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .hero-card { transform: none !important; }
  .logo path, .toast .check path { stroke-dashoffset: 0; }
}
@media (hover: none) { .place:hover { transform: none; } }

/* Tidy pass: places inside the balance card, slim spending limit, toast above the bars. */
.hero-places { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.hero-places span { display: inline-flex; align-items: center; gap: 6px; }
.hero-places i { width: 8px; height: 8px; border-radius: 4px; display: inline-block; }
.hero-places b { color: var(--fg); font-weight: 600; }
.limit-line { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.limit-line.over { border-color: var(--out); }
.limit-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; font-weight: 600; }
.limit-line.over .limit-top span { color: var(--out); }
.limit-top small { color: var(--muted); font-weight: 500; }
.chip svg { vertical-align: -3px; }
.toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
#app.has-actions ~ #toast .toast { bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }
.limit-top { flex-wrap: wrap; }

/* Party ledger header (Dec 2026 tidy) */
.pl-band { gap: 14px; }
.pl-who { display: flex; align-items: center; gap: 12px; }
.pl-who h1 { font-size: 22px; line-height: 1.2; overflow-wrap: anywhere; }
.pl-av { flex: none; width: 48px; height: 48px; border-radius: 24px; background: rgba(255,255,255,.16); display: grid; place-items: center; font-weight: 700; font-size: 20px; }
.pl-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 12px; background: rgba(255,255,255,.16); color: var(--on-brand); }
.tag.late { background: #F4A261; color: #3A1E05; }
.tag.soon { background: #FFE8A3; color: #3A2E05; }
.pl-bal { background: rgba(0,0,0,.18); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.pl-bal small { font-size: 13px; opacity: .85; }
.pl-bal b { font-size: 32px; font-weight: 700; letter-spacing: -.5px; }
.pl-bal.in b { color: #7BE3B0; } .pl-bal.out b { color: #FFB38A; } .pl-bal.zero b { color: var(--on-brand); }
.qa-row { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.qa { min-height: 52px; border-radius: 14px; border: 0; background: rgba(255,255,255,.12); color: var(--on-brand); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 600; text-decoration: none; padding: 6px 4px; }
.qa:active { background: rgba(255,255,255,.22); }
.lrow { display: flex; align-items: center; gap: 12px; min-height: 64px; }
.lrow .l { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.lrow .l b { font-size: 15px; }
.lrow .l small { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.lrow .r { flex: none; text-align: right; display: flex; flex-direction: column; gap: 1px; }
.lrow .r b { font-size: 16px; }
.lrow .r small { font-size: 11px; color: var(--muted); }
.lrow .r small:first-child { font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.mi-ic { flex: none; width: 36px; height: 36px; border-radius: 12px; background: var(--surface-2); color: var(--brand); display: grid; place-items: center; }
.danger-row b, .danger-row .mi-ic { color: var(--out); }
.band a.qa, .band a.qa:visited { color: var(--on-brand); }
.mi-ic { color: var(--fg); }

/* Send bill to HCG */
.hb-line{display:flex;flex-direction:column;gap:6px;padding:10px;border-radius:14px;background:var(--surface-2)}
.hb-top{display:flex;gap:6px;align-items:center}.hb-top input{flex:1;min-width:0;font-weight:600}
.hb-row{display:grid;grid-template-columns:1fr auto auto 1fr auto;gap:6px;align-items:center}
.hb-row input,.hb-row select,.hb-top input{min-height:44px;border-radius:10px;padding:0 10px;font:inherit;border:1px solid var(--line,rgba(127,127,127,.3));background:var(--bg,transparent);color:inherit;min-width:0}
.hb-at{opacity:.6}.hb-amt{min-width:72px;text-align:right}
.hb-x{min-width:44px;min-height:44px;border:0;background:none;color:inherit;opacity:.7}
.hb-total{display:flex;justify-content:space-between;align-items:center;font-size:18px;padding:4px 2px}

/* App lock */
.is-locked #app,.is-locked #sheet,.is-locked #toast,.is-locked #tour{visibility:hidden}
#lock:empty{display:none}
#lock{position:fixed;inset:0;z-index:100;background:#0E5E4A;color:#fff;display:flex;align-items:center;justify-content:center;overflow:auto}
.lock-box{width:100%;max-width:360px;padding:24px 20px calc(24px + env(safe-area-inset-bottom));display:flex;flex-direction:column;align-items:center;gap:14px;text-align:center}
.lock-box h1{margin:0;font-size:22px}.lock-box p{margin:0;opacity:.85}
.lock-dots{display:flex;gap:14px;height:20px;margin:6px 0}.lock-dots i{width:14px;height:14px;border-radius:50%;border:2px solid #fff;display:block}.lock-dots i.on{background:#fff}
.lock-err{min-height:22px;color:#ffd7d0;font-weight:600}
.lock-pad{display:grid;grid-template-columns:repeat(3,72px);gap:14px;justify-content:center}
.lock-pad button{width:72px;height:72px;border-radius:50%;border:0;background:rgba(255,255,255,.14);color:#fff;font:600 26px system-ui,sans-serif;display:flex;align-items:center;justify-content:center}
.lock-pad button:active{background:rgba(255,255,255,.3)}.lock-pad .ghost-k{background:none;font-size:15px}
.lock-link{background:none;border:0;color:#fff;text-decoration:underline;font:inherit;min-height:44px;padding:0 12px}
.lock-forgot{background:rgba(255,255,255,.12);border-radius:16px;padding:14px;display:flex;flex-direction:column;gap:10px}
.lock-forgot .btn{background:#fff;color:#0E5E4A}
@keyframes lock-shake{20%,60%{transform:translateX(-8px)}40%,80%{transform:translateX(8px)}}.lock-shake{animation:lock-shake .35s}

/* Welcome tour */
#tour:empty{display:none}
#tour{position:fixed;inset:0;z-index:90;display:flex;align-items:flex-end;justify-content:center}
.tour-veil{position:absolute;inset:0;background:rgba(0,0,0,.55)}
.tour-card{position:relative;width:100%;max-width:520px;background:var(--surface);color:var(--fg,#111);border-radius:24px 24px 0 0;padding:24px 20px calc(20px + env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:12px}
.tour-ic{width:56px;height:56px;border-radius:18px;background:var(--brand,#0E5E4A);color:#fff;display:flex;align-items:center;justify-content:center}
.tour-card h2{margin:0;font-size:22px}.tour-card p{margin:0;line-height:1.5;font-size:16px}
.tour-dots{display:flex;gap:6px;align-items:center}.tour-dots i{width:8px;height:8px;border-radius:50%;background:var(--line,#ccc)}.tour-dots i.on{background:var(--brand,#0E5E4A);width:22px;border-radius:4px}
.tour-btns{display:flex;gap:10px;justify-content:space-between;align-items:center}.tour-btns .btn{min-width:120px}

/* Help */
.help-card{background:var(--surface);border-radius:16px;margin-bottom:10px;overflow:hidden}
.help-card summary{list-style:none;display:flex;gap:12px;align-items:center;min-height:56px;padding:10px 14px;font-weight:600;cursor:pointer}
.help-card summary::-webkit-details-marker{display:none}.help-card summary .grow{flex:1}
.help-card[open] summary .chv{transform:rotate(90deg)}.help-card .chv{transition:transform .15s}
.help-body{padding:0 16px 16px}.help-body ol{margin:0 0 12px;padding-left:22px;display:flex;flex-direction:column;gap:8px;line-height:1.45}

/* Import */
.im-field{display:grid;grid-template-columns:110px 1fr;gap:8px;align-items:center}
.im-field select{min-height:44px;border-radius:10px;padding:0 8px;font:inherit;min-width:0;border:1px solid var(--line,rgba(127,127,127,.3));background:var(--bg,transparent);color:inherit}
.im-prev{display:flex;flex-direction:column;gap:4px;font-size:14px}.im-prev .r{display:flex;justify-content:space-between;gap:10px;padding:6px 0;border-top:1px solid var(--line,rgba(127,127,127,.2))}
.im-prev .r span:first-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.im-skip{font-size:13px;opacity:.85;display:flex;flex-direction:column;gap:2px}

/* Orders board */
.ord-badge{display:inline-grid;place-items:center;min-width:20px;height:20px;padding:0 6px;border-radius:10px;background:var(--focus);color:#15201B;font-size:12px;font-weight:700;line-height:1}
.ord-badge.big{min-width:40px;height:40px;border-radius:20px;font-size:18px;flex:none}
.ord-banner{flex-direction:row;align-items:center;gap:12px;text-align:left;border:2px solid var(--focus);cursor:pointer;color:var(--fg);font:inherit;width:100%}
.ord-banner .grow{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}
.ord-banner small{color:var(--muted)}
.ord-h{display:flex;align-items:flex-start;gap:10px}
.ord-h .grow{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}
.ord-h b{font-size:17px}
.ord-h small{color:var(--muted);font-size:13px}
.ord-when{font-size:14px;color:var(--fg)}
.ord-lines{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.ord-lines li{display:grid;grid-template-columns:1fr auto auto;gap:10px;align-items:baseline;font-size:15px;padding-bottom:6px;border-bottom:1px dashed var(--line)}
.ord-lines li span:first-child{overflow-wrap:anywhere}
.ord-lines li .num{color:var(--muted);font-size:14px}
.ord-lines li b{min-width:72px;text-align:right}
.ord-tot{display:flex;justify-content:space-between;align-items:baseline;font-size:16px}
.ord-tot b{font-size:20px}
.ord-note{font-size:14px}
.ord-btns{gap:8px}
.ord-btns .btn{flex:1;min-height:48px}
.ord-btns a.btn{flex:0 0 52px;display:grid;place-items:center}

/* Barcode scanning */
.sell-top{display:flex;gap:8px;align-items:stretch}
.sell-top .search{flex:1;min-width:0}
.scan-btn{flex:none;display:flex;align-items:center;gap:6px;padding:0 14px;min-height:48px}
.bc-row{display:flex;gap:8px;align-items:stretch}
.bc-row input{flex:1;min-width:0}
.bc-row .btn{flex:none;min-height:48px}
.bc-line{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--line)}
.bc-line .grow{flex:1;min-width:0;overflow-wrap:anywhere}
.scan-box{display:flex;flex-direction:column;gap:12px}
.scan-cam{position:relative;border-radius:16px;overflow:hidden;background:#000;aspect-ratio:4/3}
.scan-cam video{width:100%;height:100%;object-fit:cover;display:block}
.scan-frame{position:absolute;left:12%;right:12%;top:30%;bottom:30%;border:3px solid #fff;border-radius:12px;box-shadow:0 0 0 999px rgba(0,0,0,.35)}
.scan-frame::after{content:"";position:absolute;left:6px;right:6px;top:50%;height:2px;background:var(--focus);animation:scanline 1.6s ease-in-out infinite alternate}
@keyframes scanline{from{transform:translateY(-36px)}to{transform:translateY(36px)}}
@media (prefers-reduced-motion: reduce){.scan-frame::after{animation:none}}

/* Company QR */
.qr-poster{display:flex;flex-direction:column;align-items:center;gap:10px;padding:18px;border-radius:20px;background:var(--brand);color:#fff;text-align:center}
.qr-shop{font-size:20px;font-weight:700;overflow-wrap:anywhere}
.qr-img{background:#fff;border-radius:16px;padding:10px;width:min(100%,280px)}
.qr-img svg{display:block;width:100%;height:auto}
.qr-cta{font-size:18px;font-weight:600}
.qr-url{opacity:.85;font-size:12px;overflow-wrap:anywhere}
.qr-btns{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.qr-btns .btn{min-height:48px}
.pay-qr{display:flex;flex-direction:column;align-items:center;gap:8px;padding:12px;border-radius:16px;background:#fff;color:#15201B}
.pay-qr img{max-width:min(100%,260px);height:auto;display:block;border-radius:8px}
.pay-qr.big img{max-width:min(100%,340px)}
label.btn{display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
@media print{
  body.print-qr *{visibility:hidden!important}
  body.print-qr .qr-poster,body.print-qr .qr-poster *{visibility:visible!important}
  body.print-qr .qr-poster{position:fixed;left:0;top:0;width:100%;background:#fff!important;color:#000!important;padding:40px}
  body.print-qr .qr-img{width:70%;border:2px solid #000}
}

/* Customer order page */
.cp-ord{display:flex;flex-direction:column;gap:8px;padding-top:10px;border-top:1px solid var(--line)}
.cp-ord .btn{align-self:flex-start}
.cp-item{min-height:64px}
.cp-item .grow{display:flex;flex-direction:column;gap:2px}
.linkish{background:none;border:0;padding:0;font:inherit;color:inherit;text-decoration:underline;cursor:pointer;min-height:auto}

/* Printed bills */
.rc-auto{display:flex;align-items:center;gap:10px;min-height:44px;font-size:15px}
.rc-preview{background:#fff;color:#000;border-radius:12px;padding:12px;display:flex;justify-content:center;max-height:52vh;overflow:auto}
.rc{font:13px/1.35 "Inter",system-ui,sans-serif;color:#000;width:100%}
.rc-58{max-width:48mm}.rc-80{max-width:72mm}.rc-a4{max-width:180mm;font-size:14px}
.rc-head{display:flex;flex-direction:column;align-items:center;text-align:center;gap:2px;padding-bottom:6px;border-bottom:1px dashed #000}
.rc-shop{font-size:16px;font-weight:700}
.rc-meta{display:flex;justify-content:space-between;gap:6px;flex-wrap:wrap;font-size:12px;padding-top:4px}
.rc-items{width:100%;border-collapse:collapse;margin:6px 0;font-size:12px}
.rc-items th{text-align:left;border-bottom:1px solid #000;font-weight:600;padding:2px 0}
.rc-items td{padding:2px 0;vertical-align:top;overflow-wrap:anywhere}
.rc-items th:not(:first-child),.rc-items td:not(:first-child){text-align:right;padding-left:4px;white-space:nowrap}
.rc-total{display:flex;justify-content:space-between;border-top:1px dashed #000;padding-top:4px;font-size:15px}
.rc-total b{font-size:17px}
.rc-pay{font-size:12px;padding-top:2px}
.rc-qr{display:flex;flex-direction:column;align-items:center;gap:2px;padding-top:6px;font-size:11px}
.rc-qr img{width:60%;max-width:160px;height:auto}
.rc-foot{text-align:center;border-top:1px dashed #000;margin-top:6px;padding-top:6px;font-size:12px}
.rc-foot small{font-size:10px;color:#444}
#printArea{display:none}
@media print{
  body.print-rc>*:not(#printArea){display:none!important}
  body.print-rc #printArea{display:block!important}
  body.print-rc{background:#fff!important}
  body.print-rc .rc{max-width:none}
}

/* ---------- what was sold, under a sale row ---------- */
.row-items { font-size: 13px; color: var(--fg); opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.nav-brand { display: none; }
.book-side { display: contents; }

/* ---------- desktop / wide screens (shop PC, laptop) ----------
   Phones keep the bottom bar. From 900px wide: menu on the left, content uses the screen,
   Day Book shows the balance and Cash in / Cash out beside the list, sheets open as a centred box. */
@media (min-width: 900px) {
  #app, #app.has-actions { max-width: none; margin: 0 0 0 232px; padding-bottom: 24px; }
  #app.no-tabs { margin: 0 auto; max-width: 560px; }
  .tabs { left: 0; top: 0; bottom: 0; transform: none; width: 232px; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; border-top: 0; border-right: 1px solid var(--line); }
  .nav-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
  .nav-brand .logo { width: 38px; height: 38px; border-radius: 12px; background: var(--brand-soft, #E3F1EC); display: inline-flex; align-items: center; justify-content: center; flex: none; }
  .nav-brand b { display: block; font-size: 16px; }
  .nav-brand small { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
  .tabs button { height: 48px; flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; border-radius: 12px; font-size: 15px; }
  .tabs button:hover { background: var(--surface-2); }
  .tabs button[aria-current="page"] { box-shadow: none; background: var(--surface-2); }
  :root[data-theme="dark"] .tabs button[aria-current="page"] { box-shadow: none; }
  .band { padding: 20px 32px 22px; }
  .band > * { width: 100%; max-width: 1180px; margin-left: auto; margin-right: auto; }
  .band .back { align-self: auto; }
  .wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 20px 32px; }
  /* Fixed bottom bars become part of the page, kept in view at the bottom. */
  .actions, .cartbar { position: sticky; left: auto; transform: none; bottom: 0; width: 100%; max-width: 1180px; margin: 0 auto; padding: 12px 32px 16px; }
  .cartbar { position: fixed; left: auto; right: 32px; bottom: 24px; width: 420px; max-width: none; margin: 0; padding: 0; background: none; box-shadow: none; transform: none; animation: none; }
  .cartbar .btn { width: 100%; box-shadow: 0 12px 28px rgba(14,94,74,.28); }
  .actions { grid-template-columns: repeat(2, minmax(0, 220px)); justify-content: end; }
  .toast, #app.has-actions ~ #toast .toast { left: calc(50% + 116px); bottom: 28px; }
  /* Day Book: balance card and Cash in / Cash out on the left (stay in view), entries on the right. */
  #app.v-book { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); grid-template-rows: auto 1fr; column-gap: 28px; align-content: start; }
  #app.v-book > .band { grid-column: 1 / -1; }
  #app.v-book > .band.tall { padding-bottom: 22px; }
  #app.v-book > .book-side { grid-column: 1; grid-row: 2; position: sticky; top: 24px; align-self: start; margin: 24px 0 0 32px; display: flex; flex-direction: column; gap: 16px; }
  #app.v-book .hero { margin: 0; }
  #app.v-book .book-side .actions { position: static; padding: 0; background: none; width: auto; max-width: none; margin: 0; grid-template-columns: 1fr 1fr; }
  #app.v-book > .wrap { grid-column: 2; grid-row: 2; padding: 24px 32px 0 0; max-width: 900px; margin: 0; }
  .hero-card .big { font-size: 40px; }
  /* Sell, stock, orders: more items per row. */
  .grid2 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
  .item { min-height: 112px; cursor: pointer; }
  .item:hover:not(:disabled) { border-color: var(--in); }
  .row { cursor: pointer; }
  .row:hover:not(:disabled) { border-color: var(--brand); }
  /* Sheets open as a centred box instead of sliding up from the bottom. */
  .sheet { top: 50%; bottom: auto; left: calc(50% + 116px); transform: translate(-50%, -50%); width: min(600px, calc(100vw - 280px)); max-height: 86dvh; border-radius: 20px; padding: 20px 22px 22px; animation: sheetPop 200ms var(--ease) both; }
  .tour-card { border-radius: 24px; }
}
@media (min-width: 900px) and (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
@keyframes sheetPop { from { opacity: 0; transform: translate(-50%, -47%); } to { opacity: 1; transform: translate(-50%, -50%); } }
@media (min-width: 1400px) { #app.v-book { grid-template-columns: 400px minmax(0, 1fr); } }
@media print { .tabs, .actions, .cartbar { display: none !important; } #app { margin: 0 !important; } }
.use-sell { gap: 8px; } .use-sell .btn { align-self: flex-start; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; }

/* ---------- discount, returns, profit (Dec 2026) ---------- */
.disc-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.disc-row label { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.disc-row label small { font-size: 12px; }
.disc-row .input { width: 120px; flex: none; text-align: right; }
.rc-sub { display: flex; justify-content: space-between; font-size: 13px; }
.profit { gap: 8px; }
.pr-big { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 6px; }
.pr-big small { color: var(--muted); font-size: 13px; }
.pr-big b { font-size: 30px; font-weight: 700; letter-spacing: -.3px; }
.pr-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; padding: 3px 0; }
.pr-line.muted b { color: var(--muted); font-weight: 500; }
.pr-line.strong { border-top: 1px solid var(--line); padding-top: 7px; font-weight: 600; }
.pr-note { font-size: 13px; }
.pr-warn { font-size: 13px; padding: 10px 12px; display: block; }
.pr-warn .btn.link { padding: 0; min-height: 0; display: inline; }
.pr-top { display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--line); padding-top: 8px; }
@media (min-width: 900px) { .wrap > .profit { max-width: 640px; } }

/* ---------- purchase bills, item photos (Dec 2026) ---------- */
.thumb { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; flex: none; background: var(--surface-2); }
.thumb.ph { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--muted); }
.item .item-img { width: 100%; height: 72px; object-fit: cover; border-radius: 10px; }
.photo-row { display: flex; gap: 14px; align-items: center; }
.photo { width: 84px; height: 84px; border-radius: 14px; object-fit: cover; flex: none; background: var(--surface-2); }
.photo.ph { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.pl-addr { display: block; }
.pb-lines { display: flex; flex-direction: column; gap: 6px; }
.pb-h, .pb-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, .8fr) minmax(0, 1fr) minmax(0, 1fr); gap: 6px; }
.pb-h span { font-size: 12px; color: var(--muted); font-weight: 600; }
.pb-row .input { min-width: 0; padding-left: 8px; padding-right: 8px; }
.pb-row .input.num { text-align: right; }
.pb-tot { border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- new version bar (Dec 2026) ---------- */
.upd { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); width: min(528px, calc(100% - 24px)); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 16px; background: var(--brand); color: var(--on-brand); box-shadow: 0 12px 28px rgba(0,0,0,.25); z-index: 55; animation: up 260ms var(--ease) both; font-weight: 600; font-size: 14px; }
.upd span { flex: 1; min-width: 0; }
.upd button { min-height: 40px; border: 0; border-radius: 12px; padding: 0 16px; background: #FFFFFF; color: var(--brand); font-weight: 700; font-size: 14px; }
.upd .upd-x { background: transparent; color: var(--on-brand); padding: 0 10px; font-size: 22px; font-weight: 400; }
#app.has-actions ~ .upd { bottom: calc(160px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 900px) { .upd, #app.has-actions ~ .upd { left: auto; right: 28px; transform: none; bottom: 24px; width: 420px; animation: none; } }
@media print { .upd { display: none !important; } }
.tap { display: inline-block; padding: 9px 6px; margin: -9px -2px; }
.sold .sold-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: baseline; }
.sold .sold-n { overflow-wrap: anywhere; }
.sold .sold-q { white-space: nowrap; font-size: 14px; }
.sold-more summary { list-style: none; cursor: pointer; padding: 8px 0; }
.sold-more summary::-webkit-details-marker { display: none; }
.inv-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.strike { text-decoration: line-through; }
.rc-auto input { flex: none; }
.rc-save svg { width: 50%; max-width: 130px; height: auto; display: block; }
.scan-bill { display: flex; flex-direction: column; gap: 6px; }
.scan-cta { margin: 4px 2px; font-size: 16px; line-height: 1.4; }
.sold .sold-line b, .scan-bill .sold-line b, .scan-bill .sold-q { white-space: nowrap; }
.tot3 b.num { white-space: nowrap; font-size: clamp(13px, 4vw, 17px); }
