/* ==========================================================================
   Design system
   Brand colours (--brand*) are injected per store from Settings → Branding.
   ========================================================================== */

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --border: #e3e8ef;
  --border-strong: #cdd5df;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #64748b;
  --success: #16a34a; --success-bg: #ecfdf3; --success-ink: #166534;
  --warning: #d97706; --warning-bg: #fff7e6; --warning-ink: #92400e;
  --danger:  #dc2626; --danger-bg:  #fef2f2; --danger-ink:  #991b1b;
  --info:    #2563eb; --info-bg:    #eff6ff; --info-ink:    #1e40af;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);
  --sidebar-w: 256px;
  --topbar-h: 60px;
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-2: #151e2e;
  --surface-3: #1b2537;
  --border: #243044;
  --border-strong: #334155;
  --text: #e5e9f0;
  --text-2: #b4bfcd;
  --text-3: #8592a6;
  --success-bg: #0f2a1c; --success-ink: #86efac;
  --warning-bg: #2d200b; --warning-ink: #fcd34d;
  --danger-bg:  #2f1214; --danger-ink:  #fca5a5;
  --info-bg:    #0f1d3a; --info-ink:    #93c5fd;
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::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.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
p { margin: 0 0 .75em; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code, kbd, .mono { font-family: var(--mono); font-size: .92em; }
kbd { display: inline-block; padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; font-size: 11px; color: var(--text-3); background: var(--surface); line-height: 1.4; }
.kbd-light { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.35); color: inherit; margin-left: 4px; }
::selection { background: var(--brand-200); color: var(--text); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ic { width: 18px; height: 18px; flex: none; vertical-align: middle; }
.skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
.skip-link:focus { left: 8px; }

/* ---------- Utilities ---------- */
.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.text-right { text-align: right; } .text-center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }
.w-full { width: 100%; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 8px } .mt-2 { margin-top: 16px } .mt-3 { margin-top: 24px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 8px } .mb-2 { margin-bottom: 16px } .mb-3 { margin-bottom: 24px }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.grid-main-side { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.tone-success { color: var(--success); } .tone-warning { color: var(--warning); } .tone-danger { color: var(--danger); } .tone-info { color: var(--info); } .tone-brand { color: var(--brand); }
.hidden { display: none !important; }
[data-theme="dark"] .only-dark, :root:not([data-theme="dark"]) .only-light { display: inline-block; }
[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; padding: 0 14px 0 16px; border-bottom: 1px solid var(--border); flex: none; }
.sidebar-brand > a { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; text-decoration: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { font-size: 11.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), var(--brand-700)); color: var(--brand-ink); display: inline-grid; place-items: center; font-weight: 750; font-size: 13px; letter-spacing: .02em; flex: none; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12); }
.brand-mark.lg { width: 44px; height: 44px; font-size: 16px; border-radius: 12px; }
.brand-logo { height: 34px; width: auto; max-width: 120px; object-fit: contain; border-radius: 6px; flex: none; }
.brand-logo.lg { height: 44px; }
.icon-btn.sidebar-close { display: none; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px 16px; scrollbar-width: thin; }
.nav-group + .nav-group { margin-top: 12px; }
.nav-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 6px 10px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text-2); font-weight: 500; position: relative; }
.nav-link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--brand-50); color: var(--brand-700); font-weight: 600; }
.nav-link.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav-link.active .ic { color: var(--brand); }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--surface-3); color: var(--text-2); padding: 0 7px; border-radius: 999px; line-height: 18px; }
.nav-link.active .nav-count { background: var(--brand-100); color: var(--brand-700); }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.powered { font-size: 12px; color: var(--text-3); }
.powered a { color: inherit; }
.sidebar-backdrop { display: none; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 24px; background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); }
.icon-btn.menu-btn { display: none; }
.search-trigger { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 460px; height: 38px; padding: 0 10px 0 12px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; color: var(--text-3); font: inherit; cursor: pointer; text-align: left; }
.search-trigger span { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.search-trigger:hover { border-color: var(--border-strong); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn { position: relative; width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.dot-count { position: absolute; top: 3px; right: 2px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface); }
.user-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; color: var(--text); font: inherit; text-align: left; }
.user-btn:hover { background: var(--surface-3); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-100); color: var(--brand-700); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 13px; } .user-meta small { font-size: 11.5px; color: var(--text-3); }

