/* Pathlume Peedika — counter app. Layout: phone = one column with sticky pay button;
   tablet / PC (≥ 820px) = items on the left, bill on the right. */
:root {
  --bg: #F4F6F1; --surface: #FFFFFF; --sunk: #EBF0E8; --ink: #15231B; --muted: #5C6A61; --line: #D9E1D6;
  --leaf: #1F6B45; --leaf-ink: #FFFFFF; --leaf-soft: #E1EFE6; --turmeric: #E0A00A; --turmeric-soft: #FBF0D2;
  --due: #B23A1E; --due-soft: #F9E5DF; --okc: #1F6B45;
  --f-display: "Noto Sans Malayalam", "Noto Sans", system-ui, sans-serif;
  --f-body: "Noto Sans Malayalam", "Noto Sans", system-ui, sans-serif;
  --f-num: "Noto Sans", system-ui, sans-serif;
  --r: 12px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1611; --surface: #16211A; --sunk: #1B2920; --ink: #E4EDE6; --muted: #98A89E; --line: #2A3A30;
  --leaf: #5BC38B; --leaf-ink: #0B1A11; --leaf-soft: #1B3326; --turmeric: #F0B536; --turmeric-soft: #36290F;
  --due: #F08A70; --due-soft: #3A1E18; --okc: #5BC38B; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0E1611; --surface: #16211A; --sunk: #1B2920; --ink: #E4EDE6; --muted: #98A89E; --line: #2A3A30;
  --leaf: #5BC38B; --leaf-ink: #0B1A11; --leaf-soft: #1B3326; --turmeric: #F0B536; --turmeric-soft: #36290F;
  --due: #F08A70; --due-soft: #3A1E18; --okc: #5BC38B; color-scheme: dark }

* { box-sizing: border-box }
html, body { margin: 0 }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px)) }
.wrap { max-width: 1180px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)) }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; margin: 0; text-wrap: balance }
h2 { font-size: 24px; margin: 16px 0 10px }
h3 { font-size: 18px; margin: 18px 0 8px }
h3 small { font-family: var(--f-body); font-size: 13px; color: var(--muted); font-weight: 400 }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; min-height: 44px }
input:disabled, select:disabled, textarea:disabled { background: var(--sunk); color: var(--muted) }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted) }
label > input, label > select, label > textarea { color: var(--ink); font-size: 15px }
button, .btn { font: inherit; cursor: pointer; border: none; border-radius: var(--r) }
:focus-visible { outline: 3px solid var(--turmeric); outline-offset: 2px }
a { color: var(--leaf) }

.btn { background: var(--leaf); color: var(--leaf-ink); font-weight: 600; padding: 12px 16px; min-height: 48px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; text-decoration: none; gap: 2px }
.btn small { font-weight: 400; font-size: 12px; opacity: .85 }
.btn.alt { background: var(--leaf-soft); color: var(--leaf) }
.btn.small { min-height: 38px; padding: 7px 12px; font-size: 14px }
.btn.danger { background: var(--due); color: #fff }
.btn.alt.danger { background: var(--due-soft); color: var(--due) }
.btn:disabled { opacity: .45; cursor: not-allowed }
.link { background: none; color: var(--leaf); text-decoration: underline; padding: 8px; font-size: 14px }
.iconbtn { width: 42px; height: 42px; display: grid; place-items: center; background: transparent; color: var(--ink); border-radius: 50% }
.iconbtn svg, .tabs svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round }
.iconbtn.solid { background: var(--leaf); color: var(--leaf-ink); border-radius: 10px; width: 48px; height: 48px; flex: none }
.filebtn { position: relative; overflow: hidden }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer }
.stack { display: flex; flex-direction: column; gap: 10px }
.row-wrap { flex-direction: row; flex-wrap: wrap }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px }
.fine { font-size: 12.5px; color: var(--muted); margin: 6px 0 }
.center { text-align: center }
.err { color: var(--due); font-size: 14px; margin: 0 }
.empty { color: var(--muted); font-size: 14px; padding: 14px 4px; margin: 0 }
.note { background: var(--turmeric-soft); border-radius: 10px; padding: 8px 12px; font-size: 13.5px; margin: 0 }
.due { color: var(--due) } .okc { color: var(--okc) } .muted { color: var(--muted) }
.strike { text-decoration: line-through; color: var(--muted) }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 12px }
.check { flex-direction: row; align-items: center; gap: 10px; color: var(--ink); font-size: 15px }
.check input { width: 22px; min-height: 22px; height: 22px }

