/* =========================================================================
   MintX POS - design system
   Mobile-first. Every rule below the base layer widens the layout; nothing
   narrows it. Base styles target a 320px phone.
   ========================================================================= */

/* --- Tokens -------------------------------------------------------------- */

:root {
  --brand-50:  #e9fbf3;
  --brand-100: #c9f4e2;
  --brand-200: #93e8c6;
  --brand-300: #57d6a6;
  --brand-400: #24bd86;
  --brand-500: #0ea06d;
  --brand-600: #068058;
  --brand-700: #056548;
  --brand-800: #06503a;

  --danger:  #e0403c;
  --danger-bg: #fdecec;
  --warning: #e08a00;
  --warning-bg: #fff4e0;
  --success: #12a150;
  --success-bg: #e7f8ee;
  --info:    #2563eb;
  --info-bg: #e8effd;

  --bg:        #ffffff;
  --surface:   #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #eef1f4;
  --border:    #e6eaee;
  --border-strong: #d5dce3;

  --text:      #10181f;
  --text-2:    #56646f;
  --text-3:    #8a97a2;
  --on-brand:  #ffffff;

  --shadow-1: 0 1px 2px rgba(16, 24, 31, .06);
  --shadow-2: 0 2px 8px rgba(16, 24, 31, .08);
  --shadow-3: 0 8px 28px rgba(16, 24, 31, .14);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* Minimum comfortable touch target. Nothing interactive goes below this. */
  --tap: 46px;
  --appbar-h: 56px;
  --bottomnav-h: 60px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);

  --gap: 12px;
  --pad: 14px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22, .61, .36, 1);
}

[data-theme="dark"] {
  --bg:        #0d1216;
  --surface:   #151d23;
  --surface-2: #1b252c;
  --surface-3: #24313a;
  --border:    #27343d;
  --border-strong: #35454f;

  --text:      #eaf0f4;
  --text-2:    #a3b1bc;
  --text-3:    #6e7f8b;

  --danger-bg:  #3a1c1c;
  --warning-bg: #3a2c12;
  --success-bg: #10301f;
  --info-bg:    #172542;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .45);
  --shadow-3: 0 8px 28px rgba(0, 0, 0, .55);
}

/* --- Reset --------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100dvh;
  /* Horizontal clip only. Never set overflow-x on html as well — that
     nested scrollport freezes up/down swipes on Android and iOS. */
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
@supports (overflow-x: clip) {
  body {
    overflow-x: clip;
    overflow-y: visible;
  }
}

/* Native app chrome: no text selection or long-press callout on controls. */
body.is-standalone {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
body.is-standalone input,
body.is-standalone textarea,
body.is-standalone .selectable { user-select: text; -webkit-user-select: text; }

img, svg, video { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-600); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

:focus-visible {
  outline: 2px solid var(--brand-400);
  outline-offset: 2px;
}

.ico { width: 22px; height: 22px; flex: none; }
.ico--sm { width: 18px; height: 18px; }
.ico--lg { width: 26px; height: 26px; }
.ico--xl { width: 40px; height: 40px; }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.tabnum { font-variant-numeric: tabular-nums; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 {
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}

/* --- App shell ----------------------------------------------------------- */

.app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-width: 0;
  width: 100%;
  overflow: visible;
}

.shell {
  min-width: 0;
  width: 100%;
  overflow: visible;
}

/* Desktop-only. The bottom nav (and More) covers these destinations on phones. */
.sidebar { display: none; }

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--appbar-h);
  padding: calc(var(--safe-t) + 6px) calc(var(--pad) + var(--safe-r)) 6px calc(var(--pad) + var(--safe-l));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* Blur reads as native chrome on iOS/Android when it is supported. */
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.appbar--brand {
  background: #ffffff;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.appbar--brand .appbar__sub { color: var(--text-2); }
.appbar--brand .iconbtn { color: var(--text); }

.appbar__back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; margin-inline-start: -8px;
  border-radius: var(--r-pill); color: inherit;
  transition: background .15s var(--ease);
}
.appbar__back:active { background: rgba(127, 127, 127, .18); }

.appbar__titles { min-width: 0; flex: 1; }
.appbar__title { font-size: 17px; font-weight: 660; letter-spacing: -.01em; }
.appbar__sub { font-size: 12px; color: var(--text-2); }
.appbar__actions { display: flex; align-items: center; gap: 4px; }

.iconbtn {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 0; background: transparent; color: var(--text);
  border-radius: var(--r-pill); cursor: pointer;
  transition: background .15s var(--ease);
}
.iconbtn:active { background: rgba(127, 127, 127, .18); }
.iconbtn__dot {
  position: absolute; top: 7px; right: 7px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700; line-height: 1;
  color: #fff; background: var(--danger);
  border-radius: var(--r-pill);
  border: 2px solid var(--surface);
}

