:root {
  --bg: #f1f8fa; --panel: #ffffff; --ink: #0e3440; --muted: #557883; --line: #d6e8ec;
  --brand: #06869a; --brand-dark: #075f6e; --brand-ink: #ffffff; --brand-soft: #def3f6; --accent: #5fd3e0;
  --danger: #c0392b; --danger-soft: #fbe9e7; --ok: #1e8e4f; --ok-soft: #e4f5ea; --warn-soft: #fff4dc;
  --radius: 10px; --shadow: 0 1px 2px rgba(6,60,74,.06), 0 2px 8px rgba(6,60,74,.05);
  --font: "Segoe UI", system-ui, -apple-system, "Noto Sans Kannada", "Nirmala UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { font-size: 20px; margin: 0 0 14px; } h2 { font-size: 16px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .mono { font-family: ui-monospace, Consolas, monospace; }
.hidden { display: none !important; }

/* layout */
#app { display: flex; min-height: 100vh; }
#nav { width: 228px; background: #0a3d4c; color: #d4eef2; flex-shrink: 0; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
#nav .brand { padding: 16px 16px 10px; font-weight: 700; font-size: 16px; color: #fff; display: flex; gap: 8px; align-items: center; }
#nav .brand small { display: block; font-weight: 400; font-size: 11px; color: #9cd0da; }
#nav a { display: flex; align-items: center; gap: 10px; padding: 8px 16px; color: inherit; text-decoration: none; font-size: 13.5px; }
#nav a:hover { background: rgba(255,255,255,.06); }
#nav a.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
#nav .sec { padding: 12px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #7fbac6; }
#nav .ico { width: 18px; text-align: center; opacity: .9; }
#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#top { height: 52px; display: flex; align-items: center; gap: 10px; padding: 0 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
#top .title { font-weight: 600; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#menuBtn { display: none; }
#page { padding: 18px; max-width: 1400px; width: 100%; }
#offlineBar { background: var(--warn-soft); color: #7a5300; padding: 6px 16px; font-size: 13px; }

/* components */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }
.stat .k { font-size: 12px; color: var(--muted); } .stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff;
  padding: 7px 12px; border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--ink); white-space: nowrap; min-height: 34px; }
