:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-2: #fbf8f4;
  --ink: #2a2118;
  --ink-2: #5e5144;
  --muted: #8a7d70;
  --line: #ece4da;
  --line-2: #ddd2c4;
  --brand: #b5541c;
  --brand-600: #96440f;
  --brand-50: #fcf0e6;
  --ok: #1f7a3a;
  --ok-50: #e7f4eb;
  --warn: #9a5b00;
  --warn-50: #fdf3e0;
  --bad: #b8322a;
  --bad-50: #fdecea;
  --veg: #1f8a3b;
  --egg: #d39b00;
  --nonveg: #8a3b12;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(42, 33, 24, .05), 0 6px 20px rgba(42, 33, 24, .06);
  --shadow-lg: 0 10px 40px rgba(42, 33, 24, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html[lang="hi"] body { font-family: var(--font), "Noto Sans Devanagari", "Nirmala UI", Mangal, "Lohit Devanagari", sans-serif; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
.num, .tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 650; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.center { text-align: center; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { background: var(--surface-2); border-color: #cfc2b2; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ok:hover { filter: brightness(.95); }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-50); border-color: #f1c4bf; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: rgba(42, 33, 24, .05); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 52px; padding: 0 22px; font-size: 17px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn.icon { width: 40px; padding: 0; }
.btn.sm.icon { width: 32px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.sm svg { width: 16px; height: 16px; }

label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.input, select.input, textarea.input {
  height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface);
  font: inherit; color: var(--ink); width: 100%; min-width: 0; outline: none; transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; min-height: 70px; padding: 10px 12px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(181, 84, 28, .15); }
.input.lg { height: 48px; font-size: 17px; }
.input-icon { position: relative; }
.input-icon > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
.input-icon > .input { padding-left: 38px; }

.seg { display: inline-flex; background: #efe8df; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 14px; color: var(--ink-2); padding: 7px 14px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 500; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 22px; background: #d9cfc3; position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, .2); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(16px); }

/* ---------- Cards, badges, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.card-body { padding: 16px 18px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: #f0ebe4; color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-50); color: var(--ok); }
.badge.warn { background: var(--warn-50); color: var(--warn); }
.badge.bad { background: var(--bad-50); color: var(--bad); }
.badge.brand { background: var(--brand-50); color: var(--brand-600); }
.badge.info { background: #e8f1fc; color: #1d5fae; }
.badge svg { width: 13px; height: 13px; }

.veg-mark { display: inline-grid; place-items: center; width: 14px; height: 14px; border: 1.5px solid var(--veg); border-radius: 3px; flex: none; }
.veg-mark::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--veg); }
/* Veg: green dot. Egg: amber dot. Non-veg: brown triangle (FSSAI style). */
.veg-mark { background: #fff; }
.veg-mark.egg { border-color: var(--egg); }
.veg-mark.egg::after { background: var(--egg); }
.veg-mark.nonveg { border-color: var(--nonveg); }
.veg-mark.nonveg::after { border-radius: 0; width: 0; height: 0; background: none; border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid var(--nonveg); }
.food-seg button { gap: 6px; }
.thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; background: #f3ece4; flex: none; display: block; }
.thumb.sm { width: 28px; height: 28px; border-radius: 6px; }

table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fdfbf8; }
.table .r { text-align: right; }
.table-wrap { overflow: auto; border-radius: var(--radius); }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Admin shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: #2a2118; color: #e9e1d6; padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brandmark { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brandmark .logo { width: 38px; height: 38px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; font-size: 20px; }
.brandmark .name { font-weight: 700; font-size: 15px; color: #fff; line-height: 1.15; }
.brandmark .sub { font-size: 12px; color: #b6a898; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: #d8cdbf; font-weight: 550; font-size: 14.5px; text-decoration: none; }
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav a.on { background: rgba(255, 255, 255, .1); color: #fff; }
.nav a svg { width: 19px; height: 19px; flex: none; opacity: .9; }
.nav a .count { margin-left: auto; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; min-width: 22px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-foot button { background: none; border: 0; color: #b6a898; font: inherit; font-size: 13.5px; display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 8px; cursor: pointer; text-align: left; }
.side-foot button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-foot svg { width: 17px; height: 17px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #6b6157; flex: none; }
.live-dot.on { background: #3ccf6e; box-shadow: 0 0 0 3px rgba(60, 207, 110, .2); }

.main { min-width: 0; padding: 24px 28px 48px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ---------- Phones & small tablets: top bar + slide-in menu ---------- */
.mtop, .scrim { display: none; }
@media (max-width: 900px) {
  .shell { display: block; }
  .mtop { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 40; background: #2a2118; color: #fff; padding: 6px 10px; height: 54px; }
  .mtop .btn { color: #fff; } .mtop .btn:hover { background: rgba(255, 255, 255, .08); }
  .mtop .mtitle { font-weight: 700; font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side { position: fixed; z-index: 70; top: 0; bottom: 0; left: 0; width: 276px; height: 100vh; height: 100dvh; transform: translateX(-104%); transition: transform .22s ease; box-shadow: var(--shadow-lg); overflow-y: auto; }
  .side.open { transform: none; }
  .scrim.open { display: block; position: fixed; inset: 0; background: rgba(20, 14, 8, .45); z-index: 65; }
  .main { padding: 14px 14px 48px; }
  .page-head { gap: 10px; margin-bottom: 14px; }
  .page-head h1 { font-size: 21px; }
  .page-head .right { margin-left: 0; }
}
@media (max-width: 700px) { .hide-sm { display: none !important; } }
@media (max-width: 600px) {
  dialog.modal, dialog.modal.wide { width: 100vw; max-width: 100vw; max-height: 92vh; max-height: 92dvh; margin: auto 0 0 0; border-radius: 18px 18px 0 0; }
  .modal-body { max-height: calc(92dvh - 136px); }
  .modal-foot { border-radius: 0; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .kpis { gap: 10px; }
  .kpi { padding: 12px 14px; }
  .kpi .value { font-size: 22px; }
  .kpi .value.hero { font-size: 32px; }
  .card-head, .card-body { padding-left: 14px; padding-right: 14px; }
  .toasts { bottom: 86px; }
  .table td, .table th { padding: 9px 10px; }
}

/* ---------- Dialogs & toasts ---------- */
dialog.modal { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: var(--shadow-lg); color: var(--ink); background: var(--surface); }
dialog.modal.wide { width: min(760px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(30, 22, 15, .45); backdrop-filter: blur(2px); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px; overflow: auto; max-height: calc(100vh - 190px); }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 16px 16px; }

.toasts { position: fixed; z-index: 1000; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #2a2118; color: #fff; padding: 11px 16px; border-radius: 10px; font-size: 14px; font-weight: 550; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: toast-in .2s ease-out; pointer-events: auto; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast a { color: #fff; text-decoration: underline; }
/* Inside an open form, messages sit at the top and never block taps on the form's buttons. */
dialog .toasts { top: 16px; bottom: auto; }
dialog .toast { pointer-events: none; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Camera scanner ---------- */
.scanner-view { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; }
.scanner-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scanner-frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.scanner-frame::before { content: ""; width: 74%; aspect-ratio: 1.6; border-radius: 16px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .35); border: 3px solid rgba(255, 255, 255, .9); }
.scanner-frame.hit::before { border-color: #3ccf6e; }
.scan-note { margin-top: 10px; padding: 10px 12px; border-radius: 10px; background: var(--ok-50); border: 1px solid #b9e0c6; font-size: 14px; line-height: 1.35; }
.scan-note.warn { background: var(--bad-50); border-color: #f1c4bf; }
.scan-note.bump { animation: notebump .5s ease-out; }
@keyframes notebump { 0% { transform: scale(.97); background: #c9ecd5; } 100% { transform: none; } }
.scanner-msg { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px; color: #fff; text-align: center; font-size: 13px; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); }

/* ---------- KPI & chart ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 16px 18px; }
.kpi .label { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .value.hero { font-size: 48px; line-height: 1.05; }
.kpi .delta { font-size: 13px; margin-top: 4px; color: var(--muted); }
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.up { color: var(--ok); font-weight: 650; } .down { color: var(--bad); font-weight: 650; }
.chart-tip { position: fixed; z-index: 50; pointer-events: none; background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; box-shadow: var(--shadow-lg); font-size: 13px; min-width: 170px; }
.chart-tip .t { font-weight: 650; margin-bottom: 6px; color: var(--ink); }
.chart-tip .r { display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.chart-tip .r b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Qty stepper ---------- */
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 32px; height: 32px; border: 0; background: transparent; font-size: 18px; font-weight: 600; color: var(--brand); cursor: pointer; display: grid; place-items: center; }
.stepper button:hover { background: var(--brand-50); }
.stepper span { min-width: 28px; text-align: center; font-weight: 650; font-variant-numeric: tabular-nums; }

.kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; font-size: 11.5px; font-family: ui-monospace, monospace; color: var(--ink-2); background: var(--surface); }

/* ---------- Receipt (screen preview) ---------- */
.receipt-paper { background: #fff; width: 300px; margin: 0 auto; padding: 16px 14px; box-shadow: 0 1px 4px rgba(0, 0, 0, .12); font-family: ui-monospace, "Courier New", monospace; font-size: 12px; color: #000; }

/* Notices: trial ended on the login screen, trial days left in the app */
.notice { padding: 10px 12px; border-radius: 10px; font-size: 14px; line-height: 1.4; background: var(--warn-50); color: var(--warn); }
.notice.bad { background: var(--bad-50); color: var(--bad); }
.trial-bar { margin: 0 0 14px; }
.locked .card-body { opacity: .5; pointer-events: none; }
