/* MotoSupply POS — styles based on the MotoSupply Figma Make design.
   All colours and sizes are tokens on :root so the theme can be tuned in one place. */

:root {
  --accent: #dd4a2b;
  --accent-hover: #c63f22;
  --accent-soft: #fdece7;
  --sidebar: #1f2024;
  --sidebar-2: #2b2d32;
  --sidebar-text: #c9cbd0;
  --sidebar-muted: #9a9da4;
  --on-sidebar: #ffffff;
  --on-accent: #ffffff;
  --bg: #f3f2ee;
  --card: #ffffff;
  --border: #e6e3dc;
  --border-strong: #d6d2c9;
  --text: #1b1c20;
  --muted: #6c6f76;
  --success: #17804f;
  --success-soft: #e5f4ec;
  --warning: #b86e00;
  --warning-soft: #fdf2dc;
  --danger: #cc3523;
  --danger-soft: #fbe7e4;
  --info-soft: #e7eefb;
  --blue: #3866c9;
  --focus: #2f6fed;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 1px 2px rgba(20, 20, 25, .04);
  --shadow-lg: 0 18px 50px rgba(20, 20, 25, .22);
  --sidebar-w: 248px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--bg); }
h1, h2, h3, h4 { margin: 0; font-weight: 500; line-height: 1.25; }
p { margin: 0; }
a { color: inherit; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
table { border-collapse: collapse; width: 100%; }
kbd { font: 600 10px/1 var(--font); border: 1px solid var(--border-strong); border-radius: 3px; padding: 2px 4px; background: #fff; color: var(--muted); }
[hidden] { display: none !important; }
.sprite { display: none; }
.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-lg { width: 34px; height: 34px; stroke-width: 1.5; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: #fff; padding: 8px 12px; border-radius: var(--radius); }
.skip-link:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.block { display: block; }
.strong { font-weight: 600; text-decoration: none; }
a.strong:hover { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-success { color: var(--success); }
.text-accent { color: var(--accent); }
.center-text { text-align: center; }
.grow { flex: 1; min-width: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stack > * + * { margin-top: 16px; }

/* ---------- Sidebar ---------- */
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--sidebar); color: var(--sidebar-text); display: flex; flex-direction: column; z-index: 40; }
.brand, .guest-brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid rgba(255, 255, 255, .06); }
.brand-mark { width: 36px; height: 36px; border-radius: 4px; background: var(--accent); color: var(--on-accent); flex: none; display: grid; place-items: center; font-weight: 800; font-size: 20px; }
.brand-text strong { display: block; color: var(--on-sidebar); font-weight: 800; font-size: 15px; letter-spacing: .02em; }
.brand-text strong span { color: var(--accent); }
.brand-text small { display: block; font-size: 9px; letter-spacing: .24em; color: #9a9da4; }
.nav { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-form { margin: 0; }
.nav-link { position: relative; display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 14px; border-radius: var(--radius-sm); color: var(--sidebar-text); text-decoration: none; background: none; border: 0; cursor: pointer; font-size: 14px; text-align: left; }
.nav-link:hover { background: var(--sidebar-2); color: var(--on-sidebar); }
.nav-link.is-active { background: var(--sidebar-2); color: var(--on-sidebar); font-weight: 500; }
.nav-link.is-active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav-link.is-active .icon { color: var(--accent); }
.nav-badge { margin-left: auto; min-width: 22px; padding: 2px 7px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-size: 11px; text-align: center; }
.store-card { margin: 0 14px 14px; padding: 12px 14px; border-radius: var(--radius); background: linear-gradient(135deg, #2c2e33, #1a1b1e); border: 1px solid rgba(255, 255, 255, .06); }
.store-card small { display: block; color: var(--accent); font-size: 9px; font-weight: 700; letter-spacing: .12em; }
.store-card strong { display: block; color: var(--on-sidebar); font-size: 13px; }
.store-card span { display: block; font-size: 11px; color: #a9acb2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-card { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid rgba(255, 255, 255, .06); }
.user-meta strong { display: block; color: var(--on-sidebar); font-size: 13px; }
.user-meta small { color: #9a9da4; font-size: 11px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: #f1e3da; color: #5b4b40; display: grid; place-items: center; font-weight: 600; font-size: 12px; flex: none; text-decoration: none; }
.avatar-sm { width: 34px; height: 34px; }
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 35; }

/* ---------- Top bar ---------- */
.main-wrap { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 12px 26px; min-height: 72px; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-size: 20px; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.top-search { position: relative; }
.top-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-search input[type=search] { width: 220px; height: 38px; border: 1px solid transparent; border-radius: var(--radius); background: #f4f3f0; padding: 0 12px 0 38px; }
.clock { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.clock strong { display: block; color: var(--text); font-size: 12px; }
.clock small { display: block; font-size: 9px; letter-spacing: .04em; }
.icon-btn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; cursor: pointer; color: var(--text); text-decoration: none; padding: 0; }
.icon-btn:hover { background: #f6f5f2; }
.icon-btn .dot { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.menu-btn { display: none; }

/* Testing-mode warning (shown only on plain HTTP) */
.insecure-banner { display: flex; gap: 10px; align-items: flex-start; padding: 10px 26px; background: #fff4d6; color: #6b4a00; border-bottom: 1px solid #f0d58c; font-size: 13px; }
.insecure-banner a { color: inherit; font-weight: 600; }
.guest .insecure-banner { width: min(560px, 100%); border: 1px solid #f0d58c; border-radius: var(--radius); }

/* ---------- Page ---------- */
.main { flex: 1; padding: 28px 32px 40px; outline: none; min-width: 0; }
.page { max-width: 1460px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.page-narrow { max-width: 900px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 24px; font-weight: 400; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-head p { margin-top: 6px; font-size: 12px; }
.back-link { display: inline-block; font-size: 12px; color: var(--muted); text-decoration: none; margin-bottom: 6px; }
.back-link:hover { color: var(--accent); }
.section-title { font-size: 16px; font-weight: 500; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: #fff; color: var(--text); font-weight: 600; font-size: 13px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f7f6f3; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b02c1c; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn.is-selected { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.btn:disabled, .btn.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .6); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.btn-primary):not(.btn-danger).is-busy::after { border-color: var(--muted); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); cursor: pointer; font-weight: 500; }
.btn-link:hover { text-decoration: underline; }
.link-accent { color: var(--accent); text-decoration: none; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.link-accent .icon { width: 14px; height: 14px; }
.link-accent:hover { text-decoration: underline; }

/* ---------- Cards ---------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-pad { padding: 20px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h3 { font-size: 15px; font-weight: 500; }
.card-head p { margin-top: 4px; }
.card-body { padding: 20px; }
.card h3 { font-size: 15px; font-weight: 500; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat-card { display: flex; align-items: center; gap: 16px; padding: 20px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; min-width: 0; }
.stat-link:hover { border-color: var(--border-strong); }
.stat-icon { width: 42px; height: 42px; border-radius: var(--radius); display: grid; place-items: center; flex: none; }
.tone-blue { background: var(--info-soft); color: var(--blue); }
.tone-green { background: var(--success-soft); color: var(--success); }
.tone-red { background: var(--accent-soft); color: var(--accent); }
.tone-amber { background: var(--warning-soft); color: var(--warning); }
.stat-label { display: block; font-size: 11px; color: var(--muted); }
.stat-value { display: block; font-size: 22px; font-weight: 700; margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value small { font-size: 14px; }
.stat-note { display: block; font-size: 11px; color: var(--success); }
.stat-strip { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
.stat-strip > * { padding: 18px 20px; border-left: 1px solid var(--border); text-decoration: none; min-width: 0; }
.stat-strip > :first-child { border-left: 0; }
.stat-strip a:hover { background: #faf9f7; }
.stat-strip small { font-size: 11px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 1fr); gap: 14px; }
.big-number { display: block; font-size: 26px; font-weight: 700; }

/* Bar chart (heights via classes; inline styles are blocked by the CSP) */
.bar-chart { list-style: none; margin: 20px 0 0; padding: 0; display: flex; align-items: flex-end; gap: 6px; height: 190px; }
.bar-chart li { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; min-width: 0; }
.bar-wrap { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.bar { display: block; width: min(30px, 70%); background: #26282d; border-radius: 2px 2px 0 0; min-height: 2px; }
.is-today .bar { background: var(--accent); }
.bar-label { font-size: 10px; color: var(--muted); }
.h0 { height: 1%; } .h5 { height: 5%; } .h10 { height: 10%; } .h15 { height: 15%; } .h20 { height: 20%; } .h25 { height: 25%; }
.h30 { height: 30%; } .h35 { height: 35%; } .h40 { height: 40%; } .h45 { height: 45%; } .h50 { height: 50%; } .h55 { height: 55%; }
.h60 { height: 60%; } .h65 { height: 65%; } .h70 { height: 70%; } .h75 { height: 75%; } .h80 { height: 80%; } .h85 { height: 85%; }
.h90 { height: 90%; } .h95 { height: 95%; } .h100 { height: 100%; }

.alert-list { list-style: none; margin: 0; padding: 6px 14px; }
.alert-list li { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.alert-list li:last-child { border-bottom: 0; }
.alert-list a { text-decoration: none; }
.alert-list strong { display: block; font-size: 12px; font-weight: 600; }
.alert-list small { font-size: 10px; }

/* Thumbnails */
.thumb { width: 42px; height: 42px; border-radius: var(--radius-sm); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; object-fit: cover; border: 1px solid var(--border); background: #f0efeb; color: #4b4d52; }
.thumb-lg { width: 96px; height: 96px; }
.t0 { background: #f8e9e4; } .t1 { background: #ebedf0; } .t2 { background: #f5efe0; } .t3 { background: #e5ecef; } .t4 { background: #e7f1ea; } .t5 { background: #f1e9e4; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-success { background: var(--success-soft); color: var(--success); }
.pill-warning { background: var(--warning-soft); color: var(--warning); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: #efeeea; color: var(--muted); }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid transparent; font-size: 13px; }
.alert-success { background: var(--success-soft); color: #0f5c38; border-color: #c6e6d4; }
.alert-error { background: var(--danger-soft); color: #9a2416; border-color: #f2c9c2; }
.alert-info { background: var(--info-soft); color: #23468f; border-color: #cbd9f4; }
.alert-warning { background: var(--warning-soft); color: #7a4a00; border-color: #f1d9a8; }
.pos-mode-banner { grid-column: 1 / -1; margin: 12px 16px 0; }
.pos.has-mode-banner { grid-template-rows: auto minmax(0, 1fr); }
.sync-bg-status { position: fixed; right: 12px; bottom: 12px; z-index: 40; max-width: 320px; font-size: .8rem; }
.main > .alert { max-width: 1460px; margin: 0 auto 16px; }

/* ---------- Tables ---------- */
.table-wrap { position: relative; width: 100%; overflow-x: auto; }
.table th { text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; background: #fcfbfa; position: sticky; top: 0; z-index: 1; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 12px; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfaf8; }
.table th.num { text-align: right; }
.table a { text-decoration: none; }
.table small { font-size: 10px; }
.table .is-archived td { opacity: .65; }
.product-cell { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.product-cell small { display: block; }
.actions { width: 1%; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 180px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; }
.menu-list a, .menu-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: var(--radius-sm); background: none; border: 0; font-size: 13px; cursor: pointer; text-align: left; text-decoration: none; }
.menu-list a:hover, .menu-list button:hover { background: #f5f4f1; }
.menu-list form { margin: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info, .pager-page { font-size: 11px; color: var(--muted); }
.pager-links { display: flex; align-items: center; gap: 8px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; border: 0; padding: 0; }
.field label, .field .label, .field legend { font-size: 12px; font-weight: 600; padding: 0; }
.field.narrow { max-width: 260px; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=date], input[type=number], input:not([type]), input[inputmode], select, textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; min-width: 0;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input[type=file] { font-size: 13px; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 2px solid rgba(221, 74, 43, .18); outline-offset: 0; }
[aria-invalid=true] { border-color: var(--danger) !important; }
.field-error { color: var(--danger); font-size: 12px; }
.hint { color: var(--muted); font-size: 11px; }
.req { color: var(--accent); }
.input-sm { height: 32px !important; font-size: 12px; width: auto !important; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.static-value { font-size: 13px; padding: 10px 0; }
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; }
.radio, .check { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.image-current { display: flex; align-items: center; gap: 16px; }
.inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inline-label { font-size: 12px; color: var(--muted); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar-filters select, .toolbar-filters input { width: auto; height: 40px; }
.search-input { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-input input[type=search] { padding-left: 40px; }
.filter-bar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.filter-bar .field { width: auto; }
.filter-bar input[type=date], .filter-bar select { width: 170px; }

.switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 11px; background: #cfcdc7; position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--success); }
.switch:checked::after { transform: translateX(16px); }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row label { font-size: 12px; }
.toggle-row small { font-size: 11px; }

/* ---------- Empty states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 48px 20px; color: var(--muted); }
.empty-state h2, .empty-state h3 { color: var(--text); font-size: 16px; }
.empty-state.compact { padding: 28px 16px; font-size: 12px; }

/* ---------- Reports ---------- */
.library { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.library-card { display: flex; flex-direction: column; gap: 8px; padding: 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; }
.library-card strong { font-weight: 500; margin-top: 6px; }
.library-card:hover { border-color: var(--border-strong); }
.library-card.is-active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border-bottom: 1px solid var(--border); }
.summary-grid > div { padding: 16px 20px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: -1px; }
.summary-grid strong { display: block; font-size: 17px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.note { border-top: 1px solid var(--border); }

/* ---------- Settings ---------- */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 90px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius); font-size: 12px; color: var(--muted); text-decoration: none; }
.settings-nav a:hover { background: #fff; color: var(--accent); }
.settings-section { padding-bottom: 8px; border-bottom: 1px solid var(--border); scroll-margin-top: 90px; }
.settings-section:last-of-type { border-bottom: 0; }
.settings-section h3 { margin-bottom: 4px; }
.settings-section > .form-grid, .settings-section > .field { margin-top: 14px; }
#security { scroll-margin-top: 90px; }

/* ---------- Totals ---------- */
.totals { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.totals > div { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.totals .grand { border-top: 1px dashed var(--border-strong); padding-top: 12px; margin-top: 4px; align-items: baseline; }
.totals .grand dt { color: var(--text); font-weight: 700; font-size: 12px; }
.totals .grand dd { font-size: 24px; font-weight: 800; }

/* ---------- POS ---------- */
.is-pos .main { padding: 0; display: flex; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; width: 100%; min-height: calc(100vh - 72px); }
.pos-products { padding: 26px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.pos-search { position: relative; }
.pos-search .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 20px; height: 20px; }
.pos-search input[type=search] { height: 50px; padding-left: 48px; font-size: 15px; border-radius: var(--radius); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: thin; }
.tab { background: none; border: 0; padding: 10px 0; font-size: 12px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }
.pos-list-head p { margin-top: 2px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; align-content: start; }
.p-card { display: flex; gap: 14px; padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); align-items: stretch; min-width: 0; }
.p-card .thumb { width: 66px; height: 74px; flex-direction: column; font-size: 16px; }
.p-card .thumb small { font-size: 8px; font-weight: 600; letter-spacing: .08em; color: var(--muted); margin-top: 6px; }
.p-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-cat { font-size: 9px; font-weight: 700; letter-spacing: .06em; color: var(--accent); text-transform: uppercase; }
.p-name { font-size: 13px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-meta { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-price { font-size: 15px; font-weight: 700; margin-top: 6px; }
.p-stock { font-size: 10px; color: var(--success); }
.p-stock.low { color: var(--warning); }
.p-stock.out { color: var(--danger); }
.p-add { align-self: flex-end; }
.p-card.is-out { opacity: .55; }
.kbd-hints { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: auto; padding-top: 8px; }
.kbd-hints span { display: inline-flex; gap: 6px; align-items: center; }
.pos-cart { background: #fff; border-left: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 72px; height: calc(100vh - 72px); }
.cart-head { padding: 20px; border-bottom: 1px solid var(--border); }
.cart-head h2 { font-size: 16px; font-weight: 500; }
.cart-lines { flex: 1; overflow-y: auto; padding: 4px 20px; }
.c-line { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 4px 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.c-line .thumb { width: 44px; height: 44px; grid-row: span 2; font-size: 11px; }
.c-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-meta { font-size: 10px; color: var(--muted); }
.c-remove { width: 28px; height: 28px; border: 0; color: var(--muted); }
.c-remove:hover { color: var(--danger); }
.c-bottom { grid-column: 2 / 4; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); }
.qty button { width: 28px; height: 28px; border: 0; background: none; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.qty button:hover { color: var(--text); }
.qty .icon { width: 14px; height: 14px; }
.qty input { width: 52px; height: 28px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); border-radius: 0; text-align: center; padding: 0 4px; font-weight: 600; font-size: 12px; }
.c-total { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.c-warn { grid-column: 2 / 4; font-size: 10px; color: var(--danger); }
.cart-totals { padding: 16px 20px 20px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.discount-line dd { color: var(--success); }
.discount-row { display: flex; gap: 6px; }
.discount-row select { width: 130px; height: 36px; font-size: 12px; }
.discount-row input { height: 36px; }
.btn-pay { height: 52px; justify-content: space-between; font-size: 15px; letter-spacing: .02em; padding: 0 18px; }
.btn-pay kbd { margin-left: auto; background: rgba(255, 255, 255, .15); color: #fff; border-color: rgba(255, 255, 255, .4); }


/* Dialogs */
.modal { border: 0; padding: 0; border-radius: 10px; width: min(440px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; overscroll-behavior: contain; box-shadow: var(--shadow-lg); color: var(--text); }
.modal::backdrop { background: rgba(20, 20, 25, .45); }
.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h2, .modal h2 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.pay-summary { margin: 0; display: flex; flex-direction: column; gap: 8px; }
.pay-summary > div { display: flex; justify-content: space-between; font-size: 14px; }
.pay-summary dt { color: var(--muted); }
.pay-summary dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-summary .change dd { color: var(--success); font-size: 20px; }
.pay-summary .change.is-short dd { color: var(--danger); }
#tendered { height: 50px; font-size: 20px; font-weight: 700; text-align: right; }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash .btn { flex: 1; min-width: 70px; }
.done-icon { width: 60px; height: 60px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #26282d; color: #fff; padding: 12px 18px; border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 60; font-size: 13px; max-width: calc(100vw - 32px); }
.toast.is-error { background: var(--danger); }

/* ---------- Guest pages ---------- */
.guest { background: var(--sidebar); min-height: 100vh; }
.guest-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; gap: 20px; }
.guest-brand { border: 0; padding: 0; }
.auth-card { width: min(420px, 100%); background: #fff; border-radius: 10px; padding: 28px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 1280px) {
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
  .top-search input[type=search] { width: 170px; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  .sidebar.is-open { transform: none; }
  .main-wrap { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
  .library { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-strip > :nth-child(3) { border-left: 0; }
  .stat-strip > :nth-child(n+3) { border-top: 1px solid var(--border); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .pos { grid-template-columns: minmax(0, 1fr) 320px; }
  .pos-cart { top: 64px; height: calc(100vh - 64px); }
  .top-search { display: none; }
}
@media (max-width: 640px) {
  .main { padding: 18px 16px 32px; }
  .topbar { padding: 10px 16px; gap: 10px; min-height: 64px; }
  .clock { display: none; }
  .stat-grid, .library, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .stat-strip { grid-template-columns: minmax(0, 1fr); }
  .stat-strip > * { border-left: 0 !important; border-top: 1px solid var(--border); }
  .stat-strip > :first-child { border-top: 0; }
  .page-title { font-size: 20px; }
  .pos-products { padding: 16px; }
  .product-grid { grid-template-columns: minmax(0, 1fr); }
  .search-input { max-width: none; }
  .toolbar-filters, .toolbar-filters select, .toolbar-filters input { width: 100%; }
  .filter-bar .field, .filter-bar input[type=date], .filter-bar select { width: 100%; }
  .kbd-hints { display: none; }
  .is-pos .main { padding: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01ms !important; }
}

/* Installation wizard */
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; background: #f1f0ec; padding: 1px 5px; border-radius: 3px; }
.wizard-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 32px 16px; gap: 22px; }
.wizard-card { width: min(980px, 100%); background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); display: grid; grid-template-columns: 220px minmax(0, 1fr); overflow: hidden; }
.stepper { list-style: none; margin: 0; padding: 24px 18px; background: #f7f6f2; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; }
.stepper li { display: flex; align-items: center; gap: 10px; padding: 8px 6px; font-size: 13px; color: var(--muted); }
.step-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #fff; border: 1px solid var(--border-strong); flex: none; }
.stepper .is-current { color: var(--text); font-weight: 600; }
.stepper .is-current .step-dot { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.stepper .is-done .step-dot { background: var(--success-soft); border-color: #bfe0cd; color: var(--success); }
.wizard-body { padding: 30px 32px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.wizard-body h1 { font-size: 22px; }
.wizard-body h2 { font-size: 15px; font-weight: 600; margin-top: 4px; }
.lead { color: #3d4046; font-size: 14px; }
.checklist { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.wizard-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }
.req-table td { font-size: 13px; }
.fix { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.help-box { background: #f7f6f2; border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }
.help-box summary { cursor: pointer; font-weight: 600; }
.help-box ul { margin: 8px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.summary-list { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); }
.summary-list > div { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.summary-list > div:last-child { border-bottom: 0; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; overflow-wrap: anywhere; }
.wizard .done-icon { font-size: 28px; font-weight: 700; }
.wizard-foot { color: #8d9097; font-size: 11px; }
@media (max-width: 760px) {
  .wizard-card { grid-template-columns: minmax(0, 1fr); }
  .stepper { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px; }
  .stepper .step-label { display: none; }
  .stepper .is-current .step-label { display: inline; }
  .wizard-body { padding: 22px 18px; }
  .wizard .form-grid { grid-template-columns: minmax(0, 1fr); }
  .wizard .span-2 { grid-column: auto; }
  .summary-list > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .req-table thead { display: none; }
  .req-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
  .req-table td { border: 0; padding: 0 4px; }
  .req-table td:last-child { grid-column: 1 / -1; color: var(--muted); }
}

.req-explain { display: block; color: var(--text); font-size: 12px; margin-top: 4px; }
.req-action { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; }
.req-action strong { color: var(--text); }
.ack-box { border: 1px solid #f0d58c; background: #fffaeb; border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.ack-box label { display: flex; gap: 10px; align-items: flex-start; font-weight: 600; cursor: pointer; }
.ack-box input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.mode-box { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }

/* =====================================================================
   1.3 — responsive layout, collapsible sidebar, POS tablet layout, keypad,
   login, settings tabs and new admin pages. Colours come from tokens that
   the theme stylesheet (index.php?r=theme.css) can override.
   ===================================================================== */

/* ---------- Sidebar: icon rail (desktop) ---------- */
.brand { position: relative; }
.brand-logo { max-height: 40px; max-width: 170px; object-fit: contain; }
.rail-toggle { margin-left: auto; width: 28px; height: 28px; border-radius: 6px; border: 1px solid rgba(255, 255, 255, .12); background: transparent; color: var(--sidebar-text); display: grid; place-items: center; cursor: pointer; flex: none; }
.rail-toggle:hover { color: var(--on-sidebar); background: var(--sidebar-2); }
.rail-toggle .icon { width: 16px; height: 16px; transition: transform .15s; }
.user-card { text-decoration: none; color: inherit; }
.user-card:hover { background: var(--sidebar-2); }
.user-meta small { color: var(--sidebar-muted); }
.store-card span { color: var(--sidebar-muted); }

@media (min-width: 1025px) {
  .sidebar-rail { --sidebar-w: 72px; }
  .sidebar-rail .sidebar { width: 72px; }
  .sidebar-rail .brand { flex-direction: column; padding: 16px 8px; gap: 10px; }
  .sidebar-rail .brand-text, .sidebar-rail .store-card, .sidebar-rail .user-meta { display: none; }
  .sidebar-rail .brand-logo { max-width: 48px; max-height: 32px; }
  .sidebar-rail .rail-toggle { margin: 0; }
  .sidebar-rail .rail-toggle .icon { transform: rotate(180deg); }
  .sidebar-rail .nav { padding: 12px 8px; }
  .sidebar-rail .nav-link { justify-content: center; padding: 12px 0; }
  /* Labels stay available to screen readers; sighted users get the title tooltip. */
  .sidebar-rail .nav-label { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .sidebar-rail .nav-badge { position: absolute; top: 4px; right: 6px; min-width: 18px; padding: 1px 5px; font-size: 10px; }
  .sidebar-rail .nav-link.is-active::before { left: -8px; }
  .sidebar-rail .user-card { justify-content: center; padding: 14px 0; }
  .main-wrap { transition: margin-left .15s; }
  .sidebar { transition: width .15s; }
}
@media (max-width: 1024px) {
  .rail-toggle { display: none; }
}

/* ---------- Compact tables; card layout on phones ---------- */
.table td { line-height: 1.35; }
@media (max-width: 640px) {
  .table-cards thead { display: none; }
  .table-cards, .table-cards tbody { display: block; }
  .table-cards tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); position: relative; }
  .table-cards tr:last-child { border-bottom: 0; }
  .table-cards td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 3px 0; border: 0; text-align: right; font-size: 13px; }
  .table-cards td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
  .table-cards td.num { text-align: right; }
  .table-cards td.actions { position: absolute; top: 8px; right: 10px; width: auto; padding: 0; }
  .table-cards td.actions::before { content: none; }
  .table-cards td:first-child { justify-content: flex-start; text-align: left; font-size: 14px; padding-right: 44px; }
  .table-cards td:first-child::before { content: none; }
  .table-cards .product-cell { min-width: 0; }
  .table-wrap { overflow-x: visible; }
  .table th { position: static; }
}

/* ---------- Dialogs always fit the screen ---------- */
.modal-body { min-height: 0; }
@media (max-width: 640px) {
  .modal-body { padding: 18px; gap: 12px; }
  .modal-actions .btn { flex: 1; }
}

/* ---------- POS: tablet landscape keeps two columns; portrait/phone uses a cart sheet ---------- */
.qty-value { min-width: 52px; height: 32px; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); background: #fff; font-weight: 700; font-size: 14px; cursor: pointer; font-variant-numeric: tabular-nums; }
.qty-value:hover { background: var(--accent-soft); }
.qty button { width: 34px; height: 32px; }
.c-line.is-invalid { background: var(--danger-soft); margin: 0 -20px; padding-left: 20px; padding-right: 20px; }
.cart-close, .cart-bar, .cart-backdrop { display: none; }
.print-frame { position: absolute; width: 1px; height: 1px; border: 0; left: -9999px; top: 0; }
@media (min-width: 900px) and (max-width: 1279px) {
  .pos-products { padding: 18px; gap: 12px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; }
  .p-card { padding: 10px; gap: 10px; }
  .p-card .thumb { width: 54px; height: 60px; font-size: 14px; }
  .kbd-hints { display: none; }
  .cart-head { padding: 14px 16px; }
  .cart-lines { padding: 2px 16px; }
  .cart-totals { padding: 12px 16px 16px; gap: 10px; }
  .totals .grand dd { font-size: 22px; }
}
@media (max-width: 899px) {
  .pos { grid-template-columns: minmax(0, 1fr); }
  .is-pos .main { padding-bottom: 76px; }
  .pos-products { padding: 14px; gap: 12px; }
  .product-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
  .p-card { padding: 10px; gap: 10px; }
  .p-card .thumb { width: 52px; height: 58px; font-size: 14px; }
  .kbd-hints { display: none; }
  .pos-cart { position: fixed; left: 0; right: 0; bottom: 0; top: auto; z-index: 46; height: min(88dvh, 720px); border-left: 0; border-radius: 16px 16px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .25); transform: translateY(105%); transition: transform .2s ease; visibility: hidden; }
  .pos-cart.is-open { transform: none; visibility: visible; }
  .cart-close { display: inline-grid; }
  .cart-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; }
  .cart-lines { padding: 2px 16px; }
  .cart-totals { padding: 12px 16px calc(14px + env(safe-area-inset-bottom)); }
  .cart-backdrop { display: block; position: fixed; inset: 0; background: rgba(20, 20, 25, .45); z-index: 45; }
  .cart-backdrop[hidden] { display: none; }
  .cart-bar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; align-items: center; gap: 12px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--border); box-shadow: 0 -6px 18px rgba(0, 0, 0, .08); }
  .cart-bar-open { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 4px; cursor: pointer; text-align: left; min-height: 44px; }
  .cart-bar-open strong { display: block; font-size: 14px; }
  .cart-bar-open small { color: var(--accent); font-size: 12px; font-weight: 600; }
  .cart-bar-open .icon { width: 24px; height: 24px; }
  .cart-bar-total { margin-left: auto; font-size: 18px; font-variant-numeric: tabular-nums; }
  .cart-bar .btn { height: 46px; padding: 0 22px; font-size: 15px; }
}

/* Numeric keypad */
.modal-keypad { width: min(360px, calc(100vw - 24px)); }
.keypad-product { font-weight: 600; }
.keypad-display { display: block; text-align: right; font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; padding: 8px 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #fafaf8; min-height: 58px; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key { height: 58px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; font-size: 22px; font-weight: 700; cursor: pointer; display: grid; place-items: center; touch-action: manipulation; user-select: none; }
.key:hover { background: #f6f5f2; }
.key:active { background: var(--accent-soft); }
.key-fn { font-size: 14px; color: var(--muted); }
.key .icon { width: 24px; height: 24px; }
@media (max-height: 600px) { .key { height: 46px; } .keypad-display { font-size: 26px; min-height: 46px; } }

/* Touch-friendly controls on coarse pointers */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .icon-btn { width: 42px; height: 42px; }
  .qty button, .qty-value { height: 40px; }
  .tab { padding: 12px 0; }
}

/* ---------- Login ----------
   Two panels on wide screens (brand | form), a compact brand header above the form on phones.
   Colours come from the theme tokens (--accent, --accent-hover, --on-accent), so a custom
   theme from Settings → Appearance carries over. */
.is-login { background: #eef0f3; }
.is-login .guest-main {
  justify-content: center; min-height: 100vh; min-height: 100dvh; padding: 32px 20px;
  background:
    radial-gradient(circle at 1.5px 1.5px, rgba(30, 35, 45, .10) 1.5px, transparent 0) 0 0 / 22px 22px,
    radial-gradient(1200px 600px at 0% 0%, #f7f8fa 0, transparent 60%),
    linear-gradient(180deg, #f3f4f7, #e9ecf0);
}
.is-login .insecure-banner { width: min(1080px, 100%); }
.login-shell {
  width: min(1080px, 100%); display: grid; grid-template-columns: 1fr 1fr; background: #fff;
  border-radius: 18px; overflow: hidden; box-shadow: 0 24px 60px rgba(25, 30, 40, .16), 0 2px 6px rgba(25, 30, 40, .06);
}
.login-brand {
  position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  padding: 56px 40px; color: var(--on-accent);
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-hover) 100%);
}
/* Restrained geometric texture: two soft diagonal bands and a dot grid (no images needed). */
.login-brand-art { position: absolute; inset: 0; pointer-events: none; }
.login-brand-art::before {
  content: ""; position: absolute; inset: -20%;
  background:
    linear-gradient(115deg, transparent 0 46%, rgba(255, 255, 255, .055) 46% 58%, transparent 58%),
    linear-gradient(115deg, transparent 0 66%, rgba(0, 0, 0, .06) 66% 80%, transparent 80%);
}
.login-brand-art::after {
  content: ""; position: absolute; left: 24px; bottom: 24px; width: 132px; height: 88px; opacity: .22;
  background: radial-gradient(circle at 2px 2px, var(--on-accent) 1.4px, transparent 0) 0 0 / 16px 16px;
}
.login-brand-inner { position: relative; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0; max-width: 100%; }
.brand-mark-lg {
  width: 96px; height: 96px; font-size: 52px; border-radius: 18px; color: var(--on-accent);
  background: rgba(0, 0, 0, .16); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08), 0 8px 20px rgba(0, 0, 0, .12);
}
.login-logo-tile { display: grid; place-items: center; padding: 12px 16px; border-radius: 16px; background: rgba(255, 255, 255, .95); box-shadow: 0 8px 20px rgba(0, 0, 0, .12); }
.login-logo { display: block; max-width: 220px; max-height: 110px; object-fit: contain; }
.login-shop { margin: 22px 0 0; font-size: clamp(26px, 3.2vw, 40px); line-height: 1.15; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
.login-tag { margin: 10px 0 0; font-size: clamp(15px, 1.6vw, 19px); opacity: .92; }
.login-rule { display: block; width: 52px; height: 3px; border-radius: 3px; background: currentColor; opacity: .9; margin: 24px 0 0; }
.login-motto { display: flex; margin: 24px 0 0; font-size: 13px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; opacity: .9; }
.login-motto span + span::before { content: "|"; margin: 0 18px; font-weight: 400; opacity: .6; }

.login-form-wrap { padding: 88px 64px 72px; display: flex; flex-direction: column; justify-content: center; gap: 0; min-width: 0; }
.login-form-wrap h1 { margin: 0; font-size: clamp(28px, 3.1vw, 40px); line-height: 1.15; font-weight: 800; letter-spacing: -.015em; color: var(--text); }
.login-lead { margin: 8px 0 26px; font-size: 17px; color: var(--muted); }
.login-form-wrap > .alert { margin: 0 0 18px; }
.login-form { display: flex; flex-direction: column; gap: 20px; }
.login-form .field { gap: 8px; }
.login-form .field label { font-size: 15px; font-weight: 700; color: var(--text); }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); pointer-events: none; }
.login-form .input-icon input {
  height: 54px; padding: 0 16px 0 48px; font-size: 16px; border-radius: 8px; border: 1px solid #d9dce2;
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.login-form .input-icon input::placeholder { color: #8a8e97; }
.login-form .input-icon input:hover { border-color: #c4c8d0; }
.login-form .input-icon input:focus { outline: none; border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(221, 74, 43, .22); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.login-form .input-icon input:focus-visible { outline: none; }
.login-form .input-icon input[aria-invalid=true] { border-color: var(--danger); }
.password-wrap input { padding-right: 52px !important; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 6px; }
.pw-toggle:hover { color: var(--text); background: rgba(0, 0, 0, .04); }
.pw-toggle .icon { width: 20px; height: 20px; }
.login-help { margin: 2px 0 0; text-align: right; font-size: 13px; color: var(--muted); }
.login-submit { height: 56px; margin-top: 6px; font-size: 17px; border-radius: 8px; gap: 10px; box-shadow: 0 6px 16px rgba(221, 74, 43, .25); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent); transition: background-color .15s, box-shadow .15s; }
.login-submit .icon { width: 20px; height: 20px; stroke-width: 2.2; }
.login-secure { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 26px 0 0; font-size: 14px; color: var(--muted); }
.login-secure .icon { width: 16px; height: 16px; }
.btn-lg { height: 48px; font-size: 15px; }

/* Tablets and small laptops: slimmer brand panel, less padding. */
@media (max-width: 1024px) {
  .login-shell { grid-template-columns: .9fr 1.1fr; }
  .login-brand { padding: 44px 28px; }
  .login-form-wrap { padding: 56px 44px 44px; }
  .brand-mark-lg { width: 80px; height: 80px; font-size: 44px; border-radius: 16px; }
  .login-motto span + span::before { margin: 0 12px; }
}
/* Phones (and narrow tablets): compact branded header above the form. */
@media (max-width: 760px) {
  .is-login .guest-main { padding: 16px; justify-content: safe center; }
  .login-shell { grid-template-columns: 1fr; border-radius: 16px; }
  .login-brand { padding: 30px 20px 40px; clip-path: polygon(0 0, 100% 0, 100% 100%, 0 calc(100% - 14px)); }
  .brand-mark-lg { width: 64px; height: 64px; font-size: 36px; border-radius: 14px; }
  .login-logo { max-height: 64px; max-width: 180px; }
  .login-logo-tile { padding: 8px 12px; border-radius: 12px; }
  .login-shop { margin-top: 14px; font-size: 24px; }
  .login-tag { margin-top: 4px; font-size: 14px; }
  .login-rule { margin-top: 14px; width: 40px; }
  .login-motto, .login-brand-art::after { display: none; }
  .login-form-wrap { padding: 26px 22px 28px; }
  .login-form-wrap h1 { font-size: 26px; }
  .login-lead { font-size: 15px; margin-bottom: 20px; }
  .login-form { gap: 16px; }
  .login-form .input-icon input { height: 52px; }
  .login-submit { height: 54px; }
  .login-secure { margin-top: 20px; font-size: 13px; }
}
/* Short screens (phones in landscape, small laptops): keep the whole card in view. */
@media (max-height: 560px) and (min-width: 761px) {
  .is-login .guest-main { padding: 10px 20px; }
  .login-shell { grid-template-columns: .8fr 1.2fr; }
  .login-brand { padding: 24px; }
  .brand-mark-lg { width: 56px; height: 56px; font-size: 30px; border-radius: 12px; }
  .login-logo { max-height: 56px; }
  .login-shop { margin-top: 12px; font-size: 24px; }
  .login-tag { font-size: 14px; margin-top: 4px; }
  .login-rule, .login-motto { display: none; }
  .login-form-wrap { padding: 18px 32px; }
  .login-form-wrap h1 { font-size: 22px; }
  .login-lead { margin: 2px 0 10px; font-size: 14px; }
  .login-form { gap: 10px; }
  .login-form .field { gap: 4px; }
  .login-form .field label { font-size: 14px; }
  .login-form .input-icon input, .login-submit { height: 44px; }
  .login-submit { margin-top: 2px; }
  .login-secure { margin-top: 8px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .login-form .input-icon input, .login-submit { transition: none; }
}

/* ---------- Settings tabs and admin pages ---------- */
.settings-tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: thin; }
.settings-tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 13px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.settings-tabs a:hover { color: var(--text); }
.settings-tabs a.is-active { color: var(--text); font-weight: 600; border-bottom-color: var(--accent); }
.settings-tabs .icon { width: 16px; height: 16px; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.schedule-list { display: flex; flex-direction: column; gap: 12px; padding-left: 18px; margin: 0; }
code.break, .break { word-break: break-all; }
.big-code { font-size: 15px; padding: 3px 8px; }
.log-list { margin: 6px 0 0; padding-left: 18px; }
.changelog { white-space: pre-wrap; font-size: 12px; background: #f7f6f2; padding: 12px; border-radius: var(--radius); max-height: 280px; overflow: auto; }
.narrow-input { width: 90px !important; }
.audit-details { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; word-break: break-word; max-width: 420px; }
.perm-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.perm-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 13px; }
.perm-row label { font-weight: 400; }
.perm-row select { width: 96px !important; flex: none; }
.role-has { color: var(--success); font-size: 11px; font-weight: 600; margin-left: 4px; }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.role-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.color-row { display: flex; align-items: center; gap: 12px; }
.color-row input[type=color] { width: 64px; height: 42px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; cursor: pointer; }
.theme-preview { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; min-height: 120px; }
.tp-sidebar { width: 160px; background: var(--sidebar); padding: 12px 8px; display: flex; flex-direction: column; gap: 4px; flex: none; }
.tp-nav { color: var(--sidebar-text); font-size: 13px; padding: 8px 10px; border-radius: 4px; }
.tp-nav.is-active { background: var(--sidebar-2); color: var(--on-sidebar); box-shadow: inset 3px 0 0 var(--accent); }
.tp-body { padding: 16px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; align-content: flex-start; }
.tp-body p { flex-basis: 100%; }
.brand-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 24px; }
.logo-preview { display: flex; align-items: center; gap: 12px; min-height: 72px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: var(--radius); background: #fafaf8; }
.logo-preview img { max-height: 64px; max-width: 220px; object-fit: contain; }
.logo-preview .fav-preview { width: 32px; height: 32px; }
@media (max-width: 640px) {
  .theme-preview { flex-direction: column; }
  .tp-sidebar { width: auto; flex-direction: row; overflow-x: auto; }
  .perm-table { grid-template-columns: minmax(0, 1fr); }
  .settings-tabs a span { font-size: 12px; }
  .inline-form { width: 100%; }
}

.change-list { margin: 0; padding-left: 1rem; }
.change-list li { margin: 0 0 2px; }

/* POS on desktops and landscape tablets: fixed-height shell so the cart (total, Pay, Clear) always
   fits under the header and any notice banner; the product list scrolls by itself. */
@media (min-width: 900px) and (min-height: 520px) {
  .is-pos .main-wrap { height: 100vh; height: 100dvh; min-height: 0; }
  .is-pos .main { min-height: 0; overflow: hidden; }
  .is-pos .pos { min-height: 0; height: 100%; }
  .is-pos .pos-products { overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
  .is-pos .pos-cart { position: static; height: auto; min-height: 0; }
}
