/* ==========================================================================
   Yuzeif Auto Parts — Shop Management
   Design system: light-first, high contrast for counters and daylight,
   with an optional dark theme. Ink-navy + amber accent (auto-parts feel).
   ========================================================================== */

:root {
  --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, monospace;

  /* Surfaces */
  --bg: #f4f6f9;
  --bg-accent: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f8;
  --sidebar: #10151f;
  --sidebar-2: #161d29;
  --sidebar-text: #aeb9cc;
  --sidebar-active: #ffffff;

  /* Ink */
  --text: #111827;
  --text-2: #374151;
  --muted: #667085;
  --muted-2: #98a2b3;

  /* Lines */
  --border: #e3e8ef;
  --border-strong: #cfd6e1;

  /* Brand */
  --brand: #0f172a;
  --accent: #f59e0b;
  --accent-600: #d97706;
  --accent-soft: #fef3c7;
  --accent-ink: #92400e;

  /* Semantic */
  --green: #059669;
  --green-soft: #d1fae5;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --slate-soft: #eef2f7;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-md: 0 4px 8px -2px rgba(16, 24, 40, .08), 0 2px 4px -2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 24px -6px rgba(16, 24, 40, .12), 0 4px 8px -4px rgba(16, 24, 40, .05);
  --shadow-xl: 0 24px 48px -12px rgba(16, 24, 40, .25);

  --sidebar-w: 256px;
  --header-h: 68px;
  --ring: 0 0 0 4px rgba(245, 158, 11, .18);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

html[data-theme="dark"] {
  --bg: #0b1017;
  --bg-accent: #0e141d;
  --surface: #131a24;
  --surface-2: #172029;
  --surface-3: #1c2632;
  --sidebar: #080c12;
  --sidebar-2: #0e141d;
  --sidebar-text: #94a1b5;
  --text: #e8edf5;
  --text-2: #cbd5e1;
  --muted: #93a1b5;
  --muted-2: #6b7a8f;
  --border: #263141;
  --border-strong: #334155;
  --accent-soft: rgba(245, 158, 11, .14);
  --accent-ink: #fcd34d;
  --green-soft: rgba(5, 150, 105, .18);
  --red-soft: rgba(220, 38, 38, .18);
  --blue-soft: rgba(37, 99, 235, .2);
  --purple-soft: rgba(124, 58, 237, .22);
  --slate-soft: rgba(148, 163, 184, .14);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, .55);
  --shadow-xl: 0 28px 56px rgba(0, 0, 0, .65);
}

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 650; letter-spacing: -0.015em; line-height: 1.25; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
table { border-collapse: collapse; width: 100%; }
input, select, textarea { font: inherit; color: inherit; }
.icon { width: 18px; height: 18px; flex: 0 0 auto; }
::selection { background: var(--accent-soft); color: var(--accent-ink); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--muted-2); background-clip: content-box; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 60;
  border-right: 1px solid rgba(255, 255, 255, .04);
}
.sidebar::after {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(600px 300px at -10% -10%, rgba(245, 158, 11, .14), transparent 60%),
    radial-gradient(500px 300px at 110% 110%, rgba(56, 189, 248, .08), transparent 60%);
  pointer-events: none;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 18px;
  position: relative; z-index: 1;
}
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #fbbf24, #f59e0b 55%, #b45309);
  color: #1c1206;
  box-shadow: 0 6px 16px -4px rgba(245, 158, 11, .55), inset 0 1px 0 rgba(255,255,255,.4);
  flex: 0 0 auto;
}
.brand-mark svg { width: 22px; height: 22px; stroke-width: 2.1; }
.brand-text { min-width: 0; }
.brand-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand-sub { font-size: 11.5px; color: #7b8aa1; letter-spacing: .06em; text-transform: uppercase; font-weight: 600; }

.nav { padding: 8px 12px 16px; overflow-y: auto; flex: 1; position: relative; z-index: 1; }
.nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: #63718a; font-weight: 700; padding: 16px 12px 8px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin-bottom: 2px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-weight: 500; font-size: 14px;
  transition: background .16s var(--ease), color .16s var(--ease);
  position: relative;
}
.nav-item .icon { width: 18px; height: 18px; opacity: .85; }
.nav-item:hover { background: rgba(255, 255, 255, .055); color: #e9eef7; }
.nav-item.active { background: rgba(255, 255, 255, .085); color: var(--sidebar-active); box-shadow: inset 0 0 0 1px rgba(255,255,255,.06); }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item .pill { margin-left: auto; }

.sidebar-foot {
  padding: 12px; border-top: 1px solid rgba(255, 255, 255, .06);
  position: relative; z-index: 1;
}
.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 12px;
  background: rgba(255, 255, 255, .04);
}
.avatar {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center;
  background: linear-gradient(145deg, #334155, #1e293b);
  color: #e2e8f0; font-weight: 700; font-size: 12.5px; letter-spacing: .02em;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { color: #f1f5f9; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: #7b8aa1; font-size: 11.5px; text-transform: capitalize; }
.icon-btn-sm {
  width: 32px; height: 32px; border-radius: 9px; border: 0; cursor: pointer;
  display: grid; place-items: center; background: transparent; color: #8fa0b8;
  transition: background .15s, color .15s;
}
.icon-btn-sm:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--header-h);
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 17px; font-weight: 680; letter-spacing: -.02em; }
.topbar-crumb { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 7px; }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.page { padding: 26px 28px 56px; max-width: 1560px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-title { font-size: 23px; font-weight: 700; letter-spacing: -.025em; }
.page-desc { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.page-head-actions { margin-left: auto; display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--btn-bd);
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 600; font-size: 13.5px; letter-spacing: -.005em;
  cursor: pointer; white-space: nowrap; user-select: none;
  box-shadow: var(--shadow-xs);
  transition: background .15s var(--ease), border-color .15s, transform .06s, box-shadow .15s, color .15s;
}
.btn .icon { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn.is-disabled { opacity: .5; pointer-events: none; }

.btn-primary {
  --btn-bg: linear-gradient(180deg, #111827, #0b1220);
  --btn-fg: #fff; --btn-bd: #0b1220;
  box-shadow: 0 1px 2px rgba(16,24,40,.2), inset 0 1px 0 rgba(255,255,255,.12);
}
html[data-theme="dark"] .btn-primary { --btn-bg: linear-gradient(180deg, #fbbf24, #f59e0b); --btn-fg: #1c1206; --btn-bd: #d97706; }
.btn-primary:hover { background: linear-gradient(180deg, #1f2937, #111827); }
html[data-theme="dark"] .btn-primary:hover { background: linear-gradient(180deg, #fcd34d, #f59e0b); }

.btn-accent {
  --btn-bg: linear-gradient(180deg, #fbbf24, #f59e0b);
  --btn-fg: #1c1206; --btn-bd: #d97706;
  box-shadow: 0 2px 6px -1px rgba(245,158,11,.45), inset 0 1px 0 rgba(255,255,255,.35);
}
.btn-accent:hover { background: linear-gradient(180deg, #fcd34d, #f59e0b); }

.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger { --btn-bg: var(--red); --btn-fg: #fff; --btn-bd: var(--red); }
.btn-danger-soft { --btn-bg: var(--red-soft); --btn-fg: var(--red); --btn-bd: transparent; box-shadow: none; }
.btn-danger-soft:hover { background: color-mix(in srgb, var(--red-soft) 70%, var(--red)); color: #fff; }

.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; gap: 6px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 9px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 14.5px; font-weight: 650; letter-spacing: -.01em; }
.card-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.card-head-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 13px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 17px 18px 16px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease), border-color .2s;
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-top { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.stat-ico {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: var(--slot-bg, var(--slate-soft)); color: var(--slot-fg, var(--text-2));
}
.stat-ico .icon { width: 17px; height: 17px; }
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .005em; }
.stat-value { font-size: 25px; font-weight: 720; letter-spacing: -.035em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-value small { font-size: 13px; font-weight: 600; color: var(--muted); letter-spacing: -.01em; }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; font-size: 12.5px; color: var(--muted); }
.stat-link { margin-left: auto; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.stat-link:hover { color: var(--accent-600); }
.stat-link .icon { width: 14px; height: 14px; }
.stat--accent { background: linear-gradient(160deg, #fffbeb, var(--surface) 60%); border-color: #fde68a; }
html[data-theme="dark"] .stat--accent { background: linear-gradient(160deg, rgba(245,158,11,.09), var(--surface) 60%); border-color: rgba(245,158,11,.28); }

.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 650; font-size: 12px; padding: 2px 7px 2px 5px; border-radius: 99px; }
.trend .icon { width: 13px; height: 13px; stroke-width: 2.4; }
.trend.up { background: var(--green-soft); color: var(--green); }
.trend.down { background: var(--red-soft); color: var(--red); }
.trend.flat { background: var(--slate-soft); color: var(--muted); }
html[data-theme="dark"] .trend.up { color: #4ade80; }
html[data-theme="dark"] .trend.down { color: #fca5a5; }

/* ---------- Grids ---------- */
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); }
.grid-1-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1.7fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.label { font-size: 12.5px; font-weight: 620; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.label .req { color: var(--red); }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 12px; color: var(--red); font-weight: 550; }

.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 13px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s, background .15s;
  font-size: 14px;
}
.textarea { height: auto; min-height: 88px; padding: 10px 13px; resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--muted-2); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--muted-2); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.is-error, .select.is-error { border-color: var(--red); }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group .icon { position: absolute; left: 12px; width: 17px; height: 17px; color: var(--muted); pointer-events: none; }
.input-group .input { padding-left: 38px; }
.input-affix { position: absolute; right: 12px; font-size: 12.5px; color: var(--muted); font-weight: 600; pointer-events: none; }
.input-affix + .input { padding-right: 46px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.checkbox { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; user-select: none; font-size: 13.5px; }
.checkbox input { width: 17px; height: 17px; accent-color: var(--accent-600); cursor: pointer; margin: 0; }

.search-input { max-width: 340px; }
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { font-size: 13.5px; }
.table thead th {
  text-align: left; padding: 11px 16px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase;
  color: var(--muted); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
.table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn { margin-left: 4px; }
.table-compact tbody td { padding: 9px 14px; }
.table-empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.table-empty .icon { width: 34px; height: 34px; margin: 0 auto 10px; opacity: .45; }
.table tfoot td { padding: 12px 16px; font-weight: 650; border-top: 1px solid var(--border); background: var(--surface-2); }

.cell-primary { font-weight: 620; color: var(--text); letter-spacing: -.005em; }
.cell-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.cell-flex { display: flex; align-items: center; gap: 11px; }
.thumb {
  width: 38px; height: 38px; border-radius: 10px; flex: 0 0 auto;
  display: grid; place-items: center; font-weight: 700; font-size: 12.5px;
  background: var(--slate-soft); color: var(--text-2); border: 1px solid var(--border);
}
.thumb .icon { width: 17px; height: 17px; opacity: .75; }
.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.strong { font-weight: 650; }
.neg, .amount-negative { color: var(--red); }
.amount-positive { color: var(--green); }

/* ---------- Badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .005em; white-space: nowrap;
}
.badge .icon { width: 12px; height: 12px; stroke-width: 2.4; }
.badge-success { background: var(--green-soft); color: var(--green); }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-warn { background: var(--accent-soft); color: var(--accent-ink); }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-neutral { background: var(--slate-soft); color: var(--muted); }
html[data-theme="dark"] .badge-success { color: #4ade80; }
html[data-theme="dark"] .badge-danger { color: #fca5a5; }
html[data-theme="dark"] .badge-info { color: #93c5fd; }
html[data-theme="dark"] .badge-purple { color: #c4b5fd; }

.pill {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 99px;
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--accent); color: #1c1206;
}
.dot { width: 7px; height: 7px; border-radius: 99px; background: var(--muted-2); flex: 0 0 auto; }
.dot.green { background: var(--green); }
.dot.amber { background: var(--accent); }
.dot.red { background: var(--red); }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  font-size: 13.5px; border: 1px solid transparent;
}
.alert .icon { width: 17px; height: 17px; margin-top: 1px; }
.alert-error { background: var(--red-soft); color: #991b1b; border-color: #fecaca; }
.alert-warn { background: var(--accent-soft); color: var(--accent-ink); border-color: #fde68a; }
.alert-info { background: var(--blue-soft); color: #1e40af; border-color: #bfdbfe; }
.alert-success { background: var(--green-soft); color: #065f46; border-color: #a7f3d0; }
html[data-theme="dark"] .alert-error { color: #fecaca; border-color: rgba(220,38,38,.35); }
html[data-theme="dark"] .alert-info { color: #bfdbfe; border-color: rgba(37,99,235,.35); }
html[data-theme="dark"] .alert-success { color: #a7f3d0; border-color: rgba(5,150,105,.35); }

/* ---------- Flash toasts ---------- */
.toast-stack { position: fixed; right: 22px; top: 82px; z-index: 300; display: flex; flex-direction: column; gap: 10px; max-width: 400px; }
.toast {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 550;
  animation: toast-in .35s var(--ease) both;
}
.toast-icon { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex: 0 0 auto; }
.toast-icon .icon { width: 15px; height: 15px; stroke-width: 2.6; }
.toast-success .toast-icon { background: var(--green-soft); color: var(--green); }
.toast-error .toast-icon { background: var(--red-soft); color: var(--red); }
.toast-info .toast-icon { background: var(--blue-soft); color: var(--blue); }
.toast-warning .toast-icon { background: var(--accent-soft); color: var(--accent-ink); }
.toast-close { margin-left: 4px; border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 3px; border-radius: 6px; }
.toast-close:hover { background: var(--surface-3); color: var(--text); }
.toast-close .icon { width: 15px; height: 15px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 54px 24px; }
.empty-ico {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 14px;
  display: grid; place-items: center; background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--border);
}
.empty-ico .icon { width: 26px; height: 26px; }
.empty h3 { font-size: 15.5px; margin-bottom: 5px; }
.empty p { color: var(--muted); font-size: 13.5px; max-width: 380px; margin: 0 auto 18px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 20px; overflow-x: auto; }
.tab {
  padding: 12px 14px; font-weight: 600; font-size: 13.5px; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab .pill { margin-left: 7px; background: var(--surface-3); color: var(--muted); }

/* Segmented control */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 10px; border: 1px solid var(--border); }
.segmented a, .segmented button {
  padding: 6px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 620; color: var(--muted);
  border: 0; background: transparent; cursor: pointer; transition: all .15s;
}
.segmented .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: 230px; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--muted); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

.bar-list { display: flex; flex-direction: column; gap: 14px; }
.bar-item .bar-top { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; margin-bottom: 6px; }
.bar-track { height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: linear-gradient(90deg, #fbbf24, #f59e0b); transition: width .8s var(--ease); }
.bar-fill.blue { background: linear-gradient(90deg, #60a5fa, #2563eb); }
.bar-fill.green { background: linear-gradient(90deg, #34d399, #059669); }

/* ---------- Login ---------- */
.auth-shell {
  min-height: 100vh; display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--bg);
}
.auth-art {
  position: relative; overflow: hidden;
  background: #0d1219;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 46px 52px; color: #fff;
}
.auth-art::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(800px 480px at 15% 0%, rgba(245, 158, 11, .22), transparent 62%),
    radial-gradient(700px 500px at 100% 100%, rgba(14, 165, 233, .16), transparent 60%),
    repeating-linear-gradient(115deg, rgba(255,255,255,.028) 0 1px, transparent 1px 42px);
}
.auth-art > * { position: relative; z-index: 1; }
.auth-quote { max-width: 440px; }
.auth-quote h2 { font-size: 30px; letter-spacing: -.03em; line-height: 1.25; font-weight: 680; }
.auth-quote p { color: #9fb0c6; margin-top: 14px; font-size: 14.5px; line-height: 1.65; }
.auth-feats { display: grid; gap: 12px; margin-top: 30px; }
.auth-feat { display: flex; gap: 11px; align-items: center; font-size: 13.5px; color: #c3d0e0; }
.auth-feat i {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: 0 0 auto;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.09); color: #fbbf24;
}
.auth-feat .icon { width: 15px; height: 15px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .brand-name { font-size: 16px; }

.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--surface); }
.auth-form { width: 100%; max-width: 388px; }
.auth-form .brand-mark { margin-bottom: 22px; width: 46px; height: 46px; border-radius: 14px; }
.auth-form h1 { font-size: 25px; letter-spacing: -.03em; }
.auth-form .sub { color: var(--muted); margin: 7px 0 26px; font-size: 14px; }
.auth-form .btn { margin-top: 6px; }
.auth-hint { margin-top: 22px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--border-strong); font-size: 12.5px; color: var(--muted); }
.auth-hint code { font-family: var(--mono); color: var(--text-2); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 0; min-height: calc(100vh - var(--header-h)); align-items: start; }
.pos-left { padding: 22px 26px 40px; min-width: 0; }
.pos-right {
  position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h));
  display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px -18px rgba(16,24,40,.25);
}
.pos-search { display: flex; gap: 10px; margin-bottom: 16px; }
.pos-search .input-group { flex: 1; }
.pos-search .input { height: 48px; font-size: 15px; border-radius: 12px; padding-left: 42px; }
.pos-search .input-group .icon { width: 19px; height: 19px; left: 14px; }
.pos-search .btn { height: 48px; border-radius: 12px; }

.cat-chips { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 12px; margin-bottom: 14px; scrollbar-width: none; }
.cat-chips::-webkit-scrollbar { display: none; }
.chip {
  padding: 7px 13px; border-radius: 99px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text-2);
  white-space: nowrap; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--muted-2); background: var(--surface-2); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
html[data-theme="dark"] .chip.active { background: var(--accent); color: #1c1206; border-color: var(--accent); }

.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.prod-card {
  text-align: left; padding: 13px; border-radius: 13px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; position: relative;
  transition: box-shadow .16s var(--ease), transform .12s var(--ease), border-color .16s;
  display: flex; flex-direction: column; gap: 9px; min-height: 118px;
}
.prod-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: var(--border-strong); }
.prod-card:active { transform: translateY(0); }
.prod-card.is-out { opacity: .55; cursor: not-allowed; }
.prod-card.added { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.prod-top { display: flex; align-items: flex-start; gap: 9px; }
.prod-name { font-weight: 620; font-size: 13.5px; line-height: 1.35; letter-spacing: -.005em; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.prod-meta { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; margin-top: auto; }
.prod-price { font-weight: 720; font-size: 15px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.prod-stock { font-size: 11.5px; color: var(--muted); font-weight: 550; }
.prod-stock.low { color: var(--accent-600); }
.prod-stock.out { color: var(--red); }

.cart-head { padding: 16px 18px 12px; border-bottom: 1px solid var(--border); }
.cart-head-row { display: flex; align-items: center; gap: 8px; }
.cart-head h2 { font-size: 15px; font-weight: 680; }
.cart-list { flex: 1; overflow-y: auto; padding: 10px 12px; }
.cart-item {
  padding: 11px 11px 10px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface-2); margin-bottom: 8px;
  animation: cart-in .18s var(--ease) both;
}
@keyframes cart-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.cart-item-top { display: flex; gap: 9px; align-items: flex-start; }
.cart-item-name { font-weight: 620; font-size: 13px; line-height: 1.35; flex: 1; }
.cart-item-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.cart-item-row { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 8px; overflow: hidden; background: var(--surface); }
.stepper button {
  width: 28px; height: 28px; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--text-2); transition: background .12s;
}
.stepper button:hover { background: var(--surface-3); color: var(--text); }
.stepper button .icon { width: 14px; height: 14px; stroke-width: 2.4; }
.stepper input {
  width: 46px; height: 28px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  text-align: center; font-size: 13px; font-weight: 650; background: transparent; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper input:focus { outline: none; background: var(--surface-2); }
.cart-line-total { margin-left: auto; font-weight: 700; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.cart-empty { flex: 1; display: grid; place-content: center; text-align: center; padding: 30px; color: var(--muted); }
.cart-empty .icon { width: 40px; height: 40px; margin: 0 auto 12px; opacity: .35; }
.cart-empty p { font-size: 13.5px; max-width: 220px; }

.cart-foot { border-top: 1px solid var(--border); padding: 14px 18px 16px; background: var(--surface); }
.totals { display: flex; flex-direction: column; gap: 7px; margin-bottom: 12px; }
.total-row { display: flex; justify-content: space-between; font-size: 13.5px; color: var(--text-2); }
.total-row .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.total-row.grand { font-size: 20px; font-weight: 720; color: var(--text); letter-spacing: -.03em; padding-top: 9px; border-top: 1px dashed var(--border-strong); margin-top: 3px; }
.total-row.grand .v { font-weight: 760; }
.discount-row { display: flex; align-items: center; gap: 8px; }
.discount-row .input { height: 34px; font-size: 13px; border-radius: 8px; }
.discount-row .label { flex: 0 0 auto; font-size: 13px; color: var(--text-2); }

.pay-methods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 12px; }
.pay-method {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 9px;
  padding: 7px 2px 6px; cursor: pointer; text-align: center; transition: all .14s;
  font-size: 10px; font-weight: 620; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.pay-method .icon { width: 16px; height: 16px; }
.pay-method:hover { border-color: var(--muted-2); color: var(--text-2); }
.pay-method.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); box-shadow: 0 0 0 1px var(--accent); }
.pay-method input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(9, 14, 22, .55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
  opacity: 0; pointer-events: none; transition: opacity .18s var(--ease);
}
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl); border: 1px solid var(--border);
  transform: translateY(10px) scale(.985); opacity: 0;
  transition: transform .22s var(--ease), opacity .22s var(--ease);
}
.modal-backdrop.open .modal { transform: none; opacity: 1; }
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; font-weight: 680; letter-spacing: -.02em; }
.modal-head .sub { color: var(--muted); font-size: 12.5px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 15px 22px; border-top: 1px solid var(--border); display: flex; gap: 9px; justify-content: flex-end; background: var(--surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* ---------- Receipt ---------- */
.receipt-card { max-width: 400px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); overflow: hidden; }
.receipt { padding: 26px 26px 22px; font-family: var(--mono); font-size: 12.5px; color: var(--text); }
.receipt-head { text-align: center; padding-bottom: 16px; border-bottom: 1px dashed var(--border-strong); }
.receipt-head .r-name { font-family: var(--font); font-size: 17px; font-weight: 750; letter-spacing: -.02em; }
.receipt-head .r-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.receipt-meta { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; padding: 14px 0; border-bottom: 1px dashed var(--border-strong); font-size: 11.5px; }
.receipt-meta dt { color: var(--muted); }
.receipt-meta dd { margin: 0; text-align: right; }
.receipt-items { padding: 12px 0; border-bottom: 1px dashed var(--border-strong); }
.receipt-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 6px 0; }
.receipt-item .n { font-family: var(--font); font-size: 12.5px; font-weight: 600; }
.receipt-item .q { color: var(--muted); font-size: 11px; }
.receipt-item .t { font-weight: 650; }
.receipt-totals { padding: 12px 0 4px; display: grid; gap: 5px; }
.receipt-totals .rr { display: flex; justify-content: space-between; }
.receipt-totals .rr.grand { font-size: 16px; font-weight: 700; padding-top: 8px; margin-top: 4px; border-top: 1px solid var(--border-strong); font-family: var(--font); letter-spacing: -.02em; }
.receipt-foot { text-align: center; padding-top: 16px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.void-stamp {
  margin: 0 auto 6px; width: fit-content; padding: 4px 14px; border: 2px solid var(--red); color: var(--red);
  border-radius: 6px; font-family: var(--font); font-weight: 800; letter-spacing: .18em; font-size: 13px; transform: rotate(-4deg);
}

/* ---------- Printing ---------- */
@media print {
  .sidebar, .topbar, .page-head-actions, .no-print, .toast-stack { display: none !important; }
  .main { display: block; }
  .page { padding: 0; }
  body { background: #fff; }
  .receipt-card { box-shadow: none; border: 0; max-width: none; }
  .print-only { display: block !important; }
}

/* ---------- Utilities ---------- */
.text-xs { font-size: 11.5px; } .text-sm { font-size: 12.5px; } .text-lg { font-size: 16px; }
.fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; } .mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 6px; } .mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); margin: 18px 0; }
.hide { display: none !important; }
.print-only { display: none; }
.desktop-only { display: revert; }

/* ---------- Kbd ---------- */
kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 5px;
  background: var(--surface-3); border: 1px solid var(--border-strong); border-bottom-width: 2px; color: var(--text-2);
}

/* ---------- Mobile ---------- */
.mobile-menu-btn { display: none; }
@media (max-width: 1180px) {
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
  .grid-2-1, .grid-1-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth-art { display: none; }
  .auth-shell { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; transform: translateX(-100%);
    transition: transform .24s var(--ease); box-shadow: var(--shadow-xl);
  }
  .sidebar.open { transform: none; }
  .mobile-menu-btn { display: grid; }
  .pos { grid-template-columns: 1fr; }
  .pos-right { position: static; height: auto; border-left: 0; border-top: 1px solid var(--border); }
  .cart-list { max-height: 380px; }
  .page { padding: 20px 16px 48px; }
  .topbar { padding: 0 16px; }
  .pos-left { padding: 16px; }
  .desktop-only { display: none; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .page-head-actions { width: 100%; }
  .toast-stack { left: 16px; right: 16px; top: 76px; max-width: none; }
}
.scrim {
  position: fixed; inset: 0; background: rgba(9,14,22,.5); z-index: 55;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.scrim.show { opacity: 1; pointer-events: auto; }

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

/* ==========================================================================
   Refinements — single curated layer. Keep this last in the file.
   Rule of thumb: never set width/min-width on table columns; let the browser
   distribute space, and only control white-space + overflow.
   ========================================================================== */

/* ---------- Semantic text colours (explicit, never collide) ---------- */
.is-positive { color: var(--green); }
.is-negative { color: var(--red); }

/* ---------- Totals / summary rows ---------- */
.totals { display: flex; flex-direction: column; gap: 8px; }
.total-row { display: flex; flex-direction: row; align-items: baseline; justify-content: space-between; gap: 14px; }
.total-row > span:first-child { flex: 1 1 auto; min-width: 0; }
.total-row .v { flex: 0 0 auto; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Layout columns ---------- */
.grid-2-1, .grid-1-2 { align-items: start; }
.grid-2-1 > .stack, .grid-1-2 > .stack { gap: 16px; }
.page-head { align-items: center; }

/* ---------- Stat cards ---------- */
.stat-label { line-height: 1.3; }
.stat-foot { flex-wrap: wrap; row-gap: 4px; }
.stat-foot > span { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.stat-foot .stat-link { margin-left: auto; flex: 0 0 auto; }

/* ---------- Brand lockup ---------- */
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 15.5px; font-weight: 700; letter-spacing: -.015em; }
.brand-sub { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; color: #7b8aa1; margin-top: 3px; }

/* ---------- Charts ---------- */
.chart { min-height: 200px; }
.chart text { font-size: 10px; pointer-events: none; }

/* ---------- Tables: wrapping only, no width forcing ---------- */
.table-wrap { overflow-x: auto; }
.table th, .table td { white-space: nowrap; }                 /* default: no wrapping */
.table td.desc-cell, .table .cell-primary { white-space: normal; }
.table .cell-primary { overflow: hidden; text-overflow: ellipsis; max-width: 34ch; }
.table .cell-sub { overflow: hidden; text-overflow: ellipsis; max-width: 30ch; }
.table td .badge { white-space: nowrap; }
.table .actions { white-space: nowrap; }
.table .actions .btn { margin-left: 0; }

/* ---------- Inventory level bars ---------- */
.bar-fill.red { background: linear-gradient(90deg, #f87171, #dc2626); }
.bar-fill.amber { background: linear-gradient(90deg, #fbbf24, #d97706); }

/* ---------- POS ---------- */
@media (min-width: 1280px) { .pos { grid-template-columns: minmax(0, 1fr) 420px; } }
.pos-left .product-grid { grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); }
.pos-left .prod-card { min-height: 108px; padding: 12px 13px; gap: 8px; }
.pos-left .prod-name { font-size: 13px; }
.pos-left .prod-price { font-size: 14.5px; }
.prod-card:focus { outline: none; }
.prod-card:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--accent-soft); border-color: var(--accent); }
.cart-item-name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 420px) { .pay-methods { grid-template-columns: repeat(3, 1fr); } }

/* ---------- Print ---------- */
@media print {
  .sidebar, .topbar, .page-head, .page-head-actions, .no-print, .toast-stack, .modal-backdrop { display: none !important; }
  .app, .main { display: block !important; }
  .page { padding: 0 !important; max-width: none !important; }
  .receipt-card { box-shadow: none !important; border: 0 !important; }
}

/* ==========================================================================
   POS on tablet & phone
   The cart must stay reachable without scrolling past every product.
   ========================================================================== */
@media (max-width: 900px) {
  /* Two-column product grid, still tappable. */
  .pos-left .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pos-left { padding: 14px 14px 0; }

  /* Search: full-width field, icon-only button that sits flush beside it. */
  .pos-search { gap: 8px; align-items: stretch; }
  .pos-search .input-group { flex: 1 1 auto; min-width: 0; }
  .pos-search .btn { flex: 0 0 48px; width: 48px; padding: 0; }
  .pos-search .btn .desktop-only { display: none; }

  /* Chips scroll horizontally without pushing the layout. */
  .cat-chips { margin-bottom: 10px; padding: 2px 0 10px; }

  /* The cart becomes a sticky bottom sheet with its own scroll area. */
  .pos { display: block; }
  .pos-right {
    position: sticky;
    bottom: 0;
    top: auto;
    height: auto;
    max-height: 78vh;
    display: flex;
    flex-direction: column;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 30px -12px rgba(16, 24, 40, .28);
    margin: 0 -14px;
    z-index: 40;
  }
  .cart-head { padding: 12px 16px 10px; }
  .cart-list { max-height: 30vh; padding: 8px 12px; }
  .cart-foot { padding: 12px 16px 14px; }
  .cart-foot .totals { gap: 5px; }
  .total-row.grand { font-size: 18px; }
  .pay-methods { grid-template-columns: repeat(5, 1fr); gap: 4px; }
  .pay-method { font-size: 9.5px; padding: 6px 1px 5px; }
  .cart-empty { padding: 10px; }
  .cart-empty .icon { width: 26px; height: 26px; margin-bottom: 6px; }
  .cart-empty p { font-size: 12.5px; max-width: 240px; }

  /* Trim the topbar on small screens: the title is already in the nav. */
  .topbar { height: 60px; }
  .topbar-actions .btn-accent { display: none; }
  .topbar-title { font-size: 16px; }
}

@media (max-width: 480px) {
  .pos-left .prod-card { min-height: 96px; padding: 10px 11px; gap: 6px; }
  .pos-left .prod-name { font-size: 12.5px; }
  .pos-left .prod-price { font-size: 13.5px; }
  .pos-left .prod-stock { font-size: 10.5px; }
  .pos-left .prod-card .badge { font-size: 9.5px; height: 17px; }
}

/* ==========================================================================
   POS phone fixes: keep search inline and prices on one line
   ========================================================================== */

/* The search row must not wrap: the input group needs an explicit width. */
.pos-search { flex-wrap: nowrap; }
.pos-search .input-group { flex: 1 1 0; min-width: 0; }
.pos-search .input { width: 100%; min-width: 0; }
.pos-search .btn { flex: 0 0 auto; }

/* Product prices are one atomic unit — never break between TSh and digits. */
.prod-price { white-space: nowrap; }
.prod-meta { flex-wrap: nowrap; align-items: baseline; gap: 6px; }
.prod-stock { white-space: nowrap; flex: 0 0 auto; }

/* Long product names get two tidy lines instead of three ragged ones. */
@media (max-width: 900px) {
  .pos-left .prod-price { font-size: 13px; letter-spacing: -.03em; }
  .pos-left .prod-stock { font-size: 10px; }
  .pos-left .prod-meta { gap: 4px; }

  /* Search sits directly under the topbar with no orphaned button row. */
  .pos-search { margin-bottom: 10px; }
  .pos-search .btn { height: 46px; }
  .pos-search .input { height: 46px; }
}

/* ==========================================================================
   Chart axis: prevent the last two day labels colliding
   ========================================================================== */
.chart svg text { font-variant-numeric: tabular-nums; }

/* Nudge the final tick so it doesn't overrun the previous one. */
.chart svg text:last-of-type { text-anchor: end; }

/* Slightly lighter grid so the line reads first. */
.chart svg line { shape-rendering: crispEdges; }

/* ==========================================================================
   Sidebar nav: crisper icons and spacing
   ========================================================================== */
.nav-item .icon { stroke-width: 1.75; }
.nav-item span:not(.pill) { line-height: 1.2; }
.nav-label { padding-top: 14px; }
.nav-label:first-child { padding-top: 6px; }

/* ==========================================================================
   POS counter-screen polish (1280–1500px wide)
   ========================================================================== */

/* Category chips: let the row wrap so no category is hidden behind a scroll. */
.cat-chips {
  flex-wrap: wrap;
  overflow: visible;
  row-gap: 7px;
  padding-bottom: 4px;
}
.cat-chips .chip { flex: 0 0 auto; }

/* Cart item: name on its own line, metadata (unit @ price · barcode) below,
   and the barcode never pushed onto a new line by the price. */
.cart-item-top { align-items: flex-start; }
.cart-item-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
  margin-top: 3px;
}
.cart-item-sub .mono { white-space: nowrap; font-size: 10.5px; }

/* Quantity stepper and line total sit on one row, total pushed right. */
.cart-item-row { justify-content: space-between; }
.cart-line-total { margin-left: 0; white-space: nowrap; }

/* Discount field: label + input on one line, input not stretched oddly. */
.discount-row .label { white-space: nowrap; }
.discount-row .input-group { flex: 1 1 auto; min-width: 0; }

/* Payment buttons: keep the five options evenly sized and legible. */
.pay-methods { grid-auto-rows: 1fr; }
.pay-method { min-height: 54px; justify-content: center; }
.pay-method .icon { width: 17px; height: 17px; }

/* Header search shouldn't crowd the title on mid-size screens. */
@media (max-width: 1400px) {
  .topbar-actions form.desktop-only { display: none; }
}

/* Product cards in the left column: keep price and stock on one baseline. */
.prod-card .badge { align-self: flex-start; max-width: 100%; }
.prod-card .badge span { overflow: hidden; text-overflow: ellipsis; }

/* Selected/added card should read at a glance, not just by border colour. */
.prod-card.added {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-sm);
}

/* Product card: category as a quiet caption under the price row. */
.prod-cat {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: -2px;
}

/* Give cards a touch more height now that they hold three rows. */
.pos-left .prod-card { min-height: 116px; }
@media (max-width: 900px) { .pos-left .prod-card { min-height: 104px; } }

/* ==========================================================================
   POS — selection feedback (all screen sizes)
   The seller must always see which products are already in this sale.
   ========================================================================== */

.prod-card { position: relative; }

/* Quantity badge: top-right corner of the card. */
.prod-qty {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: #1c1206;
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  border: 2px solid var(--surface);
  box-shadow: 0 3px 8px -2px rgba(217, 119, 6, .6);
  z-index: 2;
  animation: qty-pop .22s var(--ease) both;
}
.prod-qty[hidden] { display: none; }

@keyframes qty-pop {
  0%   { transform: scale(.4); opacity: 0; }
  70%  { transform: scale(1.14); }
  100% { transform: scale(1); opacity: 1; }
}

/* Card is in the sale: tinted background, solid accent edge, checkmark strip. */
.prod-card.in-cart {
  border-color: var(--accent);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--accent-soft) 75%, var(--surface)), var(--surface) 62%);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-sm);
}
.prod-card.in-cart::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  border-radius: 13px 13px 0 0;
  background: linear-gradient(90deg, #fbbf24, #f59e0b);
}
.prod-card.in-cart .prod-stock { color: var(--accent-ink); font-weight: 650; }
html[data-theme="dark"] .prod-card.in-cart {
  background: linear-gradient(180deg, rgba(245,158,11,.16), var(--surface) 62%);
}

/* Brief pulse when the card is tapped (distinct from the persistent state). */
.prod-card.tapped { animation: card-tap .28s var(--ease); }
@keyframes card-tap {
  0%   { transform: scale(1); }
  45%  { transform: scale(.965); }
  100% { transform: scale(1); }
}

/* ==========================================================================
   POS — phone / tablet layout
   The products own the screen. The cart is a sheet you open on demand,
   never a panel that floats over (and blocks) the product grid.
   ========================================================================== */
.cart-bar, .cart-scrim { display: none; }
.cart-close { display: none; }

@media (max-width: 900px) {
  /* -- Product area -- */
  .pos { display: block; min-height: 0; }
  .pos-left {
    padding: 12px 12px calc(88px + env(safe-area-inset-bottom));
    max-width: 100%;
  }

  /* -- Cart becomes a bottom sheet -- */
  .pos-right {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    height: auto;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    margin: 0;
    border: 0;
    border-radius: 18px 18px 0 0;
    background: var(--surface);
    box-shadow: 0 -18px 44px -12px rgba(16, 24, 40, .38);
    transform: translateY(102%);
    transition: transform .26s var(--ease);
    z-index: 120;
    visibility: hidden;
  }
  .pos-right.open {
    transform: translateY(0);
    visibility: visible;
  }
  .pos-right form { display: flex; flex-direction: column; max-height: 92vh; overflow: hidden; }

  /* Grab handle */
  .pos-right::before {
    content: "";
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: 99px;
    background: var(--border-strong);
    z-index: 3;
  }

  .cart-head { padding: 20px 16px 10px; flex: 0 0 auto; }
  .cart-head h2 { font-size: 16px; }
  .cart-close { display: inline-flex; }
  .cart-list { flex: 1 1 auto; max-height: none; overflow-y: auto; padding: 8px 14px 12px; }
  .cart-foot { flex: 0 0 auto; padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }

  /* -- Scrim behind the sheet -- */
  .cart-scrim {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(9, 14, 22, .5);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 110;
    opacity: 0;
    pointer-events: none;
    transition: opacity .24s var(--ease);
  }
  .cart-scrim[hidden] { display: none; }
  .cart-scrim.show { opacity: 1; pointer-events: auto; }

  /* -- Sticky summary bar -- */
  .cart-bar {
    display: block;
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 100;
    animation: bar-in .24s var(--ease) both;
  }
  .cart-bar[hidden] { display: none; }
  @keyframes bar-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

  .cart-bar-main {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px 11px 11px;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    color: #fff;
    background: linear-gradient(180deg, #182131, #0d131d);
    box-shadow: 0 12px 28px -8px rgba(16, 24, 40, .55), inset 0 1px 0 rgba(255,255,255,.08);
    font-family: inherit;
    text-align: left;
    transition: transform .12s var(--ease);
  }
  .cart-bar-main:active { transform: scale(.985); }

  .cart-bar-count {
    flex: 0 0 auto;
    min-width: 38px;
    height: 38px;
    padding: 0 8px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: 16px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: #1c1206;
    background: linear-gradient(180deg, #fbbf24, #f59e0b);
  }
  .cart-bar-label { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1 1 auto; }
  .cart-bar-label strong { font-size: 16px; font-weight: 750; letter-spacing: -.02em; }
  .cart-bar-label small { font-size: 11.5px; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cart-bar-cta {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    font-weight: 700;
    padding: 7px 11px;
    border-radius: 9px;
    color: #1c1206;
    background: #fbbf24;
    white-space: nowrap;
  }
  .cart-bar-cta .icon { width: 14px; height: 14px; }

  /* Keep the grid clear of the bar. */
  body.has-cart .pos-left { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* -- Touch sizing -- */
  .pos-left .prod-card { min-height: 118px; padding: 13px; }
  .pos-left .prod-name { font-size: 13.5px; -webkit-line-clamp: 2; }
  .prod-qty { top: -6px; right: -6px; min-width: 26px; height: 26px; font-size: 13px; }

  /* Cart items are easier to hit with bigger steppers. */
  .stepper button { width: 34px; height: 34px; }
  .stepper input { width: 54px; height: 34px; font-size: 14px; }
  .cart-item { padding: 12px 12px 11px; }
  .cart-item-name { font-size: 13.5px; }
}

@media (max-width: 420px) {
  .cart-bar-cta span { display: none; }
  .cart-bar-cta { padding: 7px 9px; }
  .pos-left { padding-left: 10px; padding-right: 10px; }
  .pos-left .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
  .pos-left .prod-card { min-height: 112px; }
  .pos-left .prod-price { font-size: 13.5px; }
}

/* ==========================================================================
   Desktop cart must always keep its footer on screen
   --------------------------------------------------------------------------
   .pos-right is a column, but the <form> inside it was a plain block, so
   .cart-list's `flex: 1` did nothing and the form grew to its content height
   (~850px), pushing the discount row and "Complete sale" below the fold on
   any screen shorter than ~900px. Make the form the flex container.
   ========================================================================== */
@media (min-width: 901px) {
  .pos-right { overflow: hidden; }

  .pos-right > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;         /* allow the list to shrink instead of overflowing */
    height: 100%;
    overflow: hidden;
  }

  .cart-head { flex: 0 0 auto; }
  .cart-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .cart-foot { flex: 0 0 auto; }

  /* Tight viewports: trim vertical padding so checkout always fits. */
  @media (max-height: 780px) {
    .cart-head { padding: 12px 16px 10px; }
    .cart-head .row.mt-2 { margin-top: 8px; }
    .cart-foot { padding: 10px 16px 12px; }
    .cart-foot .totals { gap: 5px; margin-bottom: 8px; }
    .pay-methods { margin-bottom: 8px; }
    .pay-method { min-height: 44px; }
    .cart-foot .muted.mt-2 { display: none; }
    .total-row.grand { font-size: 17px; }
  }
}

/* ==========================================================================
   Desktop cart height: fit the space the panel actually occupies
   --------------------------------------------------------------------------
   The panel starts below the topbar AND the page's top padding, so sizing it
   at `100vh - header` overflowed the viewport by that padding (~26px) and cut
   off "Complete sale". Pull the POS into full-bleed on desktop and size the
   panel against the header only.
   ========================================================================== */
@media (min-width: 901px) {
  /* The POS is a workspace, not a document: no page padding, no max-width. */
  .app:has(.pos) .page {
    padding: 0;
    max-width: none;
  }

  .pos-right {
    top: var(--header-h);
    height: calc(100dvh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
  }

  /* Keep the product column comfortable inside the full-bleed layout. */
  .pos { min-height: calc(100dvh - var(--header-h)); }
  .pos-left { padding: 20px 24px 40px; }
}

/* Very short windows: let the whole cart scroll rather than clip the button. */
@media (min-width: 901px) and (max-height: 620px) {
  .pos-right > form { overflow-y: auto; }
  .cart-list { flex: 0 0 auto; min-height: 120px; overflow: visible; }
}

/* ==========================================================================
   Logo
   ========================================================================== */
.logo { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.logo img { display: block; width: 100%; height: 100%; object-fit: contain; }

/* White rounded plate so the blue logo reads on dark surfaces. */
.logo-plate {
  background: #fff;
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 6px 20px -8px rgba(0, 0, 0, .45), inset 0 0 0 1px rgba(255, 255, 255, .6);
}

.logo--sm { width: 46px; height: 46px; border-radius: 13px; padding: 5px; }
.logo--sm img { border-radius: 9px; }

.logo--lg { width: 92px; height: 92px; }
.logo--lg img { border-radius: 14px; }

/* ==========================================================================
   Login — desktop
   ========================================================================== */
.auth-logo-wrap { margin-bottom: 20px; }
.auth-brand .logo--sm { box-shadow: 0 6px 16px -6px rgba(0, 0, 0, .5); }

/* ==========================================================================
   Login — phone & small tablet
   Replaces the hidden artwork panel with a branded header band, so the first
   screen the shopkeeper sees carries the shop's own logo and colours.
   ========================================================================== */
@media (max-width: 980px) {
  .auth-shell { display: block; min-height: 100dvh; background: var(--surface); }

  /* Branded band at the top */
  .auth-art {
    display: flex;
    position: relative;
    overflow: hidden;
    min-height: 228px;
    padding: 30px 24px 34px;
    border-radius: 0 0 26px 26px;
    background: #0d1219;
    justify-content: center;
    align-items: center;
    text-align: center;
  }
  .auth-art::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
      radial-gradient(520px 280px at 20% 0%, rgba(245, 158, 11, .28), transparent 62%),
      radial-gradient(420px 300px at 100% 100%, rgba(37, 99, 235, .30), transparent 60%),
      repeating-linear-gradient(115deg, rgba(255,255,255,.03) 0 1px, transparent 1px 34px);
  }
  .auth-art > * { position: relative; z-index: 1; }

  /* Centre the logo lockup, hide the marketing copy on phones */
  .auth-brand {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
  .auth-brand .brand-name { font-size: 18px; letter-spacing: -.02em; }
  .auth-brand .brand-sub { color: #94a3b8 !important; font-size: 10.5px; }
  .auth-brand .logo--sm { width: 64px; height: 64px; border-radius: 18px; padding: 6px; }

  .auth-quote, .auth-feats { display: none; }
  /* The footer line is the last child of .auth-art — keep it subtle. */
  .auth-art > div:last-child:not(.auth-brand) {
    display: none;
  }

  /* Form area */
  .auth-panel {
    background: var(--surface);
    padding: 30px 22px calc(34px + env(safe-area-inset-bottom));
    align-items: flex-start;
    min-height: auto;
  }
  .auth-form { max-width: 420px; margin: 0 auto; }

  /* Logo already appears in the band — don't repeat it above the heading. */
  .auth-logo-wrap { display: none; }

  .auth-form h1 { font-size: 22px; letter-spacing: -.025em; }
  .auth-form .sub { margin: 6px 0 22px; font-size: 13.5px; }

  /* Comfortable touch targets */
  .auth-form .input { height: 50px; font-size: 16px; border-radius: 12px; }
  .auth-form .label { font-size: 13px; margin-bottom: 2px; }
  .auth-form .field { margin-bottom: 16px; }
  .auth-form .btn-lg { height: 52px; font-size: 15.5px; border-radius: 12px; margin-top: 4px; }
  .auth-hint { font-size: 12.5px; padding: 12px 13px; line-height: 1.55; }
}

/* Very short phones: shrink the band so the form stays above the fold. */
@media (max-width: 980px) and (max-height: 700px) {
  .auth-art { min-height: 176px; padding: 22px 20px 26px; border-radius: 0 0 22px 22px; }
  .auth-brand .logo--sm { width: 52px; height: 52px; }
  .auth-brand .brand-name { font-size: 16px; }
  .auth-panel { padding-top: 22px; }
  .auth-form .sub { margin-bottom: 18px; }
}

/* Landscape phones: put the band beside the form instead of above it. */
@media (max-width: 980px) and (max-height: 520px) and (orientation: landscape) {
  .auth-shell { display: grid; grid-template-columns: 220px 1fr; align-items: stretch; }
  .auth-art { min-height: 100dvh; border-radius: 0; }
  .auth-panel { padding: 20px 24px; height: 100dvh; overflow-y: auto; }
}

/* ==========================================================================
   Login mobile refinements
   ========================================================================== */
@media (max-width: 980px) {
  /* Let the logo fill its plate — the PNG already has its own white margin. */
  .auth-brand .logo--sm.logo-plate { padding: 3px; }
  .auth-brand .logo--sm img { border-radius: 15px; transform: scale(1.04); }

  /* Centre the whole sign-in block and lift it slightly off the band. */
  .auth-panel { align-items: flex-start; }
  .auth-form { margin-top: -6px; }

  /* Show the three feature lines under the form so the page feels complete. */
  .auth-feats-mobile {
    display: grid;
    gap: 9px;
    margin-top: 26px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
  }
  .auth-feats-mobile .auth-feat {
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 12.5px;
    color: var(--muted);
  }
  .auth-feats-mobile .auth-feat i {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--accent-soft);
    color: var(--accent-ink);
    border: 0;
  }
  .auth-feats-mobile .auth-feat .icon { width: 14px; height: 14px; }
}

@media (min-width: 981px) {
  .auth-feats-mobile { display: none; }
}

/* ==========================================================================
   Sign out
   --------------------------------------------------------------------------
   The old control was a bare 32px icon with no label, tucked at the edge of
   the user card — effectively invisible. Both entry points now read clearly.
   ========================================================================== */

/* ---------- Sidebar: labelled button under the user card ---------- */
.sidebar-foot { display: flex; flex-direction: column; gap: 8px; }
.logout-form { margin: 0; }

.logout-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, .10);
  background: rgba(255, 255, 255, .05);
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s, color .15s;
}
.logout-btn .icon { width: 16px; height: 16px; }
.logout-btn:hover {
  background: rgba(239, 68, 68, .16);
  border-color: rgba(239, 68, 68, .45);
  color: #fecaca;
}
.logout-btn:active { transform: translateY(1px); }
.logout-btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(239, 68, 68, .35); }

/* ---------- Topbar account menu ---------- */
.user-menu { position: relative; flex: 0 0 auto; }

.user-menu-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 7px 0 4px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.user-menu-toggle:hover { background: var(--surface-3); border-color: var(--border-strong); }
.user-menu-toggle:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }

.avatar--sm {
  width: 26px; height: 26px; border-radius: 50%;
  font-size: 10.5px; font-weight: 700;
  background: linear-gradient(145deg, #334155, #1e293b);
  color: #e2e8f0;
  display: grid; place-items: center;
}
.user-menu-caret { width: 14px; height: 14px; color: var(--muted); transition: transform .18s var(--ease); }
.user-menu-toggle[aria-expanded="true"] .user-menu-caret { transform: rotate(180deg); }

.user-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 216px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 150;
  animation: menu-in .14s var(--ease) both;
}
.user-menu-panel[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.user-menu-head { padding: 9px 10px 10px; }
.user-menu-head .user-name { font-size: 13px; font-weight: 650; color: var(--text); }
.user-menu-head .user-role { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s, color .12s;
}
.user-menu-item .icon { width: 16px; height: 16px; opacity: .8; }
.user-menu-item:hover { background: var(--surface-3); color: var(--text); }
.user-menu-item:focus-visible { outline: none; background: var(--surface-3); box-shadow: inset 0 0 0 2px var(--accent-soft); }

.user-menu-sep { height: 1px; margin: 5px 4px; background: var(--border); }

.user-menu-signout { color: var(--red); }
.user-menu-signout .icon { opacity: 1; }
.user-menu-signout:hover { background: var(--red-soft); color: var(--red); }

/* ---------- Phones: keep sign-out one tap away ---------- */
@media (max-width: 900px) {
  .user-menu-toggle { height: 34px; padding: 0 6px 0 3px; }
  .user-menu-panel { min-width: 200px; right: -4px; }
  /* The labelled sidebar button is inside the drawer, which is fine —
     the topbar menu covers the case where the drawer is closed. */
  .logout-btn { height: 42px; font-size: 14px; }
}
