/* Jhumka Everyday — shop tool styles. Mobile first, day/night themes, print layouts. */
:root {
  --bg: #f7f3ee; --surface: #ffffff; --surface-2: #f2ece4; --border: #e4dacd;
  --text: #231a1d; --muted: #6f6266; --primary: #7a1838; --primary-ink: #ffffff; --primary-soft: #f6e3ea;
  --gold: #b48a1f; --ok: #157347; --ok-soft: #e1f3e9; --warn: #a15c00; --warn-soft: #fdf0d8; --bad: #b42318; --bad-soft: #fde7e5;
  --radius: 14px; --shadow: 0 1px 2px rgba(35, 26, 29, .06), 0 4px 16px rgba(35, 26, 29, .06);
  --topbar-h: 56px; --bottomnav-h: 64px; --focus: 0 0 0 3px rgba(122, 24, 56, .35);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #141114; --surface: #1e1a1e; --surface-2: #272227; --border: #3a3239;
  --text: #f1eaec; --muted: #b0a3a8; --primary: #e3789d; --primary-ink: #1a0b11; --primary-soft: #3a1e29;
  --gold: #e0b84f; --ok: #5fd49a; --ok-soft: #173326; --warn: #f2b35a; --warn-soft: #3a2a12; --bad: #ff8a80; --bad-soft: #3d1b19;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3); --focus: 0 0 0 3px rgba(227, 120, 157, .45);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif; -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.hidden, [hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: calc(var(--topbar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; min-width: 0; }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 800; flex: none; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.shell { display: flex; }
.sidenav { display: none; }
.main { flex: 1; min-width: 0; padding: 16px 16px calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1200px; margin: 0 auto; }
.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a, .bottomnav button { height: var(--bottomnav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .72rem; background: none; border: 0; font-family: inherit; cursor: pointer; }
.bottomnav a:active, .bottomnav button:active { color: var(--primary); }
.more-sheet { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .45); display: flex; align-items: flex-end; }
.more-panel { width: 100%; background: var(--surface); border-radius: 18px 18px 0 0; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.more-panel a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 6px; border-radius: 12px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: .8rem; text-align: center; }
@media (min-width: 900px) {
  .sidenav { display: flex; flex-direction: column; gap: 2px; width: 232px; flex: none; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); padding: 12px; border-right: 1px solid var(--border); background: var(--surface); overflow-y: auto; }
  .sidenav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--text); text-decoration: none; font-weight: 500; }
  .sidenav a:hover { background: var(--surface-2); }
  .sidenav a.active { background: var(--primary-soft); color: var(--primary); }
  .sidenav-foot { margin-top: auto; padding: 12px; }
  .bottomnav, .more-sheet { display: none !important; }
  .main { padding: 24px 28px 40px; }
}

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.narrow { max-width: 420px; margin-left: auto; margin-right: auto; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } .grid-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.stat .label { color: var(--muted); font-size: .8rem; }
.stat .value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat .sub { color: var(--muted); font-size: .78rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px; border-radius: 11px; border: 1px solid transparent; background: var(--primary); color: var(--primary-ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; touch-action: manipulation; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ok { background: var(--ok); color: #fff; } :root[data-theme="dark"] .btn-ok { color: #0b2016; }
.btn-danger { background: var(--bad); color: #fff; } :root[data-theme="dark"] .btn-danger { color: #2a0d0b; }
.btn-wa { background: #1f9e55; color: #fff; }
.btn-sm { min-height: 34px; padding: 6px 10px; font-size: .85rem; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-lg { min-height: 54px; font-size: 1.05rem; }
:focus-visible { outline: none; box-shadow: var(--focus); }

label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.field { margin-bottom: 12px; min-width: 0; }
.hint { color: var(--muted); font-size: .78rem; margin-top: 3px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=tel], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; /* 16px stops iOS zoom */
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.inline { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline > .field { flex: 1 1 140px; margin-bottom: 0; }

.seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; gap: 3px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: .9rem; min-height: 38px; display: flex; align-items: center; gap: 6px; }
.seg input:checked + label { background: var(--surface); color: var(--primary); box-shadow: var(--shadow); }
.seg input:focus-visible + label { box-shadow: var(--focus); }

.alert { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; border: 1px solid transparent; }
.alert-ok { background: var(--ok-soft); color: var(--ok); } .alert-error { background: var(--bad-soft); color: var(--bad); } .alert-warn { background: var(--warn-soft); color: var(--warn); }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); } .badge-warn { background: var(--warn-soft); color: var(--warn); } .badge-bad { background: var(--bad-soft); color: var(--bad); } .badge-muted { background: var(--surface-2); color: var(--muted); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tbl th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tfoot td { font-weight: 700; background: var(--surface-2); }
.tbl a.rowlink { color: inherit; text-decoration: none; font-weight: 600; }
/* stacked list on phones */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; color: var(--text); text-decoration: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex: none; display: grid; place-items: center; color: var(--muted); font-weight: 700; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 14px 0; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; margin-bottom: 14px; }
.filters .field { margin: 0; flex: 1 1 140px; }
.filters .btn { flex: none; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; scrollbar-width: none; }
.tabs a { white-space: nowrap; padding: 8px 14px; border-radius: 99px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; font-size: .88rem; }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.empty { text-align: center; padding: 32px 12px; color: var(--muted); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom)); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 99px; z-index: 60; font-weight: 600; max-width: calc(100% - 32px); text-align: center; }
@media (min-width: 900px) { .toast { bottom: 24px; } }

/* ---------- login / centered ---------- */
.center-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand img { width: 72px; height: 72px; object-fit: contain; border-radius: 16px; }
.login-brand .brand-mark { width: 64px; height: 64px; font-size: 1.8rem; margin: 0 auto 8px; border-radius: 18px; }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots span.on { background: var(--primary); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.pinpad button { height: 62px; border-radius: 16px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 1.4rem; font-weight: 600; cursor: pointer; touch-action: manipulation; }
.pinpad button:active { background: var(--primary-soft); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 18px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* ---------- POS ---------- */
.pos { display: grid; gap: 16px; }
@media (min-width: 1000px) { .pos { grid-template-columns: minmax(0, 1.4fr) minmax(340px, 1fr); align-items: start; } .pos-side { position: sticky; top: calc(var(--topbar-h) + 16px); } }
.scan-row { display: flex; gap: 8px; }
.scan-row input { flex: 1; }
.search-results { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.search-results button { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; cursor: pointer; width: 100%; }
.search-results button:hover { border-color: var(--primary); }
.search-results .grow { flex: 1; min-width: 0; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 12px 0; border-bottom: 1px dashed var(--border); }
.cart-line:last-child { border-bottom: 0; }
.cart-line .nm { font-weight: 600; overflow-wrap: anywhere; }
.cart-line .meta { font-size: .8rem; color: var(--muted); }
.cart-line .ctl { display: flex; align-items: center; gap: 8px; grid-column: 1 / -1; flex-wrap: wrap; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.qty button { width: 38px; height: 38px; border: 0; background: var(--surface-2); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.qty input { width: 48px; min-height: 38px; border: 0; border-radius: 0; text-align: center; padding: 0; }
.price-in { width: 110px !important; min-height: 38px !important; padding: 6px 8px !important; }
.line-total { font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-row { display: flex; justify-content: space-between; padding: 4px 0; font-variant-numeric: tabular-nums; }
.sum-row.total { font-size: 1.35rem; font-weight: 800; border-top: 2px solid var(--border); margin-top: 6px; padding-top: 10px; }
.sum-row.disc { color: var(--ok); }
.scanner-box { position: fixed; inset: 0; z-index: 70; background: rgba(0, 0, 0, .85); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; }
.scanner-box #qr-reader { width: 100%; max-width: 460px; background: #000; border-radius: 12px; overflow: hidden; }

/* ---------- UPI pay screen ---------- */
.pay-screen { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); background: linear-gradient(160deg, var(--primary-soft), var(--bg) 60%); }
.pay-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 24px; padding: 24px 20px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.pay-logo { width: 76px; height: 76px; object-fit: contain; border-radius: 18px; margin: 0 auto 6px; display: block; }
.pay-brand { font-size: 1.35rem; font-weight: 800; margin: 4px 0 0; }
.pay-amount { font-size: 2.4rem; font-weight: 800; color: var(--primary); margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.qr-box { background: #fff; padding: 14px; border-radius: 16px; display: inline-block; margin: 10px auto; }
.qr-box svg, .qr-box img { display: block; width: 240px; height: 240px; max-width: 70vw; max-height: 70vw; }
.pay-thanks { font-size: 1.25rem; font-weight: 700; color: var(--gold); margin: 12px 0 0; }
.upi-apps { font-size: .8rem; color: var(--muted); }

/* ---------- invoice document ---------- */
.inv-doc { background: #fff; color: #1d1d1f; max-width: 800px; margin: 0 auto; padding: 28px; border-radius: 12px; border: 1px solid var(--border); font-size: 13px; }
.inv-doc table { width: 100%; border-collapse: collapse; }
.inv-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid #7a1838; padding-bottom: 12px; margin-bottom: 12px; }
.inv-head img { max-height: 64px; max-width: 140px; object-fit: contain; }
.inv-shop h2 { margin: 4px 0; color: #7a1838; font-size: 20px; }
.inv-title { text-align: right; }
.inv-title h3 { margin: 0 0 4px; font-size: 16px; letter-spacing: .08em; color: #7a1838; }
.inv-meta { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; }
.inv-items th { background: #f6eef1; color: #5b1129; font-size: 11px; text-transform: uppercase; padding: 7px 6px; text-align: left; }
.inv-items td { padding: 7px 6px; border-bottom: 1px solid #eee; vertical-align: top; }
.inv-items .r { text-align: right; white-space: nowrap; }
.inv-totals { margin-left: auto; width: 100%; max-width: 300px; margin-top: 10px; }
.inv-totals td { padding: 4px 6px; }
.inv-totals td:last-child { text-align: right; white-space: nowrap; }
.inv-totals .grand td { font-size: 16px; font-weight: 800; border-top: 2px solid #7a1838; padding-top: 8px; }
.inv-foot { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-top: 18px; border-top: 1px dashed #ccc; padding-top: 12px; flex-wrap: wrap; }
.inv-foot .qr-box { padding: 4px; margin: 0; }
.inv-foot .qr-box svg { width: 96px; height: 96px; }
.inv-thanks { font-weight: 700; color: #7a1838; font-size: 15px; }
.inv-stamp { display: inline-block; border: 2px solid #b42318; color: #b42318; padding: 2px 10px; font-weight: 800; transform: rotate(-6deg); border-radius: 6px; }
@media (max-width: 600px) { .inv-doc { padding: 14px; font-size: 12px; } .inv-head { flex-direction: column; } .inv-title { text-align: left; } }

/* thermal receipt variant */
.inv-doc.thermal { max-width: 80mm; padding: 4mm; font-size: 11px; border-radius: 0; }
.inv-doc.thermal.w58 { max-width: 58mm; font-size: 10px; }
.inv-doc.thermal .inv-head { flex-direction: column; align-items: center; text-align: center; border-bottom: 1px dashed #000; }
.inv-doc.thermal .inv-title { text-align: center; }
.inv-doc.thermal .inv-meta { display: block; }
.inv-doc.thermal .inv-items th { background: none; color: #000; border-bottom: 1px dashed #000; padding: 3px 2px; }
.inv-doc.thermal .inv-items td { padding: 3px 2px; border-bottom: 0; }
.inv-doc.thermal .inv-items .hsn, .inv-doc.thermal .inv-items .sku { display: none; }
.inv-doc.thermal .inv-totals { max-width: none; }
.inv-doc.thermal .inv-totals .grand td { border-top: 1px dashed #000; }
.inv-doc.thermal .inv-foot { flex-direction: column; align-items: center; text-align: center; }
.inv-doc.thermal, .inv-doc.thermal * { color: #000 !important; }

/* ---------- barcode tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tag { width: var(--tw, 50mm); height: var(--th, 25mm); background: #fff; color: #000; border: 1px dashed #bbb; padding: 1mm 1.5mm; display: flex; flex-direction: column; align-items: center; justify-content: space-between; overflow: hidden; text-align: center; font-family: Arial, Helvetica, sans-serif; }
.tag .t-shop { font-size: 7pt; font-weight: 700; line-height: 1.1; text-transform: uppercase; letter-spacing: .04em; }
.tag .t-name { font-size: 6.5pt; line-height: 1.1; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tag svg { width: 100%; height: auto; flex: 1; min-height: 0; }
.tag .t-price { font-size: 10pt; font-weight: 800; line-height: 1.1; }
.tag .t-mrp { font-size: 6pt; text-decoration: line-through; font-weight: 400; margin-left: 4px; }

/* ---------- print ---------- */
@media print {
  @page { margin: 8mm; }
  body { background: #fff !important; color: #000 !important; }
  .topbar, .sidenav, .bottomnav, .more-sheet, .no-print, .toast, .alert { display: none !important; }
  .main { padding: 0 !important; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .inv-doc { border: 0; padding: 0; max-width: none; border-radius: 0; }
  body.print-thermal .inv-doc { width: 100%; }
  body.print-tags .tags { gap: 0; display: block; }
  body.print-tags .tag { border: 0; page-break-after: always; break-after: page; margin: 0; }
}
