/* Showrya Jewellers — Stock Manager */

:root {
  --maroon: #7A1F2B;
  --maroon-dark: #5C1520;
  --gold: #C9A227;
  --gold-text: #8A6414;
  --gold-soft: #F3E3B0;
  --cream: #FBF7EF;
  --sand: #F6EBD3;
  --card: #FFFFFF;
  --line: #E8DCC8;
  --ink: #2A1D18;
  --ink-2: #4A3A32;
  --muted: #6B5A50;
  --ok: #22573A;  --ok-bg: #E3F1E8;
  --warn: #7A4A00; --warn-bg: #FFF0D6; --warn-line: #EBC98A;
  --info: #2C4A8A; --info-bg: #E3E9F7;
  --note: #4A3A32; --note-bg: #F6EFE2; --note-line: #E3D6BF;
  --bad: #A3261E;  --bad-bg: #FBE4E1;
  --field-line: #8F7E70; /* input borders: 3:1 or more against every surface (WCAG 1.4.11) */
  --radius: 14px;
  --nav-h: 72px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, "Nirmala UI", "Noto Sans Telugu", sans-serif;
  --font-head: "Playfair Display", Georgia, "Times New Roman", "Nirmala UI", "Noto Sans Telugu", serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
}
:lang(te) body, html:lang(te) { line-height: 1.6; }
a { color: var(--maroon); }
img { max-width: 100%; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; }
h1 { font-family: var(--font-head); font-size: 26px; line-height: 1.2; color: var(--maroon); }
h2 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
p { margin: 0 0 8px; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: 13px; }
.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.text-bad { color: var(--bad); }
.text-brand { color: var(--maroon); }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--maroon); outline-offset: 2px; } /* 8.6–10:1 on light surfaces */
.topbar :focus-visible { outline-color: var(--gold-soft); } /* 8:1 on the maroon bar */

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
  background: var(--maroon); color: #fff;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: var(--gold); color: var(--maroon-dark);
  display: grid; place-items: center; font: 600 17px var(--font-head);
}
.brand-name { font: 600 18px var(--font-head); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.pill-btn {
  border: 1px solid rgba(243, 227, 176, .55); background: transparent; color: var(--gold-soft);
  font: 600 13px var(--font); border-radius: 999px; padding: 8px 12px; min-height: 36px; cursor: pointer;
}
.icon-btn { color: #fff; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; }
.icon-btn:hover, .pill-btn:hover { background: rgba(255, 255, 255, .1); }

/* ---------- bottom nav (top on desktop) ---------- */
.mainnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--card); border-top: 1px solid var(--line);
}
.mainnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500; padding: 8px 0;
}
.mainnav a svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.mainnav a.active { color: var(--maroon); font-weight: 600; }
.mainnav .nav-scan svg {
  width: 56px; height: 56px; padding: 16px; margin-top: -30px;
  border-radius: 50%; background: var(--maroon); color: var(--gold-soft); stroke: var(--gold-soft);
  border: 4px solid var(--cream); box-shadow: 0 2px 8px rgba(42, 29, 24, .16);
}
.mainnav .nav-scan.active svg { background: var(--gold); stroke: var(--maroon-dark); }

@media (min-width: 900px) {
  body { padding-bottom: 32px; }
  .mainnav {
    position: sticky; top: 64px; bottom: auto; height: auto; padding: 0 calc(50% - 470px);
    grid-template-columns: repeat(5, auto); justify-content: start; gap: 4px;
    border-top: 0; border-bottom: 1px solid var(--line);
  }
  .mainnav a { flex-direction: row; gap: 8px; font-size: 14px; padding: 12px 16px; border-bottom: 3px solid transparent; }
  .mainnav a.active { border-bottom-color: var(--maroon); }
  .mainnav .nav-scan svg { width: 23px; height: 23px; padding: 0; margin: 0; border: 0; box-shadow: none; background: none; stroke: currentColor; }
  .mainnav .nav-scan.active svg { background: none; stroke: currentColor; }
}

