/* ==========================================================
   Store & Warehouse SaaS — single stylesheet
   One design system: tokens → base → components → screens.
   Works in RTL (Arabic) and LTR (English) through logical properties;
   the few physical bits are flipped under :root[dir="ltr"].
   ========================================================== */

/* Cairo (OFL-1.1, see fonts/CAIRO-LICENSE.txt) — self-hosted, variable weight. */
@font-face {
  font-family: "Cairo"; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url("../fonts/cairo-arabic.woff2") format("woff2-variations"), url("../fonts/cairo-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Cairo"; font-style: normal; font-display: swap; font-weight: 200 1000;
  src: url("../fonts/cairo-latin.woff2") format("woff2-variations"), url("../fonts/cairo-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---------------------------------------------------------- tokens */
:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --surface-3: #eef2f3;
  --text: #13201d;
  --text-2: #33433f;
  --muted: #66746f;
  --border: #e2e7e8;
  --border-strong: #cdd6d6;
  --primary: #0f766e;
  --primary-600: #0b5f58;
  --primary-700: #0a4d48;
  --primary-soft: #e4f3f1;
  --primary-ring: rgba(15, 118, 110, .18);
  --danger: #c62828;
  --danger-soft: #fdeded;
  --warn: #a35d05;
  --warn-soft: #fff4e0;
  --ok: #157a3d;
  --ok-soft: #e6f5ea;
  --info: #1d5fae;
  --info-soft: #e8f0fb;
  --amber: #b45309;

  --side-bg: #0e2926;
  --side-bg-2: #133733;
  --side-text: #c4dad6;
  --side-muted: #7fa29c;

  --r-xs: 6px;
  --r-sm: 8px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  --h-sm: 32px;
  --h: 40px;
  --h-lg: 48px;

  --shadow-1: 0 1px 2px rgba(16, 32, 29, .05);
  --shadow-2: 0 1px 2px rgba(16, 32, 29, .04), 0 4px 14px rgba(16, 32, 29, .06);
  --shadow-3: 0 12px 40px rgba(16, 32, 29, .16);

  --sidebar-w: 248px;
  --topbar-h: 60px;
  --font: "Cairo", "Segoe UI", Tahoma, Arial, sans-serif;
  --start: right;  /* text-align for the reading start (flips in LTR) */
  --end: left;
  color-scheme: light;
}
:root[dir="ltr"] { --start: left; --end: right; }

[data-theme="dark"] {
  --bg: #0c1413;
  --surface: #131e1c;
  --surface-2: #182624;
  --surface-3: #1e2f2c;
  --text: #e6eeec;
  --text-2: #c3d0cd;
  --muted: #8fa29d;
  --border: #243532;
  --border-strong: #31453f;
  --primary: #2bb3a3;
  --primary-600: #25a093;
  --primary-700: #1f887d;
  --primary-soft: #12322e;
  --primary-ring: rgba(43, 179, 163, .25);
  --danger: #f06a6a;
  --danger-soft: #3a1c1c;
  --warn: #f0b04a;
  --warn-soft: #382a13;
  --ok: #4cc77a;
  --ok-soft: #14301f;
  --info: #6ea8f0;
  --info-soft: #172739;
  --amber: #f0a64a;
  --side-bg: #0a1312;
  --side-bg-2: #12201e;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
  --shadow-3: 0 12px 40px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font); font-size: 14.5px; line-height: 1.6; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; font-feature-settings: "kern";
  overscroll-behavior: none; -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.35; font-weight: 800; }
p { margin: 0 0 .6em; }
[hidden] { display: none !important; }
::selection { background: var(--primary-ring); }
.ico { flex-shrink: 0; vertical-align: middle; }
button, a, .tile, .nav-link, .seg, .fchip, .pos-chip, .pay-method, .tab { -webkit-user-select: none; user-select: none; }

/* Thin, quiet scrollbars (desktop app feel). */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------- text helpers */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 800; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.link { color: var(--primary); }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }
.req { color: var(--danger); }
/* Numbers: tabular digits, isolated from the text around them. Amounts read
   naturally in both languages ("150 ج.م" / "150 EGP"); negatives carry a
   left-to-right mark from format.js so the minus stays in front. */
.mono { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.c-num { text-align: center !important; }
.c-end { text-align: var(--end) !important; }
.spacer { flex: 1; }
.gap { height: 12px; }
.sep { color: var(--border-strong); }

/* ---------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--h); padding: 0 16px; border: 1px solid transparent; border-radius: var(--r);
  font: inherit; font-size: 14px; font-weight: 700; line-height: 1; white-space: nowrap; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.is-busy { cursor: progress; opacity: .8; }
.btn .ico { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(15, 118, 110, .25); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
[data-theme="dark"] .btn-primary { color: #03201c; }
[data-theme="dark"] .btn-primary .kbd { color: #03201c; border-color: rgba(3, 32, 28, .3); background: rgba(255, 255, 255, .25); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.95); }
.btn-danger-ghost { background: var(--surface); border-color: var(--border); color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.btn-pay { background: var(--ok); color: #fff; }
.btn-pay:hover:not(:disabled) { filter: brightness(.94); }
.btn-wa { background: #1fa855; color: #fff; }
.btn-wa:hover:not(:disabled) { background: #188f47; }
.btn-wa-ghost { background: var(--surface); border-color: color-mix(in srgb, #1fa855 45%, var(--border)); color: #13853f; }
.btn-wa-ghost:hover:not(:disabled) { background: color-mix(in srgb, #1fa855 9%, var(--surface)); }
[data-theme="dark"] .btn-wa-ghost { color: #4fd187; }
.btn-sm { min-height: var(--h-sm); padding: 0 11px; font-size: 13px; border-radius: var(--r-sm); gap: 5px; }
.btn-sm .ico { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-weight: 700; padding: 4px 6px; border-radius: var(--r-xs); }
.link-btn:hover { background: var(--primary-soft); }
.icon-btn {
  display: inline-grid; place-items: center; flex-shrink: 0; width: var(--h); height: var(--h); padding: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text-2);
  font: inherit; font-size: 16px; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); color: var(--text); }
.icon-btn .ico { width: 19px; height: 19px; }
.btn-x { width: var(--h-sm); height: var(--h-sm); color: var(--muted); border-color: transparent; background: transparent; }
.btn-x:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); border-color: transparent; }
.btn-x .ico { width: 16px; height: 16px; }
.btn:focus-visible, .icon-btn:focus-visible, .fchip:focus-visible, .pay-method:focus-visible, .seg:focus-visible,
.pos-chip:focus-visible, .link-btn:focus-visible, .nav-link:focus-visible, .tile:focus-visible, .picker-item:focus-visible {
  outline: 3px solid var(--primary-ring); outline-offset: 2px;
}

/* ---------------------------------------------------------- inputs */
input, select, textarea {
  width: 100%; min-height: var(--h); padding: 0 12px; font: inherit; font-size: 14.5px; font-weight: 500; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { padding: 9px 12px; line-height: 1.6; resize: vertical; min-height: 76px; }
input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--muted) 72%, transparent); font-weight: 400; }
input:hover:not(:focus):not(:disabled), select:hover:not(:focus):not(:disabled), textarea:hover:not(:focus):not(:disabled) { border-color: color-mix(in srgb, var(--primary) 40%, var(--border-strong)); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--primary); }
input[type="date"] { min-width: 0; }
input[type="file"] { padding: 7px 10px; }
/* LTR values (numbers, phones, e-mails) align with the page's reading side. */
input[dir="ltr"], textarea[dir="ltr"] { text-align: var(--start); }
input[inputmode="decimal"], input[inputmode="numeric"], input[inputmode="tel"] { font-variant-numeric: tabular-nums; }
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2366746f' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 12px center; background-size: 12px;
}
:root[dir="ltr"] select { background-position: right 12px center; }
.input-sm { min-height: var(--h-sm); padding: 0 10px; font-size: 13px; width: auto; }
.input-inline { min-height: var(--h-sm); padding: 0 10px; }
.input-big { min-height: var(--h-lg); font-size: 22px; font-weight: 800; text-align: center !important; font-variant-numeric: tabular-nums; }
.input-group { display: flex; gap: 8px; align-items: stretch; }
.input-group > input, .input-group > select { flex: 1; min-width: 0; }
.field.invalid input, input.invalid, select.invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px var(--danger-soft) !important; }

