:root {
  --pri: #0f766e; --pri-d: #115e59; --pri-l: #ccfbf1;
  --bg: #f1f5f4; --card: #fff; --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
  --red: #dc2626; --green: #16a34a; --warn: #fef3c7; --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans Kannada", sans-serif; background: var(--bg); color: var(--text); padding-bottom: 76px; }
a { color: var(--pri); text-decoration: none; }
input, select, textarea, button { font: inherit; }
input, select, textarea { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--pri-l); border-color: var(--pri); }
label { display: block; margin: 0 0 10px; font-size: 13px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; }
h2, h3 { margin: 0 0 10px; } h3 { font-size: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small, small { font-size: 12px; } .center { text-align: center; } .right { text-align: right; }
.red { color: var(--red); } .green { color: var(--green); } .mt { margin-top: 12px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--pri); color: #fff; padding-top: max(10px, env(safe-area-inset-top)); }
.brand { color: #fff; font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.topnav { display: none; gap: 4px; }
.topnav a { color: #d1fae5; padding: 6px 12px; border-radius: 8px; }
.topnav a.on, .topnav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.topright { display: flex; gap: 6px; }
.icon-btn { color: #fff; font-size: 18px; padding: 4px 8px; }

.wrap { max-width: 900px; margin: 0 auto; padding: 14px 16px; }
.flash { background: var(--pri-l); color: var(--pri-d); padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }

/* bottom nav (app style) */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 7px 0 8px; font-size: 11px; color: var(--muted); }
.bottomnav a span { font-size: 20px; line-height: 1.2; }
.bottomnav a.on { color: var(--pri); font-weight: 600; }

@media (min-width: 900px) {
  .topnav { display: flex; } .mobile-only { display: none; }
  .bottomnav { display: none; } body { padding-bottom: 20px; }
}

/* basics */
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card.tight { padding: 10px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; font-weight: 500; }
.btn.primary { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.primary:active { background: var(--pri-d); }
.btn.danger { color: var(--red); border-color: #fecaca; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; } .btn.big { padding: 15px; font-size: 17px; margin-bottom: 12px; border-radius: var(--r); }
.btn:disabled { opacity: .6; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid2 > input, .grid2 > select, .grid2 > button { margin-bottom: 10px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 12px; } .toolbar .search { flex: 1; }
.chips { display: flex; gap: 8px; margin-bottom: 12px; }
.chips a { padding: 6px 14px; border-radius: 99px; background: #fff; color: var(--muted); border: 1px solid var(--line); }
.chips a.on { background: var(--pri); color: #fff; border-color: var(--pri); }
.check { display: flex; align-items: center; gap: 6px; } .check input { width: auto; }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.stat { background: #fff; border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; }
.stat small { color: var(--muted); } .stat b { font-size: 20px; } .stat span { font-size: 12px; color: var(--muted); }
.stat.warn { background: var(--warn); }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }

.row-line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--text); }
.row-line:last-child { border-bottom: 0; }
.row-line.link:active { background: var(--bg); }
.row-line.cancelled { opacity: .5; text-decoration: line-through; }

/* lists */
.list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.item-card { background: #fff; border-radius: var(--r); padding: 12px; display: flex; gap: 10px; align-items: center; }
.item-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--text); }
.item-card .right .btn { margin-top: 4px; }
.prices { display: flex; gap: 8px; flex-wrap: wrap; font-size: 13px; margin-top: 2px; }
.prices span { background: var(--bg); padding: 1px 7px; border-radius: 6px; }

/* dialogs as bottom sheets on mobile */
dialog.sheet { border: 0; border-radius: 18px; padding: 18px; width: min(560px, 96vw); max-height: 92vh; overflow: auto; }
dialog::backdrop { background: rgba(15,23,42,.45); }
@media (max-width: 600px) { dialog.sheet { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 18px 18px 0 0; } }

/* switch */
.switch { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.switch input { display: none; }
.switch span { width: 44px; height: 26px; border-radius: 99px; background: #cbd5e1; position: relative; flex: none; transition: .2s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + span { background: var(--pri); }
.switch input:checked + span::after { left: 21px; }

/* login */
.center-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(380px, 100%); }
.login-logo { font-size: 44px; text-align: center; }
.login-card h2 { text-align: center; }
.err { color: var(--red); } .ok { color: var(--green); }

/* ===== billing (POS) ===== */
.seg { display: flex; background: #e2e8f0; border-radius: 12px; padding: 3px; margin-bottom: 10px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px 6px; border-radius: 9px; color: var(--muted); font-weight: 600; cursor: pointer; }
.seg button.on { background: #fff; color: var(--pri); box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.seg.small button { padding: 6px; font-size: 13px; }
.ac { position: relative; }
.ac-list { display: none; position: absolute; left: 0; right: 0; top: 100%; z-index: 25; background: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.15); max-height: 50vh; overflow: auto; }
.ac-list div { padding: 10px 12px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; cursor: pointer; }
.ac-list div span { font-size: 12px; color: var(--muted); }
.ac-list div:active, .ac-list div:hover { background: var(--pri-l); }
.sticky-search { position: sticky; top: 52px; z-index: 15; margin-bottom: 10px; }
.sticky-search input { padding: 13px 14px; font-size: 16px; border: 2px solid var(--pri); box-shadow: 0 2px 8px rgba(15,118,110,.12); }
#custInfo { margin-top: 6px; } #newCust { margin-top: 8px; }

.cart { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.cart-row { background: #fff; border-radius: 12px; padding: 10px 12px; transition: background .3s; }
.cart-row.pulse { background: var(--pri-l); }
.qty { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty button { border: 0; background: var(--bg); width: 34px; height: 36px; font-size: 18px; cursor: pointer; }
.qty input { width: 58px; border: 0; border-radius: 0; text-align: center; padding: 6px 2px; }
input.mini { width: 120px; text-align: right; padding: 7px 10px; }
.summary .total { font-size: 20px; font-weight: 700; color: var(--pri-d); }

.paybar { position: fixed; left: 0; right: 0; bottom: 60px; z-index: 28; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0,0,0,.06); }
.paybar small { display: block; color: var(--muted); } .paybar b { font-size: 22px; }
.paybar .btn { padding: 13px 26px; font-size: 16px; }
.pos { padding-bottom: 80px; }

.big-due { font-size: 22px; font-weight: 700; margin: 6px 0 10px; }
details summary { cursor: pointer; }
code { background: var(--bg); padding: 2px 6px; border-radius: 6px; font-size: 12px; word-break: break-word; }

/* item sales report */
.bars { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center; font-size: 13px; }
.bar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin: 6px 0; }
.bar-row .bar { margin: 0; }
.bar i { display: block; height: 100%; background: var(--pri); border-radius: 99px; }
.mv { padding: 10px 0; border-bottom: 1px solid var(--line); }
.mv:last-child { border-bottom: 0; }
.mv-top { display: flex; align-items: center; gap: 8px; }
.mv-top .grow { flex: 1; min-width: 0; }
.mv-bot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.rank { width: 24px; height: 24px; border-radius: 50%; background: var(--pri-l); color: var(--pri-d); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 99px; }
.tag-fast { background: #dcfce7; color: #15803d; } .tag-mid { background: #e0f2fe; color: #0369a1; } .tag-slow { background: #fee2e2; color: #b91c1c; }
.row-line.head { border: 0; padding-top: 0; } .row-line.head h3 { margin: 0; }
.seg.inline { margin: 0; } .seg a { padding: 5px 12px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 13px; }
.seg a.on { background: #fff; color: var(--pri); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* ===== billing v2: phone + PC ===== */
.desk-only { display: none !important; }
.pos-grid { padding-bottom: 84px; }
.pos-row { display: flex; gap: 8px; align-items: flex-start; margin-bottom: 6px; }
.pos-row .grow { flex: 1; min-width: 0; }
.seg.compact { margin: 0; flex: none; } .seg.compact button { padding: 10px 10px; font-size: 13px; }
.newcust { margin: 6px 0 8px; } .newcust small { display: block; margin-bottom: 6px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 6px; }
.grid3 select { grid-column: 1 / -1; }
.sticky-search { margin-top: 6px; }
.empty { text-align: center; color: var(--muted); padding: 22px 10px; border: 2px dashed var(--line); border-radius: var(--r); }

.quick { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.quick::-webkit-scrollbar { display: none; }
.quick button { flex: none; display: flex; flex-direction: column; align-items: flex-start; max-width: 150px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; text-align: left; }
.quick button b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 126px; }
.quick button span { font-size: 12px; color: var(--pri); }
.quick button:active, .quick button:hover { border-color: var(--pri); background: var(--pri-l); }

.cart-row { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "name name x" "qty rate amt"; gap: 6px 8px; align-items: center; }
.cr-name { grid-area: name; display: flex; flex-direction: column; min-width: 0; }
.cart-row .qty { grid-area: qty; }
.cr-rate { grid-area: rate; display: flex; align-items: center; gap: 2px; }
.cr-rate input { width: 86px; padding: 7px 6px; text-align: right; }
.cart-row .amt { grid-area: amt; white-space: nowrap; text-align: right; }
.cart-row .x { grid-area: x; border: 0; background: none; color: var(--muted); font-size: 16px; cursor: pointer; padding: 4px 6px; }
.cart-row .x:hover { color: var(--red); }

.big-total { font-size: 32px; font-weight: 800; color: var(--pri-d); text-align: center; padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.big-total small { display: block; font-size: 11px; letter-spacing: 2px; color: var(--muted); font-weight: 600; }
.seg.inline { margin: 0; }
.paybar { bottom: 60px; }
kbd { display: inline-block; font: 600 11px ui-monospace, monospace; padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: #fff; color: var(--muted); }
.btn kbd { background: rgba(255,255,255,.2); color: #fff; border-color: rgba(255,255,255,.4); }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 12px; color: var(--muted); }
.keys b { grid-column: 1 / -1; color: var(--text); }
.ac-list div.sel { background: var(--pri-l); }
.toast { position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%) translateY(20px); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 900px) {
  .desk-only { display: revert !important; }
  .keys.desk-only { display: grid !important; }
  .cart-head.desk-only { display: grid !important; }
  .mob-only { display: none !important; }
  main.wrap:has(.pos-grid) { max-width: 1400px; }
  .pos-grid { display: grid; grid-template-columns: 1fr 360px; gap: 16px; align-items: start; padding-bottom: 0; }
  .pos-right { position: sticky; top: 64px; }
  .pos-right .btn.big { margin: 12px 0 8px; }
  .sticky-search { top: 56px; }
  .quick { flex-wrap: wrap; overflow: visible; }
  .cart { gap: 0; background: #fff; border-radius: var(--r); overflow: hidden; }
  .cart-head, .cart-row { grid-template-columns: 1fr 150px 130px 120px 36px; grid-template-areas: "name qty rate amt x"; }
  .cart-head { display: grid; gap: 8px; padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
  .cart-head span:nth-child(n+2) { text-align: right; }
  .cart-row { border-radius: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; }
  .cart-row:hover { background: #f8fafc; }
  .cart-row .qty { justify-self: end; }
  .cr-rate { justify-content: flex-end; }
  .toast { bottom: 40px; }
  /* wider lists on other pages */
  .list { display: grid; grid-template-columns: 1fr 1fr; }
}

/* search row with camera + manual buttons */
.search-row { display: flex; gap: 6px; align-items: stretch; }
.search-row .grow { flex: 1; min-width: 0; }
.btn.icon { padding: 0 12px; font-size: 18px; border-radius: 12px; border: 2px solid var(--line); }
.btn.icon span { font-size: 14px; }
dialog.cam { padding: 12px; background: #0f172a; color: #fff; }
.cam-box { position: relative; border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 4 / 3; }
.cam-box video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-line { position: absolute; left: 10%; right: 10%; top: 50%; height: 2px; background: #ef4444; box-shadow: 0 0 10px #ef4444; animation: scan 1.6s ease-in-out infinite; }
@keyframes scan { 0%, 100% { transform: translateY(-50px); } 50% { transform: translateY(50px); } }
dialog.cam p { color: #e2e8f0; margin: 10px 0; }