.content { padding: 24px; width: 100%; max-width: 1440px; margin: 0 auto; flex: 1; }
.content-wide { max-width: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title p { margin: 4px 0 0; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.back-link .ic { width: 16px; height: 16px; }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 50; }
.menu-wide { width: 320px; }
.dropdown.open > .menu { display: block; animation: pop .12s ease-out; }
.menu-head { font-size: 12px; font-weight: 600; color: var(--text-3); padding: 6px 10px 8px; text-transform: uppercase; letter-spacing: .05em; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--text); border: 0; background: none; font: inherit; cursor: pointer; text-align: left; }
.menu-item:hover { background: var(--surface-3); text-decoration: none; }
.menu-item.danger { color: var(--danger); }
.mi-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); flex: none; }
.menu-empty { padding: 14px 10px; color: var(--text-3); display: flex; gap: 8px; align-items: center; }
.menu-empty .ic { color: var(--success); }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2, .card-head h3 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card-head .ic { color: var(--text-3); }
.card-body { padding: 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-flush .table-wrap { border: 0; border-radius: 0 0 var(--radius) var(--radius); }

/* ---------- Stat tiles ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; gap: 14px; align-items: flex-start; box-shadow: var(--shadow-sm); color: var(--text); }
a.stat:hover { border-color: var(--brand-200); text-decoration: none; box-shadow: var(--shadow); }
.stat-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--brand-50); color: var(--brand); }
.stat-ic.t-success { background: var(--success-bg); color: var(--success); }
.stat-ic.t-warning { background: var(--warning-bg); color: var(--warning); }
.stat-ic.t-danger { background: var(--danger-bg); color: var(--danger); }
.stat-ic.t-info { background: var(--info-bg); color: var(--info); }
.stat-ic .ic { width: 21px; height: 21px; }
.stat-label { font-size: 12.5px; color: var(--text-3); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.trend-up { color: var(--success); font-weight: 600; } .trend-down { color: var(--danger); font-weight: 600; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s, border-color .12s, box-shadow .12s; user-select: none; }
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: .6; pointer-events: none; }
.btn .ic { width: 17px; height: 17px; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 1px 2px rgba(0,0,0,.08), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-soft { background: var(--brand-50); border-color: transparent; color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); }
.btn-sm { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 7px; gap: 4px; }
.btn-xs .ic { width: 14px; height: 14px; }
.btn-lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 9px 0 0 9px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 9px 9px 0; }
.is-loading::after { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 550; color: var(--text-2); }
.req::after { content: " *"; color: var(--danger); }
.help { font-size: 12px; color: var(--text-3); }
.field-error { font-size: 12px; color: var(--danger); font-weight: 500; }
.input, .select, .textarea, input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=tel], input[type=search], input[type=url], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; transition: border-color .12s, box-shadow .12s; }
textarea { height: auto; min-height: 84px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
input:hover, select:hover, textarea:hover { border-color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--danger); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--surface-3); color: var(--text-3); }
input[type=color] { width: 52px; height: 38px; padding: 3px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface); cursor: pointer; }
input[type=file] { font: inherit; font-size: 13px; color: var(--text-2); }
input[type=file]::file-selector-button { font: inherit; font-weight: 550; margin-right: 10px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); cursor: pointer; }
.input-sm { height: 32px !important; font-size: 13px !important; padding: 0 8px !important; }
.input-group { display: flex; align-items: stretch; }
.input-group > .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--surface-3); color: var(--text-3); font-size: 13px; }
.input-group > .addon:first-child { border-radius: 9px 0 0 9px; border-right: 0; }
.input-group > .addon:last-child { border-radius: 0 9px 9px 0; border-left: 0; }
.input-group > input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group > input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-icon { position: relative; }
.input-icon > .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon > input { padding-left: 36px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; color: var(--text); }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--border-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(16px); }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.fieldset legend { font-weight: 600; padding: 0 6px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.section-title { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 8px 0 0; grid-column: 1 / -1; padding-top: 8px; border-top: 1px dashed var(--border); }
.section-title:first-child { border-top: 0; padding-top: 0; margin-top: 0; }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .input-icon { flex: 1; min-width: 200px; max-width: 360px; }
.toolbar select, .toolbar input[type=date] { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; }
.chip:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.chip.active { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand-700); }
.chip .count { font-size: 11px; background: var(--surface-3); padding: 0 6px; border-radius: 999px; }
.chip.active .count { background: var(--brand-100); }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; z-index: 1; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table .num, .table th.num { text-align: right; }
.table tfoot td { font-weight: 650; background: var(--surface-2); border-top: 1px solid var(--border); border-bottom: 0; }
.table-sm td { padding: 8px 12px; } .table-sm th { padding: 8px 12px; }
.cell-title { font-weight: 600; color: var(--text); }
a.cell-title:hover { color: var(--brand-600); }
.cell-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-danger td { background: color-mix(in srgb, var(--danger-bg) 60%, transparent); }
.row-warning td { background: color-mix(in srgb, var(--warning-bg) 60%, transparent); }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--text-2); }
.badge-success { background: var(--success-bg); color: var(--success-ink); }
.badge-warning { background: var(--warning-bg); color: var(--warning-ink); }
.badge-danger { background: var(--danger-bg); color: var(--danger-ink); }
.badge-info { background: var(--info-bg); color: var(--info-ink); }
.badge-brand { background: var(--brand-50); color: var(--brand-700); }
.badge-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; border: 1px solid transparent; font-size: 13.5px; margin-bottom: 16px; }
.alert .ic { margin-top: 1px; }
.alert-success { background: var(--success-bg); color: var(--success-ink); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning-ink); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-danger { background: var(--danger-bg); color: var(--danger-ink); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-info { background: var(--info-bg); color: var(--info-ink); border-color: color-mix(in srgb, var(--info) 25%, transparent); }
.alert p:last-child { margin: 0; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; top: 72px; right: 20px; z-index: 90; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); font-weight: 500; animation: toast-in .25s ease-out; border-left: 4px solid var(--info); }
.toast span { flex: 1; }
.toast-success { border-left-color: var(--success); } .toast-success > .ic { color: var(--success); }
.toast-danger { border-left-color: var(--danger); } .toast-danger > .ic { color: var(--danger); }
.toast-warning { border-left-color: var(--warning); } .toast-warning > .ic { color: var(--warning); }
.toast-info > .ic { color: var(--info); }
.toast-x { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 0; display: grid; }
.toast-x .ic { width: 16px; height: 16px; }
.toast.hide { opacity: 0; transform: translateX(20px); transition: all .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; color: var(--text-3); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; font: inherit; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand-700); border-bottom-color: var(--brand); }
.tab .ic { width: 16px; height: 16px; }

/* ---------- Modal (native <dialog>) ---------- */
dialog.modal { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); }
dialog.modal-sm { width: min(420px, calc(100vw - 24px)); }
dialog.modal-lg { width: min(820px, calc(100vw - 24px)); }
dialog::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .15s ease-out; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); }
.confirm-ic { width: 48px; height: 48px; border-radius: 50%; background: var(--danger-bg); color: var(--danger); display: grid; place-items: center; margin-bottom: 12px; }
.confirm-ic .ic { width: 24px; height: 24px; }