/* header */
header.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 8; background: var(--bg); border-bottom: 1px solid var(--line) }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg) }
.top-in { display: flex; align-items: center; gap: 6px; padding-block: 8px }
.brand { flex: 1; min-width: 0; display: flex; flex-direction: column }
.brand b { font-family: var(--f-display); font-size: 21px; line-height: 1.1; color: var(--leaf); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.brand span { font-size: 12px; color: var(--muted) }
.syncchip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; white-space: nowrap }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted) }
.dot.ok { background: var(--okc) } .dot.wait { background: var(--turmeric) } .dot.bad { background: var(--due) } .dot.local { background: var(--line) }
@media (max-width: 420px) { .syncchip { font-size: 0; padding: 8px } .syncchip .dot { width: 10px; height: 10px } }

/* bottom tabs */
nav.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 4px max(6px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px)) }
nav.tabs button { background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 2px; font-size: 12.5px; min-height: 54px }
nav.tabs button[aria-current="page"] { color: var(--leaf); font-weight: 600 }
nav.tabs button[aria-current="page"] svg { stroke-width: 2.4 }

/* billing */
.bill { display: flex; flex-direction: column; gap: 12px; padding-top: 12px }
.searchrow { display: flex; gap: 8px }
.searchrow input { font-size: 16px; min-height: 48px }
.cats { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none }
.cat { background: var(--surface); border: 1px solid var(--line); color: var(--ink); border-radius: 999px; padding: 6px 12px; white-space: nowrap; font-size: 14px; min-height: 36px }
.cat[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink) }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin-top: 6px }
.tile { position: relative; background: var(--surface); border: 1px solid var(--line); color: var(--ink); text-align: left; padding: 9px 10px; min-height: 84px; display: flex; flex-direction: column; gap: 1px; border-radius: 12px }
.tile b { font-size: 15px; line-height: 1.25; font-weight: 600 }
.tile small { font-size: 11px; color: var(--muted); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.tile span { margin-top: auto; font-size: 13px; color: var(--leaf); font-weight: 600 }
.tile em { position: absolute; top: 6px; right: 6px; font-style: normal; font-size: 10.5px; background: var(--due-soft); color: var(--due); border-radius: 999px; padding: 0 6px }
.tile em.low { background: var(--turmeric-soft); color: var(--ink) }
.tile.out { opacity: .55 }
.pane-cart { display: flex; flex-direction: column; gap: 10px }
.cart { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden }
.cline { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: none; color: var(--ink); text-align: left; border-top: 1px solid var(--line); border-radius: 0; min-height: 52px }
.cline:first-child { border-top: none }
.cn { flex: 1; min-width: 0; display: flex; flex-direction: column }
.cn b { font-weight: 600 } .cn small { color: var(--muted); font-size: 12.5px }
.cv { font-weight: 600 }
.billmeta { display: flex; gap: 6px; flex-wrap: wrap }
.chipbtn { background: var(--sunk); color: var(--ink); border-radius: 999px; padding: 7px 14px; font-size: 14px; min-height: 38px }
.chipbtn.wide { border-radius: 12px; min-height: 48px; text-align: left; padding: 10px 14px }
.totals div { display: flex; justify-content: space-between; font-size: 14px }
.btn.pay { flex-direction: row; justify-content: space-between; font-size: 17px; min-height: 58px; padding: 10px 18px; position: sticky; bottom: calc(66px + env(safe-area-inset-bottom, 0px)); z-index: 4; box-shadow: 0 6px 18px rgb(0 0 0 / .18) }
.btn.pay b { font-size: 24px }
@media (min-width: 820px) {
  .bill { display: grid; grid-template-columns: minmax(0, 1fr) 380px; align-items: start; gap: 18px }
  .pane-cart { position: sticky; top: 76px; max-height: calc(100vh - 160px); overflow: auto; padding-bottom: 8px }
  .grid { grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)) }
  .btn.pay { position: static; box-shadow: none }
}