/* ---------------------------------------------------------- forms */
.form { display: flex; flex-direction: column; gap: 16px; }
.form-inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
.form-inline > input, .form-inline > select { flex: 1 1 170px; width: auto; }
.form-title { font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 13px; font-weight: 700; color: var(--text-2); }
.field-hint { font-size: 12px; color: var(--muted); line-height: 1.5; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.span-2 { grid-column: span 2; }
.check { display: flex; align-items: flex-start; gap: 9px; font-size: 13.5px; color: var(--text-2); cursor: pointer; line-height: 1.5; }
.check input { flex-shrink: 0; margin: 2px 0 0; }
.setting { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); }
.setting:hover { border-color: var(--border-strong); }
.note { background: var(--primary-soft); color: var(--text); border-radius: var(--r); padding: 10px 12px; font-size: 13px; margin: 0; line-height: 1.6; }
.tpl-hint { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.tpl-chip { font: inherit; font-size: 11.5px; padding: 2px 9px; border-radius: 999px; border: 1px dashed var(--border-strong); background: var(--surface-2); color: var(--text-2); cursor: pointer; }
.tpl-chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------------------------------------------------------- module picker */
.module-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.pick { position: relative; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick-box {
  display: flex; align-items: center; gap: 9px; min-height: var(--h); padding: 6px 12px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface); font-size: 14px; transition: all .15s;
}
.pick input:checked + .pick-box { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-700); font-weight: 700; }
[data-theme="dark"] .pick input:checked + .pick-box { color: var(--primary); }
.pick input:focus-visible + .pick-box { box-shadow: 0 0 0 3px var(--primary-ring); }
.pick-icon { display: inline-grid; place-items: center; color: var(--primary); }
.pick-icon .ico { width: 18px; height: 18px; }