.main {
  flex: 1 0 auto;
  width: 100%;
  min-width: 0;
  padding: var(--pad);
  padding-left: calc(var(--pad) + var(--safe-l));
  padding-right: calc(var(--pad) + var(--safe-r));
  /* Clears the bottom navigation plus the home indicator. */
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-b) + 20px);
}
.main--flush { padding-left: 0; padding-right: 0; }
.main--nonav { padding-bottom: calc(var(--safe-b) + 20px); }
.main:has(#cartBar) { padding-bottom: calc(88px + var(--safe-b) + 16px); }

/* --- Bottom navigation --------------------------------------------------- */

.bottomnav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 45;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding-bottom: var(--safe-b);
  background: var(--surface);
  border-top: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.bottomnav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  min-height: var(--bottomnav-h);
  padding: 6px 2px;
  color: var(--text-3);
  font-size: 11px; font-weight: 550;
  transition: color .15s var(--ease);
}
.bottomnav__item.is-active { color: var(--brand-600); }
.bottomnav__item.is-active .bottomnav__icon { background: var(--brand-50); }
[data-theme="dark"] .bottomnav__item.is-active .bottomnav__icon { background: rgba(36, 189, 134, .16); }

.bottomnav__icon {
  display: grid; place-items: center;
  width: 46px; height: 26px;
  border-radius: var(--r-pill);
  transition: background .18s var(--ease);
}
.bottomnav__label { line-height: 1; }

/* --- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--surface-3);
  color: var(--text);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: transform .12s var(--ease), background .15s var(--ease), opacity .15s var(--ease);
}
.btn:active { transform: scale(.975); }
.btn:disabled, .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn--primary { background: var(--brand-600); color: var(--on-brand); box-shadow: var(--shadow-1); }
.btn--primary:active { background: var(--brand-700); }
.btn--ghost { background: transparent; border-color: var(--border-strong); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--warning { background: var(--warning); color: #fff; }
.btn--subtle { background: var(--surface-2); border-color: var(--border); }
.btn--block { display: flex; width: 100%; }
.btn--lg { min-height: 56px; font-size: 17px; border-radius: var(--r-lg); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
.btn--fab {
  position: fixed;
  right: calc(16px + var(--safe-r));
  bottom: calc(var(--bottomnav-h) + var(--safe-b) + 16px);
  z-index: 44;
  width: 56px; height: 56px; padding: 0;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-3);
}

.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.btnrow > * { flex: 1; min-width: 0; }
.btnrow--stack .btn--danger { flex: 1 1 100%; }
.btngrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }

.page-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
.page-actions__search { min-width: 0; flex: 1; }
.page-actions__add { flex-shrink: 0; white-space: nowrap; }

/* --- Cards --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card__body { padding: var(--pad); }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px var(--pad);
  border-bottom: 1px solid var(--border);
}
.card__title { font-size: 15px; font-weight: 650; }
.card + .card { margin-top: var(--gap); }

.section { margin-bottom: 20px; }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 10px;
}
.section__title { font-size: 13px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.section__link { font-size: 13px; font-weight: 600; }

/* --- Stat cards (dashboard) ---------------------------------------------- */

/* auto-fit keeps one big card on a 320px phone and flows to 2, 3, 4 up as the
   viewport grows, with no per-breakpoint rules. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--gap);
}
.stat {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  min-width: 0;
}
.stat--wide { grid-column: 1 / -1; }
.stat--hero {
  grid-column: 1 / -1;
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.stat--hero .stat__label { color: var(--text-2); }
.stat--hero .stat__meta { color: var(--text-2); }
.stat--hero .stat__value { color: var(--brand-600); }

.stat__label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.stat__value {
  margin-top: 6px;
  font-size: clamp(21px, 6.5vw, 30px);
  font-weight: 720;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat--hero .stat__value { font-size: clamp(28px, 9vw, 42px); }
.stat__meta { margin-top: 4px; font-size: 12px; color: var(--text-3); }

.liveclock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  text-align: center;
}
.liveclock__label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.liveclock__time {
  font-size: clamp(32px, 10vw, 48px);
  font-weight: 720;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  color: var(--brand-600);
  line-height: 1.1;
}
.liveclock__date { font-size: 13px; font-weight: 550; color: var(--text-2); }
.liveclock-inline {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  font-weight: 650;
  letter-spacing: .02em;
}

body.block-capture,
body.block-capture * {
  -webkit-user-select: none !important;
  user-select: none !important;
  -webkit-touch-callout: none !important;
}
body.block-capture.is-capture-flash .receipt,
body.block-capture.is-capture-flash .saledone__card {
  filter: blur(14px);
  opacity: .2;
}
body.block-capture[data-capture-mark]::before {
  content: attr(data-capture-mark);
  pointer-events: none;
  position: fixed;
  inset: 18% -10% auto;
  z-index: 70;
  color: var(--text);
  opacity: .07;
  font-size: 42px;
  font-weight: 800;
  letter-spacing: .12em;
  text-align: center;
  transform: rotate(-18deg);
  white-space: nowrap;
}

/* --- Badges, chips ------------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 650; line-height: 1.4;
  white-space: nowrap;
}
.badge--neutral { background: var(--surface-3); color: var(--text-2); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--warning { background: var(--warning-bg); color: var(--warning); }
.badge--danger  { background: var(--danger-bg);  color: var(--danger); }
.badge--info    { background: var(--info-bg);    color: var(--info); }
.badge--brand   { background: var(--brand-50);   color: var(--brand-700); }

/* Horizontally scrolling filter row. Scrolls inside itself, so the page
   never gains a horizontal scrollbar. */
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding: 2px calc(var(--pad) + var(--safe-r)) 2px calc(var(--pad) + var(--safe-l));
  margin: 0 calc(-1 * var(--pad));
  max-width: 100%;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.chip.is-active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--on-brand);
}

