/*!
 * Galla POS — Point of Sale & Inventory Admin Template
 * Version 1.0.0 · Plain CSS, no build step required.
 *
 * Contents
 *  1. Fonts
 *  2. Design tokens (light + dark)
 *  3. Base
 *  4. App layout (sidebar, topbar, content)
 *  5. Components (card, button, badge, form, table, tabs, dropdown, modal, toast …)
 *  6. Page parts (KPIs, charts, POS register, receipt, invoice, auth)
 *  7. Utilities
 *  8. Responsive + print
 */

/* 1. Fonts ------------------------------------------------------------- */
@font-face {
  font-family: "Figtree";
  src: url("figtree-latin-wght-normal.woff2") format("woff2");
  font-weight: 300 900;
  font-display: block; /* local files load at once; no reflow when they arrive */
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("jetbrains-mono-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 800;
  font-display: block; /* local files load at once; no reflow when they arrive */
}

/* 2. Tokens ------------------------------------------------------------ */
:root {
  /* Brand — change these to rebrand the whole template */
  --primary: #c23b22;
  --primary-strong: #9f2f1a;
  --primary-soft: #fbe7e1;
  --accent: #e6a23c;
  --accent-soft: #fcf0da;

  --bg: #f4f2ee;
  --surface: #ffffff;
  --surface-2: #f9f8f5;
  --ink: #1c1d22;
  --ink-2: #4a4c55;
  --ink-3: #62656f;
  --line: #e6e3dc;
  --line-strong: #d3cfc6;

  /* Sidebar is dark in both themes */
  --side-bg: #17181d;
  --side-line: rgba(255, 255, 255, .08);
  --side-ink: #f1efe9;
  --side-ink-2: #b6b9c3;
  --side-ink-3: #8b8f9b;
  --side-hover: rgba(255, 255, 255, .06);

  --success: #1d7a46;
  --success-soft: #e2f3e8;
  --warning: #b7791f;
  --warning-text: #8a5d19;
  --warning-soft: #fcf0d9;
  --danger: #b8392a;
  --danger-soft: #fbe5e1;
  --info: #2c6585;
  --info-soft: #e2eef5;

  /* Chart series */
  --c1: var(--primary);
  --c2: var(--accent);
  --c3: #2f6f8f;
  --c4: #5f8a66;
  --c5: #8a5a9e;

  --font-ui: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 6px;
  --shadow: 0 1px 2px rgba(28, 24, 18, .05), 0 6px 20px -12px rgba(28, 24, 18, .14);
  --shadow-pop: 0 14px 40px -12px rgba(28, 24, 18, .3);
  --sidebar-w: 252px;
  --topbar-h: 64px;
  --focus: 0 0 0 3px color-mix(in srgb, var(--primary) 32%, transparent);
  color-scheme: light;
}

[data-theme="dark"] {
  --primary: #ff7a5c;
  --primary-strong: #ff9a80;
  --primary-soft: #3a1d16;
  --accent: #f0b65a;
  --accent-soft: #3a2c14;

  --bg: #0f1013;
  --surface: #17181c;
  --surface-2: #1c1d22;
  --ink: #eeece6;
  --ink-2: #bcbec6;
  --ink-3: #8f929c;
  --line: #2a2b31;
  --line-strong: #383a41;

  --side-bg: #0b0c0e;

  --success: #5cc78a;
  --success-soft: #15291d;
  --warning: #e7b45a;
  --warning-text: #e7b45a;
  --warning-soft: #33280f;
  --danger: #f2806f;
  --danger-soft: #3a1915;
  --info: #7fb4d4;
  --info-soft: #14242e;

  --c1: var(--primary);
  --c2: var(--accent);
  --c3: #7fb4d4;
  --c4: #8fbf96;
  --c5: #c39ad6;

  --shadow: 0 1px 2px rgba(0, 0, 0, .35), 0 8px 24px -12px rgba(0, 0, 0, .55);
  --shadow-pop: 0 16px 48px -12px rgba(0, 0, 0, .75);
  color-scheme: dark;
}

/* 3. Base -------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); color: var(--ink); margin: 0; line-height: 1.2; letter-spacing: -.015em; }
h1 { font-size: 27px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15.5px; font-weight: 700; }
h4 { font-size: 14px; font-weight: 700; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
.mono, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
table { font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* The "Skip to content" link appears when it gets keyboard focus */
a.sr-only:focus { position: fixed; top: 10px; left: 10px; z-index: 200; width: auto; height: auto; clip: auto; overflow: visible; padding: 10px 16px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--focus); }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* 4. Layout ------------------------------------------------------------ */
.app { --sb: var(--sidebar-w); display: grid; grid-template-columns: var(--sb) minmax(0, 1fr); min-height: 100vh;
  background: linear-gradient(90deg, var(--side-bg) 0 var(--sb), transparent var(--sb)); }

