/* Small Shop Portal — admin console styles.
   Colours are tokens: light by default, dark when the computer prefers it (theme "System") or when
   the user picks Dark in the top bar (html[data-theme]). */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --surface-3: #eef1f5;
  --border: #e3e7ed;
  --border-strong: #d0d6de;
  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --primary: #0f766e;
  --primary-hover: #0b5f58;
  --primary-soft: #e6f4f2;
  --primary-ring: rgba(15, 118, 110, .22);
  --primary-light: #14b8a6;   /* lighter end of logo / avatar gradients */
  --on-primary: #ffffff;      /* text on primary-coloured buttons */
  --danger: #c0262d;
  --danger-soft: #fdeceb;
  --warn: #a45b06;
  --warn-soft: #fdf3e1;
  --ok: #13803b;
  --ok-soft: #e6f6eb;
  --info: #2457c5;
  --info-soft: #e9effc;
  --side-bg: #0f1a19;
  --side-text: #c9d4d2;
  --side-muted: #7f8f8c;
  --side-hover: rgba(255, 255, 255, .06);
  --side-active: rgba(45, 212, 191, .14);
  --side-accent: #2dd4bf;
  --side-strong: #ffffff;     /* brightest text in the menu (shop name, hovered and active pages) */
  --side-line: rgba(255, 255, 255, .08);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 20px 48px rgba(16, 24, 40, .18);
  --font: "Inter", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --side-w: 272px;
  --top-h: 60px;
  color-scheme: light;
}

/* Dark: the same tokens with dark values. Applied for theme "System" on a dark computer,
   or for theme "Dark" whatever the computer uses. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1211; --surface: #151b1a; --surface-2: #1b2221; --surface-3: #222a29; --border: #29312f; --border-strong: #36403e;
    --text: #e8eceb; --text-2: #c7cfcd; --muted: #93a09d;
    --primary: #2bb3a3; --primary-hover: #3ccab9; --primary-soft: #16302d; --primary-ring: rgba(43, 179, 163, .3);
    --danger: #f2776b; --danger-soft: #3a1f1c; --warn: #e9a94b; --warn-soft: #362a16; --ok: #5fcf86; --ok-soft: #173122;
    --info: #7ea6ff; --info-soft: #1b2643;
    --side-bg: #0a0f0e; --side-text: #c4cecc; --side-muted: #6f7d7a;
    --shadow: none; --shadow-md: 0 4px 16px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 56px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1211; --surface: #151b1a; --surface-2: #1b2221; --surface-3: #222a29; --border: #29312f; --border-strong: #36403e;
  --text: #e8eceb; --text-2: #c7cfcd; --muted: #93a09d;
  --primary: #2bb3a3; --primary-hover: #3ccab9; --primary-soft: #16302d; --primary-ring: rgba(43, 179, 163, .3);
  --danger: #f2776b; --danger-soft: #3a1f1c; --warn: #e9a94b; --warn-soft: #362a16; --ok: #5fcf86; --ok-soft: #173122;
  --info: #7ea6ff; --info-soft: #1b2643;
  --side-bg: #0a0f0e; --side-text: #c4cecc; --side-muted: #6f7d7a;
  --shadow: none; --shadow-md: 0 4px 16px rgba(0, 0, 0, .35); --shadow-lg: 0 24px 56px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
/* A dropdown never grows wider than its space (a long category name would push phones sideways). */
select { max-width: 100%; text-overflow: ellipsis; }
.card-head > select, .card-head > input { min-width: 0; }
.pos > *, .row > *, .row3 > *, .field { min-width: 0; }
.card-head > select { flex: 0 1 auto; max-width: 45%; min-width: min(160px, 45%); }
@media (max-width: 560px) {
  .pos .card-head { flex-wrap: wrap; }
  .pos .card-head > input, .pos .card-head > select { flex: 1 1 100%; max-width: 100%; }
}
h1, h2, h3 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.015em; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.005em; }
h3 { font-size: 14px; font-weight: 650; }
a { color: var(--primary); text-underline-offset: 2px; }
a:hover { color: var(--primary-hover); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary-soft); }

/* ---------- Layout: sidebar + top bar + page ---------- */
.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.content { min-width: 0; display: flex; flex-direction: column; }

