/* =====================================================================================================
   Byte-Gorilla Assistant — mobile UI
   A small, flat design system: one accent colour, neutral surfaces, 1px borders instead of shadows, line
   icons, an 8px spacing grid and 44px minimum touch targets. No gradients, glows or decorative effects.
   ===================================================================================================== */
:root{
  /* Neutrals */
  --bg:#F3F5F8; --surface:#FFFFFF; --ink:#0F172A; --ink-2:#334155; --muted:#64748B; --line:#E2E8F0; --line-2:#EEF1F5;
  /* Brand */
  --brand:#1B72C4; --brand-strong:#12599E; --brand-soft:#EAF4FD; --on-brand:#FFFFFF;   /* ByteGorilla blue, darkened for white text */
  --logo:#3B9BEA; --logo-strong:#2B84D0; --logo-bar:#1F78C8;                                              /* the ByteGorilla logo blue */
  /* Meaning */
  --in:#0F766E; --in-soft:#E6F4F1;          /* money owed to you */
  --out:#B45309; --out-soft:#FDF3E3;        /* money you owe */
  --danger:#B42318; --danger-soft:#FDECEA;
  --ok:#067647; --ok-soft:#E7F6EC;
  --warn-bg:#FFF7E6; --warn-line:#F2D9A0; --warn-ink:#6B4A00;
  /* Shape + rhythm */
  --r-sm:8px; --r-md:12px; --r-lg:16px;
  --tabbar-h:64px;
  /* Back-compat aliases used by inline styles in assistant.js */
  --accent:var(--brand); --accent-soft:var(--brand-soft); --paper:var(--bg); --bubble-bot-border:var(--line);
}
*{box-sizing:border-box;}
html{-webkit-text-size-adjust:100%;}
body{
  margin:0; min-height:100vh; background:#E9EDF2; color:var(--ink);
  font-family:'Inter',-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  font-size:15px; line-height:1.45; -webkit-font-smoothing:antialiased;
  display:flex; align-items:center; justify-content:center; padding:24px 16px;
}
button,input,select,textarea{font-family:inherit; font-size:inherit; color:inherit;}
button{cursor:pointer;}
:focus-visible{outline:2px solid var(--logo); outline-offset:2px;}
[hidden]{display:none !important;}
svg.i{width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.75; stroke-linecap:round; stroke-linejoin:round; flex-shrink:0;}
.sr-only{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap;}

/* ---- Frame: the whole viewport on a phone; a centred 430px column elsewhere (no device mock-up) ---- */
body > div{width:100%; display:flex; justify-content:center;}
.frame{
  width:430px; max-width:100%; height:860px; max-height:calc(100vh - 48px); background:var(--bg);
  border:1px solid var(--line); border-radius:var(--r-lg); overflow:hidden; position:relative; display:flex; flex-direction:column;
  box-shadow:0 1px 2px rgba(15,23,42,.06), 0 12px 32px -12px rgba(15,23,42,.18);
}
@media (max-width:560px), (hover:none) and (pointer:coarse){
  body{padding:0; background:var(--bg);}
  .frame{width:100%; height:100vh; height:100dvh; max-height:none; border:none; border-radius:0; box-shadow:none;}
}

