/* BahiKhata — modern app UI (mobile + web) ---------------------------------- */
:root{
  --bg:#f3f4f2;            /* app background (warm light grey) */
  --surface:#ffffff;       /* cards */
  --surface-2:#f7f8f6;
  --ink:#1c2620;           /* primary text */
  --muted:#6b756e;         /* secondary text */
  --line:#e7e8e4;          /* hairlines */
  --brand:#1f7a44;         /* green accent */
  --brand-dark:#16613a;
  --brand-soft:#e9f3ec;
  --accent:#c0392b;        /* Cr / danger */
  --accent-soft:#fdecea;
  --gold:#c8881d;
  --ok:#1d6b2f;
  --shadow:0 1px 2px rgba(20,30,25,.05), 0 1px 3px rgba(20,30,25,.06);
  --shadow-lg:0 8px 30px rgba(20,30,25,.12);
  --r:14px;                /* card radius */
  --r-pill:999px;
  --topbar-h:56px;
  --bottomnav-h:62px;
  --font:'Inter',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
  --mono:'JetBrains Mono',ui-monospace,'SF Mono',Menlo,monospace;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{
  font-family:var(--font);
  font-size:15px;line-height:1.45;color:var(--ink);background:var(--bg);
  -webkit-font-smoothing:antialiased;text-rendering:optimizeLegibility;
}
/* tabular figures for all money/quantity columns (accounting precision) */
.num,td.num,th.num,input.num,.amt,.mono{font-family:var(--mono);font-variant-numeric:tabular-nums;letter-spacing:-.2px}
/* SVG icon system (Lucide-style, replaces emoji) */
.ic-svg{width:22px;height:22px;stroke:currentColor;stroke-width:1.8;fill:none;stroke-linecap:round;stroke-linejoin:round;display:block}
.tile .ic .ic-svg{width:24px;height:24px}
.bottomnav .ic-svg{width:23px;height:23px}
.sheet-card a .ic-svg{width:20px;height:20px;display:inline-block;vertical-align:-4px;margin-right:10px;stroke-width:1.7}
.cbtn .ic-svg{width:20px;height:20px;stroke:#fff}
.iconbtn .ic-svg{width:24px;height:24px}
/* motion + focus discipline (ui-ux-pro-max) */
button,a,.tile,.chip,.btn,.gw-item{transition:background .18s ease,border-color .18s ease,box-shadow .18s ease,transform .12s ease,color .18s ease}
:focus-visible{outline:2px solid var(--brand);outline-offset:2px}
@media (prefers-reduced-motion:reduce){*{animation-duration:.01ms !important;transition-duration:.01ms !important}}
.app{display:flex;flex-direction:column;min-height:100dvh}
.hide{display:none}

/* ---------- top app bar ---------- */
.topbar{
  position:sticky;top:0;z-index:40;height:var(--topbar-h);
  display:flex;align-items:center;gap:6px;padding:0 10px;
  background:rgba(255,255,255,.86);backdrop-filter:saturate(1.4) blur(10px);
  border-bottom:1px solid var(--line);
}
.topbar .topttl{flex:1;min-width:0}
#work-title{font-size:17px;font-weight:700;letter-spacing:-.2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.topsub{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.iconbtn{
  flex:none;width:40px;height:40px;border:0;background:transparent;border-radius:50%;
  font-size:22px;color:var(--ink);cursor:pointer;display:flex;align-items:center;justify-content:center;
}
.iconbtn:hover{background:var(--surface-2)}
#navback{font-size:30px;line-height:1}

/* ---------- context action pills (per-screen actions = old "button bar") ---------- */
.actionbar{display:flex;gap:8px;overflow-x:auto;padding:10px 14px 2px;-webkit-overflow-scrolling:touch}
.actionbar:empty{display:none}
.actionbar::-webkit-scrollbar{display:none}
.btn{
  flex:none;background:var(--surface);border:1px solid var(--line);border-radius:var(--r-pill);
  padding:8px 14px;font-size:13.5px;font-weight:600;color:var(--ink);cursor:pointer;white-space:nowrap;
  box-shadow:var(--shadow);
}
.btn:hover{background:var(--surface-2)}
.btn .k{color:var(--brand);font-weight:800}
.btn.dim{opacity:.45;cursor:default;box-shadow:none}

/* ---------- main scroll area ---------- */
.content{flex:1;min-height:0;overflow-y:auto;padding:14px 14px calc(var(--bottomnav-h) + 18px);max-width:920px;width:100%;margin:0 auto}

/* ---------- bottom navigation ---------- */
.bottomnav{
  position:fixed;left:0;right:0;bottom:0;z-index:45;height:var(--bottomnav-h);
  display:flex;align-items:center;justify-content:space-around;padding-bottom:env(safe-area-inset-bottom);
  background:rgba(255,255,255,.92);backdrop-filter:saturate(1.4) blur(12px);border-top:1px solid var(--line);
}
.bottomnav button{
  flex:1;border:0;background:none;cursor:pointer;color:var(--muted);
  display:flex;flex-direction:column;align-items:center;gap:3px;font-size:11px;font-weight:600;padding:6px 0;
}
.bottomnav button span{display:flex;align-items:center;justify-content:center;line-height:1}
.bottomnav button.active{color:var(--brand)}
.bottomnav .fab span{
  width:50px;height:50px;margin-top:-22px;border-radius:50%;background:var(--brand);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:28px;box-shadow:0 6px 16px rgba(31,122,68,.4);
}
.bottomnav .fab{color:var(--brand)}

/* ---------- "More" bottom sheet ---------- */
.sheet{position:fixed;inset:0;z-index:60;background:rgba(20,30,25,.42);display:flex;align-items:flex-end;justify-content:center}
.sheet-card{
  background:var(--surface);width:100%;max-width:480px;border-radius:20px 20px 0 0;padding:10px 0 22px;
  box-shadow:var(--shadow-lg);max-height:86dvh;overflow:auto;animation:sheetUp .22s ease;
}
@keyframes sheetUp{from{transform:translateY(40px);opacity:.4}to{transform:none;opacity:1}}
.sheet-card::before{content:"";display:block;width:40px;height:4px;border-radius:2px;background:#d7d9d4;margin:6px auto 12px}
.sheet-co{padding:6px 22px 12px;border-bottom:1px solid var(--line);margin-bottom:6px}
.sheet-co #cb-name{font-size:17px;font-weight:700;cursor:pointer}
.sheet-sub{font-size:12.5px;color:var(--muted);margin-top:2px}
.sheet-user{padding:4px 22px;color:var(--muted);font-size:13px}
.sheet-bill{padding:2px 22px 8px;font-size:13px}
.sheet-card a{display:block;padding:13px 22px;color:var(--ink);text-decoration:none;font-size:15px;font-weight:600;cursor:pointer}
.sheet-card a:hover{background:var(--surface-2)}

/* ---------- gateway: app tiles ---------- */
.welcome{margin:2px 2px 14px}
.welcome h2{margin:0;font-size:22px;font-weight:800;letter-spacing:-.4px}
.welcome p{margin:3px 0 0;color:var(--muted);font-size:13.5px}
.tiles{display:grid;grid-template-columns:repeat(2,1fr);gap:12px}
@media(min-width:560px){.tiles{grid-template-columns:repeat(3,1fr)}}
.tile{
  background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:16px 14px;
  cursor:pointer;box-shadow:var(--shadow);transition:transform .08s ease, box-shadow .15s ease;
}
.tile:hover{transform:translateY(-2px);box-shadow:var(--shadow-lg)}
.tile:active{transform:translateY(0)}
.tile .ic{color:var(--brand);display:block;margin-bottom:10px}
.tile .ic .ic-svg{width:26px;height:26px;stroke-width:1.7}
.welcome h2{font-family:var(--font)}
.tile .tl{font-weight:700;font-size:14.5px}
.tile .ts{font-size:11.5px;color:var(--muted);margin-top:2px;line-height:1.3}

/* ---------- cards / panels ---------- */
.ai-wrap{width:100%}
.ai-box{background:var(--surface);border:1px solid var(--line);border-radius:var(--r);padding:14px 16px;margin-bottom:12px;box-shadow:var(--shadow)}
.ai-out{background:var(--surface-2);border:1px solid var(--line);border-radius:12px;padding:12px 14px;margin-top:8px}
.badge{display:inline-block;padding:2px 9px;border-radius:var(--r-pill);font-size:11px;font-weight:700}
.badge.ok{background:var(--brand-soft);color:var(--ok)}
.badge.bad{background:var(--accent-soft);color:var(--accent)}
.hint{color:var(--muted);font-size:12.5px;margin-top:3px;line-height:1.4}
.chips{display:flex;gap:8px;flex-wrap:wrap;margin-top:8px}
.chip{background:var(--surface);border:1px solid var(--line);border-radius:var(--r-pill);padding:6px 13px;font-size:12.5px;cursor:pointer;box-shadow:var(--shadow)}
.chip:hover{background:var(--surface-2)}
/* product autocomplete dropdown (stock item form) */
.hsn-sug{display:none;position:absolute;top:100%;left:0;z-index:25;background:var(--surface);
  border:1px solid var(--line);border-radius:12px;box-shadow:var(--shadow-lg);min-width:260px;max-width:340px;max-height:300px;overflow:auto;margin-top:4px}
.hsn-opt{padding:9px 13px;cursor:pointer;border-bottom:1px solid var(--line)}
.hsn-opt:last-child{border-bottom:0}
.hsn-opt:hover{background:var(--surface-2)}
.hsn-opt b{font-size:14px}

/* ---------- tables ---------- */
.tablewrap{overflow-x:auto;-webkit-overflow-scrolling:touch;border-radius:12px;border:1px solid var(--line)}
table.tly{width:100%;border-collapse:collapse;font-size:13.5px;background:var(--surface)}
table.tly th{background:var(--surface-2);color:var(--muted);text-align:left;padding:10px 12px;font-weight:700;
  font-size:11.5px;text-transform:uppercase;letter-spacing:.4px;border-bottom:1px solid var(--line);position:sticky;top:0}
table.tly td{padding:10px 12px;border-bottom:1px solid var(--line)}
table.tly tr:last-child td{border-bottom:0}
table.tly td.num,table.tly th.num{text-align:right;font-variant-numeric:tabular-nums}
table.tly tr:hover td{background:var(--surface-2)}
.dr{color:#1f5132}.cr{color:var(--accent)}
.tot td{border-top:2px solid var(--line);font-weight:800;background:var(--surface-2)}
.pos{color:var(--ok);font-weight:700}.neg{color:var(--accent);font-weight:700}

/* ---------- forms ---------- */
.row{display:flex;gap:12px;align-items:center;margin-bottom:10px;flex-wrap:wrap}
label.fld{display:flex;flex-direction:column;font-size:11.5px;color:var(--muted);gap:4px}
label.fld b{color:var(--ink);font-size:12px;font-weight:600}
input,select,textarea{
  font-family:inherit;font-size:15px;padding:11px 13px;border:1px solid #d8dad5;border-radius:11px;
  background:var(--surface);color:var(--ink);outline:none;
}
input:focus,select:focus,textarea:focus{border-color:var(--brand);box-shadow:0 0 0 3px rgba(31,122,68,.13)}
input.num{text-align:right;font-variant-numeric:tabular-nums}
.btn-go{background:var(--brand);color:#fff;border:none;padding:11px 18px;font-weight:700;font-size:14.5px;cursor:pointer;border-radius:var(--r-pill);box-shadow:var(--shadow)}
.btn-go:hover{background:var(--brand-dark)}
.btn-go:disabled{opacity:.5;cursor:default}
.btn-sm{padding:8px 14px;font-size:13px}
.btn-danger{background:var(--accent)}
.btn-danger:hover{background:#a8311f}
.linktab{background:none;border:none;color:var(--brand);cursor:pointer;font-weight:700;padding:0;font-size:inherit}

/* voucher entry grid */
.ventry{border:1px solid var(--line);background:var(--surface);border-radius:12px;overflow:hidden}
.ventry .vrow{display:grid;grid-template-columns:84px 1fr 92px 124px 32px;gap:8px;padding:9px 11px;border-bottom:1px solid var(--line);align-items:center}
.ventry .vrow:last-child{border-bottom:0}
.ventry .vhead{background:var(--surface-2);font-weight:700;color:var(--muted);font-size:11px;text-transform:uppercase;letter-spacing:.3px}
.ventry select,.ventry input{width:100%}

/* ---------- AI chat ---------- */
.chatwrap{display:flex;flex-direction:column;height:calc(100dvh - var(--topbar-h) - var(--bottomnav-h) - 26px)}
.chatlog{flex:1;overflow-y:auto;padding:6px 2px 12px;display:flex;flex-direction:column;gap:10px}
.chat-empty{color:var(--muted);text-align:center;padding:30px 18px;font-size:14px}
.bubble{max-width:86%;padding:11px 14px;border-radius:18px;font-size:14.5px;white-space:pre-wrap;word-wrap:break-word;box-shadow:var(--shadow)}
.bubble.user{align-self:flex-end;background:var(--brand);color:#fff;border-bottom-right-radius:6px}
.bubble.ai{align-self:flex-start;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-bottom-left-radius:6px}
.bubble.ai i{color:var(--muted)}
.chatbar{display:flex;align-items:center;gap:8px;padding:10px 4px calc(env(safe-area-inset-bottom) + 4px);background:var(--bg)}
.chatbar #chat-in{flex:1;min-width:0;border-radius:var(--r-pill);padding:12px 16px}
.cbtn{flex:none;width:44px;height:44px;border:0;border-radius:50%;font-size:18px;color:#fff;cursor:pointer;display:flex;align-items:center;justify-content:center;box-shadow:var(--shadow)}
@media(max-width:400px){ .chatbar{gap:6px} .cbtn{width:40px;height:40px} }
/* icons inside action pills */
.btn .ic-svg{display:inline-block;vertical-align:-4px;width:16px;height:16px;margin-right:6px}
.btn.btn-primary{background:var(--brand);color:#fff;border-color:var(--brand)}
.btn.btn-primary:hover{background:var(--brand-dark)}
/* live voice conversation overlay */
.live-overlay{position:fixed;inset:0;z-index:90;background:rgba(14,22,18,.97);display:none;
  flex-direction:column;align-items:center;justify-content:center;gap:20px;color:#fff;padding:24px;text-align:center}
.live-orb{width:124px;height:124px;border-radius:50%;background:radial-gradient(circle at 50% 38%,#34b063,#1f7a44);
  box-shadow:0 0 0 0 rgba(46,163,90,.55);animation:livepulse 1.6s infinite}
.live-orb.thinking{background:radial-gradient(circle at 50% 38%,#e0b455,#c8881d);animation-duration:1s}
.live-orb.speaking{background:radial-gradient(circle at 50% 38%,#5aa0e6,#2a6fb0);animation-duration:.85s}
@keyframes livepulse{0%{box-shadow:0 0 0 0 rgba(46,163,90,.5)}70%{box-shadow:0 0 0 36px rgba(46,163,90,0)}100%{box-shadow:0 0 0 0 rgba(46,163,90,0)}}
.live-status{font-size:22px;font-weight:700}
.live-hint{font-size:14px;opacity:.72;max-width:280px}
.live-orb{cursor:pointer}
.live-convo{max-width:340px;width:100%;display:flex;flex-direction:column;gap:8px;min-height:8px}
.lc-you{align-self:flex-end;background:rgba(255,255,255,.15);padding:9px 13px;border-radius:14px;font-size:14px;max-width:92%}
.lc-ai{align-self:flex-start;background:rgba(46,163,90,.26);padding:9px 13px;border-radius:14px;font-size:14px;max-width:92%}
.live-end{margin-top:8px;background:var(--accent);color:#fff;border:0;border-radius:var(--r-pill);padding:14px 44px;font-size:16px;font-weight:700;cursor:pointer}
.live-end:hover{background:#a8311f}
.cbtn.send{background:var(--brand)}.cbtn.mic{background:#6a4ea3}.cbtn.bill{background:#2a7d46}.cbtn.speak{background:#2a7d46}.cbtn.ghost{background:#8a93a0}

/* ---------- toast ---------- */
.toast{position:fixed;bottom:calc(var(--bottomnav-h) + 16px);left:50%;transform:translateX(-50%);
  background:#1c2620;color:#fff;padding:11px 18px;border-radius:var(--r-pill);box-shadow:var(--shadow-lg);
  z-index:80;font-weight:600;font-size:13.5px;max-width:90vw;text-align:center}
.toast.err{background:var(--accent)}

/* ---------- web / desktop refinements ---------- */
@media(min-width:760px){
  .content{padding-left:22px;padding-right:22px}
  .bubble{max-width:72%}
  .bottomnav{max-width:560px;left:50%;transform:translateX(-50%);border:1px solid var(--line);
    border-radius:var(--r-pill);bottom:16px;height:58px;box-shadow:var(--shadow-lg)}
  .content{padding-bottom:calc(var(--bottomnav-h) + 34px)}
  .chatwrap{height:calc(100dvh - var(--topbar-h) - 110px)}
}
