:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f4f6f8;
  --text: #0f1824;
  --muted: #747c87;
  --label: #46515f;
  --faint: #a3a8af;
  --line: #e8eaeb;
  --line-strong: #d3d5d7;
  --primary: #0088ff;
  --primary-ink: #ffffff;
  --primary-soft: #e6f4ff;
  --primary-hover: #0074d9;
  --success: #0db473;
  --success-soft: #e3f7ef;
  --warning: #e49c06;
  --warning-soft: #fff6e0;
  --danger: #ee4747;
  --danger-soft: #feeceb;
  --info: #0088ff;
  --info-soft: #e6f4ff;
  --neutral-soft: #eef0f2;
  --side: #182537;
  --side-2: #2b4263;
  --side-text: #eeefef;
  --side-icon: #a3a8af;
  --side-active: #ffffff;
  --sell: #005299;
  --shadow: 0 0 0 1px rgba(15, 24, 36, .04), 0 1px 3px rgba(15, 24, 36, .12);
  --shadow-lg: 0 12px 32px rgba(15, 24, 36, .18);
  --radius: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020; --surface: #121a2c; --surface-2: #172036; --text: #e7ebf3; --muted: #9aa5ba; --faint: #6b7690;
    --line: #232e47; --line-strong: #2e3a57; --primary: #2b9bff; --primary-soft: #102c4a; --primary-hover: #57b0ff;
    --success-soft: #0f3324; --warning-soft: #3a2a0a; --danger-soft: #3d1614; --info-soft: #0e2a44; --neutral-soft: #1d2740;
    --side: #0b1220; --side-2: #1e2f49; --label: #b4bccb; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #121a2c; --surface-2: #172036; --text: #e7ebf3; --muted: #9aa5ba; --faint: #6b7690;
  --line: #232e47; --line-strong: #2e3a57; --primary: #2b9bff; --primary-soft: #102c4a; --primary-hover: #57b0ff;
  --success-soft: #0f3324; --warning-soft: #3a2a0a; --danger-soft: #3d1614; --info-soft: #0e2a44; --neutral-soft: #1d2740;
  --side: #0b1220; --side-2: #1e2f49; --label: #b4bccb; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/20px var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 22px; line-height: 28px; } h2 { font-size: 16px; } h3 { font-size: 14px; }