.sidebar { background: var(--side-bg); color: var(--side-text); padding: 16px 12px 12px; display: flex; flex-direction: column; gap: 6px; position: sticky; top: 0; height: 100vh; overflow: hidden; }
/* In a short window the menu scrolls; nothing in it is squeezed (the logo would spill over the divider). */
.sidebar > * { flex-shrink: 0; }
.sidebar { border-right: 1px solid var(--side-line); }
/* The logo stays in place; only the list of pages scrolls when the window is short. Its side padding
   (cancelled by the negative margin) keeps the active-page marker visible. */
.sidebar > .nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 -12px; padding: 0 12px 8px; scrollbar-width: thin; scrollbar-color: var(--side-line) transparent; }
/* Logo and shop name, set apart from the menu by space and a thin divider. */
.brand { position: relative; display: flex; align-items: center; gap: 10px; padding: 4px 36px 16px 8px; margin-bottom: 14px; border-bottom: 1px solid var(--side-line); font-weight: 700; font-size: 15px; color: var(--side-strong); letter-spacing: -.01em; min-height: 52px; }
.brand > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--primary-light), var(--primary)); display: grid; place-items: center; color: var(--on-primary); flex: none; box-shadow: 0 2px 8px var(--primary-ring); }
.nav { display: flex; flex-direction: column; gap: 14px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: 11px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--side-muted); padding: 0 10px 4px; white-space: nowrap; }
.nav a { position: relative; display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-weight: 500; white-space: nowrap; transition: background .15s, color .15s; }
.nav a:hover { background: var(--side-hover); color: var(--side-strong); }
.nav a.active { background: var(--side-active); color: var(--side-strong); }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--side-accent); }
.nav a.active svg { color: var(--side-accent); }
.nav svg { width: 18px; height: 18px; flex: none; }
/* « button at the top right of the logo area: collapses the menu to icons (and back). */
.nav-collapse { position: absolute; top: 2px; right: 0; display: grid; place-items: center; width: 30px; height: 30px; color: var(--side-muted); background: none; border: 0; border-radius: 8px; cursor: pointer; }
.nav-collapse:hover { background: var(--side-hover); color: var(--side-strong); }

/* Collapsed sidebar: icons only (desktop). */
@media (min-width: 861px) {
  .shell.collapsed { --side-w: 72px; }
  .shell.collapsed .brand > span, .shell.collapsed .nav a span, .shell.collapsed .nav-label { display: none; }
  .shell.collapsed .brand { flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 4px 0 14px; }
  .shell.collapsed .sidebar .brand-img { max-width: 44px; max-height: 44px; }
  .shell.collapsed .nav-collapse { position: static; }
  .shell.collapsed .nav-collapse svg { transform: scaleX(-1); }
  .shell.collapsed .nav a { justify-content: center; padding: 10px 0; }
  .shell.collapsed .nav-group + .nav-group { border-top: 1px solid var(--side-line); padding-top: 12px; }
}

.topbar { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 12px; padding: 0 28px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.topbar .menu-btn { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13.5px; color: var(--muted); }
.crumbs > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-sep { color: var(--border-strong); }
#crumb-page { color: var(--text); font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar .icon-btn { width: 36px; height: 36px; color: var(--muted); }
.topbar .icon-btn:hover { color: var(--text); }

.user-menu { position: relative; }
.user-menu > summary { list-style: none; display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 999px; cursor: pointer; color: var(--muted); }
.user-menu > summary::-webkit-details-marker { display: none; }
.user-menu > summary:hover, .user-menu[open] > summary { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--on-primary); background: linear-gradient(135deg, var(--primary-light), var(--primary)); flex: none; letter-spacing: .02em; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; text-align: left; }
.user-meta strong { color: var(--text); font-size: 13px; font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta small { font-size: 11.5px; color: var(--muted); }
.menu-list { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; animation: pop .14s ease-out; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; display: flex; flex-direction: column; }
.menu-head small { color: var(--muted); }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 10px; width: 100%; font: inherit; color: var(--text-2); text-decoration: none; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; text-align: left; }
.menu-list a:hover, .menu-list button:hover { background: var(--surface-2); color: var(--text); }
.menu-list #logout { color: var(--danger); }