/* lists */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px }
.filters > * { flex: 1 1 140px; width: auto }
.filters .btn { flex: 0 0 auto }
.sum { margin: 4px 0 10px; color: var(--muted); font-size: 14px }
.sum b { color: var(--ink) }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 12px }
.row { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-top: 1px solid var(--line); background: none; color: var(--ink); text-align: left; border-radius: 0; min-height: 52px }
.list > .row:first-child, .list > .empty:first-child { border-top: none }
.row .main { flex: 1; min-width: 0; display: flex; flex-direction: column }
.row .main b { font-weight: 600 } .row .main small { color: var(--muted); font-size: 12.5px }
.as-btn { background: none; border: none; color: inherit; text-align: left; padding: 0; font: inherit; cursor: pointer }
.amt { text-align: right; font-weight: 600; white-space: nowrap }
.amt small { font-weight: 400; color: var(--muted) }
.row.tot { background: var(--sunk) }
.pill { font-size: 11px; font-weight: 600; border-radius: 999px; padding: 2px 8px; white-space: nowrap; font-family: var(--f-body) }
.pill.bad { background: var(--due-soft); color: var(--due) } .pill.warn { background: var(--turmeric-soft); color: var(--ink) } .pill.ok { background: var(--leaf-soft); color: var(--leaf) }
.numin { width: 120px; text-align: right; font-family: var(--f-num) }
.hero { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; background: var(--leaf-soft); border-radius: 14px; padding: 12px 14px; margin-bottom: 10px }
.hero b { font-size: 26px; color: var(--leaf) } .hero b.due { color: var(--due) }
.hero.ok { background: var(--leaf); color: var(--leaf-ink) } .hero.ok b { color: var(--leaf-ink); font-size: 20px }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column }
.stat span { font-size: 12.5px; color: var(--muted) } .stat b { font-size: 20px } .stat small { font-size: 12px; color: var(--muted) }
.stat.big { grid-column: 1 / -1; background: var(--leaf-soft); border-color: transparent } .stat.big b { font-size: 30px; color: var(--leaf) }
@media (min-width: 820px) { .grid2:has(.stat) { grid-template-columns: repeat(4, 1fr) } }
.tablewrap { overflow-x: auto; margin-bottom: 6px }
table.t { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; font-size: 14px }
table.t th, table.t td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line) }
table.t th:first-child, table.t td:first-child { text-align: left }
table.t th { font-size: 12px; color: var(--muted); font-weight: 600 }
table.t tr.tot td { font-weight: 700; background: var(--sunk) }