/* ---------- Command palette ---------- */
dialog.cmdk { border: 0; padding: 0; background: transparent; width: min(640px, calc(100vw - 24px)); margin-top: 10vh; max-height: 80vh; }
.cmdk-box { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); overflow: hidden; }
.cmdk-input { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.cmdk-input .ic { color: var(--text-3); }
.cmdk-input input { border: 0 !important; box-shadow: none !important; height: 56px; font-size: 16px; padding: 0; background: transparent; }
.cmdk-results { max-height: 420px; overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 11.5px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px 4px; }
.cmdk-item { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--text); }
.cmdk-item:hover, .cmdk-item.active { background: var(--brand-50); text-decoration: none; }
.cmdk-item .mi-ic { width: 32px; height: 32px; }
.cmdk-item small { display: block; color: var(--text-3); font-size: 12px; }
.cmdk-empty { padding: 28px; text-align: center; color: var(--text-3); }

/* ---------- Empty states, pager, misc ---------- */
.empty { text-align: center; padding: 48px 20px; }
.empty-ic { width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--brand-50); color: var(--brand); display: grid; place-items: center; }
.empty-ic .ic { width: 26px; height: 26px; }
.empty h3 { margin-bottom: 6px; }
.empty p { color: var(--text-3); max-width: 420px; margin: 0 auto 16px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; font-size: 13px; }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }
.divider-text { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin: 16px 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.color-swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }

/* ---------- Charts ---------- */
.chart { width: 100%; height: 240px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-dasharray: 3 4; }
.chart .axis-text { fill: var(--text-3); font-size: 11px; }
.chart .bar { fill: var(--brand); opacity: .9; transition: opacity .1s; }
.chart .bar:hover { opacity: 1; }
.chart .bar.alt { fill: var(--brand-200); }
.chart-tip { position: absolute; pointer-events: none; background: var(--text); color: var(--surface); font-size: 12px; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -110%); opacity: 0; transition: opacity .1s; z-index: 5; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 13px; flex: 1; min-width: 160px; }
.donut-legend div { display: flex; align-items: center; gap: 8px; }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .num { margin-left: auto; }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.pos-search { position: relative; }
.pos-search input { height: 50px; font-size: 16px; padding-left: 44px; border-radius: 12px; }
.pos-search > .ic { position: absolute; left: 14px; top: 16px; color: var(--text-3); }
.pos-search kbd { position: absolute; right: 12px; top: 14px; }
.pos-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 20; max-height: 420px; overflow-y: auto; display: none; }
.pos-results.open { display: block; }
.pos-result { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid var(--border); }
.pos-result:last-child { border-bottom: 0; }
.pos-result:hover, .pos-result.active { background: var(--brand-50); }
.pos-result .grow { flex: 1; min-width: 0; }
.pos-result.disabled { opacity: .55; cursor: not-allowed; }
.cart-table td { vertical-align: middle; }
.cart-table td, .cart-table th { padding-left: 10px; padding-right: 10px; }
.cart-table td:first-child { min-width: 170px; }
.qty-ctrl { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.qty-ctrl button { width: 28px; height: 32px; border: 0; background: var(--surface-2); color: var(--text-2); cursor: pointer; display: grid; place-items: center; }
.qty-ctrl button:hover { background: var(--surface-3); color: var(--text); }
.qty-ctrl input { width: 44px; height: 32px; border: 0 !important; border-radius: 0; text-align: center; padding: 0 4px; box-shadow: none !important; -moz-appearance: textfield; }
.qty-ctrl input::-webkit-inner-spin-button { -webkit-appearance: none; }
.rate-input { width: 84px !important; text-align: right; }
.batch-select { min-width: 0; width: 150px; height: 32px !important; font-size: 12.5px !important; padding: 0 28px 0 8px !important; background-position: right 6px center !important; }
.pos-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; gap: 16px; }
.totals { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.totals > div { display: flex; justify-content: space-between; gap: 12px; }
.totals .grand { font-size: 24px; font-weight: 750; letter-spacing: -.02em; padding-top: 10px; border-top: 1px dashed var(--border-strong); margin-top: 4px; }
.pay-methods { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.pay-method { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 9px 4px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface); }
.pay-method input { position: absolute; opacity: 0; pointer-events: none; }
.pay-method:has(input:checked) { border-color: var(--brand); background: var(--brand-50); color: var(--brand-700); box-shadow: 0 0 0 1px var(--brand); }
.pay-method:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.cust-pill { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--brand-50); }
.cust-pill .grow { flex: 1; min-width: 0; }
.shortcut-bar { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-3); }