.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: var(--side-bg); color: var(--side-ink-2);
  display: flex; flex-direction: column;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 20px; border-bottom: 1px solid var(--side-line); color: var(--side-ink); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name { font-family: var(--font-display); font-weight: 800; font-size: 21px; letter-spacing: -.03em; display: flex; align-items: baseline; gap: 6px; }
.brand-name small { font: 600 10.5px var(--font-mono); letter-spacing: .08em; color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); padding: 1px 5px; border-radius: 4px; }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; scrollbar-width: thin; scrollbar-color: #33353d transparent; }
.nav-group + .nav-group { margin-top: 16px; }
.nav-title { font: 600 11px var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--side-ink-3); padding: 0 10px 6px; }
.nav a {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; border-radius: var(--r-md);
  color: var(--side-ink-2); font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: var(--side-hover); color: var(--side-ink); text-decoration: none; }
.nav a.active { background: rgba(255, 255, 255, .09); color: #fff; font-weight: 600; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--primary); }
.nav svg { width: 19px; height: 19px; flex: none; }
.nav a.active svg { color: var(--primary); }
[data-theme="light"] .nav a.active svg { color: #ff7a5c; }
.nav .count { margin-left: auto; font: 600 11.5px var(--font-mono); background: rgba(230, 162, 60, .16); color: #f0b65a; padding: 1px 7px; border-radius: 99px; }

.sidebar-foot { padding: 14px; border-top: 1px solid var(--side-line); }
.register-note { display: flex; gap: 11px; align-items: flex-start; padding: 12px 13px; border-radius: var(--r-md); background: rgba(255, 255, 255, .05); border: 1px solid var(--side-line); color: var(--side-ink-2); font-size: 12.5px; line-height: 1.4; }
.register-note:hover { text-decoration: none; background: rgba(255, 255, 255, .08); }
.register-note b { display: block; color: var(--side-ink); font-size: 13.5px; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: #4cc983; margin-top: 5px; flex: none; box-shadow: 0 0 0 3px rgba(76, 201, 131, .2); }

.sidebar-backdrop { display: none; }
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.search { position: relative; flex: 1; max-width: 420px; }
.search svg { position: absolute; left: 12px; top: 50%; translate: 0 -50%; width: 17px; height: 17px; color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 40px; padding: 0 64px 0 38px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); }
.search kbd { position: absolute; right: 10px; top: 50%; translate: 0 -50%; font: 600 11px var(--font-mono); color: var(--ink-3); border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; background: var(--surface-2); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar-actions .btn { margin-right: 6px; }
.icon-btn {
  position: relative; width: 40px; height: 40px; display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent; border-radius: var(--r-md); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn .dot { position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); border: 2px solid var(--bg); }
.menu-toggle { display: none; }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; }
.user-btn .who { text-align: left; line-height: 1.2; }
.user-btn .who b { display: block; font-size: 13.5px; }
.user-btn .who small { color: var(--ink-3); font-size: 12px; }

.content { padding: 28px; max-width: 1480px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }
.crumbs { display: flex; gap: 6px; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.crumbs a { color: var(--ink-3); }
.crumbs span::before { content: "/"; margin-right: 6px; }
/* Links inside running text are underlined so they don't rely on colour alone */
p a:not(.btn), .check a { text-decoration: underline; text-underline-offset: 2px; }
.footer { margin-top: auto; padding: 18px 28px; font-size: 13px; color: var(--ink-3); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }

.grid { display: grid; gap: 20px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-8 { grid-column: span 8; } .span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; } .span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; }
.stack > * + * { margin-top: 20px; }

/* Collapsed sidebar (desktop) */
.sidebar-collapsed .app { --sb: 76px; }
.sidebar-collapsed .brand-name, .sidebar-collapsed .nav-title, .sidebar-collapsed .nav span:not(.sr-only),
.sidebar-collapsed .nav .count, .sidebar-collapsed .sidebar-foot { display: none; }
.sidebar-collapsed .nav a { justify-content: center; }
.sidebar-collapsed .brand { justify-content: center; padding: 0; }

/* 5. Components -------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--ink-3); }
.card-body { padding: 18px 20px 20px; }
.card-flush { padding: 0; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-3); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
[data-theme="dark"] .btn-primary { color: #2a0c05; }
.btn-primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.btn-dark:hover { background: var(--ink-2); border-color: var(--ink-2); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #2b1a04; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
[data-theme="dark"] .btn-danger { background: #b8392a; border-color: #b8392a; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 50px; padding: 0 22px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12.5px; font-weight: 600; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-soft); color: var(--warning-text); border-color: transparent; }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-primary { background: var(--primary-soft); color: var(--primary); border-color: transparent; }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; flex: none; background: var(--c3); }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.person { display: flex; align-items: center; gap: 11px; min-width: 0; }
.person b { display: block; font-weight: 600; font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person small { display: block; color: var(--ink-3); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Forms */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.label { font-weight: 600; font-size: 13.5px; color: var(--ink); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 13px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 11px 13px; resize: vertical; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%237a7d87' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 13px center; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }
.error-text { color: var(--danger); font-size: 12.5px; display: none; }
.is-invalid ~ .error-text, .field.has-error .error-text, .field:has(.is-invalid) .error-text { display: block; }
.input-group { display: flex; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); min-width: 0; }
.input-group .addon { display: grid; place-items: center; padding: 0 13px; border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--surface-2); color: var(--ink-3); font-size: 14px; }
.input-group .addon-l { order: -1; border-left: 1px solid var(--line-strong); border-right: 0; border-radius: var(--r-md) 0 0 var(--r-md); font-family: var(--font-mono); }
.input-group .addon-l + .input { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-wrap { position: relative; }
.input-wrap .input { padding-right: 44px; }
.input-wrap .icon-btn { position: absolute; right: 2px; top: 1px; width: 40px; height: 40px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .field + .field { margin-top: 0; }

.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 24px; background: var(--line-strong); border-radius: 99px; position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

.dropzone { border: 1.5px dashed var(--line-strong); border-radius: var(--r-lg); padding: 26px; text-align: center; color: var(--ink-2); background: var(--surface-2); cursor: pointer; }
.dropzone.is-over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone svg { width: 30px; height: 30px; margin: 0 auto 8px; color: var(--primary); }

/* Table */
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font: 600 11.5px var(--font-mono); letter-spacing: .04em; text-transform: uppercase; color: var(--ink-3); padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .right, .table th.right { text-align: right; }
.table td.num, .table td .num { font-size: 13.5px; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]::after { content: "↕"; margin-left: 6px; opacity: .35; }
.table th[data-dir="asc"]::after { content: "↑"; opacity: 1; }
.table th[data-dir="desc"]::after { content: "↓"; opacity: 1; }
.table-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.table-tools .input, .table-tools .select { height: 38px; width: auto; }
.table-tools .input { min-width: 240px; flex: 1; max-width: 340px; }
.pager { display: flex; flex-wrap: wrap; gap: 4px; }
.pager-gap { min-width: 18px; height: 34px; display: inline-grid; place-items: center; color: var(--ink-3); }
.pager button { min-width: 34px; height: 34px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 13px; }
.pager button.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pager button:disabled { opacity: .4; cursor: default; }
@media (prefers-reduced-motion: no-preference) { tr.flash td { animation: flash 1.2s ease-out; } @keyframes flash { from { background: var(--accent-soft); } } }
.empty-row td { text-align: center; padding: 40px 16px; color: var(--ink-3); }

/* Tabs */
.tabs { display: flex; gap: 4px; box-shadow: inset 0 -1px 0 var(--line); overflow-x: auto; overflow-y: hidden; }
.tab { background: none; border: 0; padding: 11px 14px; font-weight: 600; font-size: 14px; color: var(--ink-3); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); }
.segmented button { border: 0; background: none; padding: 5px 12px; border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--ink-3); cursor: pointer; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.1); }

/* Dropdown */
.dropdown { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); padding: 6px; z-index: 60; display: none;
}
.dropdown.open > .menu { display: block; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r-sm); color: var(--ink-2); background: none; border: 0; font-size: 14px; text-align: left; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.menu svg { width: 17px; height: 17px; }
.menu hr { margin: 6px 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--primary); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.menu-head .link-btn { width: auto; padding: 0; font-size: 13px; font-weight: 600; color: var(--primary); }
.notif { display: flex; gap: 11px; padding: 10px; border-radius: var(--r-sm); }
.notif:hover { background: var(--surface-2); }
.notif p { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.notif p b { color: var(--ink); }
.notif small { color: var(--ink-3); font-size: 12px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 14, 12, .55); }
.modal-dialog { position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow: auto; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-pop); border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .modal.open .modal-dialog { animation: pop .18s ease-out; }
  @keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
}