/* ---------------------------------------------------------- cards & layout */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-1); }
.card + .card, section + section { margin-top: 16px; }
.card-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 16px; font-weight: 800; margin-bottom: 14px; }
.card-title .ico { color: var(--primary); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head .card-title { margin-bottom: 2px; }
.card-head input[type="search"] { max-width: 300px; }
.layout-2 { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 16px; align-items: start; margin-top: 16px; }
.layout-2 > section + section { margin-top: 0; }
.layout-narrow { max-width: 600px; }
.stats-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.section-title { font-size: 15px; margin: 22px 0 12px; }
.row-end { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.row-gap { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.row-gap-sm { display: inline-flex; align-items: center; gap: 8px; }
.row-center { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 5px 0; min-height: 32px; }
.center-card { max-width: 520px; margin: 48px auto; text-align: center; padding: 32px 24px; }
.center-card h2 { margin: 10px 0 6px; }

.stat { display: flex; align-items: center; gap: 14px; padding: 16px; }
.stat + .stat { margin-top: 0; }
.stat-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); font-size: 22px; flex-shrink: 0; }
.stat-icon .ico { width: 24px; height: 24px; }
.stat-value { font-size: 22px; font-weight: 800; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 12.5px; }
.mini-stat { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; }
.mini-stat + .mini-stat { margin-top: 0; }
.mini-stat strong { font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- badges, chips, tags */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; line-height: 1; padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-soon { background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.chip-sm { font-size: 11px; padding: 1px 8px; margin-inline-start: 6px; }
.tag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; line-height: 1; padding: 4px 7px; border-radius: var(--r-xs); margin-inline-start: 6px; white-space: nowrap; }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-start: 6px; }
.dot-ok { background: var(--ok); }
.dot-wait { background: var(--warn); }
.kbd { display: inline-block; font-size: 11.5px; line-height: 1; padding: 5px 8px; border-radius: var(--r-xs); border: 1px solid var(--border-strong); border-bottom-width: 2px; background: var(--surface); color: var(--muted); font-variant-numeric: tabular-nums; }
.bal { font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bal-owes { color: var(--danger); }
.bal-credit { color: var(--ok); }
.bal-zero { color: var(--muted); }

/* ---------------------------------------------------------- lists & tables */
.list { list-style: none; margin: 0 0 12px; padding: 0; }
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.table-wrap { overflow-x: auto; border-radius: var(--r); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th {
  height: 40px; padding: 0 12px; text-align: var(--start); white-space: nowrap; vertical-align: middle;
  font-size: 12.5px; font-weight: 700; color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border); border-top: 1px solid var(--border);
}
.table th:first-child { border-start-start-radius: var(--r); border-end-start-radius: var(--r); border-inline-start: 1px solid var(--border); }
.table th:last-child { border-start-end-radius: var(--r); border-end-end-radius: var(--r); border-inline-end: 1px solid var(--border); }
.table td { height: 52px; padding: 6px 12px; text-align: var(--start); vertical-align: middle; border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-muted td { opacity: .55; }
.row-error td { background: var(--danger-soft); }
.inv-row { cursor: pointer; }
.inv-row:hover td, .inv-row:focus-visible td { background: var(--surface-2); outline: none; }

/* Ellipsis cell: one line, full text in the tooltip. */
.cell-text { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-cell { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; white-space: nowrap; }

/* ---------------------------------------------------------- states */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--muted); padding: 32px; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; flex-shrink: 0; }
.spinner-sm { width: 14px; height: 14px; border-color: rgba(255, 255, 255, .35); border-top-color: currentColor; }
.btn-ghost .spinner-sm, .btn-danger-ghost .spinner-sm { border-color: var(--border); border-top-color: currentColor; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-icon { display: inline-grid; place-items: center; width: 64px; height: 64px; border-radius: 18px; background: var(--surface-2); color: var(--primary); font-size: 30px; margin-bottom: 8px; }
.empty-icon .ico { width: 32px; height: 32px; }
.empty-title { font-weight: 800; color: var(--text); font-size: 15px; }
.empty-text { font-size: 13.5px; margin-top: 2px; }
.error-block { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; border-radius: var(--r); background: var(--danger-soft); color: var(--danger); text-align: center; }
.boot { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }

/* ---------------------------------------------------------- toasts */
.toasts { position: fixed; bottom: 20px; inset-inline-start: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(400px, calc(100vw - 40px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 8px; padding: 12px 16px; border-radius: var(--r-lg);
  background: #1d2a27; color: #f1f6f5; font-size: 14px; font-weight: 600; line-height: 1.55; box-shadow: var(--shadow-3);
  opacity: 0; transform: translateY(8px); transition: opacity .22s, transform .22s; border-inline-start: 4px solid transparent;
}
.toast .ico { width: 18px; height: 18px; margin-top: 2px; }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-inline-start-color: #3ccf7d; }
.toast-error { background: #4a1414; border-inline-start-color: #ff7171; }
.toast-warn { background: #3d2c0e; border-inline-start-color: #f4b03e; }
.toast-info { border-inline-start-color: #5fb8ad; }

/* ---------------------------------------------------------- dialogs */
.modal-overlay { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgba(9, 20, 18, .48); backdrop-filter: blur(2px); }
.modal { width: min(440px, 100%); padding: 22px; border-radius: var(--r-xl); background: var(--surface); box-shadow: var(--shadow-3); }
.modal-title { font-size: 18px; margin-bottom: 8px; }
.modal-text { color: var(--muted); margin: 0 0 18px; line-height: 1.7; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

.sheet-overlay { display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .18s; }
.sheet-overlay.show { opacity: 1; }
.sheet {
  display: flex; flex-direction: column; width: 100%; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
  transform: translateY(10px) scale(.985); transition: transform .18s;
}
.sheet-overlay.show .sheet { transform: none; }
.sheet-sm { max-width: 440px; }
.sheet-md { max-width: 580px; }
.sheet-lg { max-width: 820px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; padding-block: 10px; padding-inline: 20px 14px; border-bottom: 1px solid var(--border); }
.sheet-title { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.sheet-footer { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; align-items: center; padding: 12px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.sheet-footer:empty { display: none; }
.is-drawer { justify-content: flex-start; padding: 0; }
.is-drawer .sheet { height: 100vh; height: 100dvh; max-height: none; border-radius: 0; transform: translateX(32px); }
:root[dir="ltr"] .is-drawer .sheet { transform: translateX(-32px); }
.is-drawer.show .sheet { transform: none !important; }
.is-drawer .sheet-footer { border-radius: 0; }

/* ---------------------------------------------------------- auth */
.auth-page {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1100px 520px at 50% -12%, color-mix(in srgb, var(--primary) 16%, transparent), transparent), var(--bg);
}
.auth-card { width: min(420px, 100%); padding: 28px; border-radius: 22px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 22px; margin-top: 12px; }
.auth-brand p { margin: 4px 0 0; font-size: 14px; }
.auth-lang { display: flex; justify-content: center; margin-top: 16px; }
.brand-logo { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; color: #fff; font-size: 26px; background: linear-gradient(145deg, #14b8a6, #0f766e); box-shadow: 0 6px 18px rgba(15, 118, 110, .3); }
.brand-logo .ico { width: 30px; height: 30px; }
.brand-logo.sm { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; box-shadow: none; }
.brand-logo.sm .ico { width: 20px; height: 20px; }
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 18px; border-radius: var(--r); background: var(--surface-3); }
.tab { flex: 1; min-height: 36px; border: 0; border-radius: var(--r-sm); background: transparent; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.success-box { display: flex; flex-direction: column; gap: 8px; text-align: center; }
.success-icon { font-size: 44px; color: var(--ok); }
.success-icon .ico { width: 48px; height: 48px; }
.success-box p { margin: 0; }

/* ==========================================================
   Shell: sidebar + topbar
   ========================================================== */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; overflow-x: clip; }
.sidebar {
  position: sticky; top: 0; flex-shrink: 0; width: var(--sidebar-w); height: 100vh; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 14px 12px; background: var(--side-bg); color: var(--side-text);
  scrollbar-color: rgba(255, 255, 255, .15) transparent;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: #fff; font-weight: 800; font-size: 16px; }
.brand-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; flex-direction: column; flex: 1; }
.nav-group { margin-bottom: 14px; }
.nav-group:last-child { margin-top: auto; margin-bottom: 0; }
.nav-title { padding: 0 10px 6px; font-size: 11.5px; font-weight: 700; color: var(--side-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-link {
  display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 10px; margin-bottom: 2px;
  border-radius: var(--r); color: var(--side-text); font-weight: 600; font-size: 14px; position: relative; transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.active { background: rgba(255, 255, 255, .1); color: #fff; font-weight: 700; }
.nav-link.active::before { content: ""; position: absolute; inset-block: 9px; inset-inline-start: -12px; width: 3px; border-radius: 3px; background: #2dd4bf; }
.nav-icon { display: inline-grid; place-items: center; width: 22px; color: var(--side-muted); }
.nav-link.active .nav-icon, .nav-link:hover .nav-icon { color: #5eead4; }
.nav-icon .ico { width: 19px; height: 19px; }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-soon { font-size: 10.5px; line-height: 1; padding: 3px 7px; border-radius: 999px; color: var(--side-muted); border: 1px solid rgba(255, 255, 255, .14); }
.nav-admin .nav-title { color: #f2c46d; }
.tenant-switch { width: 100%; background-color: var(--side-bg-2); border-color: rgba(255, 255, 255, .12); color: #fff; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 20px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.2) blur(10px); border-bottom: 1px solid var(--border);
}
.page-title { flex: 1; min-width: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.menu-btn, .home-btn { display: none; }
.backdrop { display: none; }
.view { flex: 1; width: 100%; max-width: 1320px; padding: 22px; }

/* user menu */
.user-menu { position: relative; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; height: var(--h); padding-inline: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; }
.user-chip:hover { border-color: var(--border-strong); background: var(--surface-2); }
.user-chip .ico { width: 16px; height: 16px; color: var(--muted); }
.avatar { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(145deg, #14b8a6, #0f766e); color: #fff; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.user-name { max-width: 160px; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-pop {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 60; width: 270px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.menu-head { padding: 10px 10px 12px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.menu-head strong { display: block; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-head span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-align: start; cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item .ico { width: 18px; height: 18px; color: var(--muted); }
.menu-item .menu-val { margin-inline-start: auto; font-size: 12px; color: var(--muted); font-weight: 600; }
.menu-item.danger { color: var(--danger); }
.menu-item.danger .ico { color: var(--danger); }
.menu-sep { height: 1px; background: var(--border); margin: 6px 4px; }
.lang-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--r); background: var(--surface-3); }
.lang-switch button { min-height: 30px; padding: 0 12px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--muted); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.lang-switch button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }

/* alerts bell */
.bell { position: relative; }
.bell-count {
  position: absolute; top: -5px; inset-inline-end: -5px; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; border: 2px solid var(--surface); background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 1;
}
.install-btn { display: none; }
.can-install .install-btn { display: inline-flex; }

/* Focus mode: the sidebar lives on the home screen only; elsewhere ☰ opens it. */
.focus-mode .menu-btn, .focus-mode .home-btn { display: inline-grid; }
.focus-mode .sidebar, .mobile-nav .sidebar {
  position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 70; transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow-3);
}
:root[dir="ltr"] .focus-mode .sidebar { transform: translateX(-105%); }
.menu-open .sidebar { transform: none !important; }
.menu-open .backdrop { display: block; position: fixed; inset: 0; z-index: 60; background: rgba(9, 20, 18, .45); }
.focus-mode .view { max-width: 1480px; }
[data-route="pos"] .view, [data-route="purchases"] .view.is-full { max-width: none; }

@media (max-width: 1024px) {
  .layout-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 70; transform: translateX(105%); transition: transform .22s ease; box-shadow: var(--shadow-3); }
  :root[dir="ltr"] .sidebar { transform: translateX(-105%); }
  .menu-btn { display: inline-grid; }
  .user-name { display: none; }
  .user-chip { padding: 0 4px; }
  .user-chip > .ico { display: none; }
  .view { padding: 14px; }
  .topbar { padding: 0 12px; gap: 8px; }
}

/* ==========================================================
   Home — tile dashboard
   ========================================================== */
.tone-emerald { --t1: #10b981; --t2: #047857; }
.tone-green   { --t1: #22c55e; --t2: #15803d; }
.tone-mint    { --t1: #34d399; --t2: #0f9f78; }
.tone-teal    { --t1: #14b8a6; --t2: #0f766e; }
.tone-cyan    { --t1: #22b8cf; --t2: #0e7490; }
.tone-sky     { --t1: #38bdf8; --t2: #0369a1; }
.tone-indigo  { --t1: #6366f1; --t2: #4338ca; }
.tone-violet  { --t1: #a78bfa; --t2: #6d28d9; }
.tone-navy    { --t1: #3b5b8c; --t2: #1e3a5f; }
.tone-amber   { --t1: #f5b52a; --t2: #c76a06; }
.tone-orange  { --t1: #fb923c; --t2: #ea580c; }
.tone-coral   { --t1: #f87171; --t2: #dc2626; }
.tone-rose    { --t1: #f472b6; --t2: #be185d; }
.tone-slate   { --t1: #94a3b8; --t2: #475569; }

.dash-hero {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 26px; border-radius: var(--r-xl); color: #fff;
  background: linear-gradient(135deg, #0f766e 0%, #115e59 55%, #134e4a 100%); box-shadow: 0 10px 30px rgba(15, 118, 110, .22);
}
.dash-hero::after { content: ""; position: absolute; inset-inline-start: -70px; top: -90px; width: 280px; height: 280px; border-radius: 50%; background: rgba(255, 255, 255, .07); }
.dash-hero-text { position: relative; z-index: 1; min-width: 0; }
.dash-greet { opacity: .85; font-size: 14px; }
.dash-shop { font-size: 26px; margin: 2px 0 8px; }
.dash-meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 13px; opacity: .85; }
.dash-meta .sep { color: inherit; opacity: .5; }
.dash-hero-art { position: relative; z-index: 1; opacity: .9; }
[data-theme="dark"] .dash-hero { background: linear-gradient(135deg, #115e59, #0b3b37); }
.dash-block { margin-top: 24px; }
.dash-title { font-size: 14px; color: var(--muted); font-weight: 800; margin-bottom: 12px; }

.tiles { display: grid; gap: 12px; }
.tiles-sections { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.tiles-actions { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-flow: dense; }
.tile {
  position: relative; overflow: hidden; isolation: isolate; display: flex; flex-direction: column; justify-content: space-between; gap: 14px;
  min-height: 128px; padding: 16px; border-radius: var(--r-xl); color: #fff;
  background: linear-gradient(150deg, var(--t1), var(--t2)); box-shadow: 0 4px 14px color-mix(in srgb, var(--t2) 28%, transparent);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.tile::before { content: ""; position: absolute; z-index: -1; width: 150px; height: 150px; border-radius: 50%; inset-inline-end: -46px; bottom: -66px; background: rgba(255, 255, 255, .12); transition: transform .3s ease; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 10px 24px color-mix(in srgb, var(--t2) 38%, transparent); filter: saturate(1.06); }
.tile:hover::before { transform: scale(1.25); }
.tile:active { transform: translateY(0) scale(.985); }
.tile-icon { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 15px; background: rgba(255, 255, 255, .18); }
.tile-text { display: flex; flex-direction: column; }
.tile-label { font-size: 17px; font-weight: 800; line-height: 1.35; }
.tile-sub { font-size: 12px; opacity: .88; }
.tile-md { min-height: 148px; }
.tile-sm { min-height: 118px; }
.tile-sm .tile-icon { width: 46px; height: 46px; border-radius: 13px; }
.tile-sm .tile-label { font-size: 15px; }
.tile-wide { grid-column: span 2; min-height: 118px; flex-direction: row; align-items: center; justify-content: flex-start; }
.tile-wide .tile-icon { width: 70px; height: 70px; border-radius: 20px; }
.tile-wide .tile-label { font-size: 22px; }
.soon-icon { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 24px; margin: 0 auto 8px; color: #fff; background: linear-gradient(145deg, var(--t1), var(--t2)); }
@media (max-width: 560px) {
  .tiles-actions, .tiles-sections { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { min-height: 112px; padding: 14px; }
  .tile-wide .tile-label { font-size: 18px; }
  .tile-wide .tile-icon { width: 56px; height: 56px; }
  .dash-hero { padding: 18px; }
  .dash-shop { font-size: 21px; }
  .dash-hero-art { display: none; }
}

/* ==========================================================
   Admin / team
   ========================================================== */
.tenant-list { display: flex; flex-direction: column; gap: 10px; }
.tenant { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); }
.tenant + .tenant { margin-top: 0; }
.tenant.is-suspended, .card.is-suspended { background: var(--surface-2); }
.tenant-main { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tenant-info { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tenant-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-weight: 800; font-size: 16px; }
.tenant-owner { display: flex; gap: 10px; flex-wrap: wrap; }
.owner { display: inline-flex; align-items: center; }
.tenant-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.tenant-edit { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border-strong); }
.branch-list { display: flex; flex-direction: column; gap: 10px; }

/* ==========================================================
   Inventory
   ========================================================== */
.pform { display: flex; flex-direction: column; gap: 16px; }
.pform-section { min-width: 0; margin: 0; padding: 14px 16px 16px; border: 1px solid var(--border); border-radius: var(--r-lg); }
.pform-section legend { padding: 0 6px; font-weight: 800; font-size: 14px; color: var(--primary); }
.pform-optional summary { cursor: pointer; font-weight: 800; color: var(--primary); }
.pform-optional[open] summary { margin-bottom: 14px; }
.profit-box:empty { display: none; }
.profit { margin-top: 12px; padding: 9px 12px; border-radius: var(--r); background: var(--ok-soft); color: var(--ok); font-size: 14px; font-weight: 600; }
.profit-bad { background: var(--danger-soft); color: var(--danger); }
.img-pick { min-height: 150px; }
.img-drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 100%; min-height: 150px; cursor: pointer;
  border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); font: inherit; color: var(--text-2);
}
.img-drop:hover { border-color: var(--primary); color: var(--primary); }
.img-drop-icon { font-size: 28px; color: var(--primary); }
.img-drop-icon .ico { width: 30px; height: 30px; }
.img-preview { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.img-preview img { width: 150px; height: 150px; object-fit: cover; border-radius: var(--r-lg); border: 1px solid var(--border); }
.img-actions { display: flex; gap: 6px; }

.inv-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.inv-stat {
  display: flex; align-items: center; gap: 12px; min-height: 84px; padding: 14px 16px; border-radius: var(--r-lg); text-align: start;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); font: inherit; color: var(--text);
}
.inv-stat.clickable { cursor: pointer; transition: border-color .15s, transform .15s; }
.inv-stat.clickable:hover { border-color: var(--danger); transform: translateY(-2px); }
.inv-stat-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; flex-shrink: 0; color: #fff; background: linear-gradient(145deg, var(--t1), var(--t2)); }
.inv-stat-text { display: flex; flex-direction: column; min-width: 0; }
.inv-stat-label { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-stat-value { font-size: 20px; font-weight: 800; line-height: 1.35; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-stat-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inv-panel { padding: 14px; }
.inv-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.inv-search {
  flex: 1 1 320px; display: flex; align-items: center; gap: 4px; min-height: var(--h); padding: 0 4px;
  border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface);
}
.inv-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.inv-search-icon { display: inline-grid; place-items: center; padding-inline: 6px 2px; color: var(--muted); }
.inv-search-icon .ico { width: 18px; height: 18px; }
.inv-search-input { min-height: 36px; border: 0 !important; box-shadow: none !important; padding: 0 4px; background: transparent; }
.inv-search .icon-btn { width: 32px; height: 32px; border-color: transparent; }
.inv-cat-select { width: auto; flex: 0 1 200px; }
.inv-subbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: 12px 0 10px; }
.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 12px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .15s;
}
.fchip .ico { width: 15px; height: 15px; }
.fchip:hover { border-color: var(--border-strong); color: var(--text); }
.fchip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.inv-table { table-layout: fixed; min-width: 860px; }
.inv-table td { height: 58px; }
.inv-table .c-code { width: 84px; }
.inv-table .c-barcode { width: 150px; }
.inv-table .c-cat { width: 150px; }
.inv-table .c-qty { width: 150px; }
.inv-table .c-price { width: 124px; }
.p-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.p-thumb { width: 40px; height: 40px; border-radius: var(--r); object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); background: var(--surface-2); }
.p-thumb-empty { display: grid; place-items: center; color: var(--muted); }
.p-thumb-empty .ico { width: 20px; height: 20px; }
.p-cell-text { display: flex; flex-direction: column; min-width: 0; }
.p-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-sub { display: flex; align-items: center; gap: 4px; min-height: 0; font-size: 12px; color: var(--muted); }
.p-sub:empty { display: none; }
.p-sub .tag { margin: 0; }
.qty-badge { display: inline-flex; align-items: baseline; gap: 4px; padding: 4px 10px; border-radius: 999px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.qty-badge small { font-weight: 600; font-size: 11px; }
.qty-ok { background: var(--ok-soft); color: var(--ok); }
.qty-low { background: var(--warn-soft); color: var(--warn); }
.qty-out { background: var(--danger-soft); color: var(--danger); }
.qty-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.inv-more { display: flex; justify-content: center; padding-top: 12px; }
.inv-more:empty { display: none; }

.pd-head { display: flex; gap: 16px; align-items: flex-start; }
.pd-img { width: 96px; height: 96px; border-radius: var(--r-xl); object-fit: cover; border: 1px solid var(--border); flex-shrink: 0; }
.pd-img-empty { display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.pd-head-text { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.pd-name { font-size: 20px; }
.pd-expiry { align-self: flex-start; font-size: 13px; padding: 6px 10px; border-radius: var(--r-sm); background: var(--surface-2); }
.pd-expiry.is-warn { background: var(--warn-soft); color: var(--warn); }
.pd-expiry.is-bad { background: var(--danger-soft); color: var(--danger); }
.pd-prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 18px 0; }
.pd-price { display: flex; flex-direction: column; padding: 10px 12px; border-radius: var(--r-lg); background: color-mix(in srgb, var(--t1) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--t1) 28%, var(--border)); }
.pd-price-label { font-size: 12px; color: var(--muted); }
.pd-price-value { font-size: 17px; font-weight: 800; color: color-mix(in srgb, var(--t2) 80%, var(--text)); font-variant-numeric: tabular-nums; }
[data-theme="dark"] .pd-price-value { color: var(--t1); }
.pd-section { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.pd-section h4 { margin: 0 0 8px; font-size: 15px; }
.pd-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.pd-section-head h4 { margin: 0; }
.pd-barcode { display: flex; justify-content: center; padding: 12px; border-radius: var(--r-lg); background: #fff; border: 1px solid var(--border); }
.pd-barcode svg { max-width: 100%; height: auto; }
.pd-barcode-text { padding: 10px; border-radius: var(--r); background: var(--surface-2); text-align: center; font-size: 18px; font-weight: 700; }
.pd-notes { margin: 0; white-space: pre-wrap; color: var(--muted); }
.moves { list-style: none; margin: 0; padding: 0; }
.move { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.move:last-child { border-bottom: 0; }
.move-dot { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; font-weight: 800; }
.move-dot.in { background: var(--ok-soft); color: var(--ok); }
.move-dot.out { background: var(--danger-soft); color: var(--danger); }
.move-text { flex: 1; min-width: 0; font-size: 14px; }
.move-qty { text-align: var(--end); }
.adj-diff { min-height: 1.4em; font-weight: 800; }

.units-note { margin: 0 0 10px; }
.units-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.unit-row { display: grid; grid-template-columns: 1.1fr 1.2fr 1fr 1.4fr auto; gap: 8px; align-items: end; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2); }
.unit-base { display: grid; place-items: center; min-height: var(--h); padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--muted); font-size: 13px; white-space: nowrap; }
.unit-hint { grid-column: 1 / -1; }
.unit-hint:empty { display: none; }
.unit-del { align-self: end; }

.steps { display: flex; flex-direction: column; gap: 8px; margin: 0 0 14px; padding-inline-start: 20px; }
.steps .btn { margin-top: 6px; }
.import-drop { min-height: 140px; }
.import-drop.drag { border-color: var(--primary); background: var(--primary-soft); }
.import-summary { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.import-file { max-width: 60%; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-cols { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 12px; }
.import-wh { max-width: 280px; margin-bottom: 12px; }
.import-table { max-height: 46vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--r-lg); }
.import-table thead th { position: sticky; top: 0; z-index: 1; border-radius: 0 !important; border-top: 0; }
.import-progress { display: flex; flex-direction: column; gap: 10px; padding: 20px 0; }
.progress { height: 10px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress-bar { width: 0; height: 100%; background: var(--primary); transition: width .3s; }
.import-result { display: flex; flex-direction: column; gap: 12px; text-align: center; }
.import-result .stat { text-align: start; }
.import-issues { text-align: start; }
.import-issues summary { cursor: pointer; font-weight: 800; }

/* camera scanner */
.scan-overlay { z-index: 120; }
.scan-box { display: flex; flex-direction: column; gap: 10px; width: min(420px, 100%); padding: 14px; border-radius: var(--r-xl); background: var(--surface); }
.scan-frame { position: relative; overflow: hidden; aspect-ratio: 4 / 3; border-radius: var(--r-lg); background: #000; }
.scan-video { display: block; width: 100%; height: 100%; object-fit: cover; }
.scan-line { position: absolute; inset-inline: 12%; top: 50%; height: 2px; background: #22d3a0; box-shadow: 0 0 12px #22d3a0; animation: scanline 1.6s ease-in-out infinite alternate; }
@keyframes scanline { from { top: 25%; } to { top: 75%; } }
.scan-status { text-align: center; color: var(--muted); font-size: 14px; }

/* ==========================================================
   POS (and the purchase screen, which reuses it)
   ========================================================== */
/* On desktop the POS fills the window: the cart scrolls, the pay panel stays. */
[data-route="pos"] .view { padding: 14px; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: stretch; }
@media (min-width: 1101px) and (min-height: 600px) {
  [data-route="pos"] .pos, .purchase-screen .pos { height: calc(100vh - var(--topbar-h) - 28px); height: calc(100dvh - var(--topbar-h) - 28px); }
  [data-route="pos"] .pos-main, [data-route="pos"] .pos-side, .purchase-screen .pos-main, .purchase-screen .pos-side { min-height: 0; overflow: hidden; }
  .pos-side-scroll { overflow-y: auto; }
}
.pos-main { display: flex; flex-direction: column; min-width: 0; padding: 14px; }
.pos-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pos-search {
  position: relative; flex: 1 1 380px; display: flex; align-items: center; gap: 6px; min-height: 54px; padding: 5px;
  border: 2px solid var(--primary); border-radius: var(--r-lg); background: var(--surface); box-shadow: 0 0 0 4px var(--primary-ring);
}
.pos-search-icon { display: grid; place-items: center; width: 36px; color: var(--primary); }
.pos-search-input { flex: 1; min-width: 0; min-height: 40px; padding: 0 4px; border: 0 !important; box-shadow: none !important; font-size: 17px; background: transparent; }
.pos-x { color: var(--muted); font-weight: 800; padding: 0 2px; }
.pos-qtybox { width: 70px; min-height: 40px; text-align: center !important; font-size: 17px; font-weight: 800; background: var(--surface-2); border-color: var(--border); }
.pos-search .icon-btn { border-color: var(--border); background: var(--surface-2); }
.pos-suggest {
  position: absolute; top: calc(100% + 8px); inset-inline: 0; z-index: 25; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
}
.sugg {
  display: grid; grid-template-columns: 64px minmax(0, 1fr) 110px 110px; gap: 12px; align-items: center; width: 100%; min-height: 48px; padding: 6px 14px;
  border: 0; border-bottom: 1px solid var(--border); background: none; font: inherit; color: var(--text); text-align: start; cursor: pointer;
}
.sugg:last-child { border-bottom: 0; }
.sugg.active, .sugg:hover { background: var(--primary-soft); }
.sugg-code { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.sugg-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg-qty { font-size: 13px; text-align: center; white-space: nowrap; }
.sugg-price { font-weight: 800; color: var(--primary); text-align: var(--end); white-space: nowrap; font-variant-numeric: tabular-nums; }

.pos-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.pos-meta { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.pos-meta strong { font-size: 15px; }
.pos-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.pos-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text-2); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap; transition: all .15s;
}
.pos-chip .ico { width: 16px; height: 16px; color: var(--muted); }
.pos-chip:hover { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.pos-chip.icon-only { width: 34px; padding: 0; justify-content: center; }
.pos-chip.on { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); color: var(--primary-700); }
[data-theme="dark"] .pos-chip.on { color: var(--primary); }
.pos-chip.on .ico { color: var(--primary); }
.pos-chip.has-items { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); color: var(--warn); }
.pos-chip.has-items .ico { color: var(--warn); }
.chip-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px; font-weight: 800; }
.switch-dot { width: 26px; height: 15px; border-radius: 999px; background: var(--border-strong); position: relative; flex-shrink: 0; transition: background .15s; }
.switch-dot::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; }
.on .switch-dot { background: var(--primary); }
.on .switch-dot::after { inset-inline-start: 13px; }

.pos-cart { flex: 1; min-height: 0; overflow: auto; margin-top: 12px; }
.pos-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; height: 100%; min-height: 300px; text-align: center; color: var(--muted); }
.pos-empty-icon { display: grid; place-items: center; width: 92px; height: 92px; margin-bottom: 6px; border-radius: 26px; background: var(--primary-soft); color: var(--primary); }
.pos-empty-keys { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; }

/* Cart table: fixed columns so every number sits exactly under its header. */
.pos-table { table-layout: fixed; min-width: 760px; }
.pos-table th { position: sticky; top: 0; z-index: 2; }
.pos-table td { height: 56px; padding: 6px 10px; }
.pos-table th { padding: 0 10px; }
.pos-table .c-idx { width: 44px; text-align: center; padding-inline: 4px; }
.pos-table .c-code { width: 84px; }
.pos-table .c-unit { width: 128px; }
.pos-table .c-stock { width: 84px; }
.pos-table .c-qty { width: 144px; }
.pos-table .c-price { width: 118px; }
.pos-table .c-total { width: 116px; }
.pos-table .c-del { width: 52px; text-align: center; padding-inline: 4px; }
.pos-table .c-sell { width: 118px; }
.pur-table .c-qty { width: 104px; }
.ret-table { table-layout: fixed; min-width: 760px; }
.ret-table td { height: 54px; padding: 6px 10px; }
.ret-table th { padding: 0 10px; }
.ret-table .c-code { width: 80px; }
.ret-table .c-unit { width: 110px; }
.ret-table .c-n { width: 92px; }
.ret-table .c-price { width: 112px; }
.ret-table .c-qty { width: 112px; }
.ret-table .c-total { width: 112px; }
.ret-table .c-del { width: 52px; text-align: center; }
.ret-table .price-input { max-width: 96px; }
.pur-table { min-width: 860px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.stack-sm .link-btn { align-self: center; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); }
.stack-sm .link-btn .ico { width: 15px; height: 15px; }
.pos-table tbody tr.just-added td { background: var(--primary-soft); }
.pos-table tbody tr.selected td { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.pos-table tbody tr.selected td:first-child { box-shadow: inset -3px 0 0 var(--primary); color: var(--primary); font-weight: 800; }
:root[dir="ltr"] .pos-table tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
.pos-table tbody tr.row-error td { background: var(--danger-soft); }
.line-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.line-name .cell-text { font-weight: 700; font-size: 14.5px; }
.line-name .tag { margin: 0; flex-shrink: 0; }
.line-total { font-weight: 800; font-size: 15px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.unit-select { width: 100%; min-height: 34px; padding-inline: 10px 30px; font-size: 13px; border-radius: var(--r-sm); background-position: left 10px center; }
:root[dir="ltr"] .unit-select { padding-inline: 10px 30px; background-position: right 10px center; }
.unit-text { color: var(--text-2); font-size: 13.5px; }
.qty-stepper { display: inline-flex; align-items: stretch; height: 36px; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface); }
.qty-stepper .step { display: grid; place-items: center; width: 34px; border: 0; background: var(--surface-2); color: var(--text-2); font-size: 17px; font-weight: 800; cursor: pointer; }
.qty-stepper .step .ico { width: 15px; height: 15px; }
.qty-stepper .step:hover { background: var(--primary-soft); color: var(--primary); }
/* Code order is [+][qty][−] (right-to-left reading); English reads [−][qty][+]. */
:root[dir="ltr"] .qty-stepper { flex-direction: row-reverse; }
.qty-input { width: 60px; min-height: 0; height: 100%; padding: 0 2px; border: 0 !important; border-radius: 0; box-shadow: none !important; text-align: center !important; font-weight: 800; font-variant-numeric: tabular-nums; }
.price-input { width: 100%; min-height: 36px; padding: 0 8px; text-align: center !important; font-variant-numeric: tabular-nums; border-radius: var(--r-sm); }
.price-cell { display: flex; flex-direction: column; align-items: stretch; gap: 3px; }
.price-cell .tag { margin: 0; align-self: center; }
.pos-cart-foot { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 4px 0; margin-top: 8px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 700; }
.pos-cart-foot:empty { display: none; }
.pos-cart-foot .kbd { font-weight: 600; }

/* Pay panel */
.pos-side { display: flex; flex-direction: column; gap: 0; padding: 0; min-width: 0; }
.pos-side-scroll { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 14px; }
.pos-side-foot { padding: 12px 14px 14px; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.pos-box { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface-2); }
.pos-cust { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.pos-cust-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.pos-cust-icon .ico { width: 20px; height: 20px; }
.pos-cust.has-customer .pos-cust-icon { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 800; }
.pos-cust-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.45; }
.pos-cust-text strong { font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-cust-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pos-tier, .seg-group { display: flex; gap: 4px; padding: 4px; border-radius: var(--r); background: var(--surface-3); }
.seg { flex: 1; min-height: 34px; padding: 0 10px; border: 0; border-radius: var(--r-sm); background: transparent; font: inherit; font-size: 13.5px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg:hover { color: var(--text); }
.seg.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1); }
.pos-sums { display: flex; flex-direction: column; gap: 8px; }
.sum-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 28px; font-size: 14px; }
.sum-row .mono { font-weight: 700; }
.pos-discount-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.pos-discount-row > span { font-size: 14px; color: var(--muted); }
.pos-discount { width: 100%; min-height: 38px; text-align: center !important; }
.seg-mini { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-sm); background: var(--surface-3); }
.seg-mini .seg { min-height: 30px; padding: 0 10px; font-size: 13px; }
.pos-total {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 64px; padding: 10px 16px; margin-top: 2px;
  border-radius: var(--r-lg); color: #fff; font-weight: 800; background: linear-gradient(135deg, #0f766e, #134e4a);
}
.pos-total > span:first-child { font-size: 15px; opacity: .92; }
.pos-total .mono { font-size: 28px; line-height: 1.2; }
.pur-total { background: linear-gradient(135deg, #b45309, #7c3a06); }
.pos-pay-block { display: flex; flex-direction: column; gap: 10px; }
.pay-methods { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 6px; }
.pay-methods.wrap { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pay-method {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 58px; padding: 6px 4px;
  border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text-2);
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.pay-method .ico { width: 20px; height: 20px; color: var(--muted); }
.pay-method:hover:not(:disabled) { border-color: var(--border-strong); background: var(--surface-2); }
.pay-method.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-700); box-shadow: inset 0 0 0 1px var(--primary); }
[data-theme="dark"] .pay-method.active { color: var(--primary); }
.pay-method.active .ico { color: var(--primary); }
.pay-method:disabled { opacity: .45; cursor: not-allowed; }
.pos-quick { display: flex; gap: 6px; }
.pos-quick > * { flex: 1 1 0; min-width: 0; }
.pos-quick:empty { display: none; }
.quick-btn {
  min-height: 34px; padding: 0 6px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface);
  color: var(--text-2); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quick-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.pos-info:empty { display: none; }
.pos-change, .pos-due, .done-change, .done-due { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 4px 10px; padding: 10px 14px; border-radius: var(--r-lg); font-weight: 700; }
.pos-change, .done-change { background: var(--ok-soft); color: var(--ok); }
.pos-change strong, .done-change strong { font-size: 22px; }
.pos-due, .done-due { background: var(--warn-soft); color: var(--warn); }
.pos-due strong, .done-due strong { font-size: 18px; }
.pos-due .small { width: 100%; font-weight: 600; }
.pos-due.warn { display: block; background: var(--danger-soft); color: var(--danger); font-size: 13.5px; }
.pos-notes { min-height: 38px; font-size: 13.5px; }
.pos-pay { width: 100%; min-height: 56px; border-radius: var(--r-lg); font-size: 17px; gap: 10px; }
.pos-pay .pay-amount { font-variant-numeric: tabular-nums; unicode-bidi: isolate; }
.pos-pay .kbd { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .28); color: #fff; }
.done { display: flex; flex-direction: column; gap: 10px; text-align: center; }
.done .kv { text-align: start; }
.done-icon { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 4px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); }
.done-icon .ico { width: 40px; height: 40px; }

/* pickers */
.picker-list { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow: auto; }
.picker-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); font: inherit; color: var(--text); text-align: start; cursor: pointer;
}
.picker-item.active, .picker-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.picker-main { display: flex; flex-direction: column; min-width: 0; }
.picker-main strong, .picker-main span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.held-item { cursor: default; }
.held-item:hover { background: var(--surface); border-color: var(--border-strong); }

/* customer / supplier page */
.cust-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.cust-info { display: flex; align-items: center; gap: 14px; min-width: 0; }
.cust-avatar { display: grid; place-items: center; width: 58px; height: 58px; border-radius: 18px; flex-shrink: 0; color: #fff; font-size: 24px; font-weight: 800; background: linear-gradient(145deg, #14b8a6, #0f766e); }
.sup-avatar { background: linear-gradient(145deg, #f5b52a, #b45309); }
.cust-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 21px; }
.cust-balance { display: flex; flex-direction: column; align-items: center; padding: 12px 22px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); }
.cust-balance strong { font-size: 24px; font-variant-numeric: tabular-nums; }
.cust-balance.bal-owes { background: var(--danger-soft); border-color: transparent; }
.cust-balance.bal-credit { background: var(--ok-soft); border-color: transparent; }
.cust-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.cust-stats { margin-bottom: 16px; }
.statement td { vertical-align: middle; }
.cust-invoices .inv-row td { vertical-align: middle; }

/* invoice drawer */
.inv-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.meta-box { display: flex; flex-direction: column; padding: 9px 12px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.meta-box > * { overflow: hidden; text-overflow: ellipsis; }
.inv-totals { display: flex; flex-direction: column; gap: 4px; max-width: 380px; margin-top: 14px; margin-inline-start: auto; }

/* purchases & returns */
.pur-head { display: flex; gap: 10px; align-items: stretch; flex-wrap: wrap; margin-bottom: 12px; }
.pur-head > .pos-box { flex: 1 1 280px; display: flex; align-items: center; }
.pur-head > .pos-box > * { flex: 1; }
.pur-fields { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 320px; align-items: center; }
.pur-fields > * { flex: 1 1 150px; width: auto; }
.ret-hero { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; margin-bottom: 16px; }
.ret-hero .tile { border: 0; cursor: pointer; font: inherit; text-align: start; }
.ret-mode { max-width: 440px; margin-bottom: 12px; }
.ret-inv-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 10px; border-radius: var(--r-lg); background: var(--surface-2); border: 1px solid var(--border); }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 1280px) {
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
  .pos-table .c-code { width: 70px; }
  .pos-table .c-unit { width: 112px; }
  .pos-table .c-stock { width: 70px; }
}
@media (max-width: 1100px) {
  .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-main { min-height: 0; }
  .pos-side-foot { position: sticky; bottom: 0; z-index: 5; box-shadow: 0 -6px 16px rgba(16, 32, 29, .06); }
}
@media (max-width: 760px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .hide-sm { display: none !important; }
  .is-drawer .sheet { max-width: 100%; }
  .sheet-overlay:not(.is-drawer) { align-items: flex-end; padding: 0; }
  .sheet-overlay:not(.is-drawer) .sheet { max-height: 92vh; max-height: 92dvh; border-radius: var(--r-xl) var(--r-xl) 0 0; }
  .sheet-overlay:not(.is-drawer) .sheet-footer { border-radius: 0; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .inv-cat-select { flex: 1 1 100%; }
  .inv-table { min-width: 0; }
  .inv-stats, .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .inv-stat, .stat { min-height: 0; padding: 10px 12px; gap: 10px; }
  .inv-stat-icon, .stat-icon { width: 34px; height: 34px; border-radius: 10px; }
  .inv-stat-icon .ico, .stat-icon .ico { width: 18px; height: 18px; }
  .inv-stat-value, .stat-value { font-size: 16px; }
  .inv-stat-sub { white-space: normal; }
  .inv-table .c-code { width: 58px; }
  .inv-table .c-qty { width: 96px; }
  .inv-table .c-price { width: 86px; }
  .inv-table .p-thumb { display: none; }
  .inv-table th, .inv-table td { padding-inline: 6px; }
  .unit-row { grid-template-columns: 1fr 1fr; }
  .unit-row .unit-del { grid-column: 2; justify-self: end; }
  .card { padding: 14px; }
  .inv-panel { padding: 10px; }
  .page-title { font-size: 16px; }
  .toasts { inset-inline: 12px; bottom: 12px; max-width: none; }

  /* POS cart becomes stacked cards: name on top, controls below. */
  .pos-main { padding: 10px; }
  .pos-search { flex-basis: 100%; min-height: 50px; }
  .pos-table { min-width: 0; table-layout: auto; }
  .pos-table thead { display: none; }
  .pos-table, .pos-table tbody { display: block; }
  .pos-table tbody tr {
    display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto; grid-template-areas: "idx name name del" "unit unit unit unit" "qty qty price total";
    gap: 6px 10px; align-items: center; padding: 10px 8px; border-bottom: 1px solid var(--border);
  }
  .pos-table td { display: block; height: auto; padding: 0; border: 0 !important; background: transparent !important; box-shadow: none !important; }
  .pos-table .c-idx { grid-area: idx; width: auto; }
  .pos-table .c-name { grid-area: name; }
  .pos-table .c-del { grid-area: del; width: auto; }
  .pos-table .c-unit { grid-area: unit; width: auto; }
  .pos-table .c-unit:not(.has-select) { display: none; }
  .pos-table .c-qty { grid-area: qty; width: auto; }
  .pos-table .c-price { grid-area: price; width: auto; }
  .pos-table .c-total { grid-area: total; width: auto; text-align: var(--end) !important; }
  .pos-table .c-code, .pos-table .c-stock { display: none; }
  .pur-table tbody tr { grid-template-areas: "name name name del" "unit unit unit unit" "qty price total total" "sell sell sell sell"; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto auto; }
  .pur-table .c-sell { grid-area: sell; width: auto; }
  .pur-table .c-sell .price-cell { flex-direction: row; align-items: center; gap: 8px; }
  .pur-table .c-qty .price-input { width: 100%; }
  .pos-table tbody tr.selected { background: color-mix(in srgb, var(--primary) 7%, var(--surface)); border-radius: var(--r); }
  .pos-table tbody tr.row-error { background: var(--danger-soft); border-radius: var(--r); }
  .price-input { width: 96px; }
  .pos-cart-foot .kbd, .pos-keys-hint { display: none; }
  .pos-tools .pos-chip .chip-label { display: none; }
  .sugg { grid-template-columns: minmax(0, 1fr) auto; }
  .sugg-code, .sugg-qty { display: none; }
}
@media (max-width: 400px) {
  .view { padding: 10px; }
  .btn { padding: 0 12px; }
  .pos-total .mono { font-size: 24px; }
}

/* Installed app (standalone window): no browser chrome, so give the
   top bar a touch more presence and avoid accidental text selection. */
@media (display-mode: standalone) {
  .topbar { background: var(--surface); }
  .page-title, .nav-title, .tile-label, th { cursor: default; }
}

/* ==========================================================
   Print safety (screens are never printed directly, but just in case)
   ========================================================== */
@media print {
  .sidebar, .topbar, .toasts { display: none !important; }
}