.main { padding: 28px 28px 56px; min-width: 0; width: 100%; max-width: 1480px; }
.page-head { display: flex; align-items: center; gap: 10px 12px; margin-bottom: 22px; flex-wrap: wrap; min-height: 40px; }
/* Title on the left; buttons (and the Export menu) grouped on the right. */
.page-head > :first-child { margin-right: auto; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 24px 0; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.nav-backdrop { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .shell.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(8, 12, 11, .5); backdrop-filter: blur(2px); }
  .sidebar { position: fixed; z-index: 30; left: 0; width: 264px; transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .nav-collapse { display: none; }
  .topbar .menu-btn { display: inline-grid; margin-left: -6px; }
  .topbar { padding: 0 16px; }
  .crumb-shop, .crumb-sep { display: none; }
  .user-meta, .user-menu > summary > svg { display: none; }
  .user-menu > summary { padding: 2px; }
  .main { padding: 18px 16px 44px; }
}

/* ---------- Cards & KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 20px; border-bottom: 1px solid var(--border); min-height: 54px; }
.card-head a { font-size: 13px; font-weight: 550; text-decoration: none; }
.grid { display: grid; gap: 18px; }
.grid > * { min-width: 0; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 18px; }
.kpi { position: relative; padding: 16px 18px; transition: box-shadow .15s, border-color .15s; animation: rise .25s ease-out both; }
.kpi:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 550; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1.15; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi:has(.kpi-icon) .label { padding-right: 44px; }
.kpi-icon { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.kpi-icon.info { background: var(--primary-soft); color: var(--primary); }
.kpi-icon.ok { background: var(--ok-soft); color: var(--ok); }
.kpi-icon.warn { background: var(--warn-soft); color: var(--warn); }
.kpi-icon.danger { background: var(--danger-soft); color: var(--danger); }
.two-col { grid-template-columns: 2fr 1fr; }
.half { grid-template-columns: 1fr 1fr; }
.side-main { grid-template-columns: minmax(240px, 1fr) 2.6fr; align-items: start; }
@media (max-width: 1100px) { .two-col, .half, .side-main { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
/* Keep rows on one line and let the table scroll sideways; only long text cells wrap. */
.table-wrap th, .table-wrap td { white-space: nowrap; }
.table-wrap td.wrap { white-space: normal; min-width: 160px; }
.table-wrap td.empty { white-space: normal; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; background: var(--surface-2); }
thead th:first-child { border-top-left-radius: calc(var(--radius) - 1px); }
thead th:last-child { border-top-right-radius: calc(var(--radius) - 1px); }
td { color: var(--text-2); }
td strong { color: var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
tr.void td { color: var(--muted); text-decoration: line-through; }
tr.void td.keep { text-decoration: none; }
.empty { padding: 36px 24px; text-align: center; color: var(--muted); }

/* ---------- Forms ---------- */
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-2); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 8px 11px; width: 100%; min-height: 38px; transition: border-color .15s, box-shadow .15s; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
input:disabled { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); box-shadow: none; }
.field { margin-bottom: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row, .row3 { grid-template-columns: 1fr; } }
.inline { display: flex; gap: 8px; align-items: center; }
.inline input, .inline select { width: auto; }

/* ---------- Buttons ---------- */
/* margin: 0 — a <label class="btn"> (file upload) must line up with real buttons. */
.btn { margin: 0; font: inherit; font-weight: 600; font-size: 13.5px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); border-radius: var(--radius-sm); padding: 8px 14px; min-height: 38px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; white-space: nowrap; text-decoration: none; box-shadow: var(--shadow); transition: background .15s, border-color .15s, color .15s, box-shadow .15s; }
.btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--muted); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 1px 2px rgba(16, 24, 40, .1), inset 0 1px 0 rgba(255, 255, 255, .12); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { padding: 4px 10px; min-height: 30px; font-size: 12.5px; }
.btn.lg { min-height: 44px; font-size: 15px; }
.btn.block { width: 100%; }
.btn:disabled, .btn:disabled:hover { opacity: .5; cursor: not-allowed; background: var(--surface); color: var(--text-2); border-color: var(--border-strong); }
.btn.primary:disabled, .btn.primary:disabled:hover { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.icon-btn { border: 0; background: none; color: inherit; cursor: pointer; padding: 6px; border-radius: 8px; display: inline-grid; place-items: center; transition: background .15s, color .15s; }
.icon-btn:hover { background: var(--surface-3); }

/* ---------- Badges & tabs ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); text-transform: capitalize; line-height: 1.6; border: 1px solid transparent; }
.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.info { background: var(--primary-soft); color: var(--primary); }
.badge.ok::before, .badge.warn::before, .badge.danger::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button { font: inherit; font-weight: 600; background: none; border: 0; padding: 10px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; border-radius: 6px 6px 0 0; transition: color .15s, background .15s; }
.tabs button:hover { color: var(--text); background: var(--surface-2); }
.tabs button.active { color: var(--primary); border-color: var(--primary); }

/* ---------- Chart ---------- */
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--primary); opacity: .9; }
.chart .bar:hover { fill: var(--primary-hover); opacity: 1; }
.chart text { fill: var(--muted); font-size: 10px; }
.chart line { stroke: var(--border); }