.btn:hover { border-color: #c8d1cd; background: #fafcfb; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: #efc3bd; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 3px 8px; min-height: 28px; font-size: 12.5px; }
.btn.lg { padding: 11px 18px; font-size: 15px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); min-width: 0; }
label.f > span { font-weight: 500; }
input, select, textarea { border: 1px solid #cfd8d4; border-radius: 8px; padding: 7px 9px; background: #fff; min-height: 34px; width: 100%; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(6,134,154,.28); border-color: var(--brand); }
input[type=checkbox] { width: auto; min-height: 0; }
textarea { min-height: 70px; resize: vertical; }
.chk { display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tbl th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfa; position: sticky; top: 0; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover td { background: #f6faf8; }
.tbl td.num, .tbl th.num { text-align: right; white-space: nowrap; }
.tblwrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 11.5px; background: #eef1f0; color: #45504c; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); } .pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--warn-soft); color: #8a5a00; } .pill.brand { background: var(--brand-soft); color: var(--brand); }
.pos { color: var(--ok); } .neg { color: var(--danger); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; margin-bottom: 12px; }
.toolbar > label.f { min-width: 140px; }

/* modal & toast */
#modalRoot .back { position: fixed; inset: 0; background: rgba(15,25,22,.45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; }
#modalRoot .modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
#modalRoot .modal.wide { max-width: 920px; }
#modalRoot .mh { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; }
#modalRoot .mb { padding: 16px; }
#modalRoot .mf { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
#toasts { position: fixed; right: 14px; bottom: 14px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast { background: #1d2a26; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); font-size: 13.5px; }
.toast.err { background: var(--danger); } .toast.ok { background: var(--ok); }

/* billing */
.pos-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 14px; align-items: start; }
.cart td input { min-height: 30px; padding: 4px 6px; }
.cart td .qty { width: 70px; } .cart td .rate { width: 90px; }
.totals .line { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-size: 24px; font-weight: 800; color: var(--brand); border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 8px; }
.paymodes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.paymodes button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.suggest { position: absolute; z-index: 30; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto; width: 100%; margin-top: 2px; }
.suggest div { padding: 7px 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggest div:hover, .suggest div.sel { background: var(--brand-soft); }
.rel { position: relative; }

/* items */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.item-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.item-card:hover { border-color: var(--brand); }
.item-card .ph { aspect-ratio: 4/3; background: #eef2f0 center/cover no-repeat; display: flex; align-items: center; justify-content: center; color: #a5b3ad; font-size: 34px; }
.item-card .bd { padding: 8px 10px; font-size: 13px; }
.item-card .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos .p { width: 92px; height: 92px; border-radius: 8px; background: #eee center/cover; position: relative; border: 1px solid var(--line); }
.photos .p button { position: absolute; top: 2px; right: 2px; padding: 0 6px; min-height: 22px; }
.side-tree { min-width: 190px; }
.side-tree a { display: block; padding: 4px 8px; border-radius: 6px; text-decoration: none; color: var(--ink); font-size: 13px; }
.side-tree a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips .pill { cursor: pointer; } .chips .pill.on { background: var(--brand); color: #fff; }
.attrs .row input { flex: 1; }

/* qr / soundbox */
.qrbox { text-align: center; }
.qrbox img { width: min(280px, 70vw); height: auto; border: 8px solid #fff; border-radius: 10px; box-shadow: var(--shadow); }
.qrbox .amt { font-size: 30px; font-weight: 800; margin: 8px 0 2px; }
#soundbox { position: fixed; inset: 0; background: #0a3d4c; color: #fff; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
#soundbox .big { font-size: 64px; font-weight: 800; }
#soundbox .feed { margin-top: 20px; max-height: 40vh; overflow-y: auto; width: min(520px, 100%); }
#soundbox .feed div { padding: 8px; border-bottom: 1px solid rgba(255,255,255,.12); display: flex; justify-content: space-between; }
.flash { animation: flash 1.2s ease; }
@keyframes flash { 0% { background: #2bd17e; } 100% { background: #0a3d4c; } }

/* scanner */
#scanVideo { width: 100%; max-height: 60vh; background: #000; border-radius: 8px; }

/* labels */
.label-preview { display: flex; flex-wrap: wrap; gap: 6px; background: #e9edeb; padding: 10px; border-radius: 8px; }
.lbl { background: #fff; border: 1px dashed #b9c4bf; display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; text-align: center; padding: 1mm; line-height: 1.1; }
.lbl img { max-width: 100%; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; background: linear-gradient(160deg, #0a3d4c, #0b7f93); }
.login-wrap .card { width: 100%; max-width: 420px; }

@media (max-width: 900px) {
  #nav { position: fixed; left: -240px; z-index: 40; transition: left .2s; }
  #nav.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  #menuBtn { display: inline-flex; }
  .pos-layout, .g2, .g3 { grid-template-columns: minmax(0,1fr); }
  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  #page { padding: 12px; }
  .side-tree { display: none; }
  .hide-sm { display: none; }
}
@media print { #nav, #top, .noprint { display: none !important; } #page { padding: 0; } }

/* quick-pick grid on the bill screen */
.qp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; max-height: 46vh; overflow-y: auto; }
.qp { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; cursor: pointer; min-height: 56px; }
.qp:hover { border-color: var(--brand); background: var(--brand-soft); }
.qp:active { transform: scale(.97); }
.qp .qn { font-size: 13px; line-height: 1.25; }
.qp .qv { font-weight: 700; color: var(--brand); font-size: 13px; }
@media (max-width: 900px) { .qp-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: none; } }

/* turquoise text accents */
h1, h2 { color: var(--brand-dark); }
h3 { color: var(--ink); }
#top .title { color: var(--brand-dark); }
.tbl th { color: var(--brand-dark); background: #f3fafb; }
.stat .k { color: var(--muted); } .stat .v { color: var(--ink); }
label.f > span { color: var(--brand-dark); }
.tabs button.on, .side-tree a.on { color: var(--brand-dark); }
.item-card .nm, .qp .qn { color: var(--ink); }
.btn { color: var(--ink); border-color: #cfe3e8; }
.btn:hover { border-color: #9fd0da; background: #f3fafb; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; filter: none; }
.btn.danger:hover { background: #fdecec; }
.btn.primary { color: #fff; }
.btn.danger { color: var(--danger); }
input, select, textarea { border-color: #c7dde3; color: var(--ink); }
.pill { background: #e8f3f5; color: #3d6470; }
.tbl tr.click:hover td { background: #eef8fa; }
::selection { background: #bfeaf1; }
/* purchase bill scanning */
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--brand-soft); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.scan-card { background: linear-gradient(135deg, #e3f6f9, #f7fcfd); border-color: #bfe4ea; }
.scan-card label.btn { cursor: pointer; }
.scan-line { padding: 10px 12px; border-left: 4px solid var(--brand); }
.scan-line.off { opacity: .5; border-left-color: var(--line); }
.scan-line .f input, .scan-line .f select { min-width: 0; }
@media (max-width: 600px) { .scan-card .row.between > .row { width: 100%; } .scan-card label.btn { flex: 1; justify-content: center; } }