/* ---------- Invoice ---------- */
.invoice { width: 100%; min-width: 0; background: #fff; color: #0f172a; border-radius: var(--radius); border: 1px solid var(--border); padding: 32px; max-width: 900px; margin: 0 auto; font-size: 13px; }
.invoice .inv-head { display: flex; justify-content: space-between; gap: 24px; padding-bottom: 18px; border-bottom: 2px solid var(--brand); flex-wrap: wrap; }
.invoice .inv-store { display: flex; gap: 14px; align-items: flex-start; }
.invoice h2 { font-size: 20px; color: #0f172a; }
.invoice .inv-title { text-align: right; }
.invoice .inv-title h3 { font-size: 13px; letter-spacing: .14em; color: var(--brand-700); text-transform: uppercase; }
.invoice .inv-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; padding: 16px 0; }
.invoice .inv-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; font-weight: 600; margin-bottom: 3px; }
.invoice table { width: 100%; border-collapse: collapse; }
.invoice th { background: #f1f5f9; color: #334155; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; padding: 8px; text-align: left; border-bottom: 1px solid #cbd5e1; }
.invoice td { padding: 8px; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
.invoice .num { text-align: right; }
.invoice .inv-bottom { display: grid; grid-template-columns: 1fr 300px; gap: 24px; margin-top: 16px; }
.invoice .inv-totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.invoice .inv-totals .grand { font-size: 17px; font-weight: 750; border-top: 2px solid #0f172a; margin-top: 6px; padding-top: 8px; }
.invoice .inv-foot { margin-top: 28px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; color: #64748b; font-size: 12px; flex-wrap: wrap; }
.invoice .sign { text-align: center; min-width: 180px; border-top: 1px solid #94a3b8; padding-top: 6px; color: #334155; }
.invoice .badge { background: #f1f5f9; }
.invoice.thermal { max-width: 80mm; padding: 10px; font-size: 11px; border-radius: 0; }
.invoice.thermal .inv-head { flex-direction: column; text-align: center; border-bottom: 1px dashed #000; gap: 6px; }
.invoice.thermal .inv-store { flex-direction: column; align-items: center; }
.invoice.thermal .inv-title { text-align: center; }
.invoice.thermal .inv-meta { grid-template-columns: 1fr; gap: 4px; padding: 8px 0; }
.invoice.thermal .inv-bottom { grid-template-columns: 1fr; }
.invoice.thermal .hide-thermal { display: none; }
.invoice.thermal th, .invoice.thermal td { padding: 4px 2px; }
.invoice.thermal .brand-logo, .invoice.thermal .brand-mark { display: none; }

/* ---------- Auth (split) ---------- */
body.auth { background: var(--bg); }
.auth-split { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 46%) 1fr; }
.auth-aside { position: relative; overflow: hidden; color: #fff; background:
  radial-gradient(1200px 500px at -10% 110%, rgba(255,255,255,.14), transparent 60%),
  radial-gradient(700px 400px at 110% -10%, rgba(255,255,255,.12), transparent 60%),
  linear-gradient(150deg, var(--brand) 0%, var(--brand-700) 100%); }
.auth-aside::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(rgba(255,255,255,.12) 1px, transparent 1px); background-size: 22px 22px; mask-image: linear-gradient(to bottom, transparent, #000 40%, transparent); pointer-events: none; }
.auth-aside-inner { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; padding: 40px 48px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand strong { display: block; font-size: 17px; } .auth-brand small { opacity: .8; font-size: 12.5px; }
.auth-brand .brand-mark { background: rgba(255,255,255,.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.auth-hero { margin: auto 0; max-width: 460px; padding: 40px 0; }
.auth-hero h2 { font-size: 34px; line-height: 1.15; font-weight: 750; letter-spacing: -.025em; margin-bottom: 14px; }
.auth-hero p { font-size: 16px; opacity: .88; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-direction: column; gap: 14px; }
.auth-points li { display: flex; gap: 12px; align-items: center; font-weight: 500; }
.auth-points .ic { width: 34px; height: 34px; padding: 8px; border-radius: 10px; background: rgba(255,255,255,.16); }
.auth-aside-foot { font-size: 12.5px; opacity: .8; } .auth-aside-foot .powered { color: #fff; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-3); margin-bottom: 24px; }
.auth-card .toast-stack { position: static; width: auto; margin-bottom: 16px; }
.auth-card form .field + .field { margin-top: 14px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin: 14px 0 20px; font-size: 13px; }
.auth-alt { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; font-size: 13px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 30px; height: 30px; border: 0; background: none; color: var(--text-3); cursor: pointer; border-radius: 6px; display: grid; place-items: center; }
.pw-toggle:hover { background: var(--surface-3); }
.error-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px; gap: 8px; }
.error-code { font-size: 88px; font-weight: 800; letter-spacing: -.04em; line-height: 1; background: linear-gradient(135deg, var(--brand), var(--brand-700)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.error-page p { max-width: 420px; margin-bottom: 18px; }

/* ---------- Setup wizard ---------- */
.setup { max-width: 860px; margin: 0 auto; padding: 40px 20px 60px; }
.setup-head { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.steps { display: flex; gap: 0; margin-bottom: 24px; counter-reset: s; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--text-3); position: relative; padding-right: 12px; }
.step::after { content: ""; flex: 1; height: 2px; background: var(--border); border-radius: 2px; }
.step:last-child::after { display: none; }
.step-n { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); font-size: 12.5px; flex: none; border: 1px solid var(--border-strong); }
.step.done .step-n { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.step.done::after { background: var(--brand); }
.step.current { color: var(--text); }
.step.current .step-n { border: 2px solid var(--brand); color: var(--brand-700); background: var(--brand-50); }
.choice-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choice { display: flex; gap: 12px; padding: 16px; border: 1px solid var(--border-strong); border-radius: 12px; cursor: pointer; background: var(--surface); }
.choice input { margin-top: 3px; accent-color: var(--brand); }
.choice:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); background: var(--brand-50); }
.choice strong { display: block; margin-bottom: 2px; }
.req-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.req-item { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 13px; }

/* ---------- Portals ---------- */
body.portal { min-height: 100vh; display: flex; flex-direction: column; }
.portal-top { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.portal-bar { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: 12px; padding: 12px 20px; }
.portal-brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.portal-brand:hover { text-decoration: none; }
.portal-brand span { display: flex; flex-direction: column; line-height: 1.25; }
.portal-brand small { color: var(--text-3); font-size: 12px; }
.portal-nav { max-width: 1120px; margin: 0 auto; display: flex; gap: 4px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; }
.portal-nav a { display: inline-flex; align-items: center; gap: 7px; padding: 10px 12px; color: var(--text-3); font-weight: 550; border-bottom: 2px solid transparent; white-space: nowrap; }
.portal-nav a:hover { color: var(--text); text-decoration: none; }
.portal-nav a.active { color: var(--brand-700); border-bottom-color: var(--brand); }
.portal-nav .ic { width: 16px; height: 16px; }
.portal-main { max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px 20px; flex: 1; }
.portal-main .toast-stack { top: 120px; }
.portal-foot { max-width: 1120px; width: 100%; margin: 0 auto; padding: 18px 20px; display: flex; justify-content: space-between; gap: 12px; color: var(--text-3); font-size: 12.5px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.welcome { background: linear-gradient(135deg, var(--brand), var(--brand-700)); color: var(--brand-ink); border-radius: 16px; padding: 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.welcome h2 { font-size: 22px; margin-bottom: 4px; } .welcome p { margin: 0; opacity: .88; }
.welcome .btn { background: rgba(255,255,255,.95); color: var(--brand-700); border-color: transparent; }

/* ---------- Chat ---------- */
.chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 560px; }
.chat-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 680px; }
.chat-thread-link { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); align-items: center; }
.chat-thread-link:hover { background: var(--surface-2); text-decoration: none; }
.chat-thread-link.active { background: var(--brand-50); }
.chat-thread-link .grow { flex: 1; min-width: 0; }
.chat-thread-link .preview { font-size: 12.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; }
.chat-msgs { flex: 1; padding: 18px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; max-height: 560px; background: var(--surface-2); }
.bubble { max-width: 76%; padding: 10px 13px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); align-self: flex-start; word-wrap: break-word; }
.bubble.mine { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.bubble.mine a { color: inherit; text-decoration: underline; }
.bubble .meta { font-size: 11px; opacity: .7; margin-top: 4px; }
.bubble .subject { font-weight: 650; margin-bottom: 2px; }
.attach { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12.5px; font-weight: 600; }
.chat-form { border-top: 1px solid var(--border); padding: 12px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pos { grid-template-columns: minmax(0, 1fr) 340px; }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
  .icon-btn.sidebar-close { display: inline-grid; }
  .main { margin-left: 0; }
  .icon-btn.menu-btn { display: inline-grid; }
  .grid-main-side, .pos { grid-template-columns: minmax(0, 1fr); }
  .pos-side { position: static; }
  .cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-split { grid-template-columns: 1fr; }
  .auth-aside-inner { padding: 24px; }
  .auth-hero { padding: 24px 0 8px; } .auth-hero h2 { font-size: 24px; } .auth-points, .auth-hero p { display: none; }
}
@media (max-width: 720px) {
  .content { padding: 16px; }
  .topbar { padding: 0 12px; gap: 8px; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .search-trigger { flex: 0; width: 38px; padding: 0; justify-content: center; border: 0; background: transparent; }
  .hide-sm { display: none !important; }
  .cols-2, .cols-3, .cols-4, .form-grid, .form-grid.cols-3, .choice-cards, .req-list { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .page-head { align-items: flex-start; }
  h1 { font-size: 20px; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 12px; flex-direction: column; gap: 8px; }
  .stat-ic { width: 34px; height: 34px; }
  .stat-value { font-size: 18px; }
  .kv { grid-template-columns: 1fr; gap: 2px; } .kv dd { margin-bottom: 8px; }
  .invoice { padding: 16px; overflow-x: auto; }
  .invoice table { min-width: 520px; }
  .invoice .inv-bottom table { min-width: 0; }
  .invoice .inv-meta, .invoice .inv-bottom { grid-template-columns: 1fr; }
  .chat { grid-template-columns: 1fr; }
  .chat-list { max-height: 220px; border-right: 0; border-bottom: 1px solid var(--border); }
  .pay-methods { grid-template-columns: repeat(3, 1fr); }
  .steps .step-label { display: none; }
  .toast-stack { top: auto; bottom: 16px; right: 16px; }
  .toolbar .input-icon { max-width: none; }
}
@media (max-width: 480px) {
  .hide-xs { display: none !important; }
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 10mm; }
  body { background: #fff !important; color: #000; }
  .sidebar, .topbar, .page-head, .toast-stack, .no-print, .portal-top, .portal-foot, .portal-main > .page-head { display: none !important; }
  .main { margin: 0 !important; }
  .content, .portal-main { padding: 0 !important; max-width: none; }
  .invoice { border: 0; padding: 0; max-width: none; box-shadow: none; }
  .invoice.thermal { max-width: 72mm; }
  .card { box-shadow: none; border: 0; }
  a { color: inherit; text-decoration: none; }
}