/* Toast */
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 120; display: grid; gap: 10px; pointer-events: none; }
/* On the POS screen toasts sit over the product grid so they never cover the Pay button */
body:has(.content-pos) .toasts { bottom: auto; top: calc(var(--topbar-h) + 14px); right: 424px; }
@media (max-width: 960px) { body:has(.content-pos) .toasts { right: 12px; left: 12px; top: auto; bottom: 84px; } body:has(.content-pos) .toast { min-width: 0; max-width: none; } }
.toast { display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 380px; padding: 12px 14px; border-radius: var(--r-md); background: var(--ink); color: var(--bg); box-shadow: var(--shadow-pop); font-size: 14px; }
.toast svg { width: 19px; height: 19px; color: #ff9a80; flex: none; }
[data-theme="dark"] .toast svg { color: #c23b22; }

/* Alerts, progress, misc */
.alert { display: flex; gap: 12px; padding: 13px 15px; border-radius: var(--r-md); font-size: 14px; border: 1px solid transparent; }
.alert svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.alert p { margin: 2px 0 0; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning-text); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--info-soft); color: var(--info); }
.alert b { color: inherit; }
.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.progress.tone-warning > span { background: var(--accent); }
.progress.tone-success > span { background: var(--success); }
.progress.tone-danger > span { background: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li > .person, .person > div { min-width: 0; }
.list > li > b, .list > li > .badge { flex-shrink: 0; }
.list > li:last-child { border-bottom: 0; padding-bottom: 0; }
.list > li:first-child { padding-top: 0; }
.muted { color: var(--ink-3); }
.trend { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; font-size: 13px; }
.trend.up { color: var(--success); }
.trend.down { color: var(--danger); }
.trend svg { width: 14px; height: 14px; }
.kbd { font: 600 11.5px var(--font-mono); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; background: var(--surface-2); color: var(--ink-2); }

/* 6. Page parts -------------------------------------------------------- */
/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px 20px 16px; min-width: 0; }
.kpi-label { font-size: 13.5px; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.kpi-label i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.kpi-value { font-size: 28px; font-weight: 700; margin: 8px 0 4px; line-height: 1.1; white-space: nowrap; }
.kpi-value small { font-size: 15px; font-weight: 600; color: var(--ink-3); margin-left: 3px; }
.kpi-foot { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); flex-wrap: wrap; }
.kpi-spark { height: 34px; margin-top: 10px; }