input, select, textarea, button { font: inherit; color: inherit; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.right { text-align: right; } .center { text-align: center; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.layout-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }

/* ------------------------------------------------ shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 230px; background: var(--side); color: var(--side-text); position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 40; }
.brand { height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 16px; color: #fff; font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; background: linear-gradient(135deg, #0088ff, #00c2ff); display: grid; place-items: center; font-weight: 800; font-size: 15px; color: #fff; }
.brand small { display: block; font-size: 11px; font-weight: 500; color: var(--side-text); letter-spacing: 0; }
.brand:hover { text-decoration: none; }
.brand-logo { height: 28px; width: auto; display: block; }
.auth-brand { margin-bottom: 22px; }
:root[data-theme="dark"] .auth-brand img { filter: none; }
.side-quick { margin: 8px 12px 6px; display: flex; position: relative; }
.side-quick .sell-main { flex: 1; display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 8px; border-radius: 6px 0 0 6px; background: var(--sell); color: var(--side-text); font-weight: 500; }
.side-quick .sell-main:hover { text-decoration: none; filter: brightness(1.1); }
.side-quick .sell-main svg { width: 20px; height: 20px; }
.side-quick .sell-caret { width: 30px; height: 32px; border: 0; border-left: 1px solid rgba(255,255,255,.18); border-radius: 0 6px 6px 0; background: var(--sell); color: #fff; display: grid; place-items: center; cursor: pointer; }
.side-quick .sell-caret svg { width: 14px; height: 14px; }
.sell-menu { position: absolute; top: 36px; left: 0; right: 0; background: var(--surface); border-radius: 6px; box-shadow: var(--shadow-lg); padding: 4px; z-index: 50; }
.sell-menu a { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 4px; color: var(--text); }
.sell-menu a:hover { background: var(--surface-2); text-decoration: none; }
.sell-menu svg { width: 18px; height: 18px; color: var(--muted); }
.nav { flex: 1; overflow-y: auto; padding: 4px 12px 16px; }
.nav::-webkit-scrollbar { width: 6px; } .nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 3px; }
.nav-group { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--side-text); padding: 14px 6px 6px; margin-top: 6px; border-top: 1px solid rgba(255,255,255,.1); }
.nav a { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 6px; margin: 1px 0; border-radius: 6px; color: var(--side-text); font-weight: 450; font-size: 14px; }
.nav a svg { color: var(--side-icon); }
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--side-2); color: var(--side-active); }
.nav a.active svg { color: var(--side-text); }
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .sub { margin: 0 0 4px 30px; }
.nav .sub a { height: 32px; padding: 0 6px; font-size: 14px; }
.nav .sub a.active { background: transparent; color: #4fb0ff; }
.side-foot { padding: 8px 12px; border-top: 1px solid rgba(255,255,255,.1); font-size: 12px; }
.side-foot .foot-link { display: flex; align-items: center; gap: 10px; height: 32px; padding: 0 6px; border-radius: 6px; color: var(--side-text); font-size: 14px; }
.side-foot .foot-link svg { width: 20px; height: 20px; color: var(--side-icon); }
.side-foot .foot-link:hover, .side-foot .foot-link.active { background: var(--side-2); text-decoration: none; }

.main { flex: 1; margin-left: 230px; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 48px; background: var(--surface); box-shadow: 0 1px 0 var(--line); display: flex; align-items: center; gap: 14px; padding: 0 24px; position: sticky; top: 0; z-index: 30; }
.topbar .search { flex: 1; max-width: 520px; position: relative; }
.topbar .search input { width: 100%; padding: 6px 12px 6px 34px; border: 1px solid transparent; border-radius: 6px; background: transparent; outline: none; }
.topbar .search input:focus { border-color: var(--line-strong); background: var(--surface); }
.topbar .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--faint); }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 8px; border-radius: 8px; position: relative; }
.user-chip:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: #d5f5e3; color: #1f622e; display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.content { padding: 20px 24px 32px; max-width: 1280px; width: 100%; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .back { width: 32px; height: 32px; border: 1px solid var(--line-strong); border-radius: 6px; display: grid; place-items: center; background: var(--surface); color: var(--text); }
.page-head .back:hover { text-decoration: none; background: var(--surface-2); }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.demo-bar { background: linear-gradient(90deg, #1d5bff, #00a3ff); color: #fff; font-size: 13px; padding: 7px 24px; display: flex; gap: 6px 10px; align-items: center; flex-wrap: wrap; }
.demo-bar a { color: #fff; text-decoration: underline; }

/* ------------------------------------------------ cards */
.card { background: var(--surface); border: 0; border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; min-height: 56px; }
.card-h h2 { font-size: 16px; font-weight: 600; }
.card-h .actions { margin-left: auto; display: flex; gap: 8px; }
.card-b { padding: 20px; }
.card-b.tight { padding: 0; }
.card-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.totals { margin-left: auto; width: min(380px, 100%); }
.totals .t { display: flex; justify-content: space-between; padding: 5px 0; }
.totals .t.big { font-weight: 700; font-size: 16px; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }

/* ------------------------------------------------ buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap; line-height: 1.3; color: var(--text); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--line-strong); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--neutral-soft); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; border: 0; background: transparent; display: inline-grid; place-items: center; cursor: pointer; color: var(--muted); }
.icon-btn:hover { background: var(--neutral-soft); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; padding: 0; font-weight: 500; }
.link-btn:hover { text-decoration: underline; }
.link-btn svg { width: 15px; height: 15px; vertical-align: -3px; }
.pos-top .picker-results { color: var(--text); }

/* ------------------------------------------------ forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 450; color: var(--label); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input { width: 100%; padding: 7px 12px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); outline: none; min-height: 36px; line-height: 20px; }
textarea.input { min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.input.sm { min-height: 32px; padding: 5px 9px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-radius: 8px 0 0 8px; }
.input-group .addon { border: 1px solid var(--line-strong); border-left: 0; border-radius: 0 8px 8px 0; padding: 0 10px; display: flex; align-items: center; background: var(--surface-2); color: var(--muted); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line-strong); }
.seg button.on { background: var(--primary); color: #fff; }

/* ------------------------------------------------ tables */
.toolbar { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.toolbar .search-input { flex: 1; min-width: 200px; position: relative; }
.toolbar .search-input input { padding-left: 34px; }
.toolbar .search-input svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; color: var(--faint); }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 14px 12px 12px; cursor: pointer; color: var(--label); font-weight: 450; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--primary); border-bottom-color: var(--primary); }
.tabs button .cnt { font-size: 11px; background: var(--neutral-soft); color: var(--muted); padding: 1px 6px; border-radius: 10px; margin-left: 4px; }
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-weight: 500; color: var(--label); font-size: 14px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr.click { cursor: pointer; }
.tbl tbody tr.click:hover td { background: var(--surface-2); }
.tbl th.right, .tbl td.right { text-align: right; }
.tbl td .input { min-height: 32px; padding: 5px 8px; }
.tbl tfoot td { font-weight: 600; background: var(--surface-2); }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.pager .spacer { flex: 1; }
.thumb { width: 40px; height: 40px; border-radius: 6px; background: var(--neutral-soft); object-fit: cover; flex: none; display: grid; place-items: center; color: var(--faint); border: 1px solid var(--line); overflow: hidden; }
.thumb svg { width: 18px; }
.thumb { position: relative; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cell-prod { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty svg { width: 56px; height: 56px; color: var(--line-strong); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

/* ------------------------------------------------ badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 20px; font-size: 13px; font-weight: 450; white-space: nowrap; background: var(--neutral-soft); color: var(--muted); }
.badge::before { display: none; }
.badge.plain::before { display: none; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.orange { background: var(--warning-soft); color: var(--warning); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.blue { background: var(--info-soft); color: var(--info); }
.badge.purple { background: #f1e9ff; color: #7a3ff2; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--neutral-soft); font-size: 12px; margin: 2px 4px 2px 0; }

/* ------------------------------------------------ stats & charts */
.stat { padding: 16px 18px; }
.stat .lbl { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.stat .val { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.delta.up { color: var(--success); } .delta.down { color: var(--danger); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart .grid-line { stroke: var(--line); }
.chart .bar { fill: var(--primary); }
.chart .bar:hover { fill: var(--primary-hover); }
.chart .line { fill: none; stroke: var(--primary); stroke-width: 2.2; }
.chart .area { fill: var(--primary); opacity: .08; }
.hbar { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.hbar .name { width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { display: block; flex: 1; height: 8px; background: var(--neutral-soft); border-radius: 4px; overflow: hidden; }
.hbar .fill { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.hbar .v { width: 110px; text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }
.chart-tip { position: fixed; pointer-events: none; background: #0d1424; color: #fff; padding: 6px 10px; border-radius: 6px; font-size: 12px; z-index: 100; white-space: nowrap; }

/* ------------------------------------------------ modal / toast / dropdown */
.overlay { position: fixed; inset: 0; background: rgba(13, 20, 36, .45); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; animation: fade .12s ease; }
.modal { background: var(--surface); border-radius: 12px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); animation: pop .16s ease; }
.modal.wide { max-width: 860px; }
.modal-h { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-h h2 { font-size: 16px; }
.modal-h .icon-btn { margin-left: auto; }
.modal-b { padding: 20px; max-height: 70vh; overflow-y: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: #141b2d; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: pop .16s ease; max-width: 90vw; }
.toast.error { background: var(--danger); }
.toast.success::before { content: '✓  '; color: #4ade80; font-weight: 700; }
.dropdown { position: absolute; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 60; min-width: 200px; padding: 6px; }
.dropdown button, .dropdown a { display: flex; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--text); gap: 8px; align-items: center; }
.dropdown button:hover, .dropdown a:hover { background: var(--surface-2); text-decoration: none; }
.picker { position: relative; }
.picker-results { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 50; max-height: 360px; overflow-y: auto; }
.picker-results .opt { display: flex; gap: 10px; align-items: center; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--line); }
.picker-results .opt:last-child { border-bottom: 0; }
.picker-results .opt:hover, .picker-results .opt.hl { background: var(--primary-soft); }
.picker-results .opt .grow { flex: 1; min-width: 0; }
.picker-results .opt .t1 { font-weight: 500; }
.picker-results .opt .t2 { font-size: 12px; color: var(--muted); }
.picker-results .none { padding: 14px; color: var(--muted); text-align: center; }
.picker-results .add { color: var(--primary); font-weight: 500; }

/* ------------------------------------------------ timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ''; position: absolute; left: 7.5px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--muted); font-size: 12px; }

/* ------------------------------------------------ status steps */
.steps { display: flex; gap: 0; margin: 4px 0 2px; }
.steps .s { flex: 1; text-align: center; font-size: 12px; color: var(--muted); position: relative; padding-top: 22px; }
.steps .s::before { content: ''; position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 14px; height: 14px; border-radius: 50%; background: var(--line-strong); z-index: 1; }
.steps .s::after { content: ''; position: absolute; top: 10px; left: -50%; width: 100%; height: 2px; background: var(--line-strong); }
.steps .s:first-child::after { display: none; }
.steps .s.done { color: var(--text); }
.steps .s.done::before, .steps .s.done::after { background: var(--success); }
.steps .s.bad::before { background: var(--danger); }

/* ------------------------------------------------ POS */
.pos { position: fixed; inset: 0; background: var(--bg); display: flex; flex-direction: column; z-index: 70; }
.pos-top { height: 56px; background: var(--side); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 16px; }
.pos-top .picker { flex: 1; max-width: 560px; }
.pos-top .input { background: #fff; color: #141b2d; border: 0; }
.pos-top .btn { background: transparent; color: #fff; border-color: rgba(255,255,255,.2); }
.pos-top .btn:hover { background: rgba(255,255,255,.08); }
.pos-tabs { display: flex; gap: 4px; }
.pos-tabs button { background: rgba(255,255,255,.08); border: 0; color: #c8d1e3; padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.pos-tabs button.on { background: #fff; color: #141b2d; font-weight: 600; }
.pos-body { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 400px; min-height: 0; }
.pos-left { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.pos-cart { flex: 1; overflow-y: auto; background: var(--surface); }
.pos-cart .line { display: grid; grid-template-columns: 28px minmax(0, 1fr) 120px 110px 110px 32px; gap: 10px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.qty button { width: 30px; height: 32px; border: 0; background: var(--surface-2); cursor: pointer; font-size: 16px; }
.qty input { width: 48px; border: 0; text-align: center; height: 32px; background: var(--surface); outline: none; }
.pos-grid { height: 38%; min-height: 180px; overflow-y: auto; padding: 12px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; align-content: start; background: var(--bg); border-top: 1px solid var(--line); }
.pos-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: 4px; }
.pos-item:hover { border-color: var(--primary); }
.pos-item .nm { font-weight: 500; font-size: 13px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.pos-item .pr { color: var(--primary); font-weight: 600; }
.pos-item .st { font-size: 11px; color: var(--muted); }
.pos-right { background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.pos-right .sec { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.pos-right .sum { flex: 1; overflow-y: auto; }
.pos-right .pay { padding: 14px 16px; border-top: 1px solid var(--line); }
.pos-total { font-size: 24px; font-weight: 700; color: var(--primary); }
.quick-cash { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.quick-cash button { padding: 7px 4px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); cursor: pointer; font-size: 13px; }
.quick-cash button:hover { border-color: var(--primary); color: var(--primary); }

/* ------------------------------------------------ auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 10%, #1d5bff22, transparent 40%), var(--bg); }
.auth .card { width: 100%; max-width: 420px; padding: 28px; }
.auth .brand { color: var(--text); padding: 0; border: 0; height: auto; margin-bottom: 20px; }

/* ------------------------------------------------ settings */
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-nav { position: sticky; top: 76px; }
.settings-nav a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text); }
.settings-nav a.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.settings-nav a:hover { text-decoration: none; background: var(--surface-2); }
.report-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.report-list .card-b a { display: block; padding: 5px 0; }

@media (max-width: 1100px) {
  .layout-main, .grid-21 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos-body { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 820px) {
  .side { transform: translateX(-100%); transition: transform .2s ease; }
  .side.open { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-grid; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; display: flex; overflow-x: auto; gap: 4px; }
  .settings-nav a { white-space: nowrap; }
  .report-list { grid-template-columns: 1fr; }
  .pos-body { grid-template-columns: 1fr; overflow-y: auto; }
  .pos-left { min-height: 60vh; }
  .pos-cart .line { grid-template-columns: minmax(0, 1fr) 110px 32px; }
  .pos-cart .line .hide-m { display: none; }
  .user-chip .nm { display: none; }
  .demo-bar { padding: 7px 16px; }
  .demo-bar .dm-long { display: none; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media (max-width: 520px) { .grid-4 { grid-template-columns: 1fr 1fr; } .stat .val { font-size: 18px; } }


/* ------------------------------------------------ thanh thao tác của trang biểu mẫu (giống Sapo: nút Lưu nằm trên cùng) */
.form-bar { position: fixed !important; top: 0; left: 230px; right: 0; height: 48px; z-index: 35; margin: 0 !important; border-radius: 0 !important; box-shadow: 0 1px 0 var(--line) !important; }
.form-bar > .card-b { height: 100%; padding: 0 24px !important; }
.form-bar .btn { height: 34px; }
body.pos-mode .form-bar { display: none; }
@media (max-width: 820px) { .form-bar { left: 0; } .form-bar #sumline { display: none; } }
.auth-or { display: flex; align-items: center; gap: 10px; margin: 18px 0 14px; color: var(--muted); font-size: 13px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
/* Màn hình tải: logo NEX SHOP xoay */
.nx-loader { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 90px 20px; }
.nx-loader .ring { position: relative; width: 76px; height: 76px; }
.nx-loader .ring::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 3px solid rgba(255, 90, 31, .15); border-top-color: #ff5a1f; border-right-color: #1b2a4a; animation: nx-spin .9s linear infinite; }
.nx-loader img { position: absolute; inset: 14px; width: 48px; height: 48px; border-radius: 12px; animation: nx-flip 1.8s ease-in-out infinite; box-shadow: 0 6px 18px rgba(255, 90, 31, .28); }
.nx-loader .txt { font-size: 13px; color: var(--muted, #667085); letter-spacing: .2px; }
.nx-loader.full { min-height: 100vh; padding: 0; }
@keyframes nx-spin { to { transform: rotate(360deg); } }
@keyframes nx-flip { 0% { transform: perspective(300px) rotateY(0); } 50% { transform: perspective(300px) rotateY(180deg); } 100% { transform: perspective(300px) rotateY(360deg); } }
@media (prefers-reduced-motion: reduce) { .nx-loader .ring::before, .nx-loader img { animation-duration: 3s; } }
