/* Naa Mary Shops POS
   Palette: aubergine & gold on porcelain — classic beauty-counter feel. */
:root {
  --plum: #3A1E36;
  --plum-2: #55294D;
  --plum-soft: #F3E8EF;
  --rose: #B4566C;
  --gold: #C29A4E;
  --gold-soft: #F6EEDD;
  --bg: #FAF6F7;
  --surface: #FFFFFF;
  --line: #EADFE3;
  --ink: #2B1828;
  --muted: #7B6676;
  --ok: #2F7552;
  --ok-bg: #E5F2EA;
  --warn: #9A6412;
  --warn-bg: #FBF0DC;
  --danger: #A3283C;
  --danger-bg: #FBE6E9;
  --serif: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --shadow: 0 1px 2px rgba(58, 30, 54, .06), 0 4px 16px rgba(58, 30, 54, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--plum-2); }
img { max-width: 100%; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.num { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.r { text-align: right; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 10px; }
.mt { margin-top: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-lg { display: flex; flex-direction: column; gap: 22px; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Forms ---------- */
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--ink); cursor: pointer; }
input, select, textarea {
  font: 15px var(--sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; min-height: 42px; width: 100%;
}
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; accent-color: var(--plum); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--plum-2); box-shadow: 0 0 0 3px var(--plum-soft); }
input:disabled { background: var(--bg); color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.span-2 { grid-column: span 2; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 14px var(--sans); padding: 10px 16px; min-height: 42px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { border-color: var(--plum-2); }
.btn.primary { background: var(--plum); border-color: var(--plum); color: #fff; }
.btn.primary:hover { background: var(--plum-2); }
.btn.primary:disabled { background: #B9A9B6; border-color: #B9A9B6; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 13px; }
.btn.lg { min-height: 52px; font-size: 16px; }
.btn.block { width: 100%; }
.btn.danger { background: var(--surface); border-color: var(--danger-bg); color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.push-right { margin-left: auto; }
.row-actions { display: inline-flex; gap: 6px; align-items: center; justify-content: flex-end; }
.row-actions form { margin: 0; }
form.inline { display: inline; }

.alert { padding: 12px 16px; border-radius: var(--r-sm); margin-bottom: 16px; font-weight: 500; border-left: 4px solid; }
.alert.success { background: var(--ok-bg); color: var(--ok); }
.alert.error { background: var(--danger-bg); color: var(--danger); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--plum-soft); color: var(--plum-2); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.role-admin { background: var(--gold-soft); color: #7A5A1E; }

/* ---------- Monogram crest & product placeholders ---------- */
.crest {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%;
  border: 1.5px solid var(--gold); color: var(--gold); font: italic 600 19px/1 var(--serif); letter-spacing: .5px; flex: none;
}
.monogram { display: grid; place-items: center; font: 600 22px/1 var(--serif); }
.tone-1 { background: #F6E1E4; color: #8E3F52; }
.tone-2 { background: #F1E6DA; color: #7E5A35; }
.tone-3 { background: #E3ECE4; color: #3F6A4F; }
.tone-4 { background: #EAE3F2; color: #5A4580; }
.tone-5 { background: #FBE8DC; color: #9A5530; }
.tone-6 { background: #EDE7DD; color: #6A5B44; }

.thumb { width: 44px; height: 44px; border-radius: var(--r-sm); object-fit: cover; flex: none; }
img.thumb { background: #fff; border: 1px solid var(--line); }
.thumb.sm { width: 38px; height: 38px; }
.thumb.monogram { font-size: 17px; border: 0; }

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 236px; flex: none; background: var(--plum); color: #EADCE6; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 22px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; padding: 0 8px 22px; border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 14px; }
.brand-name { font: 600 22px/1.1 var(--serif); color: #fff; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-sm);
  color: #D9C6D3; text-decoration: none; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.on { background: rgba(194,154,78,.16); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.sidebar svg, .menu-btn svg, .search svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding: 14px 8px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong { color: #fff; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { font-size: 12px; color: var(--gold); }
.signout { color: #D9C6D3; font-size: 13px; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.page-title { font: 600 28px/1.1 var(--serif); color: var(--plum); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.branch-switch select { min-height: 38px; padding: 6px 34px 6px 12px; font-weight: 600; background-color: var(--plum-soft); border-color: transparent; color: var(--plum); }
.branch-pill { background: var(--plum-soft); color: var(--plum); font-weight: 600; padding: 8px 14px; border-radius: 999px; font-size: 14px; }
.today { color: var(--muted); font-size: 14px; white-space: nowrap; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; color: var(--plum); cursor: pointer; }
.content { padding: 26px 28px 40px; flex: 1; }
.scrim { display: none; }

/* ---------- Panels & lists ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-head h3, .panel h3 { font: 600 21px/1.2 var(--serif); color: var(--plum); }
.link { font-size: 14px; font-weight: 600; }
.empty { color: var(--muted); padding: 18px 20px; margin: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list.compact li { padding: 9px 0; }
.list .grow span { line-height: 1.35; }
.delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); } .delta.down { color: var(--danger); }
.back { display: inline-block; margin-bottom: 14px; font-weight: 600; font-size: 14px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar > p { margin: 0; }
.filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .filters { margin-bottom: 0; flex: 1; }
.filters label.grow { min-width: 220px; }
.filters label.check { padding-bottom: 10px; }
.inline-add { display: flex; gap: 8px; }
.inline-add input { width: 170px; }

/* ---------- Dashboard ---------- */
.greeting { margin-bottom: 20px; }
.greeting h2 { font: 600 34px/1.15 var(--serif); color: var(--plum); }
.greeting p { margin: 4px 0 0; }
.kpis { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.kpis.three { grid-template-columns: repeat(3, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.kpi-value { font: 600 28px/1.15 var(--serif); color: var(--plum); font-variant-numeric: lining-nums tabular-nums; }
.kpi-sub { font-size: 13px; color: var(--muted); }
.hero-kpi { background: var(--plum); border-color: var(--plum); }
.hero-kpi .kpi-label, .hero-kpi .kpi-sub { color: #D9C6D3; }
.hero-kpi .kpi-value { color: #fff; font-size: 36px; }

.bars { display: flex; align-items: flex-end; gap: 10px; height: 200px; padding-top: 18px; }
.bar-col { flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; }
.bar { width: 100%; max-width: 46px; background: var(--plum-soft); border-radius: 6px 6px 2px 2px; min-height: 3px; }
.bar-col.is-today .bar { background: var(--gold); }
.bar-amt { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-day { font-size: 12px; font-weight: 600; color: var(--muted); }
.bar-col.is-today .bar-day { color: var(--plum); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 700; color: var(--muted); padding: 12px 16px; background: #FCF9FA; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th.r { text-align: right; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr.is-void td { color: var(--muted); }
.table tr.is-void td a { text-decoration: line-through; }
.table tr.is-off { opacity: .55; }
.t-thumb { width: 60px; }
.stock-form { display: grid; grid-template-columns: 1.3fr 80px 1fr auto; gap: 8px; min-width: 460px; }
.stock-form select, .stock-form input { min-height: 36px; padding: 6px 10px; font-size: 14px; }

.tabs { display: flex; gap: 6px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--plum); border-color: var(--gold); }
.transfer-lines { display: flex; flex-direction: column; gap: 10px; margin: 16px 0 10px; }
.tline { display: grid; grid-template-columns: 1fr 100px auto; gap: 8px; }

/* ---------- Product form ---------- */
.product-form { display: grid; grid-template-columns: 240px 1fr; gap: 28px; }
.photo-col { display: flex; flex-direction: column; gap: 10px; }
.photo-drop { cursor: pointer; color: var(--muted); font-weight: 500; }
.photo { width: 240px; height: 240px; border-radius: var(--r); object-fit: cover; display: grid; place-items: center; font-size: 56px; border: 1px solid var(--line); }
.photo.placeholder { background: var(--bg); border: 2px dashed var(--line); font: 600 15px var(--sans); color: var(--muted); }
.photo-hint { font-size: 13px; line-height: 1.45; }
.photo-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-buttons .btn { cursor: pointer; flex: 1 1 auto; justify-content: center; }
#photoStatus:empty { display: none; }
#photoStatus { color: #B3261E; }

/* ---------- Staff & branches ---------- */
.staff-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.staff-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.staff-card.is-off { opacity: .6; }
.staff-top { display: flex; align-items: center; gap: 12px; }
.staff-top h3 { font: 600 20px/1.2 var(--serif); color: var(--plum); }
.staff-top p { margin: 0; }
.avatar { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font: 600 18px var(--serif); flex: none; }
.staff-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.staff-card > p { margin: 0; }
.staff-actions { display: flex; gap: 6px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 12px; }
.role-guide dl { margin: 12px 0 0; }
.role-guide dt { font-weight: 700; color: var(--plum); margin-top: 12px; }
.role-guide dd { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.branch-list { display: flex; flex-direction: column; gap: 14px; }
.branch-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px 20px; }
.branch-card.is-off { opacity: .6; }
.branch-card-head { display: flex; justify-content: space-between; gap: 12px; }
.branch-card h3 { font: 600 23px/1.2 var(--serif); color: var(--plum); }
.branch-card-head p { margin: 2px 0 0; }
.branch-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.branch-stats dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.branch-stats dd { margin: 2px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- POS ---------- */
.pos-page .content { padding: 0; display: flex; flex-direction: column; }
.pos-page .content > .alert { margin: 16px 20px 0; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; flex: 1; min-height: 0; }
.catalog { padding: 18px 22px 30px; min-width: 0; }
.catalog-tools { position: sticky; top: 69px; z-index: 5; background: var(--bg); padding-bottom: 14px; display: flex; flex-direction: column; gap: 12px; }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 14px; color: var(--muted); }
.search input { padding-left: 44px; padding-right: 50px; min-height: 50px; font-size: 16px; border-radius: var(--r); background: var(--surface); }
.search kbd { position: absolute; right: 12px; font: 600 11px var(--sans); color: var(--muted); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; font: 600 14px var(--sans); padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.chip.on { background: var(--plum); border-color: var(--plum); color: #fff; }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.pcard {
  display: flex; flex-direction: column; text-align: left; padding: 0; overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); font: inherit; color: inherit;
  transition: border-color .15s, transform .1s;
}
.pcard:hover { border-color: var(--rose); }
.pcard:active { transform: scale(.98); }
.pcard.is-out { cursor: not-allowed; }
.pcard.is-out .pcard-img { filter: grayscale(1); opacity: .5; }
.pcard-img { position: relative; aspect-ratio: 1; background: #fff; border-bottom: 1px solid var(--line); }
.pcard-img { display: block; overflow: hidden; min-height: 0; }
.pcard-img img, .pcard-img .monogram { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.pcard-img .monogram { font-size: 42px; }
.in-cart { position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; background: var(--plum); color: #fff; font-weight: 700; font-size: 14px; display: grid; place-items: center; box-shadow: 0 0 0 2px #fff; }
.pcard-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pcard-name { font-weight: 600; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard-foot { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; margin-top: auto; padding-top: 6px; }
.pcard-price { font-weight: 700; color: var(--plum); font-variant-numeric: tabular-nums; }
.stock { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.stock.low { color: var(--warn); }
.stock.out { color: var(--danger); }

.cart { background: var(--surface); border-left: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 69px; height: calc(100vh - 69px); }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.cart-head h2 { font: 600 24px var(--serif); color: var(--plum); }
.cart-list { list-style: none; margin: 0; padding: 4px 16px; overflow-y: auto; flex: 1; }
.cart-empty { flex: 1; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 20px; }
.line { display: grid; grid-template-columns: 40px 1fr auto; grid-template-areas: "img info x" "img qty total" "img disc disc"; gap: 4px 10px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: center; }
.line-img { grid-area: img; width: 40px; height: 40px; border-radius: var(--r-sm); overflow: hidden; align-self: start; }
.line-img img, .line-img .monogram { width: 100%; height: 100%; object-fit: cover; font-size: 15px; }
.line-info { grid-area: info; min-width: 0; }
.line-info strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-info span { font-size: 12px; color: var(--muted); }
.line-x { grid-area: x; background: none; border: 0; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.line-x:hover { color: var(--danger); }
.qty { grid-area: qty; display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); width: max-content; }
.qty button { width: 34px; height: 34px; border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--plum); }
.qty input { width: 44px; min-height: 34px; border: 0; padding: 0; text-align: center; font-weight: 700; -moz-appearance: textfield; }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }
.line-total { grid-area: total; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

.cart-foot { border-top: 1px solid var(--line); padding: 14px 20px 18px; display: flex; flex-direction: column; gap: 12px; background: #FDFBFC; }
.totals > div { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-variant-numeric: tabular-nums; }
.disc-row label { flex-direction: row; font-size: 15px; font-weight: 400; color: var(--ink); }
.disc-input { display: flex; gap: 4px; width: 160px; }
.disc-input input { min-height: 36px; padding: 4px 8px; text-align: right; }
.disc-input select { width: 66px; min-height: 36px; padding: 4px; }
.grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px !important; }
.grand span:first-child { font-weight: 700; }
.grand span:last-child { font: 600 34px/1 var(--serif); color: var(--plum); }

.pay-methods { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay-methods label { display: block; }
.pay-methods input { position: absolute; opacity: 0; }
.pay-methods span { display: block; text-align: center; padding: 10px 6px; border: 1px solid var(--line); border-radius: var(--r-sm); font-weight: 600; color: var(--ink); cursor: pointer; background: var(--surface); }
.pay-methods input:checked + span { border-color: var(--plum); background: var(--plum-soft); color: var(--plum); box-shadow: inset 0 0 0 1px var(--plum); }
.pay-methods input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.pay-fields { display: flex; flex-direction: column; gap: 8px; }
.change { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }
.change strong { color: var(--ok); }
.change.short strong { color: var(--danger); }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { flex: 1; font: 600 13px var(--sans); padding: 7px 4px; border: 1px dashed var(--line); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; color: var(--plum-2); }
.quick-cash button:hover { border-color: var(--plum-2); border-style: solid; }
.customer summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--plum-2); }
.customer[open] { display: flex; flex-direction: column; gap: 8px; }
.momo-hint { font-size: 13px; color: var(--muted); margin: 0; }

.dialog { border: 0; border-radius: var(--r-lg); padding: 32px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 60px rgba(58,30,54,.25); }
.dialog::backdrop { background: rgba(43, 24, 40, .45); }
.done { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.done-mark { width: 64px; height: 64px; border-radius: 50%; background: var(--ok-bg); color: var(--ok); display: grid; place-items: center; font-size: 30px; font-weight: 700; animation: pop .35s ease-out; }
.done h2 { font: 600 30px var(--serif); color: var(--plum); }
.done p { margin: 0; }
.done-change { font: 600 24px var(--serif); color: var(--ok); }
.done .row { margin-top: 12px; justify-content: center; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--r-sm); font-weight: 500; opacity: 0; pointer-events: none; transition: .2s; z-index: 100; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Floating "Pay" button on the sale page: shows once something is in the sale */
.cart-jump { display: none; }
.cart-jump:not([hidden]) {
  display: flex; align-items: center; gap: 14px;
  position: fixed; bottom: 24px; right: 24px; z-index: 30;
  background: var(--plum); color: #fff; border: 0; border-radius: 999px; padding: 8px 8px 8px 8px;
  font: 600 15px var(--sans); box-shadow: 0 10px 30px rgba(58,30,54,.35); cursor: pointer;
  transition: transform .25s ease, opacity .25s ease, background .15s;
}
.cart-jump:hover { background: var(--plum-2); }
.cj-count { min-width: 40px; height: 40px; padding: 0 10px; border-radius: 999px; background: var(--gold); color: var(--plum); display: grid; place-items: center; font: 700 17px/1 var(--sans); font-variant-numeric: tabular-nums; }
.cj-text { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.1; }
.cj-label { font-size: 12px; font-weight: 600; color: #E3CFDD; }
.cj-text strong { font: 600 21px/1.1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.cj-go { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.14); padding: 10px 16px; border-radius: 999px; font-weight: 700; }
.cj-go svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cart-jump.bump { animation: cj-bump .35s ease-out; }
.cart-jump.bump .cj-count { animation: cj-pop .35s ease-out; }
.cart-jump.away { opacity: 0; transform: translateY(140%); pointer-events: none; }
@keyframes cj-bump { 40% { transform: scale(1.06); } }
@keyframes cj-pop { 40% { transform: scale(1.3); } }
.pos-page .catalog { padding-bottom: 100px; }
.pos-page.has-cart .toast { bottom: 96px; }
@media (max-width: 960px) {
  .cart-jump:not([hidden]) {
    left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-radius: var(--r); padding: 10px 10px 10px 12px;
  }
  .cj-text { flex: 1; }
  .pos-page.has-cart .toast { bottom: 92px; }
}

/* ---------- Sign in ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--plum); background-image: radial-gradient(circle at 20% 15%, #55294D 0, transparent 45%), radial-gradient(circle at 85% 90%, #4A2343 0, transparent 40%); }
.auth-card { background: var(--surface); border-radius: 22px; padding: 38px 34px; width: 100%; max-width: 400px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.auth-card.wide { max-width: 620px; }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .crest { width: 64px; height: 64px; font-size: 26px; background: var(--plum); margin-bottom: 14px; }
.auth-brand h1 { font: 600 34px/1.1 var(--serif); color: var(--plum); }
.auth-brand p { margin: 6px 0 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
  .kpis { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 960px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(43,24,40,.4); z-index: 40; }
  .menu-btn { display: block; }
  .topbar { padding: 12px 16px; }
  .today { display: none; }
  .content { padding: 18px 16px 30px; }
  .grid-2, .grid-main-side { grid-template-columns: 1fr; }
  .pos { grid-template-columns: 1fr; }
  .catalog-tools { top: 63px; }
  .cart { position: static; height: auto; border-left: 0; border-top: 1px solid var(--line); }
  .cart-list { max-height: none; }
  .product-form { grid-template-columns: 1fr; }
  .photo { width: 100%; max-width: 280px; height: auto; aspect-ratio: 1; }
}
@media (max-width: 600px) {
  .page-title { font-size: 22px; }
  .kpis, .kpis.three { grid-template-columns: 1fr 1fr; gap: 10px; }
  .hero-kpi { grid-column: span 2; }
  .kpi-value { font-size: 22px; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .catalog { padding: 14px; }
  .branch-switch select { max-width: 150px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- Add stock (products page) ---------- */
.spread { margin-top: 2px; line-height: 1.35; white-space: nowrap; }
.stock-panel { margin-top: 16px; }
.stock-panel .list { margin-bottom: 16px; }
.add-stock-form { display: grid; grid-template-columns: 110px 1fr 1.4fr auto; gap: 10px; align-items: end; }
.add-stock-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; }
.add-stock-dialog { border: 1px solid var(--line); border-radius: var(--r-lg); padding: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); }
.add-stock-dialog::backdrop { background: rgba(30, 10, 25, .45); }
.add-stock-dialog .add-stock-form { grid-template-columns: 1fr; align-items: stretch; }
.add-stock-dialog h3 { font: 600 21px/1.2 var(--serif); color: var(--plum); margin: 0; }
.add-stock-dialog p { margin: 0; }
@media (max-width: 720px) {
  .add-stock-form { grid-template-columns: 1fr 1fr; }
  .add-stock-form label:nth-of-type(3), .add-stock-form button { grid-column: 1 / -1; }
}

/* ---------- Remove stock & manage categories (products page) ---------- */
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); }
.rs-have { font-weight: 600; color: var(--plum-2); }
.cats-dialog { display: none; }
.cats-dialog[open] { display: flex; flex-direction: column; gap: 12px; max-height: min(80vh, 640px); }
.cats-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.cats-dialog p { margin: 0; }
.cats-list { overflow-y: auto; margin: 0; }
.cats-list form { margin: 0; }
.row-actions { flex-wrap: wrap; }

/* ==========================================================
   Checkout page (checkout.php): full screen, items left, payment right
   ========================================================== */
.checkout-page .sidebar, .checkout-page .topbar, .checkout-page .scrim { display: none; }
.checkout-page .content { padding: 0; }
.checkout-page .content > .alert { margin: 12px 16px 0; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace; font-variant-numeric: tabular-nums; }
.co { min-height: 100vh; display: flex; flex-direction: column; }

/* Header bar */
.co-bar { display: flex; align-items: center; gap: 18px; padding: 14px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.co-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.co-title h1 { display: flex; align-items: center; gap: 8px; font: 700 19px var(--sans); color: var(--ink); margin: 0; }
.co-title h1 svg { width: 22px; height: 22px; fill: none; stroke: var(--plum); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.co-title span { font-size: 13px; color: var(--plum-2); margin-top: 3px; }
.co-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.co-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; min-height: 36px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  font: 700 13px var(--sans); color: var(--plum); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.co-btn:hover { border-color: var(--plum-2); background: #FDFBFC; }
.co-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.co-btn.danger { color: var(--danger); border-color: #EDB9C1; }
.co-btn.danger:hover { background: var(--danger-bg); border-color: var(--danger); }
.co-btn:disabled { opacity: .45; cursor: not-allowed; }
.co-count { background: var(--plum); color: #fff; border-radius: 999px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 11px; }
.co-count[hidden] { display: none; }

/* Two columns */
.co-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 380px; }
.co-items { padding: 16px 16px 30px 12px; }
.co-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.co-empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.co-empty[hidden] { display: none; }

/* Item card */
.co-line {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto auto 28px; grid-template-areas: "img info qty price x";
  align-items: center; gap: 16px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
}
.co-thumb { grid-area: img; width: 40px; height: 40px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--plum-soft); }
.co-thumb img, .co-thumb .monogram { width: 100%; height: 100%; object-fit: cover; font-size: 15px; }
.co-info { grid-area: info; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.co-info strong { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.co-info span { font-size: 12px; color: var(--plum-2); }
.co-qty { grid-area: qty; display: flex; align-items: center; gap: 4px; }
.co-qty button { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--plum); font: 700 16px/1 var(--sans); cursor: pointer; }
.co-qty button:hover { border-color: var(--plum-2); background: var(--plum-soft); }
.co-qty input { width: 40px; min-height: 30px; border: 0; padding: 0; text-align: center; font-weight: 700; background: transparent; -moz-appearance: textfield; }
.co-qty input::-webkit-inner-spin-button, .co-disc-box input::-webkit-inner-spin-button { -webkit-appearance: none; }
.co-price { grid-area: price; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 112px; }
.co-line-total { font-weight: 700; font-size: 15px; text-align: right; color: var(--ink); }
.co-line-total s { display: block; font-size: 11px; font-weight: 500; color: var(--muted); }
.co-line-total small { display: block; font-size: 11px; font-weight: 600; color: var(--ok); font-family: var(--sans); }
.co-disc-box { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; height: 26px; }
.co-disc-box:focus-within { border-color: var(--plum-2); box-shadow: 0 0 0 2px var(--plum-soft); }
.co-disc-box input { width: 68px; min-height: 0; height: 24px; border: 0; border-radius: 0; padding: 0 6px; text-align: center; font-size: 13px; color: var(--plum-2); -moz-appearance: textfield; }
.co-disc-box input:focus { box-shadow: none; }
.co-disc-unit { display: grid; place-items: center; min-width: 30px; white-space: nowrap; padding: 0 6px; border-left: 1px solid var(--line); background: var(--plum-soft); color: var(--plum); font: 700 11px var(--sans); }
.co-x { grid-area: x; width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--danger-bg); color: var(--danger); font: 700 16px/1 var(--sans); cursor: pointer; }
.co-x:hover { background: var(--danger); color: #fff; }

/* Right panel */
.co-side { background: var(--surface); border-left: 1px solid var(--line); padding: 20px 20px 28px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 65px; align-self: start; min-height: calc(100vh - 65px); }
.co-label { font: 700 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--plum); margin: 4px 0 -4px; }
.co-customer { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--plum-soft); font: 600 14px var(--sans); color: var(--ink); text-align: left; cursor: pointer; }
.co-customer:hover { border-color: var(--plum-2); }
.co-customer svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--plum); stroke-width: 2; stroke-linecap: round; }
.co-cust-fields { display: flex; flex-direction: column; gap: 8px; }
.co-cust-fields[hidden] { display: none; }
.co-methods { border: 0; padding: 0; margin: 0; display: flex; gap: 8px; flex-wrap: wrap; }
.co-methods label { display: block; }
.co-methods input { position: absolute; opacity: 0; }
.co-methods span { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 80px; height: 56px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font: 700 12px var(--sans); color: var(--plum-2); cursor: pointer; }
.co-methods svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.co-methods input:checked + span { border: 2px solid var(--plum); background: var(--plum-soft); color: var(--plum); }
.co-methods input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.co-row-input { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 4px; }
.co-row-input[hidden] { display: none; }
.co-row-input label { font-size: 14px; font-weight: 600; color: var(--plum-2); }
.co-row-input input { width: 140px; text-align: right; font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-weight: 700; }
#refWrap input { width: 170px; font-family: var(--sans); }
.co-hint { margin: 0; font-size: 13px; color: var(--muted); }
.co-hint[hidden] { display: none; }
.co-summary { border: 1px solid var(--line); border-radius: 10px; background: #FDF9FB; padding: 14px 16px; margin-top: 6px; }
.co-summary > div { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; font-size: 14px; color: var(--plum-2); }
.co-summary > div[hidden] { display: none; }
.co-disc span:last-child { color: var(--ok); }
#changeRow.short span:last-child { color: var(--danger); font-weight: 700; }
.co-summary .co-total { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; font-size: 17px; font-weight: 800; color: var(--ink); }
.co-total .mono { font-size: 18px; }
.co-complete { width: 100%; min-height: 54px; margin-top: 4px; border: 0; border-radius: 12px; background: linear-gradient(180deg, var(--plum-2), var(--plum)); color: #fff; font: 800 16px var(--sans); cursor: pointer; box-shadow: 0 8px 20px rgba(58,30,54,.25); }
.co-complete:hover { filter: brightness(1.08); }
.co-complete:disabled { background: #D9C9D4; box-shadow: none; cursor: not-allowed; filter: none; }

/* Drafts pop-up */
.drafts-dialog { max-width: 520px; padding: 24px; }
.drafts-dialog[open] { display: flex; flex-direction: column; gap: 10px; max-height: min(80vh, 640px); }
.drafts-head { display: flex; justify-content: space-between; align-items: center; }
.drafts-head h2 { font: 600 24px var(--serif); color: var(--plum); margin: 0; }
.drafts-dialog p { margin: 0; }
.drafts-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
.drafts-list li { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.drafts-list li .muted.small { display: block; }

@media (max-width: 960px) {
  .co-body { grid-template-columns: 1fr; }
  .co-side { position: static; min-height: 0; border-left: 0; border-top: 1px solid var(--line); }
  .co-items { padding: 12px; }
}
@media (max-width: 720px) {
  .co-bar { flex-wrap: wrap; gap: 10px 12px; padding: 10px 12px; }
  .co-title { order: -1; flex-basis: calc(100% - 120px); }
  .co-bar > .co-btn:first-child { order: -2; }
  .co-actions { width: 100%; justify-content: stretch; gap: 6px; }
  .co-actions .co-btn { flex: 1; justify-content: center; padding: 8px 6px; }
  .co-line { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "img info x" "qty qty price"; gap: 10px 12px; padding: 12px; }
  .co-x { justify-self: end; }
  .co-price { min-width: 0; }
  .co-qty { padding-left: 52px; }
  .co-methods span { width: auto; flex: 1; }
  .co-methods label { flex: 1; }
}

/* ---------- Live search (stock page) ---------- */
.live-count { margin: 0 0 0 auto; align-self: flex-end; padding-bottom: 10px; }
.js-name mark { background: var(--gold-soft); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: inset 0 -2px 0 var(--gold); }
tr[hidden] { display: none; }

/* ---------- Cancelling a selection (sell page) ---------- */
.pcard-wrap { position: relative; display: flex; }
.pcard-wrap > .pcard { width: 100%; }
.pcard.is-picked { border-color: var(--plum-2); box-shadow: 0 0 0 1px var(--plum-2); }
.pcard-minus {
  position: absolute; top: 8px; left: 8px; z-index: 2; width: 32px; height: 32px; border-radius: 50%;
  border: 0; background: #fff; color: var(--danger); font: 700 20px/1 var(--sans); cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,.18), 0 0 0 1px var(--line); display: grid; place-items: center;
}
.pcard-minus:hover { background: var(--danger); color: #fff; }
.cart-jump:not([hidden]) { padding: 6px; gap: 6px; cursor: default; }
.cart-jump:hover { background: var(--plum); }
.cj-clear {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
}
.cj-clear:hover { background: var(--danger); }
.cj-clear svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.cj-pay { display: flex; align-items: center; gap: 14px; background: none; border: 0; color: inherit; font: inherit; padding: 2px 2px 2px 4px; cursor: pointer; border-radius: 999px; }
.cj-pay:hover .cj-go { background: rgba(255,255,255,.24); }
.toast.has-action { display: flex; align-items: center; gap: 16px; pointer-events: auto; }
.toast-action { background: none; border: 0; padding: 4px 2px; color: var(--gold); font: 700 14px var(--sans); text-transform: uppercase; letter-spacing: .04em; cursor: pointer; }
.toast:not(.show) { pointer-events: none; }
@media (max-width: 960px) {
  .cj-pay { flex: 1; }
  .cj-pay .cj-text { flex: 1; }
}

/* ---------- Camera barcode scanner (sell page) ---------- */
/* The Scan button sits inside the search box, at the right */
.search .scan-btn {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  border: 0; border-radius: 8px; background: var(--plum); color: #fff; font: 700 13px var(--sans); cursor: pointer;
}
.search .scan-btn:hover { background: var(--plum-2); }
.pos-page .search input { padding-right: 140px; }
.pos-page .search kbd { right: 96px; }
.search .scan-btn svg { position: static; color: inherit; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.scan-dialog {
  width: min(560px, 100vw); max-width: 100vw; max-height: 100dvh; padding: 0; border: 0; border-radius: 16px;
  background: #140D13; color: #fff; overflow: hidden;
}
.scan-dialog[open] { display: flex; flex-direction: column; }
.scan-dialog::backdrop { background: rgba(10,6,10,.75); }
.scan-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.scan-head strong { font: 600 20px var(--serif); }
.scan-done { background: #fff; color: var(--plum); border: 0; border-radius: 999px; padding: 8px 18px; font: 700 14px var(--sans); cursor: pointer; }
.scan-stage { position: relative; background: #000; min-height: 240px; }
.scan-view { width: 100%; }
.scan-view video { width: 100% !important; display: block; object-fit: cover; }
.scan-view img[alt="Info icon"], .scan-view img[alt="Camera based scan"] { display: none; }
.scan-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
.scan-flash.ok { animation: scan-ok .45s ease-out; }
.scan-flash.bad { animation: scan-bad .6s ease-out; }
@keyframes scan-ok { 0% { opacity: .55; background: #2E9E6A; } 100% { opacity: 0; } }
@keyframes scan-bad { 0% { opacity: .5; background: #C0394B; } 100% { opacity: 0; } }
.scan-msg { margin: 0; padding: 12px 16px; min-height: 48px; font-size: 15px; line-height: 1.4; color: #E9DDE6; }
.scan-msg.ok { color: #7BE0AE; font-weight: 600; }
.scan-msg.bad { color: #FFB3BD; font-weight: 600; }
.scan-msg a { color: var(--gold); }
.scan-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid rgba(255,255,255,.1); }
.scan-tally { font-weight: 700; font-variant-numeric: tabular-nums; }
.scan-pay { background: var(--gold); color: var(--plum); border: 0; border-radius: 999px; padding: 10px 22px; font: 800 15px var(--sans); cursor: pointer; }
.scan-pay:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 600px) {
  .search .scan-btn span { display: none; }
  .search .scan-btn { padding: 8px 10px; }
  .pos-page .search input { padding-right: 60px; }
  .scan-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .scan-stage { flex: 1; display: flex; align-items: center; }
  .search kbd { display: none; }
}
.scan-msg .scan-detail { display: block; margin-top: 6px; font: 400 12px/1.35 ui-monospace, Menlo, Consolas, monospace; color: rgba(233,221,230,.6); word-break: break-word; }

/* ---------- Barcode box on the product form ---------- */
.barcode-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.barcode-field { display: flex; gap: 8px; align-items: stretch; }
.barcode-field input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.barcode-field input.is-bad { border-color: var(--danger); }
.barcode-scan {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px; min-height: 42px;
  border: 0; border-radius: var(--r-sm); background: var(--plum); color: #fff; font: 700 14px var(--sans); cursor: pointer;
}
.barcode-scan:hover { background: var(--plum-2); }
.barcode-scan svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.barcode-note { font-size: 13px; font-weight: 500; line-height: 1.35; }
.barcode-note:empty { display: none; }
.barcode-note.ok { color: var(--ok); }
.barcode-note.bad { color: var(--danger); font-weight: 600; }

/* ==========================================================
   Fit and finish on every screen size
   Phones up to 600px, tablets up to 960px, laptops and desktops above.
   These rules come last on purpose so they win over the older ones above.
   ========================================================== */

/* Money never breaks across two lines */
.kpi-value, .pcard-price, .branch-stats dd, .co-line-total, .line-total { white-space: nowrap; }
.mono { font-family: var(--sans); font-variant-numeric: tabular-nums; }

/* Very wide screens: keep pages from stretching edge to edge */
.content { width: 100%; max-width: 1640px; margin-inline: auto; }
.pos-page .content, .checkout-page .content { max-width: none; }

/* ---------- Toolbars ---------- */
.toolbar-actions { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.inline-add input { width: 180px; }

/* ---------- Product cards on the Sell page ---------- */
.pcard-foot { flex-wrap: wrap; row-gap: 2px; }

/* ---------- Tables: action buttons ---------- */
.rt .row-actions { flex-wrap: nowrap; }
.rt td.rt-actions .badge { margin-top: 6px; }

/* Stock page: the update form needs room, so recent changes move below until the screen is wide */
.grid-main-side.wide-main { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1500px) {
  .grid-main-side.wide-main { grid-template-columns: minmax(0, 1fr) 340px; }
}

/* ---------- Laptops and small desktops ---------- */
@media (max-width: 1279px) {
  /* Product actions sit in a tidy 2 × 2 block instead of a ragged pile */
  .rt .row-actions { display: inline-grid; grid-template-columns: repeat(2, max-content); justify-content: end; }
  .rt .row-actions > *, .rt .row-actions form .btn { width: 100%; }
}
@media (min-width: 961px) and (max-width: 1279px) {
  .grid-main-side { grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); }
}

/* ---------- Tablets ---------- */
@media (max-width: 960px) {
  .page-title { font-size: 25px; }
  .content { padding: 18px 18px 32px; }
  .greeting h2 { font-size: 30px; }
  .bars { height: 170px; }

  /* Checkout keeps items and payment side by side on a tablet */
  .co-body { grid-template-columns: minmax(0, 1fr) 340px; }
  .co-side { position: sticky; top: 65px; min-height: calc(100vh - 65px); border-top: 0; border-left: 1px solid var(--line); }
  .co-items { padding: 14px 12px 30px; }
  .co-line { grid-template-columns: 40px minmax(0, 1fr) auto; grid-template-areas: "img info x" "qty qty price"; gap: 10px 12px; padding: 12px; }
  .co-x { justify-self: end; }
  .co-price { min-width: 0; }
  .co-qty { padding-left: 52px; }
  .co-methods label { flex: 1; }
  .co-methods span { width: auto; }
}

@media (min-width: 700px) and (max-width: 960px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
}

/* ---------- Phones and narrow tablets: tables become cards ---------- */
@media (max-width: 760px) {
  /* Checkout stacks: items first, payment below */
  .co-body { grid-template-columns: 1fr; align-content: start; }
  .co-side { position: static; min-height: 0; border-left: 0; border-top: 1px solid var(--line); }
}


/* ---------- Tables turn into cards when there is not enough room for columns ----------
   Decided by the width the table actually has (so a laptop with the menu open behaves
   like a tablet), with a screen-width fallback for older browsers. */
.table-wrap { container-type: inline-size; }
@media (max-width: 760px) {
  .rt thead { display: none; }
  .rt, .rt tbody { display: block; }
  .rt tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .rt tr:last-child { border-bottom: 0; }
  .rt tr[hidden] { display: none; }
  .rt td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  .rt td.t-thumb { width: auto; }
  .rt td.rt-thumb { order: -3; flex: none; }
  .rt td.rt-title { order: -2; flex: 1 1 45%; align-self: center; }
  .rt td.rt-title strong { display: block; line-height: 1.3; }
  .rt td.rt-end { order: -1; flex: none; margin-left: auto; align-self: center; text-align: right; font-weight: 700; }
  .rt td[data-label] { flex: 1 1 26%; font-size: 14px; }
  .rt td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rt tr::before { content: ""; order: 0; flex: 1 1 100%; height: 0; margin-top: -10px; }
  .rt td[data-label] { order: 1; }
  .rt td.rt-actions { order: 2; flex: 1 1 100%; }
  .rt td.rt-actions.rt-tight { flex: none; margin-left: auto; align-self: flex-end; }
  .rt .spread { white-space: normal; }
  .rt .row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .rt .row-actions > *, .rt .row-actions form .btn { width: 100%; }
  .rt tr.is-off { opacity: .6; }

  /* Stock page: the update form under each product */
  .stock-form { min-width: 0; grid-template-columns: 90px minmax(0, 1fr) auto; }
  .stock-form select { grid-column: 1 / -1; }
  .stock-form input, .stock-form select, .stock-form .btn { min-height: 42px; font-size: 15px; }

}
@container (max-width: 880px) {
  .rt thead { display: none; }
  .rt, .rt tbody { display: block; }
  .rt tr { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .rt tr:last-child { border-bottom: 0; }
  .rt tr[hidden] { display: none; }
  .rt td { display: block; padding: 0; border: 0; text-align: left; min-width: 0; }
  .rt td.t-thumb { width: auto; }
  .rt td.rt-thumb { order: -3; flex: none; }
  .rt td.rt-title { order: -2; flex: 1 1 45%; align-self: center; }
  .rt td.rt-title strong { display: block; line-height: 1.3; }
  .rt td.rt-end { order: -1; flex: none; margin-left: auto; align-self: center; text-align: right; font-weight: 700; }
  .rt td[data-label] { flex: 1 1 26%; font-size: 14px; }
  .rt td[data-label]::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rt tr::before { content: ""; order: 0; flex: 1 1 100%; height: 0; margin-top: -10px; }
  .rt td[data-label] { order: 1; }
  .rt td.rt-actions { order: 2; flex: 1 1 100%; }
  .rt td.rt-actions.rt-tight { flex: none; margin-left: auto; align-self: flex-end; }
  .rt .spread { white-space: normal; }
  .rt .row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
  .rt .row-actions > *, .rt .row-actions form .btn { width: 100%; }
  .rt tr.is-off { opacity: .6; }

  /* Stock page: the update form under each product */
  .stock-form { min-width: 0; grid-template-columns: 90px minmax(0, 1fr) auto; }
  .stock-form select { grid-column: 1 / -1; }
  .stock-form input, .stock-form select, .stock-form .btn { min-height: 42px; font-size: 15px; }

}
/* Two cards side by side when there is room */
@container (min-width: 600px) and (max-width: 880px) {
  .rt tbody { display: grid; grid-template-columns: 1fr 1fr; }
  .rt tr, .rt tr:last-child { border-bottom: 1px solid var(--line); }
  .rt tr:nth-child(odd of :not([hidden])) { border-right: 1px solid var(--line); }
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .topbar { gap: 10px; padding: 10px 12px; }
  .menu-btn { margin-left: -4px; }
  .page-title { font-size: 21px; }
  .branch-switch select { max-width: 44vw; min-height: 36px; font-size: 14px; padding: 6px 30px 6px 10px; text-overflow: ellipsis; }
  .branch-pill { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 7px 12px; font-size: 13px; }
  .content { padding: 14px 12px 28px; }
  .alert { margin-bottom: 12px; }
  .panel { padding: 16px; border-radius: var(--r); }
  .panel.flush { padding: 0; }
  .panel-head h3, .panel h3 { font-size: 20px; }
  .greeting { margin-bottom: 14px; }
  .greeting h2 { font-size: 26px; }
  .grid-2, .grid-main-side { gap: 14px; }
  .bars { gap: 6px; height: 150px; }
  .bar-amt { font-size: 10px; }

  /* Figures at the top of a page: the big one as a card, the rest as one tidy list */
  .kpis, .kpis.three { grid-template-columns: 1fr; gap: 0; margin-bottom: 14px; }
  .kpis .hero-kpi { grid-column: auto; margin-bottom: 10px; border-radius: var(--r); padding: 16px 18px; }
  .kpis .hero-kpi .kpi-value { font-size: 32px; }
  .kpis .kpi:not(.hero-kpi) { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; border-radius: 0; border-top: 0; padding: 12px 16px; }
  .kpis .kpi:not(.hero-kpi) .kpi-value { font-size: 21px; text-align: right; }
  .kpis .kpi:not(.hero-kpi) .kpi-label { font-size: 14px; }
  .kpis > .kpi:first-child:not(.hero-kpi), .kpis > .hero-kpi + .kpi { border-top: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; }
  .kpis > .kpi:last-child:not(.hero-kpi) { border-radius: 0 0 var(--r) var(--r); }

  /* Search and filter rows */
  .toolbar { gap: 12px; margin-bottom: 14px; }
  .toolbar .filters, .filters { width: 100%; gap: 10px; margin-bottom: 14px; }
  .toolbar .filters { margin-bottom: 0; }
  .filters label.grow { flex: 1 1 100%; min-width: 0; }
  .filters > label:not(.grow):not(.check) { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .filters > .btn, .filters > a.btn { flex: 1 1 auto; }
  .filters label.check { padding-bottom: 0; }
  .live-count { margin: 0; padding: 0; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions > * { flex: 1 1 auto; }
  .inline-add { flex: 1 1 100%; }
  .inline-add input { width: auto; flex: 1; min-width: 0; }

  /* Sell page */
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pcard-img { aspect-ratio: 4 / 3; }
  .pcard-body { padding: 8px 10px 10px; }
  .pcard-name { font-size: 13.5px; }
  .catalog { padding: 12px; }
  .search input { min-height: 46px; font-size: 16px; }
  .chip { padding: 7px 14px; font-size: 13px; }

  /* Product form */
  .product-form { gap: 18px; }
  .photo-col { align-items: stretch; }
  .photo { max-width: 200px; }
  .add-stock-form { grid-template-columns: 1fr 1fr; }

  /* Branches, staff, transfers */
  .branch-card { padding: 16px; border-radius: var(--r); }
  .branch-card h3 { font-size: 21px; }
  .branch-stats { gap: 8px; }
  .branch-stats dd { font-size: 14px; }
  .staff-grid { grid-template-columns: 1fr; gap: 12px; }
  .staff-card { border-radius: var(--r); }
  .tline { grid-template-columns: minmax(0, 1fr) auto; }
  .tline select { grid-column: 1 / -1; }
  .tabs { overflow-x: auto; scrollbar-width: none; }
  .tabs a { white-space: nowrap; }

  /* Pop-ups use the full width */
  .dialog, .add-stock-dialog { padding: 20px; width: calc(100vw - 24px); }
}

/* Very small phones */
@media (max-width: 360px) {
  .page-title { font-size: 19px; }
  .kpis .hero-kpi .kpi-value { font-size: 28px; }
  .rt td[data-label] { flex-basis: 40%; }
}

/* Checkout: same typeface for every amount, payment buttons share the row evenly */
.co-row-input input { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.co-methods label { flex: 1; }
.co-methods span { width: auto; }

/* Closed branches: tucked away at the bottom of the Branches page */
.closed-branches { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--r-lg); padding: 14px 18px; }
.closed-branches summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.closed-branches[open] summary { margin-bottom: 8px; }
.closed-branches > p { margin: 0 0 6px; }
.closed-branches .list li { flex-wrap: wrap; }

/* ---------- Touch screens ----------
   No double-tap zoom on buttons and cards (pinch to zoom still works),
   and no grey flash when something is tapped. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
a, button, label, summary, select, input, .pcard, .chip { -webkit-tap-highlight-color: transparent; }
.pcard, .pcard-minus, .chip, .cart-jump, .btn { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.pcard img { -webkit-user-drag: none; pointer-events: none; }
/* A gentle press instead of the flash */
.pcard { transition: transform .08s ease, border-color .15s ease, box-shadow .15s ease; }
.pcard:active:not([disabled]) { transform: scale(.97); }
@media (hover: none) { .pcard:hover { border-color: var(--line); } .pcard.is-picked:hover { border-color: var(--plum-2); } }