.stat { display: flex; align-items: center; gap: 14px; }
.stat .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .ic svg { width: 21px; height: 21px; }
.stat b { font-size: 20px; font-weight: 700; display: block; line-height: 1.2; }
.stat span { color: var(--ink-3); font-size: 13px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 20px; }

/* Charts */
.chart { position: relative; width: 100%; }
.chart svg { overflow: visible; }
.chart .axis text { fill: var(--ink-3); font-size: 11px; font-family: var(--font-mono); }
.chart .gridline { stroke: var(--line); stroke-dasharray: 3 4; }
.chart-tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-pop); border-radius: var(--r-md); padding: 9px 11px; font-size: 12.5px; min-width: 140px; opacity: 0; transition: opacity .1s; z-index: 5; }
.chart-tip.show { opacity: 1; }
.chart-tip b { display: block; font-size: 12.5px; margin-bottom: 4px; }
.chart-tip div { display: flex; align-items: center; gap: 7px; color: var(--ink-2); }
.chart-tip div span { margin-left: auto; color: var(--ink); font-weight: 600; padding-left: 12px; font-family: var(--font-mono); }
.chart-tip i, .legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex: none; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.donut-wrap { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 20px; align-items: center; }
.card-body:has(> .donut-wrap) { container-type: inline-size; }
@container (max-width: 340px) { .donut-wrap { grid-template-columns: 1fr; justify-items: center; } .donut-wrap > .list { width: 100%; } }
.donut-center { font-family: var(--font-mono); }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center; font-size: 14px; }
.bar-row + .bar-row { margin-top: 14px; }
.bar-row .progress { grid-column: 1 / -1; height: 6px; }

/* Product tile (icon square) */
.thumb { width: 42px; height: 42px; border-radius: var(--r-md); display: grid; place-items: center; flex: none; }
.thumb svg { width: 22px; height: 22px; }
.thumb-sm { width: 32px; height: 32px; border-radius: 8px; }
.thumb-sm svg { width: 17px; height: 17px; }
/* Category tints: set with style="--tb: background; --ti: icon colour" */
[style*="--tb"] { background: var(--tb); color: var(--ti); }
[data-theme="dark"] [style*="--tb"] { background: color-mix(in srgb, var(--ti) 26%, var(--surface-2)); color: color-mix(in srgb, var(--ti) 35%, #fff); }

/* Category cards */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.cat-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.cat-card .thumb { width: 52px; height: 52px; border-radius: 14px; }
.cat-card .thumb svg { width: 26px; height: 26px; }
.cat-card h3 { font-size: 16.5px; }
.cat-card p { margin: 2px 0 0; color: var(--ink-3); font-size: 13.5px; }
.cat-meta { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); margin: 0 -20px -20px; }
.cat-meta div { padding: 12px 16px; font-size: 12px; color: var(--ink-3); }
.cat-meta div + div { border-left: 1px solid var(--line); }
.cat-meta b { display: block; font: 700 15px var(--font-mono); color: var(--ink); }

/* Supplier cards */
.sup-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.sup { padding: 20px; }
.sup-top { display: flex; gap: 12px; align-items: center; }
.sup-top .avatar { border-radius: 12px; }
.sup dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 16px 0; font-size: 13.5px; }
.sup dt { color: var(--ink-3); }
.sup dd { margin: 0; text-align: right; font-weight: 600; }