/* --- Forms --------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px; font-weight: 620; color: var(--text-2);
}
.field__hint { margin-top: 5px; font-size: 12px; color: var(--text-3); }
.field__error { margin-top: 5px; font-size: 12px; color: var(--danger); font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  /* 16px is the threshold below which iOS Safari zooms on focus. */
  font-size: 16px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
  appearance: none;
  -webkit-appearance: none;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(36, 189, 134, .18);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:disabled, .select:disabled { background: var(--surface-3); color: var(--text-3); }
input[type="date"],
input[type="time"],
input[type="datetime-local"] {
  min-width: 0;
  max-width: 100%;
}
.textarea { min-height: 88px; resize: vertical; }

.select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%238a97a2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m5 9 7 7 7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.inputgroup { position: relative; display: flex; align-items: center; }
.inputgroup .input { padding-left: 42px; }
.inputgroup__icon {
  position: absolute; left: 13px;
  display: grid; place-items: center;
  color: var(--text-3); pointer-events: none;
}
.inputgroup__action {
  position: absolute; right: 6px;
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border: 0; background: transparent; color: var(--text-2);
  border-radius: var(--r-sm); cursor: pointer;
}
.inputgroup--action .input { padding-right: 48px; }

.pos-search { position: relative; z-index: 6; }
.pos-suggest {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 4px);
  max-height: min(320px, 50dvh);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
}
.pos-suggest__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.pos-suggest__item + .pos-suggest__item { border-top: 1px solid var(--border); }
.pos-suggest__item.is-active,
.pos-suggest__item:hover { background: var(--brand-50); }
.pos-suggest__name { font-size: 14px; font-weight: 620; }
.pos-suggest__meta {
  flex-shrink: 0;
  font-size: 12.5px;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.formgrid { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
.formgrid .field--full:has(> .formgrid) { margin-bottom: 0; }

/* Switch */
.switch {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: var(--tap);
  padding: 8px 0;
  cursor: pointer;
}
.switch__text { min-width: 0; }
.switch__title { font-size: 14.5px; font-weight: 600; }
.switch__desc { font-size: 12.5px; color: var(--text-3); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch__track {
  position: relative; flex: none;
  width: 50px; height: 30px;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  transition: background .2s var(--ease);
}
.switch__track::after {
  content: "";
  position: absolute; top: 3px; left: 3px;
  width: 24px; height: 24px;
  background: #fff;
  border-radius: var(--r-pill);
  box-shadow: var(--shadow-1);
  transition: transform .2s var(--ease);
}
.switch input:checked + .switch__track { background: var(--brand-500); }
.switch input:checked + .switch__track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--brand-400); outline-offset: 2px; }

/* Segmented control */
.segment {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.segment__item {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px;
  border: 0; background: transparent; color: var(--text-2);
  border-radius: 9px;
  font-size: 14px; font-weight: 620;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.segment__item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* --- List rows ----------------------------------------------------------- */

.list { display: flex; flex-direction: column; gap: 10px; }

.row {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 12px var(--pad);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  color: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .12s var(--ease);
}
.row:active { transform: scale(.99); }
.row--plain { cursor: default; }
.row--plain:active { transform: none; }
.row__main { flex: 1; min-width: 0; }

.productrow { display: flex; align-items: stretch; gap: 8px; }
.productrow .row { flex: 1; min-width: 0; }
.productrow__delete { align-self: center; flex: none; white-space: nowrap; }
.row__title { font-size: 14.5px; font-weight: 620; }
.row__sub { margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.row__side { text-align: right; flex: none; }
.row__amount { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.row__chev { color: var(--text-3); flex: none; }

.row__avatar {
  display: grid; place-items: center; flex: none;
  width: 42px; height: 42px;
  border-radius: var(--r-pill);
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 14px; font-weight: 700;
}
[data-theme="dark"] .row__avatar { background: rgba(36, 189, 134, .14); color: var(--brand-300); }

/* Grouped settings list */
.grouplist { border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); }
.grouplist .row { border: 0; border-radius: 0; }
.grouplist .row + .row { border-top: 1px solid var(--border); }

/* --- Key/value lines (totals) -------------------------------------------- */

.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 14px; }
.kv__k { color: var(--text-2); }
.kv__v { font-weight: 620; font-variant-numeric: tabular-nums; text-align: right; }
.kv--total {
  margin-top: 6px; padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
  font-size: 19px; font-weight: 750;
}
.kv--total .kv__k { color: var(--text); font-weight: 700; }
.kv--danger .kv__v { color: var(--danger); }
.kv--success .kv__v { color: var(--success); }

/* --- Product grid (POS) --------------------------------------------------- */

.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: var(--gap);
}
@media (max-width: 359px) {
  /* Below 360px a 2-up grid gets cramped, so fall back to one column. */
  .pgrid { grid-template-columns: 1fr; }
}

.pcard {
  position: relative;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
  text-align: left;
  cursor: pointer;
  transition: transform .12s var(--ease), box-shadow .15s var(--ease);
}
.pcard:active { transform: scale(.97); }
.pcard.is-out { opacity: .55; }
.pcard__flag {
  display: inline-block;
  margin-left: 4px;
  vertical-align: middle;
}
.pcard__qty {
  position: absolute; top: 8px; right: 8px;
  min-width: 24px; height: 24px; padding: 0 6px;
  display: grid; place-items: center;
  background: var(--brand-600); color: #fff;
  border-radius: var(--r-pill);
  font-size: 12px; font-weight: 700;
  box-shadow: var(--shadow-2);
}
.pcard__body { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 6px; padding-right: 36px; flex: 1; }
.pcard__name { font-size: 13.5px; font-weight: 620; line-height: 1.3; }
.pcard__price { font-size: 16px; font-weight: 720; font-variant-numeric: tabular-nums; }
.pcard__stock { font-size: 11.5px; color: var(--text-3); }
.pcard__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 8px 8px;
  padding: 3px 3px 3px 10px;
  background: var(--surface-2);
  border-radius: var(--r-pill);
}
.pcard__id {
  flex: 1;
  min-width: 0;
  font-size: 11.5px;
  font-weight: 650;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.pcard__add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  min-height: 30px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--brand-600);
  color: var(--on-brand);
  border: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
}
[data-theme="dark"] .pcard__add { background: var(--brand-500); color: #fff; }

.thumb {
  width: 52px; height: 52px; flex: none;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--surface-3);
}
.thumb--mono {
  display: grid; place-items: center;
  background: hsl(var(--tile-hue, 160) 55% 92%);
  color: hsl(var(--tile-hue, 160) 55% 30%);
  font-weight: 720; font-size: 15px;
}
[data-theme="dark"] .thumb--mono {
  background: hsl(var(--tile-hue, 160) 35% 22%);
  color: hsl(var(--tile-hue, 160) 55% 75%);
}