/* ---- Buttons ---- */
.btn{
  min-height:48px; padding:0 18px; border-radius:var(--r-md); border:1px solid transparent; font-weight:600; font-size:15px;
  display:inline-flex; align-items:center; justify-content:center; gap:8px; flex:1; transition:background .12s ease, border-color .12s ease;
}
.btn.confirm,.btn-primary{background:var(--brand); color:var(--on-brand);}
.btn.confirm:hover,.btn-primary:hover{background:var(--brand-strong);}
.btn.cancel,.btn.download,.btn-secondary{background:var(--surface); color:var(--ink); border-color:var(--line);}
.btn.cancel:hover,.btn.download:hover,.btn-secondary:hover{background:var(--line-2);}
.btn.download{color:var(--brand); border-color:#BBDCF6;}
.btn:disabled{opacity:.5; cursor:default;}
.actions{display:flex; gap:8px; margin-top:16px;}

/* ===================================================================================================
   Sign in
   =================================================================================================== */
.login-screen{
  position:absolute; inset:0; z-index:50; background:var(--bg); overflow-y:auto; display:flex; flex-direction:column;
  align-items:center; justify-content:safe center; padding:32px 20px; transition:opacity .25s ease;
}
.login-screen.hide{opacity:0; pointer-events:none;}
.login-screen.gone{display:none;}
.login-inner{width:100%; max-width:380px; display:flex; flex-direction:column; align-items:stretch;}
.login-brand{display:flex; flex-direction:column; align-items:center; text-align:center; margin-bottom:24px;}
.login-logo{
  width:72px; height:72px; border-radius:18px; background:#fff; border:1px solid var(--line); padding:10px; margin-bottom:16px;
  display:flex; align-items:center; justify-content:center; overflow:hidden;
}
.login-logo svg,.login-logo img{width:100%; height:100%; object-fit:contain; display:block;}
.login-title{margin:0; font-size:24px; font-weight:700; letter-spacing:-.01em;}
.login-sub{margin:6px 0 0; font-size:14px; color:var(--muted);}
.auth-card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:20px;}
.auth-card h2{margin:0 0 4px; font-size:18px; font-weight:700;}
.auth-card p{margin:0 0 16px; font-size:14px; color:var(--muted);}
.field{display:flex; flex-direction:column; gap:6px; margin-bottom:16px;}
.field label{font-size:14px; font-weight:600; color:var(--ink-2);}
.field .hint{font-size:13px; color:var(--muted);}
.input-wrap{position:relative; display:flex;}
.input-wrap input,.field input{
  width:100%; min-height:48px; border:1px solid #CBD5E1; border-radius:var(--r-md); padding:0 14px; background:#fff; font-size:16px; outline:none;
  transition:border-color .12s ease, box-shadow .12s ease;
}
.input-wrap input{padding-right:72px;}
.input-wrap input:focus,.field input:focus{border-color:var(--logo); box-shadow:0 0 0 3px rgba(59,155,234,.28);}
.input-wrap input::placeholder,.field input::placeholder{color:#94A3B8;}
.input-toggle{
  position:absolute; right:4px; top:4px; bottom:4px; min-width:56px; border:none; background:transparent; color:var(--brand);
  font-weight:600; font-size:14px; border-radius:var(--r-sm);
}
.input-toggle:hover{background:var(--brand-soft);}
.login-btn{width:100%; min-height:50px; border:none; border-radius:var(--r-md); background:var(--brand); color:#fff; font-weight:600; font-size:16px;}
.login-btn:hover{background:var(--brand-strong);}
.login-btn:disabled{opacity:.6; cursor:default;}
.link-btn{background:none; border:none; color:var(--brand); font-weight:600; font-size:14px; padding:12px; min-height:44px; align-self:center;}
.link-btn:hover{text-decoration:underline;}
.login-spinner{display:inline-block; width:16px; height:16px; margin-right:8px; vertical-align:-3px; border:2px solid rgba(255,255,255,.4); border-top-color:#fff; border-radius:50%; animation:spin .7s linear infinite;}
@keyframes spin{to{transform:rotate(360deg);}}
.login-note{margin-top:16px; font-size:13px; color:var(--muted); text-align:center;}
.login-support{margin-top:20px;}
.login-support-label{font-size:13px; font-weight:600; color:var(--muted); text-align:center; margin-bottom:8px;}
.login-support-btns{display:flex; gap:8px;}
.support-btn{
  flex:1; min-height:48px; display:flex; align-items:center; justify-content:center; gap:6px; padding:0 8px; border-radius:var(--r-md); white-space:nowrap;
  background:var(--surface); border:1px solid var(--line); color:var(--ink); text-decoration:none; font-weight:600; font-size:14px;
}
.support-btn:hover{background:var(--line-2);}
@media (max-width:359px){.support-btn{font-size:13px;}}
.support-btn img,.support-btn svg{width:20px; height:20px; flex-shrink:0;}
.support-whatsapp svg{color:#25D366;}
.login-note-banner{margin-bottom:16px; padding:12px 14px; border-radius:var(--r-md); background:var(--warn-bg); border:1px solid var(--warn-line); color:var(--warn-ink); font-size:14px;}

/* ===================================================================================================
   App shell: top bar, views, bottom tab bar
   =================================================================================================== */
.app-screen{display:flex; flex-direction:column; flex:1; min-height:0; opacity:0; transition:opacity .25s ease; position:relative;}
.app-screen.show{opacity:1;}
.appbar{
  flex-shrink:0; background:var(--logo-bar); color:#fff; padding:14px 16px 12px;
  padding-top:max(14px, env(safe-area-inset-top)); display:flex; align-items:center; gap:12px;
}
.appbar-logo{width:40px; height:40px; border-radius:10px; border:1px solid rgba(255,255,255,.25); background:#fff; padding:5px; flex-shrink:0; overflow:hidden;}
.appbar-logo img{width:100%; height:100%; object-fit:contain; display:block;}
.appbar-text{flex:1; min-width:0;}
.appbar-brand{font-size:11px; font-weight:700; letter-spacing:.12em; text-transform:uppercase; opacity:.92; line-height:1.2;}
.appbar-title{font-size:18px; font-weight:700; letter-spacing:-.01em; line-height:1.2; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.appbar-sub{font-size:13px; color:rgba(255,255,255,.95); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.icon-btn{
  width:44px; height:44px; border-radius:50%; border:1px solid var(--line); background:var(--surface); color:var(--ink-2); position:relative;
  display:flex; align-items:center; justify-content:center; flex-shrink:0;
}
.icon-btn:hover{background:var(--line-2);}
.appbar .icon-btn{background:rgba(255,255,255,.1); border-color:rgba(255,255,255,.28); color:#fff;}
.appbar .icon-btn:hover{background:rgba(255,255,255,.18);}
.notif-badge{
  position:absolute; top:-4px; right:-4px; min-width:18px; height:18px; padding:0 5px; border-radius:9px; background:var(--danger); color:#fff;
  font-size:11px; font-weight:700; display:flex; align-items:center; justify-content:center; border:2px solid var(--logo); box-sizing:content-box;
}

.views{flex:1; min-height:0; position:relative; overflow:hidden;}
.view{position:absolute; inset:0; overflow-y:auto; padding:16px 16px calc(var(--tabbar-h) + 36px); display:none;}
.view.active{display:block;}
.view::-webkit-scrollbar{width:0;}

.tabbar{
  position:absolute; left:0; right:0; bottom:0; z-index:45; height:calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom:env(safe-area-inset-bottom);
  background:var(--surface); border-top:1px solid var(--line); display:grid; grid-template-columns:1fr 1fr 112px 1fr 1fr; align-items:stretch;
}
.tab{
  border:none; background:none; color:var(--muted); display:flex; flex-direction:column; align-items:center; justify-content:center; gap:3px;
  font-size:12px; font-weight:500; padding:6px 2px; min-width:0;
}
.tab svg.i{width:24px; height:24px;}
.tab{position:relative;}
.tab[aria-current="page"]{color:var(--brand); font-weight:700;}
.tab[aria-current="page"] svg{color:var(--logo-strong);}
.tab[aria-current="page"]::before{content:''; position:absolute; top:-1px; left:22%; right:22%; height:3px; border-radius:0 0 3px 3px; background:var(--logo);}
.tab-add{position:relative; display:flex; justify-content:center;}
.tab-add button{
  position:absolute; top:-22px; min-width:104px; height:44px; padding:0 16px; border:2px solid #fff; border-radius:22px; background:var(--brand); color:#fff;
  display:flex; align-items:center; justify-content:center; gap:6px; font-weight:600; font-size:14px; white-space:nowrap; box-shadow:0 4px 12px rgba(27,114,196,.35);
}
.tab-add button:hover{background:var(--brand-strong);}
.tab-add svg.i{width:18px; height:18px; stroke-width:2.5;}

/* ---- Cards & lists ---- */
.card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg);}
.card + .card,.card + .section-head,.section-head + .card{margin-top:16px;}
.section-head{display:flex; align-items:center; justify-content:space-between; margin:24px 0 8px; padding:0 4px;}
.section-head h2{margin:0; font-size:15px; font-weight:700;}
.text-link{background:none; border:none; color:var(--brand); font-weight:600; font-size:14px; padding:8px 4px; min-height:36px;}
.text-link:hover{text-decoration:underline;}
.greet h1{margin:0; font-size:22px; font-weight:700; letter-spacing:-.01em;}
.greet p{margin:2px 0 16px; font-size:14px; color:var(--muted);}

.reminder{display:flex; align-items:center; gap:12px; padding:12px 14px; margin-bottom:16px; border-radius:var(--r-md); background:var(--warn-bg); border:1px solid var(--warn-line); color:var(--warn-ink);}
.reminder b{display:block; font-size:14px;}
.reminder span{display:block; font-size:13px; margin-top:2px;}
.reminder .btn{flex:none; min-height:40px; padding:0 14px; font-size:14px; background:var(--warn-ink); color:#fff;}

.balances{display:grid; grid-template-columns:1fr 1fr; overflow:hidden;}
.balance{padding:16px; text-align:left; background:var(--surface); border:none; display:flex; flex-direction:column; gap:4px; min-width:0;}
.balance + .balance{border-left:1px solid var(--line);}
.balance:hover{background:var(--line-2);}
.balance-label{font-size:13px; color:var(--muted); font-weight:500;}
.balance-value{font-size:22px; font-weight:700; letter-spacing:-.01em; font-variant-numeric:tabular-nums; overflow-wrap:anywhere;}
.balance-in .balance-value{color:var(--in);}
.balance-out .balance-value{color:var(--out);}
.balance-foot{font-size:12px; color:var(--muted);}
.net-note{margin:10px 4px 0; font-size:13px; color:var(--muted);}
.net-note b{color:var(--ink); font-weight:600;}

.kv-list{padding:4px 16px;}
.kv{display:flex; justify-content:space-between; align-items:center; padding:12px 0; border-bottom:1px solid var(--line-2); font-size:14px;}
.kv:last-child{border-bottom:none;}
.kv span{color:var(--ink-2);}
.kv b{font-weight:600; font-variant-numeric:tabular-nums;}
.kv.kv-in b{color:var(--in);} .kv.kv-out b{color:var(--out);}

.entry-row{display:flex; align-items:center; gap:12px; padding:12px 16px; border-bottom:1px solid var(--line-2);}
.entry-row:last-child{border-bottom:none;}
.entry-main{flex:1; min-width:0;}
.entry-main b{display:block; font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.entry-main span{display:block; font-size:13px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.entry-amt{font-weight:600; font-size:14px; font-variant-numeric:tabular-nums;}
.chip-btn{border:1px solid var(--line); background:var(--surface); color:var(--brand); font-weight:600; font-size:13px; min-height:36px; padding:0 12px; border-radius:18px;}
.chip-btn:hover{background:var(--brand-soft);}
.empty{padding:28px 16px; text-align:center; color:var(--muted); font-size:14px;}

/* ---- Customers & suppliers ---- */
.segmented{display:flex; background:#E6EAF0; border-radius:var(--r-md); padding:3px; margin-bottom:12px;}
.segmented button{flex:1; min-height:38px; border:none; background:transparent; border-radius:10px; font-weight:600; font-size:14px; color:var(--ink-2);}
.segmented button.active{background:var(--surface); color:var(--ink); box-shadow:0 1px 2px rgba(15,23,42,.12);}
.search{position:relative; margin-bottom:12px;}
.search svg.i{position:absolute; left:14px; top:50%; transform:translateY(-50%); width:20px; height:20px; color:var(--muted); pointer-events:none;}
.search input{width:100%; min-height:48px; border:1px solid #CBD5E1; border-radius:var(--r-md); padding:0 14px 0 44px; background:#fff; font-size:16px; outline:none; -webkit-appearance:none; appearance:none;}
.search input:focus{border-color:var(--logo); box-shadow:0 0 0 3px rgba(59,155,234,.28);}
.picking-note{margin:0 0 12px; padding:10px 14px; border-radius:var(--r-md); background:var(--brand-soft); color:var(--brand-strong); font-size:14px; font-weight:500;}
.people-list{padding:0; overflow:hidden;}
.person{
  display:flex; align-items:center; gap:12px; width:100%; text-align:left; padding:12px 16px; min-height:68px; background:var(--surface); border:none;
  border-bottom:1px solid var(--line-2);
}
.person:last-child{border-bottom:none;}
.person:hover{background:var(--line-2);}
.person-avatar{width:42px; height:42px; border-radius:50%; background:#E6EAF0; color:var(--ink-2); font-weight:600; font-size:14px; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.person-info{flex:1; min-width:0;}
.person-name{font-weight:600; font-size:15px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.person-sub{font-size:13px; color:var(--muted); white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.person-bal{text-align:right; flex-shrink:0;}
.person-bal b{display:block; font-size:15px; font-weight:600; font-variant-numeric:tabular-nums;}
.person-bal span{display:block; font-size:12px;}
.person-bal.dr b,.person-bal.dr span{color:var(--in);}
.person-bal.cr b,.person-bal.cr span{color:var(--out);}
.person-bal.zero b,.person-bal.zero span{color:var(--muted);}

/* ---- Reports + Account lists ---- */
.nav-list{overflow:hidden;}
.nav-row{display:flex; align-items:center; gap:14px; width:100%; text-align:left; background:var(--surface); border:none; border-bottom:1px solid var(--line-2); padding:14px 16px; min-height:68px; color:var(--ink); text-decoration:none;}
.nav-row:last-child{border-bottom:none;}
.nav-row:hover{background:var(--line-2);}
.nav-ic{width:40px; height:40px; border-radius:10px; background:var(--brand-soft); color:var(--brand); display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.nav-ic.neutral{background:#E6EAF0; color:var(--ink-2);}
.nav-ic.danger{background:var(--danger-soft); color:var(--danger);}
.nav-text{flex:1; min-width:0;}
.nav-text b{display:block; font-size:15px; font-weight:600;}
.nav-text span{display:block; font-size:13px; color:var(--muted);}
.nav-row .chev{width:18px; height:18px; color:#94A3B8;}
.nav-row.danger .nav-text b{color:var(--danger);}
.profile{display:flex; align-items:center; gap:14px; padding:16px; margin-bottom:16px;}
.profile-avatar{width:52px; height:52px; border-radius:50%; background:var(--brand-soft); color:var(--brand-strong); font-weight:700; font-size:18px; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.profile b{display:block; font-size:17px;}
.profile span{display:block; font-size:14px; color:var(--muted);}
.app-foot{margin:20px 0 0; text-align:center; font-size:12px; color:var(--muted);}

/* ---- Bottom sheet ---- */
.sheet-backdrop{position:absolute; inset:0; z-index:60; background:rgba(15,23,42,.45); opacity:0; transition:opacity .18s ease;}
.sheet-backdrop.open{opacity:1;}
.sheet{
  position:absolute; left:0; right:0; bottom:0; z-index:61; background:var(--surface); border-radius:var(--r-lg) var(--r-lg) 0 0; padding:8px 16px calc(16px + env(safe-area-inset-bottom));
  transform:translateY(100%); transition:transform .2s ease; max-height:86%; overflow-y:auto;
}
.sheet.open{transform:translateY(0);}
.sheet-grab{width:40px; height:4px; border-radius:2px; background:#CBD5E1; margin:0 auto 12px;}
.sheet-head{display:flex; align-items:flex-start; justify-content:space-between; gap:12px; margin-bottom:8px;}
.sheet-title{font-size:18px; font-weight:700;}
.sheet-sub{font-size:14px; color:var(--muted); margin-top:2px;}
.sheet .nav-list{border:none; border-radius:0;}
.sheet .nav-row{padding-left:0; padding-right:0;}

/* ===================================================================================================
   Guided flows (add entry, add account, reports) — full-screen over the tabs
   =================================================================================================== */
.chat-screen{display:none; position:absolute; top:0; left:0; right:0; bottom:calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index:30; background:var(--bg); flex-direction:column;}
.chat-screen.show{display:flex;}
.flowbar{flex-shrink:0; display:flex; align-items:center; gap:8px; background:var(--surface); border-bottom:1px solid var(--line); padding:10px 12px; padding-top:max(10px, env(safe-area-inset-top));}
.flowbar-title{flex:1; text-align:center; font-size:17px; font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.back-flow-btn,.cancel-flow-btn{
  min-width:44px; height:44px; border-radius:var(--r-md); border:none; background:transparent; color:var(--brand); font-weight:600; font-size:15px;
  display:flex; align-items:center; justify-content:center; gap:4px; padding:0 10px;
}
.back-flow-btn:hover,.cancel-flow-btn:hover{background:var(--brand-soft);}
.cancel-flow-btn{color:var(--ink-2);}
.progress{display:flex; gap:4px; padding:12px 16px 0; flex-shrink:0;}
.progress .seg{flex:1; height:4px; border-radius:2px; background:#DDE3EA; overflow:hidden;}
.progress .seg i{display:block; height:100%; width:0; background:var(--logo); transition:width .25s ease;}
.steprow{padding:8px 16px 0; min-height:24px; flex-shrink:0;}
.steplabel{font-size:13px; color:var(--muted); font-weight:500;}
.steplabel b{color:var(--ink);}
.chat{flex:1; min-height:0; overflow-y:auto; padding:16px 16px 36px; display:flex; flex-direction:column; gap:12px;}
.chat::-webkit-scrollbar{width:0;}
.row{display:flex; flex-direction:column;}
.row.user{align-items:flex-end;}
.row.bot{align-items:flex-start;}
.botline{display:flex; max-width:92%;}
.bubble{max-width:88%; padding:12px 14px; border-radius:var(--r-md); font-size:15px; line-height:1.45;}
.row.bot .bubble{background:var(--surface); border:1px solid var(--line); color:var(--ink); border-top-left-radius:4px;}
.row.user .bubble{background:var(--brand); color:#fff; border-top-right-radius:4px;}
.optrow{display:flex; flex-wrap:wrap; gap:8px; max-width:100%;}
.optbtn{min-height:44px; padding:0 16px; border-radius:var(--r-md); border:1px solid #BBDCF6; background:var(--surface); color:var(--brand); font-weight:600; font-size:15px;}
.optbtn:hover{background:var(--brand-soft);}
.optbtn:disabled{opacity:.55; cursor:default;}
.optbtn.skip{border-color:var(--line); color:var(--ink-2); font-weight:500;}
.summary-card,.date-card,.ledger-card,.arap-card,.report-card{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:16px; width:100%; max-width:100%;}
.summary-card .label{font-size:13px; font-weight:700; color:var(--ink); margin-bottom:8px;}
.srow{display:flex; justify-content:space-between; gap:16px; padding:10px 0; border-bottom:1px solid var(--line-2); font-size:14px;}
.srow:last-of-type{border-bottom:none;}
.srow .k{color:var(--muted);}
.srow .v{font-weight:600; text-align:right; overflow-wrap:anywhere;}
.date-card{display:flex; flex-direction:column; gap:10px;}
.date-label{font-size:14px; font-weight:600; color:var(--ink-2);}
.date-input{min-height:48px; border:1px solid #CBD5E1; border-radius:var(--r-md); padding:0 12px; font-size:16px; background:#fff; outline:none;}
.date-input:focus{border-color:var(--logo); box-shadow:0 0 0 3px rgba(59,155,234,.28);}
.date-confirm{width:100%;}
.result-card{display:flex; align-items:center; gap:12px; padding:14px 16px; border-radius:var(--r-md); font-size:14px; width:100%;}
.result-card.ok{background:var(--ok-soft); border:1px solid #B7E1C4; color:#05442B;}
.result-card.err{background:var(--danger-soft); border:1px solid #F3C1BC; color:#7A1B13;}
.result-card .checkwrap{width:24px; height:24px; border-radius:50%; background:var(--ok); color:#fff; display:flex; align-items:center; justify-content:center; flex-shrink:0;}
.result-card.err .checkwrap{background:var(--danger);}
.result-card .checkwrap svg{width:14px; height:14px; stroke-width:3;}
.clarify-card{background:var(--warn-bg); border:1px solid var(--warn-line); color:var(--warn-ink); border-radius:var(--r-md); padding:12px 14px; font-size:14px; width:100%;}
.typing{display:flex; gap:4px; padding:14px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md); border-top-left-radius:4px; width:fit-content;}
.typing span{width:6px; height:6px; border-radius:50%; background:#94A3B8; animation:bounce 1.1s infinite ease-in-out;}
.typing span:nth-child(2){animation-delay:.15s;} .typing span:nth-child(3){animation-delay:.3s;}
@keyframes bounce{0%,60%,100%{transform:translateY(0);opacity:.5;}30%{transform:translateY(-3px);opacity:1;}}
.inputbar{display:flex; align-items:center; gap:8px; padding:10px 12px 34px; background:var(--surface); border-top:1px solid var(--line); flex-shrink:0;}
.inputbar input{flex:1; min-height:48px; border:1px solid #CBD5E1; border-radius:var(--r-md); padding:0 14px; background:#fff; font-size:16px; outline:none;}
.inputbar input:focus{border-color:var(--logo); box-shadow:0 0 0 3px rgba(59,155,234,.28);}
.inputbar input:disabled{background:var(--line-2); color:#94A3B8;}
.sendbtn{min-width:76px; min-height:48px; border:none; border-radius:var(--r-md); background:var(--brand); color:#fff; font-weight:600; font-size:15px;}
.sendbtn:hover{background:var(--brand-strong);}
.sendbtn:disabled{background:#CBD5E1; cursor:default;}

/* ---- Ledger / AR-AP / aging / daily register cards ---- */
.ledger-head{display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:8px;}
.lh-name{font-weight:700; font-size:16px;}
.lh-badge{background:var(--brand-soft); color:var(--brand-strong); font-size:12px; font-weight:600; padding:3px 10px; border-radius:12px;}
.ledger-table{border-top:1px solid var(--line); margin-top:8px;}
.lrow{display:grid; grid-template-columns:48px 1fr 60px 60px 72px; gap:4px; padding:10px 0; border-bottom:1px solid var(--line-2); align-items:center;}
.lc{font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.lc.date{color:var(--muted);}
.lc.num{text-align:right; font-variant-numeric:tabular-nums;}
.lc.debit{color:var(--out); font-weight:600;} .lc.credit{color:var(--in); font-weight:600;}
.lrow.lhead .lc{font-size:11px; font-weight:600; color:var(--muted); white-space:normal; line-height:1.2;}
.lrow.lopen,.lrow.lclose{background:var(--line-2); border-radius:8px; padding-left:6px; padding-right:6px; border-bottom:none;}
.lc.bold{font-weight:700;}
.lc small{font-weight:500; color:var(--muted);}
.lc .rcpt{all:unset; display:block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer; color:var(--brand); text-decoration:underline; text-underline-offset:2px;}
.lc .rcpt:focus-visible{outline:2px solid var(--logo); outline-offset:2px; border-radius:4px;}
.arap-total,.rc-total{display:flex; justify-content:space-between; align-items:center; border-radius:var(--r-md); padding:12px 14px; margin:12px 0; font-weight:600;}
.arap-total{flex-direction:column; align-items:flex-start; gap:2px;}
.arap-total-label{font-size:13px; font-weight:500; color:var(--muted);}
.arap-total-value{font-size:22px; font-weight:700;}
.rc-total{background:var(--brand-soft); color:var(--brand-strong);}
.arow{display:grid; grid-template-columns:1fr 92px 84px; gap:6px; padding:10px 0; border-bottom:1px solid var(--line-2); align-items:center;}
.arow.ahead{font-size:11px; font-weight:600; color:var(--muted); background:var(--line-2); border-radius:8px; padding-left:6px; padding-right:6px;}
.arow .ac{font-size:13px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.arow .ac.num{text-align:right; font-weight:600; font-variant-numeric:tabular-nums;}
.type-chip{font-size:11px; font-weight:500; padding:2px 6px; white-space:nowrap; border-radius:10px; background:var(--line-2); color:var(--muted);}
.report-card .rc-head{display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:12px;}
.rc-title{font-size:16px; font-weight:700;}
.rc-sub{font-size:13px; color:var(--muted);}
.rc-buckets{display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:8px; margin-bottom:12px;}
.rc-bucket{border:1px solid var(--line); border-radius:var(--r-md); padding:10px; min-width:0;}
.rc-bucket .k{font-size:12px; color:var(--muted);}
.rc-bucket .v{font-size:14px; font-weight:700; overflow-wrap:anywhere; font-variant-numeric:tabular-nums;}
.rc-b4 .v{color:var(--danger);}
.rc-list{display:flex; flex-direction:column;}
.rc-row{display:flex; justify-content:space-between; align-items:center; gap:10px; padding:12px 0; border-bottom:1px solid var(--line-2); font-size:14px;}
.rc-row:last-child{border-bottom:none;}
.rc-name{font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.rc-meta{font-size:13px; color:var(--muted);}
.rc-amt{font-weight:600; white-space:nowrap; font-variant-numeric:tabular-nums;}
.rc-old{color:var(--danger); font-weight:600;}
.rc-receipt{border:1px solid var(--line); background:var(--surface); color:var(--brand); border-radius:18px; min-height:36px; padding:0 12px; font-weight:600; font-size:13px;}
.rc-daynav{display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:12px;}
.rc-daynav button{min-height:40px; border:1px solid var(--line); background:var(--surface); border-radius:var(--r-md); padding:0 12px; font-weight:600; font-size:14px;}
.rc-daynav button:disabled{opacity:.4; cursor:default;}
.rc-day{flex:1; text-align:center; font-weight:700; font-size:14px;}
.rc-kpis{display:grid; grid-template-columns:1fr 1fr; gap:8px; margin-bottom:12px;}
.rc-kpi{border:1px solid var(--line); border-radius:var(--r-md); padding:10px;}
.rc-kpi .k{font-size:12px; color:var(--muted);}
.rc-kpi .v{font-size:15px; font-weight:700; font-variant-numeric:tabular-nums;}
.report-card .actions{margin-top:16px;}

/* ===================================================================================================
   Notifications panel, password screen, toasts
   =================================================================================================== */
.notif-panel,.password-screen,.receipt-screen{display:none; position:absolute; top:0; left:0; right:0; bottom:calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index:40; background:var(--bg); flex-direction:column;}
.notif-panel.show,.password-screen.show,.receipt-screen.show{display:flex;}
.overlay-head{flex-shrink:0; display:flex; align-items:center; gap:8px; background:var(--surface); border-bottom:1px solid var(--line); padding:10px 12px; padding-top:max(10px, env(safe-area-inset-top));}
.overlay-title{flex:1; font-size:17px; font-weight:700;}
.overlay-head .text-link{padding:8px 10px;}
.notif-list{flex:1; min-height:0; overflow-y:auto; padding:12px 16px 40px;}
.notif-item{display:flex; gap:12px; padding:14px; margin-bottom:8px; background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md);}
.notif-item.unread{border-color:#BBDCF6; background:#F3F9FE;}
.notif-dot{width:10px; height:10px; border-radius:50%; margin-top:6px; flex-shrink:0; background:#94A3B8;}
.notif-dot.Warning{background:#D97706;} .notif-dot.Error{background:var(--danger);} .notif-dot.Success{background:var(--ok);} .notif-dot.Info{background:var(--logo-strong);}
.notif-body{flex:1; min-width:0;}
.notif-title{font-size:14px; font-weight:600;}
.notif-message{font-size:14px; color:var(--ink-2); margin-top:2px;}
.notif-time{font-size:12px; color:var(--muted); margin-top:4px;}
.notif-empty{padding:40px 16px; text-align:center; color:var(--muted);}
.password-body{flex:1; overflow-y:auto; padding:16px 16px 44px;}
.password-body .field input{font-size:16px;}
.toast-stack{position:absolute; left:12px; right:12px; bottom:calc(var(--tabbar-h) + 28px); z-index:90; display:flex; flex-direction:column-reverse; gap:8px; pointer-events:none;}
.toast{pointer-events:auto; display:flex; align-items:flex-start; gap:10px; padding:12px 14px; border-radius:var(--r-md); background:var(--ink); color:#fff; font-size:14px; line-height:1.4; box-shadow:0 8px 24px rgba(15,23,42,.3); animation:toastIn .18s ease both;}
.toast.leaving{animation:toastOut .15s ease both;}
.toast .toast-icon{width:20px; height:20px; flex-shrink:0; margin-top:1px;}
.toast .toast-icon svg{width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round;}
.toast .toast-msg{flex:1;}
.toast .toast-close{background:none; border:none; color:rgba(255,255,255,.7); font-size:18px; line-height:1; padding:0 2px; min-width:24px; min-height:24px;}
.toast-error .toast-icon{color:#FCA5A5;} .toast-warning .toast-icon{color:#FCD34D;} .toast-success .toast-icon{color:#86EFAC;} .toast-info .toast-icon{color:#93C5FD;}
@keyframes toastIn{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:translateY(0);}}
@keyframes toastOut{from{opacity:1;} to{opacity:0;}}
.login-screen .toast-stack{bottom:24px;}

@media (prefers-reduced-motion:reduce){
  *{animation:none !important; transition:none !important;}
}
.person-name,.person-sub{display:block;}
.person-bal span{display:block;}

/* ---- Native-app feel: no text selection on chrome, no tap flash, no rubber-banding, press feedback, screen transitions ---- */
html,body{overscroll-behavior:none; -webkit-tap-highlight-color:transparent; touch-action:manipulation;}
body{-webkit-user-select:none; user-select:none; -webkit-touch-callout:none;}
input,textarea,.selectable,.lc,.rc-kpi .v{-webkit-user-select:text; user-select:text;}
.view,.chat,.notif-list,.password-body,.sheet{overscroll-behavior:contain; -webkit-overflow-scrolling:touch;}
button,.nav-row,.person,.tab,.optbtn,.chip-btn{transition:transform .08s ease, background-color .15s ease;}
button:active,.nav-row:active,.person:active,.optbtn:active,.chip-btn:active{transform:scale(.97);}
.tab:active{transform:scale(.92);}
@keyframes screen-in{from{transform:translateX(24px); opacity:0;} to{transform:none; opacity:1;}}
@keyframes fade-in{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;}}
.chat-screen.show,.notif-panel.show,.password-screen.show,.receipt-screen.show{animation:screen-in .22s ease-out;}
.view.active{animation:fade-in .18s ease-out;}
@media (display-mode:standalone){ body{background:var(--bg);} }
@media (prefers-reduced-motion:reduce){ .chat-screen.show,.notif-panel.show,.password-screen.show,.view.active{animation:none;} }
#toast{position:absolute; left:50%; bottom:calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom)); transform:translateX(-50%) translateY(8px); z-index:90; background:var(--ink); color:#fff; padding:10px 18px; border-radius:22px; font-size:14px; font-weight:600; opacity:0; pointer-events:none; transition:opacity .2s, transform .2s;}
#toast.show{opacity:1; transform:translateX(-50%);}
.rc-kpi .v.in{color:var(--in);} .rc-kpi .v.out{color:var(--out);}
/* Numbers people may want to copy (entry numbers, amounts, names) stay selectable. */
.result-card,.summary-card,.report-card,.arap-card,.bubble,.clarify-card,.rc-row,.arow,.lrow,.notif-item,.person-name{-webkit-user-select:text; user-select:text;}

/* ---- Receipt screen ---- */
.receipt-body{flex:1; overflow-y:auto; padding:16px; overscroll-behavior:contain;}
.rcpt-paper{background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); padding:20px 18px; position:relative; overflow:hidden;}
.rcpt-paper::after{content:''; position:absolute; left:0; right:0; bottom:0; height:6px; background:repeating-linear-gradient(135deg, var(--bg) 0 6px, transparent 6px 12px);}
.rcpt-biz{font-size:13px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); text-align:center;}
.rcpt-what{margin-top:10px; text-align:center; font-size:15px; font-weight:600; color:var(--ink-2);}
.rcpt-amount{margin-top:4px; text-align:center; font-size:32px; font-weight:800; font-variant-numeric:tabular-nums;}
.rcpt-amount.in{color:var(--in);} .rcpt-amount.out{color:var(--out);}
.rcpt-no{margin-top:6px; text-align:center; font-size:13px; color:var(--muted);}
.rcpt-status{display:block; width:max-content; margin:10px auto 0; font-size:12px; font-weight:700; padding:3px 12px; border-radius:12px; background:var(--ok-soft); color:var(--ok);}
.rcpt-status.bad{background:var(--danger-soft); color:var(--danger);}
.rcpt-rows{margin-top:16px; border-top:1px dashed var(--line);}
.rcpt-row{display:flex; justify-content:space-between; gap:16px; padding:11px 0; border-bottom:1px solid var(--line-2); font-size:14px;}
.rcpt-row .k{color:var(--muted); flex-shrink:0;}
.rcpt-row .v{text-align:right; font-weight:600; word-break:break-word; min-width:0;}
.rcpt-balance{margin-top:14px; display:flex; justify-content:space-between; align-items:center; background:var(--brand-soft); color:var(--brand-strong); border-radius:var(--r-md); padding:12px 14px; font-weight:700; margin-bottom:8px;}
.receipt-actions{display:flex; gap:10px; padding:12px 16px 36px; border-top:1px solid var(--line); background:var(--surface);}
.receipt-actions .btn{flex:1; min-height:48px;}
.rcpt-logo{display:block; width:48px; height:48px; object-fit:contain; margin:0 auto 8px;}