/* ---------- layout ---------- */
.view { max-width: 940px; margin: 0 auto; padding: 16px; outline: none; }
.view > * + * { margin-top: 16px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; text-decoration: none; padding: 8px 4px 8px 0; min-height: 44px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.grid2 { display: grid; gap: 12px; }
@media (min-width: 760px) { .grid2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.empty { color: var(--muted); text-align: center; padding: 16px 8px; margin: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--maroon);
  font: 600 14px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--gold); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.btn.primary:hover { background: var(--maroon-dark); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.gold-soft { background: var(--gold-soft); border-color: var(--gold-soft); color: var(--maroon-dark); }
.btn.ghost { background: transparent; color: var(--ink-2); }
.btn.link { border: 0; background: transparent; padding: 0 4px; }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.wide { width: 100%; }
.btn.danger-link { border: 0; background: transparent; color: var(--bad); }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.danger-zone { text-align: center; }

/* ---------- home ---------- */
.hero h1 { font-size: 24px; }
.hero p { color: var(--muted); margin: 2px 0 0; }
.rates-card.stale { border-color: var(--warn-line); }
.rates-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; margin-bottom: 8px; }
.rates-grid div { display: flex; flex-direction: column; }
.rates-grid b { font-size: 16px; }
.rates-card p { margin: 0; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat {
  display: flex; flex-direction: column; gap: 2px; padding: 12px 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  color: var(--ink); text-decoration: none;
}
.stat span { font-size: 13px; color: var(--muted); }
.stat b { font-size: 20px; line-height: 1.25; }
.stat small { font-size: 13px; font-weight: 500; color: var(--muted); }
.stat-warn { background: #FFF4E0; border-color: var(--warn-line); }
.stat-warn span, .stat-warn small { color: var(--warn); }
a.stat:hover { border-color: var(--gold); }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.quick-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  min-height: 74px; padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--maroon); font-weight: 600; font-size: 13px; text-decoration: none;
}
.quick-btn .ic { width: 22px; height: 22px; }
.quick-btn.primary { background: var(--maroon); border-color: var(--maroon); color: #fff; }
.activity { list-style: none; margin: 0; padding: 0; }
.activity a { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; color: var(--ink); text-decoration: none; border-top: 1px solid #F1E8D9; }
.activity li:first-child a { border-top: 0; }
.act-main { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 14px; }
.act-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-main .muted { font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 8px; flex: none; background: var(--muted); }
.dot-ok { background: #2E6B45; } .dot-warn { background: #B26A00; } .dot-info { background: #3B5BA9; } .dot-gold { background: var(--gold); }

/* ---------- alerts & toasts ---------- */
.alert { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 12px; border-radius: 12px; border: 1px solid; font-size: 14px; }
.alert > span { flex: 1 1 200px; }
.alert.ok { background: var(--ok-bg); border-color: #B9DCC5; color: var(--ok); }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); color: #5A3600; }
.alert.info { background: var(--note-bg); border-color: var(--note-line); color: var(--note); }
.alert.info .ic { color: var(--maroon); }
.alert.bad { background: var(--bad-bg); border-color: #F0B8B1; color: var(--bad); }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 14px); z-index: 50; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.2); transition: opacity .3s, transform .3s; text-align: center; }
.toast.ok { background: var(--ok); } .toast.bad { background: var(--bad); }
.toast.out { opacity: 0; transform: translateY(8px); }
@media (min-width: 900px) { .toasts { bottom: 24px; } }

/* ---------- stock list ---------- */
.search { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--field-line); border-radius: 12px; padding: 0 12px; color: var(--muted); }
.search input { border: 0; outline: 0; flex: 1; min-width: 0; height: 46px; font: 15px var(--font); background: transparent; color: var(--ink); }
.search:focus-within { border-color: var(--maroon); outline: 2px solid var(--maroon); outline-offset: 1px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  font: 500 13px var(--font); cursor: pointer; text-decoration: none;
}
.chip span { color: var(--muted); font-size: 12px; }
.chip.on { background: var(--maroon); border-color: var(--maroon); color: #fff; font-weight: 600; }
.chip.on span { color: #F3D9DC; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.list-bar { display: flex; justify-content: space-between; align-items: center; }
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
}
.item-row:hover { border-color: var(--gold); }
.thumb, .item-photo {
  position: relative; flex: none; overflow: hidden; display: grid; place-items: center;
  background: var(--sand); color: #A07A1E; border-radius: 10px;
}
.thumb { width: 54px; height: 54px; }
.thumb img, .item-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ir-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.ir-main b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ir-main .muted { font-size: 13px; }
.ir-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; font-size: 14px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; border-radius: 6px; padding: 4px 8px; white-space: nowrap; }
.st-instock { background: var(--ok-bg); color: var(--ok); }
.st-approval { background: var(--warn-bg); color: var(--warn); }
.st-repair { background: var(--info-bg); color: var(--info); }
.st-sold { background: #EEE6E0; color: var(--ink-2); }

/* ---------- item detail ---------- */
.item-top { display: grid; gap: 12px; }
.item-photo { width: 100%; height: 220px; border-radius: var(--radius); }
.item-photo .ic { width: 48px; height: 48px; stroke-width: 1.3; }
@media (min-width: 760px) { .item-top { grid-template-columns: 280px 1fr; align-items: start; } }
.item-head { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.item-head p { margin: 0; }
.item-info { font-size: 14px; color: var(--ink-2); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 8px; }
.kv div { display: flex; flex-direction: column; min-width: 0; }
.kv b { font-size: 15px; overflow-wrap: anywhere; }
.notes { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); white-space: pre-wrap; }
.bill { margin: 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.bill div { display: flex; justify-content: space-between; gap: 8px; }
.bill dt { color: var(--ink-2); } .bill dd { margin: 0; white-space: nowrap; }
.bill .total { border-top: 1px dashed var(--line); padding-top: 8px; font-size: 16px; font-weight: 600; }
.bill .total dt { color: var(--ink); } .bill .total dd { color: var(--maroon); }
.tag-preview {
  margin: 0 auto; width: 228px; height: 127px; display: flex; align-items: center; gap: 8px; padding: 12px;
  border: 1px solid var(--ink); border-radius: 6px; background: #fff; color: #000; font: 11px/1.25 Arial, sans-serif;
}
.tag-qr { width: 88px; height: 88px; flex: none; }
.tag-qr svg, .label-qr svg { width: 100%; height: 100%; display: block; }
.tag-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tag-text b { font-size: 14px; }
.history { list-style: none; margin: 0; padding: 0; }
.history li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid #F1E8D9; font-size: 14px; }
.history li:first-child { border-top: 0; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.grow { flex: 1; }
.field label, .manual label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 0 12px; border: 1px solid var(--field-line); border-radius: 10px;
  font: 15px var(--font); color: var(--ink); background: var(--card);
}
textarea { padding: 12px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--maroon); outline-offset: 1px; border-color: var(--maroon); }
input[readonly] { background: #F6F1E6; }
input.computed { background: var(--sand); color: var(--maroon); font-weight: 600; }
[aria-invalid="true"] { border-color: var(--bad) !important; box-shadow: 0 0 0 3px rgba(163, 38, 30, .18) !important; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; min-width: 0; }
.inline select { width: auto; flex: none; }
.grid-2, .grid-3 { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 420px) { .grid-2 .inline { flex-direction: column; } .grid-2 .inline select { width: 100%; } }
.photo-row { display: flex; gap: 12px; align-items: flex-start; }
.photo-pick {
  position: relative; width: 84px; height: 84px; flex: none; overflow: hidden; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  border: 1.5px dashed var(--gold); border-radius: 12px; background: var(--card); color: var(--gold-text); font-size: 12px; font-weight: 600;
}
.photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
#photoInput:focus-visible + .field, .photo-pick:focus-within { outline: 3px solid var(--maroon); }
.est { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: var(--cream); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; }
.est span { display: flex; flex-direction: column; font-size: 13px; }
.est small { font-size: 12px; }
.est b { font-size: 19px; color: var(--maroon); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
@media (max-width: 520px) { .form-actions .btn { flex: 1 1 30%; } .form-actions .btn.primary { flex-basis: 100%; order: -1; } }

/* ---------- dialog ---------- */
.modal { border: 0; border-radius: 16px; padding: 16px; width: min(94vw, 440px); background: var(--card); color: var(--ink); box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal::backdrop { background: rgba(42, 29, 24, .45); }
.modal h2 { font: 600 19px var(--font-head); color: var(--maroon); margin: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ---------- scanner ---------- */
.scan-card { display: flex; flex-direction: column; gap: 12px; }
.reader { display: none; width: 100%; max-width: 460px; margin: 0 auto; border-radius: 14px; overflow: hidden; background: #2A1F1B; }
.reader.on { display: block; min-height: 240px; }
.reader video { display: block; width: 100% !important; height: auto !important; }
.cam-msg { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.cam-msg:empty { display: none; }
.manual { display: flex; flex-direction: column; gap: 8px; }

/* ---------- stock check ---------- */
.intro p { color: var(--ink-2); }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 18px; }
.bar { height: 9px; border-radius: 999px; background: #EFE6D6; overflow: hidden; margin: 8px 0; }
.bar div { height: 100%; background: #2E6B45; border-radius: 999px; transition: width .3s; }
.progress-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; font-size: 13px; color: var(--muted); }
.progress-nums b { display: block; font-size: 17px; color: var(--ink); }
.progress-nums b.text-ok { color: var(--ok); } .progress-nums b.text-bad { color: var(--bad); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { flex: none; border: 0; background: transparent; font: 500 14px var(--font); color: var(--muted); padding: 12px 12px; min-height: 44px; border-bottom: 3px solid transparent; cursor: pointer; }
.tab.on { color: var(--maroon); font-weight: 600; border-bottom-color: var(--maroon); }
.check-list { margin-top: 0 !important; }
.check-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 2px; border-bottom: 1px solid #EFE6D6; color: var(--ink); text-decoration: none; }
.check-row > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.past { list-style: none; margin: 0; padding: 0; }
.past li { border-top: 1px solid #F1E8D9; }
.past li:first-child { border-top: 0; }
.past summary { display: flex; justify-content: space-between; gap: 8px; padding: 12px 0; cursor: pointer; font-size: 14px; }
.codes { display: flex; flex-wrap: wrap; gap: 8px 8px; font-size: 13px; }

/* ---------- reports ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 520px; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 8px; border-bottom: 1px solid var(--line); }
td { padding: 8px 8px; border-bottom: 1px solid #F1E8D9; vertical-align: top; }
.r { text-align: right; white-space: nowrap; }

/* ---------- segmented choice (Estimate / GST bill, card language) ---------- */
.seg { display: inline-flex; gap: 2px; padding: 4px; border-radius: 10px; background: #EFE6D6; }
.seg.wide { display: flex; }
.seg.wide label { flex: 1; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 16px; border-radius: 8px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.seg input:checked + span { background: #fff; color: var(--maroon); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.seg input:focus-visible + span { outline: 3px solid var(--maroon); }
.lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }

/* ---------- bill builder ---------- */
.bill-lines { margin-top: 8px; }
.bline { display: flex; justify-content: space-between; gap: 8px; padding: 12px 0; border-top: 1px solid #F1E8D9; }
.bline-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bline-side { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: none; }
.bline-side .btn.link { min-height: 32px; }
#newTotals:not(:empty) { margin-top: 4px; padding-top: 12px; border-top: 1px dashed var(--line); }
.oldgold { background: #FFF8E8; border-color: var(--warn-line); }
.oldgold h2 { color: #5A3600; }
.oldgold .bline { border-top-color: #F3DDB0; }
.old-total { display: flex; justify-content: space-between; padding-top: 12px; border-top: 1px dashed var(--warn-line); color: #5A3600; }
.pay-total { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 15px; }
.pay-total b { font-size: 24px; color: var(--maroon); }
.pay-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.action-bar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px)); z-index: 5; padding: 12px 0; background: var(--cream); }
@media (min-width: 900px) { .action-bar { bottom: 0; } }
.btn.wa { background: #1F6B3A; border-color: #1F6B3A; color: #fff; }
a.alert { justify-content: space-between; text-decoration: none; }

/* ---------- invoice (screen + print) ---------- */
/* invoice layouts: see "Printed invoice" at the end of this file */

/* ---------- More menu ---------- */
.hero-tile { display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 16px; background: var(--maroon); color: #fff; text-decoration: none; }
.hero-tile b { display: block; font-size: 17px; }
.hero-tile span span { display: block; font-size: 13px; color: #F3D9DC; }
.tile-ic { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 12px; background: var(--sand); color: var(--maroon); font-size: 17px; font-weight: 600; }
.tile-ic.gold { background: var(--gold); color: var(--maroon-dark); }
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
/* More page from tablet width: 4 even columns (no section has more than 4 cards, so every row is full
   width and the cards line up across all sections) and one card height for every row. Phones keep 3 columns. */
@media (min-width: 760px) {
  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .tiles > .tile { min-height: 136px; }
  .view:has(> .tiles) .section-title { margin: 32px 0 12px; }
}
.tile { display: flex; flex-direction: column; align-items: center; gap: 8px; min-height: 104px; padding: 16px 8px; text-align: center; font-size: 13px; color: var(--ink); text-decoration: none; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.tile b { font-weight: 600; line-height: 1.25; }
a.tile:hover { border-color: var(--gold); }
.tile.soon { opacity: .75; }
.section-title { margin: 24px 0 8px; font-size: 14px; font-weight: 500; color: var(--gold-text); }

/* ---------- rate card ---------- */
.ratecard-preview { max-width: 420px; margin: 0 auto; }
.ratecard-preview img { display: block; width: 100%; border-radius: 16px; box-shadow: 0 4px 16px rgba(42, 29, 24, .14); }

/* ---------- printing (QR labels and bills) ----------
   Labels fit standard A4 sticker sheets with 65 labels (5 × 13, 38.1 × 21.2 mm). */
#print-area { display: none; }
@media print {
  @page { size: A4; margin: 12mm; }
  @page labels { size: A4; margin: 10.7mm 4.7mm; }
  body { background: #fff; padding: 0; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block; }
  .label-sheet { page: labels; display: grid; grid-template-columns: repeat(5, 38.1mm); grid-auto-rows: 21.2mm; column-gap: 2.5mm; }
  .label { display: flex; align-items: center; gap: 1.2mm; padding: 1.2mm 1.5mm; overflow: hidden; break-inside: avoid; font: 6.5pt/1.15 Arial, sans-serif; color: #000; }
  .label-qr { width: 17mm; height: 17mm; flex: none; }
  .label-text { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; }
  .label-text b { font-size: 8pt; }
}

/* ---------- Phase 2: shop records, staff, sync, website ---------- */
.dot-bad { background: var(--bad); }
.grid-4 { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 620px) { .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.modal { max-height: 92vh; overflow-y: auto; }
.modal input[type="file"] { font-size: 13px; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 14px; min-height: 40px; }
label.check input { width: 20px; height: 20px; accent-color: var(--maroon); }

/* order / repair progress */
.steps { display: flex; list-style: none; margin: 4px 0 0; padding: 0; gap: 4px; counter-reset: st; }
.steps li { flex: 1; position: relative; padding-top: 12px; font-size: 12px; text-align: center; color: var(--muted); border-top: 4px solid #E6DBC8; }
.steps li.done { border-top-color: var(--maroon); color: var(--maroon); font-weight: 600; }
.progress { height: 10px; border-radius: 999px; background: #EFE6D6; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--maroon); }

/* cash book */
.day-nav { display: flex; align-items: center; gap: 8px; }
.day-nav input { min-height: 36px; padding: 4px 8px; border: 1px solid var(--field-line); border-radius: 8px; font: inherit; background: #fff; }

/* topbar: sync dot and user button */
.sync-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #bbb; flex: none; }
.sync-dot.ok { background: #4CC17A; } .sync-dot.syncing { background: var(--gold); animation: pulse 1s infinite alternate; }
.sync-dot.error { background: #FF6B5E; } .sync-dot.offline { background: #9A8F86; }
@keyframes pulse { to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .sync-dot.syncing { animation: none; } }
.user-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--gold-soft); color: var(--maroon-dark); font: 600 15px var(--font); cursor: pointer; }

/* lock screen */
/* flex + margin:auto centres the box, and lets it scroll from the top when it is taller than the screen */
.lock { position: fixed; inset: 0; z-index: 100; display: flex; padding: 24px; overflow-y: auto; background: var(--maroon-dark); }
.lock-box { margin: auto; width: min(100%, 360px); background: #fff; border-radius: 20px; padding: 28px 24px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.lock-box h1 { font: 600 22px var(--font-head); color: var(--maroon); }
.lock-box form { width: 100%; }
.brand-mark.big { width: 56px; height: 56px; font-size: 28px; }
.pin-input { width: 100%; text-align: center; font-size: 28px !important; letter-spacing: .5em; min-height: 56px; }
.net-banner { position: sticky; top: 0; z-index: 90; background: #8B1E1E; color: #fff; padding: 10px 16px; font-size: 15px; text-align: center; }
.net-banner b { margin-right: 6px; }
.mfa-qr { width: 200px; max-width: 70vw; background: #fff; padding: 8px; }
.mfa-qr svg { width: 100%; height: auto; display: block; }
.mfa-secret { font: 600 14px ui-monospace, monospace; word-break: break-all; background: var(--gold-soft); padding: 6px 8px; border-radius: 8px; user-select: all; }
.user-pick { display: grid; gap: 8px; width: 100%; }
.user-pick .btn { display: flex; justify-content: space-between; width: 100%; }

/* staff & sync page */
.setup { margin-top: 12px; }
.setup summary { cursor: pointer; font-weight: 600; color: var(--maroon); min-height: 36px; display: flex; align-items: center; }
pre.code { max-width: 100%; overflow-x: auto; background: #2A1D18; color: #F6EBD3; padding: 12px; border-radius: 10px; font-size: 12px; line-height: 1.45; white-space: pre; }

/* website page */
.item-row.pick { cursor: pointer; }
.item-row.pick input { width: 20px; height: 20px; flex: none; accent-color: var(--maroon); }
.web-preview { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: 14px; background: #fff; margin-top: 12px; }

/* printed slips (order / repair receipts, scheme passbook) — fit 80 mm receipt printers and A4 */
.slip { width: 76mm; font: 9.5pt/1.35 Arial, sans-serif; color: #000; }
.slip-shop { font: 700 13pt Georgia, serif; text-align: center; }
.slip-c { text-align: center; }
.slip-title { margin: 6px 0 4px; padding: 3px 0; text-align: center; font-weight: 700; letter-spacing: .08em; border-top: 1px dashed #000; border-bottom: 1px dashed #000; }
.slip-row { display: flex; justify-content: space-between; gap: 8px; padding: 1.5px 0; }
.slip-row span:last-child { text-align: right; }
.slip-total { margin-top: 4px; padding-top: 4px; border-top: 1px dashed #000; font-weight: 700; }
.slip-sign { margin-top: 28px; text-align: right; }
.slip-sign span { display: inline-block; min-width: 40mm; border-top: 1px solid #000; padding-top: 2px; text-align: center; }
.actions { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.actions .btn { white-space: normal; line-height: 1.25; text-align: center; min-height: 48px; height: auto; padding-block: 8px; }

/* =====================================================================
   Stage 1 design pass — readable text, 44–48px touch targets, clear statuses.
   Shared rules first (they lift every screen a little), then Home, Stock,
   Piece details and the Scanner.
   ===================================================================== */
:root { --nav-h: 76px; --radius: 16px; }
body { font-size: 16px; }
h1 { font-size: 28px; }
h2 { font-size: 17px; font-weight: 600; color: var(--ink); }
.small { font-size: 14px; }
.muted { color: #66554B; }
.card { padding: 16px; }
.view > * + * { margin-top: 16px; }
.code { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace; font-weight: 600; letter-spacing: .02em; color: var(--maroon); }

/* buttons, chips, inputs: one size system */
.btn { min-height: 48px; font-size: 15px; border-radius: 12px; padding: 0 16px; }
.btn.small { min-height: 44px; font-size: 14px; padding: 0 16px; border-radius: 10px; }
.btn.link { min-height: 44px; }
.btn.danger { background: var(--bad-bg); border-color: #F0B8B1; color: var(--bad); }
.btn.danger:hover { background: #F8D3CE; }
.pill-btn { min-height: 44px; font-size: 14px; padding: 0 16px; }
input, select, textarea { min-height: 48px; font-size: 16px; }
.field label, .manual label, .lbl { font-size: 14px; }
.chip { min-height: 44px; font-size: 14px; padding: 0 16px; }
.chip span { font-size: 13px; font-weight: 600; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.alert { font-size: 15px; padding: 12px 16px; }
.history li { font-size: 15px; padding: 12px 0; }

/* top bar */
.brand-name { font-size: clamp(15px, 4.4vw, 19px); }
.topbar-actions { gap: 4px; }

/* bottom navigation: bigger, darker labels; Scan stays the hero */
.mainnav a { font-size: 13px; font-weight: 600; color: #5E4E45; gap: 4px; min-height: 56px; justify-content: center; }
.mainnav a svg { width: 25px; height: 25px; }
.mainnav a.active { color: var(--maroon); }
.mainnav a.active:not(.nav-scan) svg { stroke-width: 2.2; }
.mainnav .nav-scan svg { width: 62px; height: 62px; padding: 16px; margin-top: -32px; stroke-width: 2.2; }
@media (min-width: 900px) { .mainnav a { min-height: 48px; font-size: 15px; } .mainnav .nav-scan svg { width: 25px; height: 25px; padding: 0; margin: 0; } }

/* status badges: each status has its own colour and a dot, so they differ even without colour vision */
.badge { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 4px 12px 4px 8px; border: 1px solid transparent; line-height: 1.2; }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.st-instock { background: #E1F2E7; color: #1E5634; border-color: #B6DCC3; }
.st-sold { background: #ECE7E3; color: #3F342E; border-color: #D5CBC3; }
.st-sold::before { border-radius: 2px; }
.st-approval { background: #FFF0D2; color: #774600; border-color: #EDC78A; }
.st-repair { background: #E3EAF8; color: #24427F; border-color: #BFCDEB; }
.st-returned { background: #F0E6F6; color: #5B2C79; border-color: #D7C0E6; }
.st-plain { background: var(--sand); color: var(--gold-text); border-color: #E8D6AA; }

/* ---------- Home ---------- */
.home-head h1 { font-size: 26px; }
.eyebrow { margin: 0 0 2px; font-size: 14px; color: var(--muted); }
.rates-card { border-color: #E6D29A; background: var(--card); }
.rates-card h2 .muted { font-weight: 500; font-size: 14px; }
.rate-main { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rate-big { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; border-radius: 12px; background: var(--maroon); color: #fff; }
.rate-big span { font-size: 14px; color: var(--gold-soft); }
.rate-big b { font-size: 24px; letter-spacing: .01em; }
.rate-more { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.rate-more div { display: flex; flex-direction: column; padding: 8px 12px; border-radius: 10px; background: var(--sand); }
.rate-more span { font-size: 13px; color: var(--muted); }
.rate-more b { font-size: 16px; }
.rate-status { display: flex; align-items: center; gap: 8px; margin: 8px 0 0 !important; font-size: 14px; font-weight: 600; }
.rate-status .ic { width: 18px; height: 18px; }
.quick { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.quick-btn { min-height: 84px; font-size: 14px; border-radius: 12px; padding: 16px 4px 12px; line-height: 1.2; justify-content: flex-start; gap: 8px; }
.quick-btn .ic { width: 26px; height: 26px; }
.key-stats .stat { gap: 4px; padding: 16px; min-height: 108px; }
.stat span { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.stat b.amount { font-size: 24px; color: var(--ink); letter-spacing: .01em; }
.stat small { font-size: 14px; }
.stat-warn b.amount { color: #6A3D00; }
.home-stats > .stat:last-child:nth-child(odd) { grid-column: 1 / -1; } /* Home: 3 cards on a 2-column phone grid, the last one full width */
@media (min-width: 760px) { .home-stats > .stat:last-child:nth-child(odd) { grid-column: auto; } }
/* Money owed (Upgrade 4): one column on phones, side by side from 760px; never added together */
.owed-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 8px 0 8px; }
.owed-head .section-title { margin: 0; }
.owed-stats { grid-template-columns: 1fr; }
@media (min-width: 760px) { .owed-stats { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); } }
.owed-stats .stat { gap: 4px; padding: 16px; }
.glance { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.glance div { display: flex; flex-direction: column; padding: 12px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); }
.glance span { font-size: 14px; color: var(--muted); }
.glance b { font-size: 16px; }
.welcome { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 16px; }
.activity a { padding: 12px 0; min-height: 56px; }
.act-main { font-size: 15px; gap: 2px; }
.act-main .muted { font-size: 14px; }
.act-main .code { font-size: 13px; }

/* ---------- Stock list ---------- */
.list-bar { gap: 8px; flex-wrap: wrap; }
.list-count { font-size: 15px; color: var(--ink-2); }
.item-list { gap: 8px; }
.stock-card { display: flex; gap: 12px; padding: 12px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); border-left-width: 5px; color: var(--ink); text-decoration: none; }
.stock-card:hover { border-color: var(--gold); }
.st-edge-instock { border-left-color: #3E8E5C; }
.st-edge-sold { border-left-color: #A99B91; }
.st-edge-approval { border-left-color: #D9962A; }
.st-edge-repair { border-left-color: #4F6FB5; }
.stock-card .thumb { width: 72px; height: 72px; border-radius: 12px; }
.sc-body { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.sc-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sc-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.sc-price { font-size: 17px; color: var(--maroon); white-space: nowrap; flex: none; }
.sc-meta { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc-meta .code { font-size: 14px; }
.sc-wt { font-size: 14px; color: var(--ink-2); }
.sc-wt b { color: var(--ink); }
.sc-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 12px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty-state .ic { width: 30px; height: 30px; }
.empty-state p { margin: 0; font-size: 15px; }

/* ---------- Piece details ---------- */
.piece-top { display: grid; gap: 12px; }
.piece-top.has-photo .item-photo { width: 100%; height: auto; aspect-ratio: 4 / 3; max-height: 360px; }
.piece-top.no-photo { grid-template-columns: 84px 1fr; align-items: start; }
.piece-top.no-photo .item-photo { width: 84px; height: 84px; border-radius: 14px; }
.piece-top.no-photo .item-photo .ic { width: 34px; height: 34px; }
@media (min-width: 760px) { .piece-top.has-photo { grid-template-columns: 320px 1fr; align-items: start; } }
.piece-top .item-head h1 { font-size: 26px; overflow-wrap: anywhere; }
.badges { display: flex; flex-wrap: wrap; gap: 8px; }
.piece-code { display: inline-flex; align-items: baseline; gap: 8px; margin: 2px 0 0 !important; padding: 8px 12px; border-radius: 10px; background: #FBF1DA; border: 1px solid #E8D6AA; }
.piece-code span { font-size: 13px; color: var(--gold-text); font-weight: 600; }
.piece-code .code { font-size: 20px; }
.item-info { font-size: 15px; }
.action-card h2 { margin-bottom: 8px; }
.actions.two { grid-template-columns: 1fr 1fr; }
.actions.two .span-2 { grid-column: 1 / -1; }
.spec { margin: 0; display: flex; flex-direction: column; }
.spec-row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid #F1E8D9; font-size: 15px; }
.spec-row:first-child { border-top: 0; padding-top: 2px; }
.spec-row dt { color: var(--ink-2); }
.spec-row dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.spec-row.hl dd { color: var(--maroon); font-size: 18px; }
.bill { font-size: 15px; gap: 8px; }
.bill .total { font-size: 18px; }
.bill .total dd { font-size: 22px; }
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.qr-card h2 { align-self: flex-start; margin: 0; }
.qr-big { width: min(230px, 70vw); aspect-ratio: 1; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.qr-big svg { width: 100%; height: 100%; display: block; }
.qr-code { margin: 0 !important; font-size: 22px; }
.label-prev { align-self: stretch; text-align: left; }
.label-prev summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; font-weight: 600; color: var(--maroon); }
.label-prev .tag-preview { margin-top: 8px; }
.danger-card { border-color: #F0C7C1; background: #FFFAF9; }
.danger-card h2 { color: var(--bad); }

/* ---------- Scanner ---------- */
.scan-card { gap: 12px; }
.scan-stage { position: relative; display: flex; flex-direction: column; gap: 12px; padding: 12px; border-radius: 20px; background: #221513; border: 2px solid #5C3A1E; }
.scan-stage .reader { max-width: none; border-radius: 14px; background: #120B0A; }
.scan-stage .reader.on { min-height: 300px; }
.scan-stage .reader #qr-shaded-region div { background-color: var(--gold) !important; }
.scan-idle { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 260px; border-radius: 14px; border: 2px dashed rgba(201, 162, 39, .55); color: var(--gold-soft); text-align: center; }
.scan-idle .ic { width: 64px; height: 64px; stroke-width: 1.4; color: var(--gold); }
.scan-idle p { margin: 0; font-size: 16px; }
.scan-tools { display: flex; gap: 8px; }
.scan-tools #camBtn { flex: 1; }
.scan-tools #camBtn:not(.primary) { background: #2C1C19; border-color: #5C3A1E; color: var(--gold-soft); }
.btn.torch { background: #2C1C19; border-color: #5C3A1E; color: var(--gold-soft); }
.btn.torch.on { background: var(--gold); border-color: var(--gold); color: var(--maroon-dark); }
.cam-msg:empty { display: none; }
.cam-status { margin: 0; text-align: center; font-size: 15px; color: var(--ink-2); }
.cam-help { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: 14px; background: var(--warn-bg); border: 1px solid var(--warn-line); color: #4F3000; text-align: left; }
.cam-help .ic { width: 24px; height: 24px; flex: none; margin-top: 2px; }
.cam-help b { font-size: 16px; }
.cam-help p { margin: 4px 0 0; font-size: 15px; }
.cam-help p.small { font-size: 14px; color: #6A4A16; }
.manual.card { gap: 8px; }
.manual .inline .btn { min-width: 88px; }
.brand { min-height: 44px; }

/* ---- Stage 2: new bill, payments, bill view ---- */
.type-hint { margin: -4px 0 12px; font-size: 14px; }
.step-h { display: flex; align-items: center; gap: 8px; }
.step-n { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--maroon); color: var(--gold-soft); font: 600 14px/1 system-ui, sans-serif; }
.oldgold .step-n { background: #8A5A00; color: #FFF3D6; }

.bline { display: block; padding: 12px 0; }
.bline-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.bline-amt { flex: none; font-size: 17px; }
.bline-break { margin-top: 8px; }
.bline-break summary { display: inline-flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--maroon); font-weight: 600; font-size: 14px; }
.bill.mini { margin: 2px 0 4px; padding: 8px 12px; border-radius: 10px; background: #FBF6EC; font-size: 14px; }
.oldgold .bill.mini { background: #FFF3DC; }
.bill.mini > div { padding: 4px 0; }
.bill.mini dt { color: var(--ink-2); }
.bline-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.btn.btn-bad { color: var(--bad); }
.old-preview { min-height: 22px; margin: 0; color: #5A3600; }

.total-card { border-color: var(--gold); background: #FFFBF2; }
.total-card .pay-total b { font-size: 28px; }
.pay-lines { display: grid; gap: 8px; margin-bottom: 12px; }
.pay-line { display: grid; grid-template-columns: minmax(96px, 38%) 1fr; align-items: center; gap: 8px; }
.pay-line label { font-weight: 600; }
.pay-line input { text-align: right; font-size: 18px; font-variant-numeric: tabular-nums; }
.pay-sum { margin-top: 12px; }
.bill .total.due dd, .bill .total.due dt { color: var(--warn); }
.bill .total.due { background: var(--warn-bg); margin: 4px -8px 0; padding: 8px; border-radius: 8px; border-top: 0; }

/* sticky amount bar above the bottom menu */
.bill-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 -16px; padding: 12px 16px; background: var(--card); border-top: 2px solid var(--gold); box-shadow: 0 -6px 16px rgba(90, 40, 20, .08); }
.bb-amt { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.bb-amt span { font-size: 13px; color: var(--ink-2); }
.bb-amt b { font-size: 22px; color: var(--maroon); font-variant-numeric: tabular-nums; }
.bb-amt small { font-size: 13px; font-weight: 600; }
.bill-bar .btn { flex: none; max-width: 56%; white-space: normal; text-align: center; line-height: 1.2; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.confirm-bill { width: min(440px, calc(100vw - 32px)); }
.confirm-bill .bill { margin-bottom: 8px; }
.confirm-bill .alert { margin: 8px 0; }
.modal-actions.three { flex-wrap: wrap; }
.modal-actions.three .btn { flex: 1 1 120px; }

/* bill view */
.bill-sum { display: flex; flex-direction: column; gap: 8px; }
.bill-sum.is-cancelled { background: #F7F3EE; }
.bill-sum.is-cancelled .bs-amt b { text-decoration: line-through; color: var(--ink-2); }
.bs-no { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; }
.bs-no .code { font-size: 17px; }
.bs-cust { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; font-size: 17px; }
.bs-amt { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 12px 0; border-top: 1px dashed var(--line); border-bottom: 1px dashed var(--line); }
.bs-amt b { font-size: 28px; color: var(--maroon); font-variant-numeric: tabular-nums; }
.bs-h { margin: 8px 0 0; font-size: 15px; }
.pay-hist { list-style: none; margin: 0; padding: 0; }
.pay-hist li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid #F1E8D9; }
.pay-hist li span { display: flex; flex-direction: column; }
.pay-hist li small { font-size: 13px; }
.pay-hist li.refund b { color: var(--bad); }
.bv-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 12px 0; }
.bv-actions .wide { grid-column: 1 / -1; }
.due-box { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); }
.due-box b { font-size: 20px; }

/* =====================================================================
   Printed invoice: 80 mm / 58 mm thermal receipts, A5 and A4 sheets.
   Sizes are in mm / pt so the screen preview matches the paper.
   The @page size for each print is set by js/invoice.js.
   ===================================================================== */
.inv-te { display: block; font-size: max(.92em, 7.8pt); font-weight: 400; color: #444; }
.inv-page { background: #fff; color: #111; box-shadow: 0 6px 18px rgba(60, 30, 10, .16); transform-origin: top left; }
.inv-page.fmt-r80 { width: 80mm; padding: 4mm 4mm 5mm; }
.inv-page.fmt-r58 { width: 58mm; padding: 3mm 5mm 4mm; }
.inv-page.fmt-a5 { width: 148mm; min-height: 210mm; padding: 9mm; }
.inv-page.fmt-a4 { width: 210mm; min-height: 297mm; padding: 12mm; }
.inv-probe { position: absolute; left: -10000px; top: 0; visibility: hidden; }

/* receipt */
.rc { font: 9.5pt/1.35 Arial, Helvetica, "Nirmala UI", "Noto Sans Telugu", sans-serif; color: #000; font-variant-numeric: tabular-nums; }
.fmt-r58 .rc { font-size: 8.8pt; }
.rc-shop { padding-bottom: 1mm; font: 700 15pt/1.15 Georgia, "Times New Roman", serif; text-align: center; letter-spacing: .02em; }
.fmt-r58 .rc-shop { font-size: 12.5pt; }
.rc-c { text-align: center; font-size: .92em; overflow-wrap: anywhere; }
.rc-title { margin: 2mm 0 1.5mm; padding: 1.2mm 0; border-top: 1.5px solid #000; border-bottom: 1.5px solid #000; text-align: center; font-weight: 700; letter-spacing: .12em; }
.rc-kv { display: flex; justify-content: space-between; align-items: baseline; gap: 2mm; padding: .3mm 0; }
.rc-kv > span:first-child { min-width: 0; }
.rc-kv > span:last-child { flex: none; text-align: right; white-space: nowrap; }
.rc-sec { margin-top: 2.2mm; padding: .6mm 0 .5mm; border-bottom: 1px dashed #000; font-size: .92em; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.rc-cust { padding: 1mm 0; overflow-wrap: anywhere; }
.rc-cust b { font-size: 1.08em; }
.rc-item { padding: 1.6mm 0; border-bottom: 1px dashed #000; break-inside: avoid; }
.rc-iname { display: flex; justify-content: space-between; align-items: baseline; gap: 2mm; font-size: 1.05em; }
.rc-iname b:first-child { min-width: 0; overflow-wrap: anywhere; }
.rc-amt { flex: none; white-space: nowrap; }
.rc-sub { margin: .3mm 0 .8mm; font-size: .88em; overflow-wrap: anywhere; }
.rc-kvs { display: grid; grid-template-columns: 1fr 1fr; column-gap: 3.5mm; font-size: .93em; }
.fmt-r58 .rc-kvs { grid-template-columns: 1fr; }
.rc-totals { margin-top: 1.5mm; }
.rc-sign { display: flex; justify-content: space-between; gap: 5mm; margin-top: 11mm; }
.rc-sign div { flex: 0 1 48%; text-align: center; }
.rc-sign div:last-child { margin-left: auto; }
.rc-sign div > span { display: block; padding-top: .8mm; border-top: 1px solid #000; font-size: .88em; }
.fmt-r58 .rc-sign { flex-direction: column; gap: 11mm; }
.fmt-r58 .rc-sign div { flex: none; width: 100%; }

/* totals rows: shared by every format */
.it-row { display: flex; justify-content: space-between; align-items: baseline; gap: 3mm; padding: .5mm 0; }
.it-row > span { min-width: 0; }
.it-row small { display: block; font-size: .85em; color: #333; }
.it-row b { flex: none; font-weight: 600; white-space: nowrap; }
.it-row.strong { border-top: 1px solid #000; font-weight: 700; }
.it-row.strong b, .it-row.grand b, .it-row.due.open b { font-weight: 700; }
.rc .it-row.grand { margin: 1.5mm 0; padding: 1.8mm 0; border-top: 2px solid #000; border-bottom: 2px solid #000; font-size: 1.35em; font-weight: 700; }
.rc .it-row.due.open { font-size: 1.12em; font-weight: 700; }
.inv-words { margin-top: 2mm; font-size: .92em; font-style: italic; }
.inv-words > span { display: block; font-style: normal; font-weight: 700; }
.inv-note { margin-top: 1.5mm; font-size: .9em; }
.inv-thanks { margin-top: 3.5mm; text-align: center; font-size: .92em; font-weight: 600; }

/* A5 / A4 sheet */
.sh { font: 10.5pt/1.4 Arial, Helvetica, "Nirmala UI", "Noto Sans Telugu", sans-serif; color: #1a1a1a; font-variant-numeric: tabular-nums; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.fmt-a5 .sh { font-size: 9.5pt; }
.fmt-a5 .sh-table { font-size: .9em; }
.fmt-a5 .sh-table th, .fmt-a5 .sh-table td { padding: 1.5mm .8mm; }
.fmt-a5 .sh-table th { font-size: .95em; }
.sh-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 6mm; padding-bottom: 4mm; border-bottom: 3px double #C9A227; }
.sh-brand { display: flex; align-items: center; gap: 3.5mm; min-width: 0; overflow-wrap: anywhere; }
.sh-logo { flex: none; width: 16mm; height: 16mm; }
.fmt-a5 .sh-logo { width: 12mm; height: 12mm; }
.sh-shop { font: 700 20pt/1.1 Georgia, "Times New Roman", serif; color: #7A1F2B; }
.fmt-a5 .sh-shop { font-size: 15pt; }
.sh-doc { flex: none; text-align: right; }
.sh-title { display: inline-block; margin-bottom: 2mm; padding: 1.2mm 3.5mm; border-radius: 1mm; background: #7A1F2B; color: #fff; font-size: .95em; font-weight: 700; letter-spacing: .12em; }
.sh-title .inv-te, .sh-table th .inv-te, .sh .it-row.grand .inv-te { color: #F3E3B0; }
.sh-meta { display: flex; justify-content: flex-end; gap: 3mm; }
.sh-meta > span { color: #555; }
.sh-party { display: flex; justify-content: space-between; align-items: flex-start; gap: 5mm; margin: 4mm 0; padding: 3mm 4mm; border: 1px solid #E8DCC8; border-left: 3px solid #C9A227; border-radius: 1.5mm; background: #FBF7EF; }
.sh-party > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.sh-cap { color: #8A6414; font-size: .9em; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.sh-cname { font-size: 1.2em; font-weight: 700; }
.sh-status { flex: none; color: #7A1F2B; font-weight: 600; text-align: right; }
.sh-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: .95em; }
.sh-table thead { display: table-header-group; }
.sh-table th { padding: 2mm 1.6mm; background: #7A1F2B; color: #fff; font-size: .92em; font-weight: 600; text-align: right; vertical-align: bottom; }
.sh-table td { padding: 2mm 1.6mm; border-bottom: 1px solid #E8DCC8; text-align: right; vertical-align: top; }
.sh-table th:first-child, .sh-table td.c { text-align: center; }
.sh-table .l { text-align: left; }
.sh-table td.l { overflow-wrap: anywhere; }
.sh-table tbody tr:nth-child(even) td { background: #FCF8F0; }
.sh-table tr { break-inside: avoid; }
.sh-sub { color: #555; font-size: .9em; }
.sh-table .wt div { white-space: nowrap; }
.wl { color: #666; font-size: .92em; }
.fmt-a5 .col-hsn, .fmt-a5 .col-mv, .fmt-a4 .hsn-in { display: none; }
.fmt-a4 .sh-table th.l { width: 27%; }
.sh-bottom { display: grid; grid-template-columns: 1fr 1fr; align-items: start; gap: 6mm; margin-top: 4mm; }
.sh-left { display: flex; flex-direction: column; gap: 3mm; }
.sh-pay { padding: 2.5mm 3mm; border: 1px solid #E8DCC8; border-radius: 1.5mm; break-inside: avoid; }
.sh-pay .it-row:first-of-type { padding-top: .5mm; }
.sh-totals { break-inside: avoid; }
.it-row { break-inside: avoid; }
.fmt-a5 .sh-bottom { grid-template-columns: 1fr 1.15fr; gap: 4mm; }
.sh .it-row { padding: 1mm 0; }
.sh .it-row.strong { border-top-color: #D9C9AE; }
.sh .it-row.grand { margin: 1.5mm 0; padding: 2.2mm 3mm; border-radius: 1.5mm; background: #7A1F2B; color: #fff; font-size: 1.25em; font-weight: 700; }
.sh .it-row.due.open { color: #7A1F2B; font-weight: 700; }
.sh .inv-thanks { break-before: avoid; }
.sh .inv-words { margin-top: 0; padding: 2.5mm 3mm; border-radius: 1.5mm; background: #FBF7EF; }
.sh-sign { display: flex; justify-content: space-between; gap: 10mm; margin-top: 13mm; break-inside: avoid; }
.sh-sign div { flex: 0 1 60mm; text-align: center; }
.sh-sign div > span { display: block; padding-top: 1.5mm; border-top: 1px solid #555; }
.sh-sign small { display: block; color: #666; font-size: .85em; }
.sh .inv-thanks { margin-top: 6mm; padding-top: 3mm; border-top: 3px double #C9A227; color: #7A1F2B; font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 400; }

/* A5: tighter vertical rhythm so an everyday bill stays on one sheet */
.fmt-a5 .sh-head { padding-bottom: 3mm; }
.fmt-a5 .sh-party { margin: 3mm 0; padding: 2.2mm 3mm; }
.fmt-a5 .sh-bottom { margin-top: 3mm; }
.fmt-a5 .sh-sign { margin-top: 9mm; }
.fmt-a5 .inv-thanks { margin-top: 3mm; padding-top: 2mm; }
.sh .it-row.pay small { display: inline; }
.sh .it-row.pay small::before { content: " · "; }
.rc-kv.wide { grid-column: 1 / -1; }

/* preview on screen */
.inv-stage { padding: 12px; border-radius: 12px; background: #EDE3D1; overflow: hidden; }
.inv-scale { margin: 0 auto; }
.inv-chips { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 12px; }
.inv-chips label, .ps-fmt { position: relative; cursor: pointer; }
.inv-chips input, .ps-fmt input { position: absolute; opacity: 0; pointer-events: none; }
.inv-chips span { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 4px 6px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--card); font-size: 13.5px; font-weight: 600; line-height: 1.2; text-align: center; }
.inv-chips input:checked + span, .ps-fmt input:checked + span { border-color: var(--maroon); background: #FBF0F1; color: var(--maroon); box-shadow: inset 0 0 0 1px var(--maroon); }
.inv-chips input:focus-visible + span, .ps-fmt input:focus-visible + span { outline: 3px solid var(--maroon); outline-offset: 2px; }
.print-sheet { width: min(640px, calc(100vw - 24px)); }
.ps { display: flex; flex-direction: column; gap: 12px; }
.ps-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.ps-head h2 { margin: 0; }
.ps-formats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ps-fmt span { display: flex; flex-direction: column; gap: 2px; min-height: 56px; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card); }
.ps-fmt b { font-size: 15px; }
.ps-fmt small { color: var(--muted); font-size: 13px; }
.print-sheet .inv-stage { max-height: 50vh; overflow-y: auto; }
.ps-help summary { display: flex; align-items: center; min-height: 44px; color: var(--maroon); font-weight: 600; cursor: pointer; }
.ps-help ul { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.5; }
.ps-pdf-hint { margin: 0; }

@media print {
  .inv-print .inv-page { margin: 0; box-shadow: none; transform: none !important; }
  .inv-print .inv-page.fmt-a5, .inv-print .inv-page.fmt-a4 { width: auto; min-height: 0; padding: 0; }
}

/* =====================================================================
   Stage 3: stock check and reports
   ===================================================================== */
.check-start { display: flex; flex-direction: column; gap: 12px; }
.check-start h2, .check-start p { margin: 0; }
.check-expect { display: flex; align-items: baseline; gap: 8px; padding: 16px 16px; border-radius: 14px; background: var(--sand); }
.check-expect b { font-size: 34px; line-height: 1; color: var(--maroon); font-variant-numeric: tabular-nums; }
.check-expect span { font-size: 15px; color: var(--ink-2); }
.progress-nums.four { grid-template-columns: repeat(4, minmax(0, 1fr)); font-size: 13px; }
.progress-nums b.text-warn { color: var(--warn); }
.tab-n { display: inline-block; min-width: 22px; margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: #EFE6D6; color: var(--ink-2); font-size: 13px; font-weight: 600; text-align: center; }
.tab.on .tab-n { background: var(--maroon); color: #fff; }
.check-row > a:first-child { display: flex; flex-direction: column; min-width: 0; flex: 1; color: var(--ink); text-decoration: none; }
.check-row .btn.small { flex: none; }
.check-actions { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-top: 16px; }
.badge.st-missing { background: var(--bad-bg); color: var(--bad); border-color: #F0B8B1; }
.check-result { display: flex; align-items: flex-start; gap: 12px; border-width: 2px; }
.check-result h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.2; }
.check-result p { margin: 0; }
.cr-icon { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; }
.cr-icon svg { width: 28px; height: 28px; }
.check-result.r-ok { border-color: #B6DCC3; background: #F1F8F3; }
.check-result.r-ok .cr-icon { background: var(--ok-bg); color: var(--ok); }
.check-result.r-bad { border-color: #F0B8B1; background: #FDF3F1; }
.check-result.r-bad .cr-icon { background: var(--bad-bg); color: var(--bad); }
.check-result.r-warn { border-color: var(--warn-line); background: #FFF8EA; }
.check-result.r-warn .cr-icon { background: var(--warn-bg); color: var(--warn); }
.stat-bad { background: #FDF0EE; border-color: #F0B8B1; }
.stat-bad span, .stat-bad b { color: var(--bad); }
@media (min-width: 620px) { .check-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.range-form .grid-2 { margin-bottom: 8px; }
.cat-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.cat-bars li { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: baseline; }
.cat-bars b { font-variant-numeric: tabular-nums; }
.cb-bar { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: #EFE6D6; overflow: hidden; }
.cb-bar span { display: block; height: 100%; border-radius: 999px; background: var(--maroon); }
.stock-links { margin-top: 12px; }
.bill dt small, .bill dd small { font-weight: 400; }

/* =====================================================================
   Stage 4: orders, savings scheme, karigar ledger, cash book, rate card
   ===================================================================== */
/* order statuses: New · Confirmed · In progress · Ready · Delivered */
.st-new { background: #E3EAF8; color: #24427F; border-color: #BFCDEB; }
.st-confirmed { background: var(--sand); color: var(--gold-text); border-color: #E8D6AA; }
.st-progress { background: #FFF0D2; color: #774600; border-color: #EDC78A; }
.st-progress::before { border-radius: 2px; }
.stat-ok { background: #F1F8F3; border-color: #B6DCC3; }
.stat-ok span, .stat-ok b { color: var(--ok); }
@media (min-width: 620px) { .rec-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.steps.steps-5 li { font-size: 12px; overflow-wrap: anywhere; }
.ir-side .small { text-align: right; line-height: 1.35; }

.money-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.money-strip > div { display: flex; flex-direction: column; gap: 4px; padding: 12px; min-width: 0; }
.money-strip > div + div { border-left: 1px solid var(--line); }
.money-strip span { font-size: 13px; color: var(--muted); }
.money-strip b { font-size: 18px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.money-strip small { font-size: 12px; color: var(--muted); }
.money-strip .ms-due { background: var(--warn-bg); }
.money-strip .ms-due span, .money-strip .ms-due b { color: var(--warn); }

/* karigar: traceable balance + ledger rows */
.trace { margin: 0 0 12px; display: flex; flex-direction: column; }
.trace > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid #F1E8D9; }
.trace > div:first-child { border-top: 0; }
.trace dt { display: flex; flex-direction: column; font-size: 15px; }
.trace dt small { font-size: 13px; color: var(--muted); }
.trace dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trace .trace-total { border-top: 2px solid var(--maroon); }
.trace .trace-total dt, .trace .trace-total dd { color: var(--maroon); font-weight: 600; }
.ledger { list-style: none; margin: 0; padding: 0; }
.lg-row { padding: 12px 0 12px 12px; border-top: 1px solid #F1E8D9; border-left: 4px solid var(--line); margin-left: -4px; }
.lg-row:first-child { border-top: 0; }
.lg-issue { border-left-color: var(--warn-line); }
.lg-receive, .lg-return { border-left-color: #B6DCC3; }
.lg-pay { border-left-color: #BFCDEB; }
.lg-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.lg-desc { margin-top: 2px; }
.lg-calc { margin-top: 2px; font-variant-numeric: tabular-nums; }
.lg-amts { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }
.lg-bal { margin-left: auto; font-weight: 600; font-size: 13px; color: var(--ink-2); background: var(--sand); padding: 2px 8px; border-radius: 999px; }

/* savings scheme instalment calendar */
.inst-grid { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.inst { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px; border-radius: 12px; border: 1px solid var(--line); background: #fff; text-align: center; }
.inst b { font-size: 17px; }
.inst span { font-size: 12px; color: var(--muted); }
.inst small { font-size: 12px; font-weight: 600; }
.inst-paid { background: #E1F2E7; border-color: #B6DCC3; color: #1E5634; }
.inst-paid span { color: #2E6A45; }
.inst-late { background: var(--bad-bg); border-color: #F0B8B1; color: var(--bad); border-width: 2px; }
.inst-late span { color: var(--bad); }
.inst-next small { color: var(--muted); font-weight: 600; }
.passbook li > span:last-child { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.passbook li > span:last-child small { font-size: 12px; }

/* cash book */
.cb-quick { margin-bottom: 4px; }
.cb-quick button.chip { font: inherit; cursor: pointer; }
.cb-daynav { justify-content: center; }
.cb-daynav input { min-height: 44px; flex: 1; max-width: 220px; }
.cb-daynav .btn.small { min-width: 44px; min-height: 44px; }
.cash-sum { display: flex; flex-direction: column; gap: 0; }
.cs-line { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid #F1E8D9; font-size: 15px; }
.cs-line:first-child { border-top: 0; padding-top: 0; }
.cs-line b { font-size: 17px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cs-total { border-top: 2px solid var(--maroon); }
.cs-total span, .cs-total b { color: var(--maroon); font-weight: 600; }
.cs-total b { font-size: 21px; }
.cash-sum p { margin: 8px 0 0; }
.cb-list .cb-row { align-items: flex-start; }
.cb-main { display: flex; flex-direction: column; min-width: 0; }
.cb-amt { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.mode-tag { display: inline-block; padding: 0 8px; border-radius: 6px; background: var(--sand); color: var(--gold-text); font-size: 12px; font-weight: 600; }
.mode-tag.m-upi { background: var(--info-bg); color: var(--info); }
.mode-tag.m-card { background: #F0E6F6; color: #5B2C79; }

/* rate card */
.rcard-layout { display: grid; gap: 16px; }
.rcard-side { display: flex; flex-direction: column; gap: 12px; }
.rcard-rates .history b small { font-weight: 400; }
.rcard-buttons .btn { flex: 1 1 140px; }
@media (min-width: 760px) {
  .rcard-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .rcard-layout .ratecard-preview { max-width: none; margin: 0; }
}

/* =====================================================================
   Stage 5: touch and iPhone fixes found by the all-screens sweep
   ===================================================================== */
/* 16px stops iPhone Safari from zooming the page when a search box is tapped */
.search input { font-size: 16px; }
/* every tappable control at least 44 × 44 */
.seg span { min-height: 44px; }
.btn.link, .bline-side .btn.link { min-height: 44px; min-width: 44px; justify-content: center; }

/* =====================================================================
   Data safety: backups, recycle bin, change log
   ===================================================================== */
.kv-list { margin: 0 0 12px; display: flex; flex-direction: column; }
.kv-list > div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 8px 0; border-top: 1px solid #F1E8D9; flex-wrap: wrap; }
.kv-list > div:first-child { border-top: 0; }
.kv-list dt { color: var(--muted); font-size: 14px; }
.kv-list dd { margin: 0; font-weight: 600; text-align: right; }
.sub-h { margin: 16px 0 8px; font-size: 16px; }
.alert-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.bk-modes { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.bk-mode { display: flex; gap: 8px; align-items: flex-start; padding: 12px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; min-height: 44px; }
.bk-mode input { margin-top: 4px; width: 20px; height: 20px; flex: none; }
.bk-mode span { display: flex; flex-direction: column; gap: 2px; }
.bk-mode small { color: var(--muted); font-size: 13px; }
.bk-mode:has(input:checked) { border-color: var(--maroon); box-shadow: 0 0 0 1px var(--maroon) inset; }
.check-line { display: flex; gap: 8px; align-items: flex-start; min-height: 44px; padding: 8px 0; }
.check-line input { width: 20px; height: 20px; flex: none; margin-top: 2px; }
.snap-list li { align-items: center; }
.snap-list li > span:first-child { display: flex; flex-direction: column; min-width: 0; }
.snap-btns { flex: none; }
.trash-list .button-row { margin-top: 8px; }
.au-list .lg-row { border-left-color: var(--line); }
.au-list .au-delete, .au-list .au-purge, .au-list .au-erase, .au-list .au-cancel, .au-list .au-replaceAll { border-left-color: #F0B8B1; }
.au-list .au-create, .au-list .au-restoreBin { border-left-color: #B6DCC3; }
.au-changes { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.au-changes li { overflow-wrap: anywhere; }
.au-f { color: var(--muted); }
.au-from { text-decoration: line-through; color: var(--muted); }
.bs-cancel { margin-top: 8px; }

/* =====================================================================
   Polish pass: weights top out at 600; list titles read by size, not weight
   ===================================================================== */
b, strong { font-weight: 600; }
.act-main b { font-weight: 500; }
:is(#print-area, .inv-stage, .inv-print, .inv-page, .slip, .label-sheet, .label-prev) :is(b, strong) { font-weight: bolder; } /* printed paper keeps its own weights */
.notice-text { white-space: pre-wrap; font: inherit; font-size: 14px; line-height: 1.5; max-height: 40vh; overflow: auto; background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 12px 0; }

/* =====================================================================
   Laptop & desktop layout (Upgrade 1). Phones and tablets under 900px are unchanged:
   everything that changes the look is inside "screen and (min-width: 900px)".
   - 900px and up: the main menu becomes a left sidebar (same items, colours and icons).
   - 900–1199px: sidebar shows icons only. 1200px and up: icons + names, can be collapsed (remembered per device).
   ===================================================================== */
:root { --side-w: 232px; --side-mini: 76px; --top-h: 68px; }
.side-toggle { display: none; }
/* Bill page groups: same 16px spacing as the rest of the page on phones. */
.bill-cols > * + *, .bill-main > * + *, .bill-side > * + * { margin-top: 16px; }

@media screen and (min-width: 900px) {
  body { padding-left: var(--side-w); padding-bottom: 32px; }
  .topbar { margin-left: calc(-1 * var(--side-w)); padding-left: 20px; padding-right: 20px; }

  /* sidebar */
  .mainnav {
    position: fixed; top: var(--top-h); bottom: 0; left: 0; right: auto; z-index: 15;
    width: var(--side-w); height: auto;
    display: flex; flex-direction: column; align-items: stretch; gap: 4px;
    padding: 16px 12px; border-top: 0; border-bottom: 0; border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .mainnav a {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    min-height: 48px; padding: 0 14px; border-radius: 12px; border-bottom: 0;
    font-size: 15px; color: #5E4E45;
  }
  .mainnav a:hover { background: var(--cream); color: var(--maroon); }
  .mainnav a.active { background: var(--sand); color: var(--maroon); box-shadow: inset 3px 0 0 var(--maroon); }
  .mainnav a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  /* page area next to the sidebar */
  .view { max-width: 1440px; padding: 24px 32px 32px; }
  .bill-bar { margin: 0 -32px; padding: 12px 32px; }
  .toasts { left: calc(50% + var(--side-w) / 2); }

  /* pop-up forms with two or three columns of boxes get room for them */
  .modal:has(.grid-2), .modal:has(.grid-3) { width: min(94vw, 640px); }
}

/* icons-only sidebar: always at 900–1199px; at 1200px+ when collapsed */
@media screen and (min-width: 900px) and (max-width: 1199.98px) {
  body { padding-left: var(--side-mini); }
  .topbar { margin-left: calc(-1 * var(--side-mini)); }
  .mainnav { width: var(--side-mini); padding: 16px 10px; }
  .mainnav a { justify-content: center; padding: 0; }
  .mainnav a span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .toasts { left: calc(50% + var(--side-mini) / 2); }
}
@media screen and (min-width: 1200px) {
  .side-toggle {
    display: flex; align-items: center; gap: 12px; margin-top: auto;
    min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px; background: none;
    color: var(--muted); font: 500 14px var(--font); cursor: pointer; text-align: left;
  }
  .side-toggle:hover { background: var(--cream); color: var(--maroon); }
  .side-toggle svg { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
  html.side-collapsed body { padding-left: var(--side-mini); }
  html.side-collapsed .topbar { margin-left: calc(-1 * var(--side-mini)); }
  html.side-collapsed .mainnav { width: var(--side-mini); padding: 16px 10px; }
  html.side-collapsed .mainnav a, html.side-collapsed .side-toggle { justify-content: center; padding: 0; }
  html.side-collapsed .mainnav a span, html.side-collapsed .side-toggle span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  html.side-collapsed .side-toggle svg { transform: rotate(180deg); }
  html.side-collapsed .toasts { left: calc(50% + var(--side-mini) / 2); }
}
@media screen and (min-width: 1200px) and (prefers-reduced-motion: reduce) { .side-toggle svg { transition: none; } }

/* wider screens: use the room */
@media screen and (min-width: 1100px) {
  .key-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .key-stats.home-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  /* long lists (stock, bills, customers, orders…): cards side by side */
  .view > .item-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 12px; align-items: start; }
  .view > .item-list > .empty-state, .view > .item-list > p { grid-column: 1 / -1; }
  /* bill: pieces, old gold and discount on the left; total and payment on the right */
  .bill-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 420px); gap: 24px; align-items: start; }
  .bill-cols > * + * { margin-top: 0; }
}
@media screen and (min-width: 1100px) {
  /* pages that are mainly one form (add / edit piece, settings, website) stay at a comfortable width */
  .view:has(> form.card.form) { max-width: 1100px; }
  /* More page: banner and card grid share one width, so wide screens stay balanced and cards don't over-stretch */
  .view:has(> .tiles) { max-width: 1280px; }
}

/* Silver stock (Upgrade 2) */
.sv-table { min-width: 560px; }
.sv-table th.num, .sv-table td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sv-table tr.sv-add td.num:nth-last-child(2) { color: var(--ok); }
.sv-table tr.sv-sold td.num:nth-last-child(2), .sv-table tr.sv-remove td.num:nth-last-child(2) { color: var(--bad); }
.sv-rate { display: flex; align-items: center; min-height: 48px; font-size: 18px; color: var(--maroon); }

/* Online: who changed today's rates (owner Home), phones for login codes (owner Settings) */
.rate-log { margin: 6px 0 0; padding-left: 18px; font-size: 13px; color: var(--muted); }
.rate-log li { margin: 2px 0; }
.phone-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.phone-list li > span { display: flex; flex-direction: column; }
.backup-status { display: flex; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 14px; font-weight: 600; }
.backup-status .ic { width: 18px; height: 18px; }
.backup-list li { display: flex; justify-content: space-between; gap: 8px; }