/* ---------- Pos Sales ---------- */
.pos { display: grid; grid-template-columns: 1fr 390px; gap: 18px; align-items: start; }
.cart-jump { display: none; }
@media (max-width: 1000px) {
  .pos { grid-template-columns: 1fr; }
  .product-grid { max-height: none; }
  .cart { position: static; }
  /* On one-column layouts the cart is below the products: a floating bar shows it. */
  .cart-jump:not(.hidden) { display: flex; position: fixed; z-index: 15; left: 16px; right: 16px; bottom: 16px; justify-content: space-between; min-height: 50px; font-size: 15px; box-shadow: var(--shadow-lg); }
  .pos { padding-bottom: 64px; }
}
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(156px, 1fr)); gap: 12px; padding: 16px; max-height: calc(100vh - 250px); overflow-y: auto; }
.tile { text-align: left; font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 13px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; min-height: 98px; transition: border-color .15s, box-shadow .15s, transform .1s; }
.tile:hover { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.tile:active { transform: scale(.98); }
.tile:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.tile .t-name { font-weight: 600; line-height: 1.3; color: var(--text); }
.tile .t-price { margin-top: auto; font-weight: 700; color: var(--primary); font-variant-numeric: tabular-nums; }
.tile .t-stock { font-size: 12px; color: var(--muted); }
.cart { position: sticky; top: calc(var(--top-h) + 16px); }
.cart-lines { max-height: 340px; overflow-y: auto; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 11px 20px; border-bottom: 1px solid var(--border); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; }
.qty button { border: 0; background: var(--surface-2); color: inherit; width: 30px; height: 30px; cursor: pointer; font-size: 16px; }
.qty button:hover { background: var(--surface-3); }
.qty input { width: 44px; border: 0; text-align: center; padding: 0; min-height: 30px; border-radius: 0; box-shadow: none; }
.totals { padding: 16px 20px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-size: 20px; font-weight: 750; border-top: 1px solid var(--border); margin-top: 8px; padding-top: 12px; color: var(--text); letter-spacing: -.01em; }

/* Searchable product picker */
.picker { position: relative; }
.picker-list { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin-top: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; padding: 4px; }
.picker-item { display: flex; justify-content: space-between; gap: 12px; width: 100%; text-align: left; font: inherit; color: inherit; background: none; border: 0; border-radius: 6px; padding: 9px 12px; cursor: pointer; }
.picker-item:hover, .picker-item.active { background: var(--primary-soft); }
.rs-lines th, .rs-lines td { padding: 8px 10px; }
.rs-lines th:first-child { width: 100%; }
.rs-lines input { min-height: 34px; padding: 5px 8px; width: 84px; }
.rs-lines input[data-f="cost"], .rs-lines input[data-f="price"] { width: 100px; }

/* ---------- Two-step login ---------- */
.twostep-setup { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
.qr-box { background: #fff; border-radius: 10px; padding: 6px; line-height: 0; border: 1px solid var(--border); }
.qr-box svg { width: 220px; height: 220px; }
.setup-key { font-family: var(--mono); font-size: 15px; letter-spacing: .04em; background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; margin: 6px 0 2px; word-break: break-all; user-select: all; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.recovery-codes code { font-family: var(--mono); font-size: 16px; text-align: center; padding: 9px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; user-select: all; }
@media (max-width: 560px) {
  .twostep-setup { grid-template-columns: 1fr; justify-items: center; }
  .qr-box svg { width: 200px; height: 200px; }
}

/* ---------- Export menu (PDF / Excel) in each page header ---------- */
.export-menu { position: relative; }
.export-menu > summary { list-style: none; }
.export-menu > summary::-webkit-details-marker { display: none; }
.export-list { position: absolute; z-index: 10; left: 0; top: calc(100% + 6px); min-width: 150px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; display: flex; flex-direction: column; animation: pop .14s ease-out; }
.export-menu.flip .export-list { left: auto; right: 0; }
.export-list button { font: inherit; text-align: left; background: none; border: 0; color: var(--text-2); padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.export-list button:hover { background: var(--surface-2); color: var(--text); }
.export-list button:disabled { opacity: .5; }

/* Discount: number box with a money / % switch */
.discount-field { display: flex; gap: 8px; }
.discount-field input { flex: 1; min-width: 0; }
.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; flex: none; background: var(--surface-2); padding: 2px; gap: 2px; }
.seg button { font: inherit; font-weight: 650; min-width: 40px; padding: 0 10px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.seg button.active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-md); }

/* ---------- Statements ---------- */
.statement td { padding: 9px 20px; }
.statement .indent td:first-child { padding-left: 36px; color: var(--muted); }
.statement .subtotal td { font-weight: 650; border-top: 1px solid var(--border); color: var(--text); }
.statement .total td { font-weight: 750; font-size: 16px; background: var(--surface-2); color: var(--text); }
.pos-num { color: var(--ok); }
.neg-num { color: var(--danger); }

/* ---------- Modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8, 12, 11, .5); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .15s ease-out; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 540px; max-height: calc(100vh - 32px); overflow-y: auto; box-shadow: var(--shadow-lg); animation: rise .18s ease-out; }
.modal.wide { max-width: 720px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-head h2 { font-size: 16px; }
.modal-body { padding: 20px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; position: sticky; bottom: 0; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.error-msg { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent); }
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; max-width: calc(100vw - 32px); }
.toast { background: var(--surface); color: var(--text); padding: 12px 16px 12px 14px; border-radius: 10px; font-weight: 500; box-shadow: var(--shadow-lg); border: 1px solid var(--border); border-left: 4px solid var(--ok); animation: rise .2s ease-out; max-width: 420px; }
.toast.error { border-left-color: var(--danger); }
@media (max-width: 560px) { #toast-root { left: 16px; right: 16px; bottom: 16px; align-items: stretch; } .toast { max-width: none; } }

/* ---------- Sign-in: one card in the middle of a plain page ---------- */
.auth { min-height: 100vh; display: grid; background: var(--bg); }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); padding: 32px 32px 28px; }
/* The shop's logo (or the default mark) centred at the top of the card. */
.auth-card > .brand-logo { width: 48px; height: 48px; border-radius: 12px; margin: 0 auto 22px; }
.auth-card > .brand-logo svg { width: 24px; height: 24px; }
.auth-card > .brand-img { max-height: 84px; max-width: 240px; margin: 0 auto 22px; }
.auth h1 { margin: 0 0 18px; font-size: 22px; text-align: center; }
.auth h1 + p { margin: -10px 0 20px; text-align: center; }
.auth .field input { min-height: 44px; }
@media (max-width: 480px) {
  .auth-main { align-items: start; padding-top: 48px; }
  .auth-card { padding: 26px 20px 22px; }
}

/* ---------- Receipt & printing ---------- */
.receipt { font-family: var(--mono); font-size: 13px; max-width: 320px; margin: 0 auto; }
.receipt .c { text-align: center; }
.receipt .r { display: flex; justify-content: space-between; gap: 8px; }
.receipt hr { border: 0; border-top: 1px dashed var(--muted); margin: 8px 0; }
#print-root { display: none; }
@media print {
  body { background: #fff; }
  body.printing-receipt > *:not(#print-root) { display: none !important; }
  body.printing-receipt #print-root { display: block; color: #000; }
  #print-root .receipt hr { border-color: #000; }
  .print-doc { font-size: 12px; }
  .print-doc th, .print-doc td { padding: 5px 8px; border-bottom: 1px solid #999; background: none; color: #000; }
  .shell { display: block; }
  .sidebar, .topbar, .toolbar, .tabs, .btn, #toast-root, .export-menu { display: none !important; }
  .card { box-shadow: none; }
}

/* ---------- Phones. Kept late so it overrides the base rules above. ---------- */
@media (max-width: 560px) {
  h1 { font-size: 20px; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 13px; }
  .kpi .value { font-size: 18px; }
  .kpi-icon { width: 28px; height: 28px; top: 10px; right: 10px; }
  .kpi-icon svg { width: 15px; height: 15px; }
  .kpi:has(.kpi-icon) .label { padding-right: 32px; }
  .page-head { margin-bottom: 16px; }
  .page-head > .toolbar, .page-head > .toolbar > .toolbar { width: 100%; }
  .card-head { padding: 12px 14px; }
  .card-pad { padding: 14px; }
  th, td { padding: 9px 10px; }
  .statement td { padding: 8px 14px; }
  .statement .indent td:first-child { padding-left: 24px; }
  .modal-body, .modal-head, .modal-foot { padding-left: 16px; padding-right: 16px; }
}

/* ---------- Roles & permissions editor ---------- */
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 8px 14px 10px; margin: 0 0 12px; }
.perm-group legend { font-size: 11.5px; font-weight: 650; color: var(--muted); padding: 0 4px; text-transform: uppercase; letter-spacing: .05em; }
.perm { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; margin: 0; font-size: 14px; font-weight: 400; line-height: 1.35; color: var(--text); cursor: pointer; }
.perm input { margin: 2px 0 0; flex: none; width: 16px; height: 16px; min-height: 0; }
.badge.perm-chip { text-transform: none; margin: 1px; font-weight: 500; }

/* New sale page: discount beside the totals, stacked on phones */
.ns-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 16px; }
.ns-bottom .totals { padding: 0; }
@media (max-width: 560px) { .ns-bottom { grid-template-columns: 1fr; } }

/* ---------- Shop logo & icon (Settings → Logo & icon) ---------- */
.brand-img { display: block; max-height: 36px; max-width: 120px; width: auto; height: auto; object-fit: contain; flex: none; }
.brand-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; align-items: start; padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.brand-preview { height: 64px; border: 1px dashed var(--border-strong); border-radius: 8px; display: grid; place-items: center; overflow: hidden; background: var(--surface-2); font-size: 12px; }
.brand-preview.icon { width: 64px; }
.brand-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.print-logo img { max-height: 70px; max-width: 260px; margin-bottom: 6px; }
/* With an uploaded logo: logo centred and large, the shop name centred underneath. */
.sidebar .brand:has(.brand-img) { flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 6px 32px 18px; }
.sidebar .brand:has(.brand-img) > span { white-space: normal; font-size: 16px; font-weight: 500; color: var(--side-strong); letter-spacing: 0; }
/* The logo as uploaded (no frame): a wide logo uses the full width, a tall one up to 104px high.
   A logo with a transparent background blends into the dark menu. */
.sidebar .brand-img { max-height: 104px; max-width: 100%; }

/* ---------- Settings → Appearance ---------- */
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 4px; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--surface); background: var(--c); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; transition: transform .1s, box-shadow .15s; }
.swatch:hover { transform: scale(1.08); }
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--text); }
.swatch-custom { position: relative; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.swatch-custom input[type="color"] { width: 34px; height: 30px; min-height: 0; padding: 2px; border-radius: 8px; cursor: pointer; }
.appearance-preview { display: grid; grid-template-columns: 76px 1fr; height: 92px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin: 6px 0 14px; }
.appearance-preview .pv-side { background: var(--side-bg); padding: 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.appearance-preview .pv-side i { display: block; height: 7px; border-radius: 4px; background: var(--side-text); opacity: .35; }
.appearance-preview .pv-side i.on { background: var(--side-accent); opacity: 1; }
.appearance-preview .pv-main { background: var(--bg); padding: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.appearance-preview .pv-main b { display: block; height: 8px; width: 60%; border-radius: 4px; background: var(--border-strong); }
.appearance-preview .pv-main span { display: inline-block; padding: 5px 12px; border-radius: 7px; background: var(--primary); color: var(--on-primary); font-size: 11.5px; font-weight: 650; }

/* ---------- Settings: two independent columns (shop | your account), so cards never leave gaps ---------- */
.settings-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.settings-cols.single { grid-template-columns: minmax(0, 720px); }
.settings-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.col-title { font-size: 11.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin: 0 2px -8px; }
@media (max-width: 1100px) { .settings-cols { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Settings → Backups ---------- */
.backup-status { padding: 10px 12px; border-radius: 8px; font-size: 13px; border: 1px solid var(--border); background: var(--surface-2); }
.backup-status.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.backup-status.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.backup-status.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.backup-list th, .backup-list td { padding: 8px 12px; }
.backup-list td.keep .btn + .btn { margin-left: 4px; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; word-break: break-all; }

/* ---------- "Open your shift" box (Pos Sales, New sale) ---------- */
.open-shift-box { margin-bottom: 18px; border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); background: color-mix(in srgb, var(--warn-soft) 55%, var(--surface)); }
.open-shift-box .card-pad { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: flex-end; justify-content: space-between; }
.osb-text { display: flex; flex-direction: column; gap: 2px; max-width: 520px; }