/* --- Cart ---------------------------------------------------------------- */

.cartline {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0;
}
.cartline + .cartline { border-top: 1px solid var(--border); }
.cartline__main { flex: 1; min-width: 0; }
.cartline__name { font-size: 14px; font-weight: 620; }
.cartline__meta { margin-top: 2px; font-size: 12.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.cartline__total { font-size: 14.5px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cartline--stack { flex-direction: column; align-items: stretch; gap: 8px; }
.cartline__row { display: flex; align-items: center; gap: 10px; width: 100%; min-width: 0; }
.pricemodes { display: flex; flex-wrap: wrap; gap: 6px; }
.pricemodes__btn {
  flex: 1 1 calc(33.33% - 6px);
  min-width: 72px;
  min-height: 34px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.pricemodes__btn.is-active {
  background: var(--brand-600);
  border-color: var(--brand-600);
  color: var(--on-brand);
}
.pricemodes__btn--free.is-active {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.pricemodes__btn--driver.is-active {
  background: #0b6e99;
  border-color: #0b6e99;
  color: #fff;
}
.cartline__note {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  font-size: 12px;
  color: var(--text-3);
  cursor: pointer;
}
.cartline__free-reason {
  margin-top: 8px;
}
.cartline__free-reason .field__label {
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  font-weight: 650;
  color: var(--text-2);
}
.cartline__free-input {
  min-height: 56px;
  padding: 8px 10px;
  font-size: 13px;
  resize: vertical;
}

.stepper {
  display: flex; align-items: center; gap: 2px;
  padding: 2px;
  background: var(--surface-3);
  border-radius: var(--r-pill);
}
.stepper__btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 0; background: var(--surface); color: var(--text);
  border-radius: var(--r-pill);
  cursor: pointer;
  box-shadow: var(--shadow-1);
}
.stepper__btn:active { transform: scale(.92); }
.stepper__value {
  min-width: 34px;
  text-align: center;
  font-size: 14.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

/* Sticky POS action bar */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 46;
  padding: 10px calc(var(--pad) + var(--safe-r)) calc(10px + var(--safe-b)) calc(var(--pad) + var(--safe-l));
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(16, 24, 31, .08);
}
[data-theme="dark"] .actionbar { box-shadow: 0 -4px 20px rgba(0, 0, 0, .4); }

.actionbar__cart {
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 0 8px 0 16px;
  border: 0; border-radius: var(--r-lg);
  background: var(--brand-600); color: var(--on-brand);
  cursor: pointer;
  box-shadow: var(--shadow-2);
}
.actionbar__cart:disabled { opacity: .45; }
.actionbar__count { font-size: 13px; font-weight: 600; opacity: .9; }
.actionbar__total { flex: 1; text-align: left; font-size: 19px; font-weight: 750; font-variant-numeric: tabular-nums; }
.actionbar__pay {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .2);
  font-size: 15px; font-weight: 700;
}

/* --- Sheets & modals ----------------------------------------------------- */

.scrim {
  position: fixed; inset: 0;
  z-index: 60;
  background: rgba(8, 14, 19, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s var(--ease);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.scrim.is-open { opacity: 1; pointer-events: auto; }

.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 61;
  display: flex; flex-direction: column;
  max-height: 92dvh;
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-3);
  transform: translateY(100%);
  transition: transform .28s var(--ease);
  padding-bottom: var(--safe-b);
  /* Closed sheets stay in the layout (especially centered on tablet+).
     Without this they sit invisible on top of the open menu and eat taps. */
  pointer-events: none;
}
.sheet.is-open {
  transform: translateY(0);
  pointer-events: auto;
  z-index: 62;
}

.sheet__grip {
  width: 38px; height: 4px;
  margin: 8px auto 2px;
  background: var(--border-strong);
  border-radius: var(--r-pill);
  flex: none;
}
.sheet__head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px var(--pad) 10px;
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sheet__title { font-size: 16.5px; font-weight: 680; }
.sheet__body {
  padding: var(--pad);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1;
}
.sheet__foot {
  padding: 12px var(--pad);
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}
.sheet--tall { height: 92dvh; }

/* --- Toasts -------------------------------------------------------------- */

.toasts {
  position: fixed;
  left: 50%;
  top: calc(12px + var(--safe-t, 0px));
  bottom: auto;
  z-index: 120;
  display: flex; flex-direction: column; gap: 8px;
  width: min(440px, calc(100vw - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: #10181f;
  color: #fff;
  font-size: 14px; font-weight: 550;
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toast-in .24s var(--ease);
}
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }
.toast--success { background: var(--success); }
.toast--danger  { background: var(--danger); }
.toast--warning { background: var(--warning); }
.toast__text { flex: 1; min-width: 0; }

@keyframes toast-in  { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* --- Number pad ---------------------------------------------------------- */

.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.numpad__key {
  display: grid; place-items: center;
  min-height: 58px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: 22px; font-weight: 620;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: transform .1s var(--ease), background .12s var(--ease);
}
.numpad__key:active { transform: scale(.95); background: var(--surface-3); }
.numpad__key--accent { background: var(--brand-600); color: var(--on-brand); border-color: transparent; }
.numpad__key--wide { grid-column: span 2; }

.numdisplay {
  padding: 14px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  text-align: right;
}
.numdisplay__label { font-size: 12px; font-weight: 600; color: var(--text-2); text-align: left; }
.numdisplay__value {
  margin-top: 2px;
  font-size: 32px; font-weight: 720;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Quick cash denominations */
.denoms { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 8px; }

/* --- Payment method tiles ------------------------------------------------ */

.paygrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.paytile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 84px;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  font-size: 14.5px; font-weight: 680;
  cursor: pointer;
  transition: all .15s var(--ease);
}
.paytile:active { transform: scale(.97); }
.paytile.is-active { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .paytile.is-active { background: rgba(36, 189, 134, .12); color: var(--brand-300); }
.paytile__amount { font-size: 12.5px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; }
.paytile.is-active .paytile__amount { color: inherit; }
.paytile.is-editing { box-shadow: inset 0 0 0 2px var(--brand-500); }
.payhint {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  background: var(--brand-50);
  color: var(--brand-700);
  font-size: 13.5px;
  line-height: 1.35;
}
[data-theme="dark"] .payhint { background: rgba(36, 189, 134, .12); color: var(--brand-300); }

.changebox {
  padding: 18px;
  border-radius: var(--r-lg);
  background: var(--success-bg);
  border: 1px solid rgba(18, 161, 80, .3);
  text-align: center;
}
.changebox__label { font-size: 13px; font-weight: 650; color: var(--success); text-transform: uppercase; letter-spacing: .05em; }
.changebox__value { margin-top: 4px; font-size: clamp(34px, 11vw, 48px); font-weight: 780; color: var(--success); font-variant-numeric: tabular-nums; }

.returnmode {
  padding: 18px 16px;
  border-radius: var(--r-lg);
  background: var(--warning-bg);
  border: 3px solid var(--warning);
  text-align: center;
}
.returnmode__label {
  font-size: 13px;
  font-weight: 700;
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.returnmode__value {
  margin-top: 6px;
  font-size: clamp(28px, 9vw, 44px);
  font-weight: 800;
  line-height: 1.1;
  color: var(--text);
}
.returnmode__hint {
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
}

/* --- Empty / status states ----------------------------------------------- */

.state { padding: 40px 20px; text-align: center; }
.state--full { display: grid; place-content: center; min-height: 60dvh; }
.state__icon {
  display: grid; place-items: center;
  width: 74px; height: 74px;
  margin: 0 auto 14px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  color: var(--text-3);
}
.state__icon--danger { background: var(--danger-bg); color: var(--danger); }
.state__title { font-size: 17px; font-weight: 660; }
.state__text { margin: 6px auto 16px; max-width: 34ch; font-size: 14px; color: var(--text-2); }

/* --- Tables (desktop) / cards (mobile) ------------------------------------ */

/* Wrapper scrolls internally so a wide table can never push the page sideways. */
.tablewrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
}
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; white-space: nowrap; }
.table th {
  font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.table tbody tr + tr td { border-top: 1px solid var(--border); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --- Sales page ---------------------------------------------------------- */

.callout {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
}
.callout--info { background: var(--info-bg); border-color: transparent; color: var(--info); }
.callout .ico { flex: none; margin-top: 2px; }

.saleshero {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--r-xl);
  background: linear-gradient(145deg, var(--brand-700) 0%, var(--brand-500) 58%, var(--brand-400) 100%);
  color: #fff;
  box-shadow: var(--shadow-2);
  max-width: 100%;
  min-width: 0;
}
.saleshero__label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase;
  opacity: .85;
}
.saleshero__value {
  margin-top: 4px;
  font-size: clamp(28px, 8vw, 40px);
  font-weight: 760;
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.saleshero__meta { margin-top: 4px; font-size: 13px; opacity: .88; }
.saleshero__pays { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.salespay {
  display: flex; align-items: center; gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(255,255,255,.14);
  backdrop-filter: blur(8px);
}
.salespay__dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: #fff;
}
.salespay__dot--cash { background: #b8f5d2; }
.salespay__dot--upi { background: #c9dcff; }
.salespay__dot--card { background: #ffe7b0; }
.salespay__dot--credit { background: #ffd0c7; }
.salespay__dot--other { background: #e4e9ee; }
.salespay__name { flex: 1; font-size: 12px; font-weight: 620; opacity: .92; }
.salespay__val { font-size: 13px; font-weight: 720; font-variant-numeric: tabular-nums; }

.salesmodes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
  gap: 8px;
  max-width: 100%;
}
.salesmode {
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.salesmode__label { font-size: 11.5px; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.salesmode__value { margin-top: 4px; font-size: 18px; font-weight: 740; font-variant-numeric: tabular-nums; }
.salesmode__meta { margin-top: 2px; font-size: 12px; color: var(--text-3); }

.salesfilters {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  max-width: 100%;
  min-width: 0;
}
.salesfilters .field { margin-bottom: 0; min-width: 0; }
.salesfilters .chips {
  margin: 0;
  padding: 0;
  flex-wrap: wrap;
  overflow: visible;
  scroll-snap-type: none;
}
.salesfilters__dates {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 12px;
}
.salesfilters__dates > * { min-width: 0; }
.salesfilters__apply {
  grid-column: 1 / -1;
  min-height: 44px;
}
.salesfilters__group { margin-top: 12px; }
.salesfilters__kicker {
  margin-bottom: 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
}
.salesfilters__hint { margin-top: 10px; font-size: 12.5px; color: var(--text-3); }

@media (max-width: 767px) {
  .salesfilters__dates--phone-hide { display: none; }
}

.salelist { display: flex; flex-direction: column; gap: 10px; }
.salecard {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-1);
  color: inherit;
  max-width: 100%;
  min-width: 0;
  transition: transform .12s var(--ease), box-shadow .15s var(--ease);
}
.salecard:active { transform: scale(.99); }
.salecard__mark {
  display: grid; place-items: center; flex: none;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--brand-50);
  color: var(--brand-700);
}
.salecard__mark--cash { background: var(--success-bg); color: var(--success); }
.salecard__mark--upi { background: var(--info-bg); color: var(--info); }
.salecard__mark--card { background: var(--brand-50); color: var(--brand-700); }
.salecard__mark--credit { background: var(--warning-bg); color: var(--warning); }
.salecard__body { flex: 1; min-width: 0; }
.salecard__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.salecard__invoice {
  min-width: 0;
  font-size: 14.5px; font-weight: 720; font-family: var(--mono);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.salecard__amount {
  flex: none;
  font-size: 16px; font-weight: 760; font-variant-numeric: tabular-nums; color: var(--brand-700);
  white-space: nowrap;
}
.salecard__meta {
  display: block; margin-top: 3px; font-size: 12.5px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.salecard__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.salecard__note { display: block; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.salecard__chev { color: var(--text-3); flex: none; margin-top: 10px; }

.sales-invoice {
  font-family: var(--mono);
  font-weight: 720;
  color: var(--brand-700);
}
.sales-table tbody tr:hover td { background: var(--surface-2); }

[data-theme="dark"] .saleshero {
  background: linear-gradient(145deg, #034433 0%, #068058 55%, #0ea06d 100%);
}
[data-theme="dark"] .salecard__amount,
[data-theme="dark"] .sales-invoice { color: var(--brand-300); }
[data-theme="dark"] .salecard__mark { background: rgba(36, 189, 134, .16); color: var(--brand-300); }

/* Show the card list on phones, the table from tablet up.
   Do not force display:block on .only-mobile — lists/cards keep their flex layout. */
.only-desktop { display: none; }

/* --- Offline / connection banner ----------------------------------------- */

.netbar {
  display: none;
  align-items: center; justify-content: center; gap: 8px;
  padding: 7px 12px;
  font-size: 13px; font-weight: 620;
  background: var(--danger); color: #fff;
}
body.is-offline .netbar { display: flex; }
body.is-offline .netbar--reconnected { display: none; }

.netdot { width: 8px; height: 8px; border-radius: var(--r-pill); background: var(--success); flex: none; }
body.is-offline .netdot { background: var(--danger); }

/* --- Splash -------------------------------------------------------------- */

.splash {
  position: fixed; inset: 0;
  z-index: 200;
  display: grid; place-content: center; justify-items: center; gap: 18px;
  background: #ffffff;
  color: var(--text);
  transition: opacity .35s var(--ease), visibility .35s;
}
.splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash__logo {
  display: grid; place-items: center;
  width: 92px; height: 92px;
  border-radius: 26px;
  background: var(--brand-500);
  color: #fff;
  box-shadow: 0 10px 32px rgba(14, 160, 109, .22);
  font-size: 34px; font-weight: 800; letter-spacing: -.02em;
}
.splash__name { font-size: 21px; font-weight: 720; letter-spacing: -.01em; }
.splash__by { font-size: 13px; color: var(--text-2); margin-top: -12px; }
.spinner {
  width: 26px; height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--brand-500);
  border-radius: var(--r-pill);
  animation: spin .8s linear infinite;
}
.spinner--dark { border-color: var(--border-strong); border-top-color: var(--brand-500); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Route-change progress bar */
.progress {
  position: fixed; top: 0; left: 0;
  z-index: 90;
  height: 3px; width: 0;
  background: var(--brand-400);
  transition: width .3s var(--ease), opacity .3s var(--ease);
}

/* Skeleton placeholders */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* --- Login --------------------------------------------------------------- */

.auth {
  display: flex; flex-direction: column;
  min-height: 100dvh;
  background: #ffffff;
}
.auth__head {
  padding: calc(var(--safe-t) + 40px) 24px 24px;
  text-align: center; color: var(--text);
}
.auth__logo {
  display: grid; place-items: center;
  width: 76px; height: 76px;
  margin: 0 auto 14px;
  border-radius: 22px;
  background: var(--brand-500);
  color: #fff;
  border: 0;
  font-size: 28px; font-weight: 800;
  box-shadow: 0 8px 24px rgba(14, 160, 109, .22);
  overflow: hidden;
}
.auth__logo img { width: 100%; height: 100%; object-fit: cover; }
.auth__brand { font-size: 22px; font-weight: 730; letter-spacing: -.01em; }
.auth__tag { margin-top: 3px; font-size: 13.5px; color: var(--text-2); }

.auth__body {
  flex: 1;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 0 20px calc(28px + var(--safe-b));
}
.auth__card {
  padding: 22px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-3);
}
.auth__title { font-size: 19px; font-weight: 700; text-align: center; }
.auth__sub { margin: 4px 0 20px; font-size: 13.5px; color: var(--text-2); text-align: center; }
.auth__foot { margin-top: 20px; text-align: center; font-size: 12.5px; color: var(--text-3); }
.auth__divider {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0;
  font-size: 12px; color: var(--text-3);
}
.auth__divider::before, .auth__divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.pindots { display: flex; justify-content: center; gap: 12px; margin: 6px 0 18px; }
.pindot {
  width: 14px; height: 14px;
  border-radius: var(--r-pill);
  border: 2px solid var(--border-strong);
  transition: all .15s var(--ease);
}
.pindot.is-filled { background: var(--brand-500); border-color: var(--brand-500); }

/* --- Utility ------------------------------------------------------------- */

.stack   { display: flex; flex-direction: column; gap: var(--gap); }
.stack--sm { gap: 8px; }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow    { flex: 1; min-width: 0; }
.mt-0 { margin-top: 0; }  .mt-1 { margin-top: 8px; }  .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* Collapsible section (product form, permission groups) */
.accordion { border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
.accordion + .accordion { margin-top: 10px; }
.accordion__head {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px var(--pad);
  border: 0; background: transparent; color: inherit;
  font-size: 14.5px; font-weight: 650;
  text-align: left;
  cursor: pointer;
}
.accordion__chev { margin-left: auto; color: var(--text-3); transition: transform .2s var(--ease); }
.accordion.is-open .accordion__chev { transform: rotate(90deg); }
.accordion__body { display: none; padding: 0 var(--pad) var(--pad); }
.accordion.is-open .accordion__body { display: block; }
.accordion__count { font-size: 12px; font-weight: 600; color: var(--text-3); }

/* Wizard step dots */
.steps { display: flex; align-items: center; gap: 6px; margin-bottom: 16px; }
.steps__dot { flex: 1; height: 4px; border-radius: var(--r-pill); background: var(--border); }
.steps__dot.is-done { background: var(--brand-400); }
.steps__dot.is-active { background: var(--brand-600); }

/* =========================================================================
   Breakpoints - everything from here up only widens the layout
   ========================================================================= */

/* 480px+ : roomier phones and small tablets */
@media (min-width: 480px) {
  :root { --pad: 18px; --gap: 14px; }
  .paygrid { gap: 12px; }
  .formgrid--2 { grid-template-columns: 1fr 1fr; }
  .salesfilters__dates { grid-template-columns: 1fr 1fr; }
}

/* 768px+ : tablets. Tables replace card lists, sheets become centred dialogs. */
@media (min-width: 768px) {
  body { font-size: 15.5px; }

  .main { max-width: 900px; margin: 0 auto; padding-top: 20px; }
  .only-mobile { display: none !important; }
  .only-desktop { display: block; }

  .page-actions {
    flex-direction: row;
    align-items: flex-start;
  }

  .stats { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
  .stat--hero { grid-column: span 2; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
  .paygrid { grid-template-columns: repeat(4, 1fr); }
  .formgrid { grid-template-columns: 1fr 1fr; }
  .formgrid .field--full { grid-column: 1 / -1; }

  .saleshero { grid-template-columns: 1.15fr 1fr; align-items: center; }
  .saleshero__pays { grid-template-columns: 1fr 1fr; }
  .salesfilters__dates { grid-template-columns: 1fr 1fr auto; align-items: end; }
  .salesfilters__apply { grid-column: auto; min-width: 108px; }

  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    width: min(560px, calc(100vw - 48px));
    max-height: 86dvh;
    border-radius: var(--r-xl);
    transform: translate(-50%, -46%) scale(.97);
    opacity: 0;
    transition: transform .22s var(--ease), opacity .22s var(--ease);
  }
  .sheet.is-open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet__grip { display: none; }
  .sheet--tall { height: auto; }

  .toasts { bottom: 24px; }
}

/* 1024px+ : desktop and large POS displays. Sidebar replaces bottom nav. */
@media (min-width: 1024px) {
  .app {
    flex-direction: row;
    align-items: flex-start;
  }

  .bottomnav { display: none; }

  .sidebar {
    position: sticky; top: 0;
    display: flex; flex-direction: column;
    flex: none;
    width: 244px;
    height: 100dvh;
    padding: 16px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow-y: auto;
  }
  .sidebar__brand {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px 16px;
    font-size: 17px; font-weight: 730;
  }
  .sidebar__mark {
    display: grid; place-items: center;
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-400));
    color: #fff; font-size: 15px; font-weight: 800;
  }
  .sidebar__group { margin-top: 14px; }
  .sidebar__grouptitle {
    padding: 0 10px 6px;
    font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
    color: var(--text-3);
  }
  .sidebar__item {
    display: flex; align-items: center; gap: 10px;
    min-height: 42px;
    padding: 0 10px;
    border-radius: var(--r-md);
    color: var(--text-2);
    font-size: 14.5px; font-weight: 580;
  }
  .sidebar__item:hover { background: var(--surface-2); color: var(--text); }
  .sidebar__item.is-active { background: var(--brand-50); color: var(--brand-700); font-weight: 660; }
  [data-theme="dark"] .sidebar__item.is-active { background: rgba(36, 189, 134, .13); color: var(--brand-300); }
  .sidebar__foot { margin-top: auto; padding-top: 14px; }

  .shell {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    overflow: visible;
  }

  .main {
    max-width: 1180px;
    padding: 24px;
    padding-bottom: 40px;
  }
  .main--wide { max-width: none; }

  .appbar { padding-top: 10px; padding-bottom: 10px; }
  .appbar__back { display: none; }

  .stats { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
  .stat--hero { grid-column: span 2; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }

  /* Two-pane POS: catalogue on the left, live cart docked on the right. */
  .poslayout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
  .poslayout__cart { position: sticky; top: 84px; }
  .actionbar { display: none; }
  .poslayout__cart .actionbar--inline {
    display: block; position: static; padding: 0; border: 0; box-shadow: none; background: transparent;
  }

  .toasts { left: auto; right: 24px; transform: none; }
  .btn--fab { display: none; }
}

/* 1400px+ : large POS displays get a denser product grid */
@media (min-width: 1400px) {
  .main { max-width: 1360px; }
  .pgrid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
}

/* --- Motion / accessibility --------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* --- Print (thermal receipt) --------------------------------------------- */

.saledone {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: rgba(8, 12, 14, .55);
  backdrop-filter: blur(6px);
}
.saledone[hidden] { display: none !important; }
.saledone__card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 22px 18px 18px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg, 0 18px 50px rgba(0,0,0,.25));
  text-align: center;
}
.saledone__ok {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
}
.saledone__title {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
}
.saledone__invoice {
  margin: 6px 0 0;
  color: var(--text-2);
  font-size: 14px;
}
.saledone__total {
  margin-top: 10px;
  font-size: clamp(32px, 10vw, 44px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.saledone__print {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 650;
  color: var(--text-2);
}
.saledone__slip {
  margin: 12px 0 0;
  padding: 12px;
  text-align: left;
  font: 12.5px/1.35 ui-monospace, Consolas, monospace;
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-md);
  max-height: 28vh;
  overflow: auto;
}

@media print {
  .saledone, .appbar, .bottomnav, .actionbar, .sidebar, .toasts, .no-print, .btn, .netbar { display: none !important; }
  body { background: #fff; color: #000; font-size: 12px; }
  .main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; }
  .receipt { width: 100%; max-width: 302px; margin: 0 auto; font-family: var(--mono); }
  body.block-capture .receipt,
  body.block-capture .saledone,
  body.block-capture .card { display: none !important; }
  body.block-capture::after {
    content: 'Cashiers cannot print or save this bill.';
    display: block;
    padding: 24px;
    font-size: 16px;
  }
}