/* ===== POS register ===== */
.content-pos { padding: 0; max-width: none; flex: 1; min-height: 0; }
.app:has(.content-pos) .footer { display: none; }
.app:has(.content-pos) .main { height: 100vh; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - var(--topbar-h)); }
.pos-products { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pos-bar { display: flex; gap: 10px; align-items: center; padding: 16px 22px 12px; flex-wrap: wrap; }
.pos-scan { position: relative; flex: 1; min-width: 220px; }
.pos-scan svg { position: absolute; left: 13px; top: 50%; translate: 0 -50%; width: 19px; height: 19px; color: var(--ink-3); pointer-events: none; }
.pos-scan .input { height: 46px; padding-left: 42px; padding-right: 70px; font-size: 15px; background: var(--surface); }
.pos-scan .kbd { position: absolute; right: 12px; top: 50%; translate: 0 -50%; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 0 22px 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; font-size: 13.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.chip svg { width: 16px; height: 16px; }
.chip small { font: 600 11.5px var(--font-mono); color: var(--ink-3); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .7; }
.ptiles { flex: 1; overflow-y: auto; padding: 4px 22px 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 14px; align-content: start; }
.ptile { position: relative; display: flex; flex-direction: column; gap: 10px; text-align: left; padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, border-color .12s; min-height: 168px; }
.ptile:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.ptile:active { transform: translateY(0) scale(.99); }
.ptile .pic { height: 74px; border-radius: 10px; display: grid; place-items: center; }
.ptile .pic svg { width: 34px; height: 34px; }
.ptile .nm { font-weight: 600; font-size: 13.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 35px; }
.ptile .row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-top: auto; }
.ptile .pr { font: 700 15px var(--font-mono); letter-spacing: -.03em; }
.ptile .st { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.ptile .st.low { color: var(--warning-text); font-weight: 600; }
.ptile .in-cart { position: absolute; top: 8px; right: 8px; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 99px; background: var(--ink); color: var(--bg); font: 700 12px var(--font-mono); display: grid; place-items: center; }
.ptile[disabled] { cursor: not-allowed; opacity: .55; transform: none; }
.ptile[disabled] .st { color: var(--danger); font-weight: 600; }
.ptiles-empty { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--ink-3); }
@media (prefers-reduced-motion: no-preference) {
  .ptile.bump { animation: bump .25s ease-out; }
  @keyframes bump { 40% { transform: scale(.96); } }
}

.cart { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border-left: 1px solid var(--line); }
.cart-head { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }
.cart-head .row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cart-head h2 { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.cart-head h2 .mono { font-size: 12.5px; color: var(--ink-3); font-weight: 500; }
.cart-lines { flex: 1; overflow-y: auto; padding: 6px 18px; }
.cline { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 12px 0; border-bottom: 1px dashed var(--line-strong); }
.cline:last-child { border-bottom: 0; }
.cline .nm { font-weight: 600; font-size: 14px; line-height: 1.3; }
.cline .unit { font: 500 12px var(--font-mono); color: var(--ink-3); }
.cline .tot { font: 700 14.5px var(--font-mono); text-align: right; align-self: start; }
.cline .ctrl { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 99px; overflow: hidden; }
.qty button { width: 32px; height: 30px; border: 0; background: var(--surface-2); cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.qty button:hover { background: var(--line); color: var(--ink); }
.qty button svg { width: 15px; height: 15px; }
.qty input { width: 40px; height: 30px; border: 0; text-align: center; font: 700 13.5px var(--font-mono); background: transparent; -moz-appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cline .rm { border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; padding: 4px; border-radius: 6px; }
.cline .rm:hover { color: var(--danger); background: var(--danger-soft); }
.cline .rm svg { width: 15px; height: 15px; }
.cart-empty { display: grid; place-items: center; text-align: center; color: var(--ink-3); padding: 48px 12px; font-size: 14px; }
.cart-empty svg { width: 46px; height: 46px; margin: 0 auto 10px; color: var(--line-strong); }
.cart-empty b { display: block; color: var(--ink-2); font-size: 15px; margin-bottom: 2px; }
.cart-sum { border-top: 1px solid var(--line); padding: 14px 18px 18px; background: var(--surface-2); }
.sum-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--ink-2); padding: 3px 0; }
.sum-row .mono { color: var(--ink); font-weight: 600; }
.sum-row .link-btn { font-size: 13px; font-weight: 600; }
.sum-total { display: flex; justify-content: space-between; align-items: baseline; margin: 10px 0 14px; padding-top: 12px; border-top: 2px solid var(--ink); }
.sum-total span { font-weight: 700; font-size: 15px; }
.sum-total b { font: 800 28px var(--font-mono); letter-spacing: -.04em; }
.cart-actions { display: grid; grid-template-columns: auto auto 1fr; gap: 8px; }
.btn-pay { height: 52px; font-size: 16px; font-weight: 700; }
.btn-pay .mono { font-weight: 700; }
.held-count { font: 700 11px var(--font-mono); background: var(--accent); color: #2b1a04; border-radius: 99px; padding: 0 6px; margin-left: -2px; }
.cart-bar, .cart-scrim, .cart-close { display: none; }

/* Payment */
.pay-due { text-align: center; padding: 6px 0 18px; }
.pay-due span { display: block; font-size: 13px; color: var(--ink-3); font-weight: 600; }
.pay-due b { font: 800 40px var(--font-mono); letter-spacing: -.04em; }
.pay-methods { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.pay-method { display: grid; justify-items: center; gap: 6px; padding: 14px 8px; border-radius: var(--r-md); border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px; color: var(--ink-2); }
.pay-method svg { width: 24px; height: 24px; }
.pay-method[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-strong); }
[data-theme="dark"] .pay-method[aria-pressed="true"] { color: var(--primary); }
.quick-cash { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.quick-cash button { flex: 1; min-width: 64px; height: 38px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface-2); font: 600 13.5px var(--font-mono); cursor: pointer; }
.quick-cash button:hover { border-color: var(--ink-3); }
.change-due { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding: 14px 16px; border-radius: var(--r-md); background: var(--success-soft); color: var(--success); font-weight: 600; }
.change-due b { font: 800 22px var(--font-mono); }
.change-due.short { background: var(--danger-soft); color: var(--danger); }

/* Receipt (thermal 80 mm) */
.receipt-stage { background: var(--surface-2); padding: 22px 16px 28px; display: grid; place-items: center; }
/* Long names typed into forms wrap instead of widening the page */
.person b, .person small, .cat-card h3, .cat-card p, .sup dd, .receipt, .notif p, td { overflow-wrap: anywhere; }
.user-btn .who b { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-missing { text-align: center; max-width: 340px; padding: 40px 8px; color: var(--ink-2); }
.receipt-missing b { display: block; color: var(--ink); font-size: 17px; margin-bottom: 6px; }
.receipt-missing p { margin: 0 0 16px; }
.receipt {
  --paper: #fffdf8;
  width: 100%; max-width: 310px; background: var(--paper); color: #1f1d19;
  font: 500 12.5px/1.5 var(--font-mono); padding: 20px 18px 26px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 26px -14px rgba(0,0,0,.35);
  position: relative;
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
          mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) 50% / 12px 100%;
}
.receipt .r-head { text-align: center; margin-bottom: 12px; }
.receipt .r-head svg { width: 30px; height: 30px; margin: 0 auto 6px; }
.receipt .r-head b { display: block; font-size: 15px; font-weight: 800; letter-spacing: .02em; }
.receipt .r-head small { display: block; color: #5b574f; font-size: 11.5px; }
.receipt .r-rule { border: 0; border-top: 1px dashed #b8b2a6; margin: 10px 0; }
.receipt .r-meta, .receipt .r-line, .receipt .r-sum { display: flex; justify-content: space-between; gap: 10px; }
.receipt .r-meta { color: #5b574f; font-size: 11.5px; }
.receipt .r-item { margin: 6px 0; }
.receipt .r-item .r-sub { color: #6b665c; font-size: 11.5px; }
.receipt .r-sum { padding: 1px 0; }
.receipt .r-total { font-size: 16px; font-weight: 800; padding: 6px 0; }
.receipt .r-foot { text-align: center; margin-top: 12px; color: #5b574f; font-size: 11.5px; }
.receipt .r-code { height: 38px; margin: 12px auto 4px; width: 80%; background: repeating-linear-gradient(90deg, #1f1d19 0 2px, transparent 2px 4px, #1f1d19 4px 5px, transparent 5px 8px, #1f1d19 8px 11px, transparent 11px 12px); }

/* Invoice (A4) */
.invoice { padding: 40px; }
.invoice-top { display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; padding-bottom: 28px; border-bottom: 1px solid var(--line); }
.invoice-title { font-size: 32px; font-weight: 800; letter-spacing: -.03em; }
.invoice-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; padding: 28px 0; }
.invoice-meta h3 { font: 600 11.5px var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 6px; }
.invoice-meta p { margin: 0; font-size: 14px; color: var(--ink-2); }
.invoice-meta p b { color: var(--ink); }
.totals { margin-left: auto; max-width: 320px; width: 100%; margin-top: 20px; }
.totals div { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; color: var(--ink-2); }
.totals div span:last-child { font-family: var(--font-mono); color: var(--ink); }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 12px; font-size: 20px; font-weight: 800; color: var(--ink); }

/* Settings */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: start; }
.side-tabs { display: grid; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 20px); }
.side-tabs .tab { text-align: left; border: 0; border-radius: var(--r-md); margin: 0; padding: 9px 12px; display: flex; align-items: center; gap: 10px; }
.side-tabs .tab svg { width: 18px; height: 18px; }
.side-tabs .tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: 0; }
.setting-row p { margin: 2px 0 0; font-size: 13.5px; color: var(--ink-3); }
.receipt-setup { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.saved-note { font-size: 13px; color: var(--success); display: inline-flex; align-items: center; }

/* Auth */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); }
.auth-form { display: flex; flex-direction: column; padding: 32px clamp(24px, 6vw, 88px); }
.auth-form .inner { margin: auto 0; width: 100%; max-width: 400px; }
.auth-form h1 { font-size: 30px; margin: 0 0 8px; }
.auth-form .lead { color: var(--ink-2); margin-bottom: 26px; }
.auth-form .brand { border: 0; padding: 0; height: auto; color: var(--ink); }
.auth-form .brand-name small { color: var(--warning-text); border-color: color-mix(in srgb, var(--warning-text) 45%, transparent); }
.auth-art { position: relative; overflow: hidden; background: var(--side-bg); color: #f1efe9; padding: 48px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 26px; }
.auth-art::before { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 50% at 70% 20%, rgba(194, 59, 34, .35), transparent 70%), radial-gradient(50% 40% at 20% 90%, rgba(230, 162, 60, .22), transparent 70%); }
.auth-art .receipt { transform: rotate(-3deg); max-width: 290px; }
.auth-art p { position: relative; max-width: 380px; text-align: center; font-size: 19px; font-weight: 600; line-height: 1.4; margin: 0; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 4px; }
.pin-pad button { height: 54px; border-radius: var(--r-md); border: 1px solid var(--line-strong); background: var(--surface); font: 600 19px var(--font-mono); cursor: pointer; }
.pin-pad button:hover { background: var(--surface-2); }
.pin-dots { display: flex; justify-content: center; gap: 12px; margin: 6px 0 16px; }
.pin-dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); }
.pin-dots i.on { background: var(--ink); border-color: var(--ink); }

/* Error page */
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.error-page .receipt { margin: 0 auto 26px; max-width: 280px; text-align: left; }
.error-page p { color: var(--ink-2); max-width: 420px; margin: 12px auto 26px; }

/* 7. Utilities --------------------------------------------------------- */
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .wrap { flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; } .mb-0 { margin-bottom: 0; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.text-right { text-align: right; } .text-center { text-align: center; } .small { font-size: 13px; } .strong { font-weight: 600; color: var(--ink); }
.w-100 { width: 100%; } .nowrap { white-space: nowrap; }
.bg-primary-soft { background: var(--primary-soft); color: var(--primary); }
.bg-accent-soft, .bg-warning-soft { background: var(--accent-soft); color: var(--warning-text); }
.bg-info-soft { background: var(--info-soft); color: var(--info); }
.bg-danger-soft { background: var(--danger-soft); color: var(--danger); }
.bg-success-soft { background: var(--success-soft); color: var(--success); }
.text-danger { color: var(--danger); } .text-success { color: var(--success); } .text-warning { color: var(--warning-text); }
[hidden] { display: none !important; }

/* 8. Responsive -------------------------------------------------------- */
@media (max-width: 1280px) {
  .kpis, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span-3 { grid-column: span 6; }
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
}
@media (max-width: 1100px) {
  .span-8, .span-7, .span-6, .span-5, .span-4 { grid-column: span 12; }
  .receipt-setup { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .app, .sidebar-collapsed .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; box-shadow: var(--shadow-pop); }
  .sidebar-open .sidebar { transform: none; visibility: visible; transition: transform .25s ease; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(15,14,12,.5); z-index: 35; display: none; }
  .sidebar-open .sidebar-backdrop { display: block; }
  .menu-toggle { display: inline-grid; }
  .collapse-toggle { display: none; }
  .sidebar-collapsed .brand-name, .sidebar-collapsed .nav-title, .sidebar-collapsed .nav span:not(.sr-only), .sidebar-collapsed .nav .count, .sidebar-collapsed .sidebar-foot { display: revert; }
  .sidebar-collapsed .brand-name { display: flex; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .side-tabs { position: static; display: flex; overflow-x: auto; }
  .invoice-meta { grid-template-columns: 1fr 1fr; }
  /* POS: cart becomes a bottom sheet */
  .pos { grid-template-columns: minmax(0, 1fr); height: calc(100dvh - var(--topbar-h)); }
  .ptiles { padding-bottom: 96px; }
  .cart { position: fixed; left: 0; right: 0; bottom: 0; height: min(86dvh, 720px); z-index: 50; border-left: 0; border-radius: 18px 18px 0 0; box-shadow: var(--shadow-pop); transform: translateY(105%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
  .cart-open .cart { transform: none; visibility: visible; transition: transform .25s ease; }
  .cart-open .cart-scrim { display: block; }
  .cart-open body { overflow: hidden; } /* no page scroll behind the open sheet */
  .cart-scrim { position: fixed; inset: 0; background: rgba(15,14,12,.5); z-index: 45; }
  .cart-bar { display: flex; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 44; height: 58px; border: 0; border-radius: 14px; background: var(--ink); color: var(--bg); align-items: center; justify-content: space-between; padding: 0 18px; font-weight: 700; font-size: 15px; box-shadow: var(--shadow-pop); cursor: pointer; }
  .cart-bar .mono { font-size: 17px; }
  .cart-bar .n { font: 700 12px var(--font-mono); background: var(--primary); color: #fff; border-radius: 99px; padding: 1px 8px; margin-right: 8px; }
  .cart-close { display: inline-grid; }
}
@media (max-width: 640px) {
  body { font-size: 14.5px; }
  .content { padding: 18px 16px; }
  .topbar { padding: 0 12px; gap: 6px; }
  .search { display: none; }
  .user-btn .who, .hide-sm { display: none !important; }
  .span-3 { grid-column: span 12; }
  .kpis, .stats { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .donut-wrap { grid-template-columns: 1fr; justify-items: center; }
  .invoice { padding: 22px; }
  .invoice-meta { grid-template-columns: 1fr; }
  .footer { padding: 16px; }
  h1 { font-size: 23px; }
  .table-tools .input { min-width: 0; max-width: none; flex: 1 1 100%; }
  .table-tools .btn { margin-left: 0 !important; }
  .pos-bar, .chips { padding-left: 14px; padding-right: 14px; }
  .ptiles { padding-left: 14px; padding-right: 14px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .pay-due b { font-size: 34px; }
  .pager button { min-width: 30px; height: 32px; }
  .pager-gap { min-width: 12px; height: 32px; }
}
@page { margin: 12mm; }
@page invoice { size: A4; margin: 12mm; }
@page receipt { size: 80mm 297mm; margin: 0; }
@media print {
  /* Always print with the light colours, even when the screen is in dark mode */
  [data-theme="dark"] {
    --primary: #c23b22; --primary-strong: #9f2f1a; --primary-soft: #fbe7e1; --accent: #e6a23c; --accent-soft: #fcf0da;
    --bg: #ffffff; --surface: #ffffff; --surface-2: #f9f8f5; --ink: #1c1d22; --ink-2: #4a4c55; --ink-3: #62656f; --line: #e6e3dc; --line-strong: #d3cfc6;
    --success: #1d7a46; --success-soft: #e2f3e8; --warning: #b7791f; --warning-text: #8a5d19; --warning-soft: #fcf0d9;
    --danger: #b8392a; --danger-soft: #fbe5e1; --info: #2c6585; --info-soft: #e2eef5;
    --c3: #2f6f8f; --c4: #5f8a66; --c5: #8a5a9e;
    color-scheme: light;
  }
  .sidebar, .topbar, .footer, .no-print, .toasts { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; }
  body { background: #fff; }
  /* Printing only the receipt (POS and sale pages) */
  body.print-receipt > *:not(.print-area) { display: none !important; }
  body.print-receipt .print-area { display: block !important; }
  .print-area { display: none; }
  .print-area .receipt { box-shadow: none; max-width: 80mm; margin: 0 auto; -webkit-mask: none; mask: none; }
  body.print-receipt .print-area { page: receipt; }
  /* A4 invoice: one clean page, no on-screen padding */
  .invoice { page: invoice; padding: 0; break-inside: auto; }
  .invoice tr, .invoice .totals { break-inside: avoid; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* Theme toggle icon */
.theme-sun { display: none; }
[data-theme="dark"] .theme-sun { display: contents; }
[data-theme="dark"] .theme-moon { display: none; }

/* Scrollable tables get a visible focus ring when reached with the keyboard */
.table-wrap:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