/* sheets */
.sheet { position: fixed; inset: 0; z-index: 20; background: rgb(0 0 0 / .45); display: flex; align-items: flex-end; justify-content: center }
.sh { position: relative; width: 100%; max-width: 560px; margin: 0; border-radius: 20px 20px 0 0; max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) calc(18px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)) }
.sh h3 { margin: 0; padding-right: 44px }
.shx { position: absolute; top: 8px; right: 8px }
@media (min-width: 820px) { .sheet { align-items: center } .sh { border-radius: 20px } }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px }
.seg button { background: var(--surface); border: 1px solid var(--line); color: var(--ink); padding: 10px 4px; min-height: 46px; font-weight: 600 }
.seg button[aria-pressed="true"] { background: var(--leaf); color: var(--leaf-ink); border-color: var(--leaf) }
.upiamt { text-align: center; font-size: 34px; font-weight: 700; color: var(--leaf); margin: 0 }
.qrbox { align-self: center; background: #fff; padding: 10px; border-radius: 14px; border: 1px solid var(--line); width: 220px; max-width: 100% }
.qrbox svg { display: block; width: 100%; height: auto }
.qtyrow { display: flex; gap: 8px }
.qtyrow input { text-align: center; font-size: 20px; font-family: var(--f-num) }
.qb { width: 52px; flex: none; background: var(--leaf-soft); color: var(--leaf); font-size: 24px; font-weight: 600 }
fieldset.pick { border: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px }
fieldset.pick legend { font-size: 13px; color: var(--muted); padding: 0; margin-bottom: 4px }
.opt { flex-direction: row; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); font-size: 15px; cursor: pointer }
.opt input { width: 20px; min-height: 20px; height: 20px; margin-top: 2px; flex: none }
.opt span { display: flex; flex-direction: column } .opt small { color: var(--muted); font-size: 12.5px }
.opt:has(input:checked) { border-color: var(--leaf); background: var(--leaf-soft) }
.warnbox { background: var(--due-soft); border-color: transparent }
#scanV { width: 100%; border-radius: 12px; background: #000; aspect-ratio: 4/3; object-fit: cover; max-width: 100% }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(140px + env(safe-area-inset-bottom, 0px)); z-index: 30; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: 90vw; text-align: center }
.toast.bad { background: var(--due); color: #fff }

/* setup */
.setup { max-width: 440px; padding-block: 8vh 24px; display: flex; flex-direction: column; gap: 12px }
.logo-k { width: 72px; height: 72px; border-radius: 18px; display: block }
.grid > .empty { grid-column: 1 / -1 }
.setup h1 { font-size: 34px; color: var(--leaf) }
.lede { margin: 0; color: var(--muted) }
.shopname { font-family: var(--f-display); font-size: 22px; margin: 0 }
details summary { cursor: pointer; color: var(--muted); font-size: 13px }

/* receipt (screen preview + print) */
.rcwrap { background: #fff; color: #000; border-radius: 8px; padding: 10px; border: 1px dashed var(--line); align-self: center; width: 100%; max-width: 320px }
.rc { font: 12px/1.35 "Noto Sans Malayalam", "Noto Sans", sans-serif; color: #000 }
.rc .r { display: flex; justify-content: space-between; gap: 8px }
.rc .r.big { font-size: 15px; font-weight: 700; margin-top: 2px }
.rc-h { text-align: center } .rc-h b { font-size: 15px }
.rc-t { text-align: center; font-weight: 700; margin: 4px 0; letter-spacing: .05em }
.rc-line { border-top: 1px dashed #000; margin: 4px 0 }
.rc-i small { color: #333 }
.rc-tax { width: 100%; font-size: 11px; border-collapse: collapse } .rc-tax th, .rc-tax td { text-align: right; padding: 1px 2px } .rc-tax th:first-child, .rc-tax td:first-child { text-align: left }
.rc-legend { text-align: center; font-size: 11px; margin-top: 4px; font-style: italic }
.rc-f { text-align: center; font-weight: 700; margin-top: 6px } .rc-p { text-align: center; font-size: 10px; color: #444 }
.rc-x { text-align: center; font-weight: 700; border: 2px solid #000; margin-bottom: 4px }
#printArea { display: none }
@media print {
  @page { margin: 0 }
  body { background: #fff; padding: 0 }
  body > *:not(#printArea) { display: none !important }
  body::before { display: none }
  #printArea { display: block; padding: 2mm }
  #printArea.paper58 { width: 48mm } #printArea.paper80 { width: 72mm; } #printArea.paper80 .rc { font-size: 13px }
}
@media (prefers-reduced-motion: no-preference) { .tile, .btn, .cat, .chipbtn { transition: transform .08s } .tile:active, .btn:active, .cat:active { transform: scale(.97) } }
