/*
 * Squidb stylesheet — production design system (see UI-SYSTEM.md).
 * Clean-SaaS aesthetic on a slate + accent token system. Built in core so every
 * module inherits it. Hand-written, CSP-safe (no inline styles), escape-by-default
 * templates. Tokens layer primitive -> semantic -> component; per-tenant theming
 * overrides only --primary / --accent (validated #rrggbb, injected with the nonce).
 */

/* Nunito — self-hosted (SIL OFL), latin subset. Google Fonts CDN is blocked by our
 * font-src 'self' CSP, so the woff2 files live under /assets/fonts. Paces admin look. */
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 400; font-display: swap; src: url("/assets/fonts/nunito-400.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 500; font-display: swap; src: url("/assets/fonts/nunito-500.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 600; font-display: swap; src: url("/assets/fonts/nunito-600.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 700; font-display: swap; src: url("/assets/fonts/nunito-700.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-style: normal; font-weight: 800; font-display: swap; src: url("/assets/fonts/nunito-800.woff2") format("woff2"); }

:root {
    /* ── primitive ramps ─────────────────────────────────────────────────── */
    --slate-50: #f8fafc;  --slate-100: #f1f5f9; --slate-200: #e2e8f0; --slate-300: #cbd5e1;
    --slate-400: #94a3b8; --slate-500: #64748b; --slate-600: #475569; --slate-700: #334155;
    --slate-800: #1e293b; --slate-900: #0f172a; --slate-950: #0b1220;
    --blue-50: #eff6ff; --blue-100: #dbeafe; --blue-500: #3b82f6; --blue-600: #2563eb; --blue-700: #1d4ed8;

    /* ── Paces brand hues (pure — for icon chips, charts, sparklines) ──────── */
    --c-primary: #236dc9; --c-secondary: #7b70ef; --c-success: #02bc9c;
    --c-info: #5bc3e1; --c-warning: #f9bf59; --c-danger: #f7577e; --c-dark: #313a46;

    /* ── semantic (themeable surface) — Paces (CoderThemes) palette ────────── */
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #eef2f7;
    --surface-hover: #f6f7fb;
    --sidebar: #1e1f27;                 /* Paces dark sidenav */
    --sidebar-2: #22232c;               /* active item bg */
    --sidebar-text: #8495ab;            /* item text (AA ~5:1 on #1e1f27) */
    --sidebar-muted: #8896a8;           /* section-title dividers */
    --sidebar-hover-bg: #2f3742;
    --sidebar-hover-text: #bccee4;
    --sidebar-active-text: #ced6df;
    --border: #e7e9eb;
    --border-strong: #d7dce2;
    --text: #313a46;                    /* Paces headings/dark */
    --muted: #5b636b;                   /* AA: ~5.4:1 on white */
    --subtle: #656d75;                  /* AA on white AND the #f6f7fb hover row (>=4.9) */
    --primary: var(--c-primary);
    --primary-hover: #1e5dab;
    --primary-soft: #e9f1fb;
    --accent: var(--c-primary);
    --ring: rgba(35, 109, 201, .35);
    --ring-soft: rgba(35, 109, 201, .15);

    /* status — AA-safe text on Paces soft tints (badge bg = hue @ ~15%) */
    --ok-bg: #e3f7f2; --ok-text: #05674c; --ok-border: #b6ece0;
    --warn-bg: #fdf4e3; --warn-text: #8a5e0f; --warn-border: #f7e4b8;
    --err-bg: #fde8ee; --err-text: #c2334f; --err-border: #f8c6d3;
    --info-bg: #e7f5fb; --info-text: #0e7490; --info-border: #c2e7f3;

    /* ── spacing (4px base, 8pt rhythm) ──────────────────────────────────── */
    --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-8: 48px;

    /* ── radii (Paces: 4px base, tight) ──────────────────────────────────── */
    --r-sm: 4px; --r-md: 6px; --r-lg: 8px; --r-xl: 10px; --r-full: 999px;

    /* ── elevation (Paces soft cool-gray shadow) ─────────────────────────── */
    --card-shadow: 0 1px 4px 0 rgba(130, 143, 163, .15);
    --shadow-sm: var(--card-shadow);
    --shadow: 0 1px 4px 0 rgba(130, 143, 163, .15);
    --shadow-md: 0 3px 10px 0 rgba(130, 143, 163, .2), 0 1px 3px rgba(130, 143, 163, .12);
    --shadow-lg: 0 10px 30px 0 rgba(48, 58, 70, .16), 0 4px 8px rgba(130, 143, 163, .1);

    /* ── motion ──────────────────────────────────────────────────────────── */
    --ease: cubic-bezier(.4, 0, .2, 1);
    --ease-out: cubic-bezier(.16, 1, .3, 1);
    --t-fast: 120ms; --t-base: 180ms; --t-slow: 240ms;

    /* ── type ────────────────────────────────────────────────────────────── */
    --font: 14px/1.5 "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --mono: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    /* ── safe-area (notch / home indicator) ──────────────────────────────── */
    --sa-top: env(safe-area-inset-top, 0px);
    --sa-bottom: env(safe-area-inset-bottom, 0px);
    --sa-left: env(safe-area-inset-left, 0px);
    --sa-right: env(safe-area-inset-right, 0px);
    --bottomnav-h: 60px;
}

/* Note: cross-document @view-transition was trialled for page-swap animation but
   removed — Chrome fires an uncaught "Transition was skipped" pageerror and leaves the
   page in a non-stable paint state (breaks click/snapshot stability) for marginal gain.
   Native feel is carried by the bottom nav, PWA shell, safe-area, and element motion. */

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: var(--font); color: var(--text); background: var(--bg);
    -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
[x-cloak] { display: none !important; }
a { color: inherit; text-decoration: none; }
/* Inline content link (emails, cross-references): accent colour, never underlined. */
.link { color: var(--primary); font-weight: 500; }
.link:hover { color: var(--primary-hover); }
.icon { width: 20px; height: 20px; flex: 0 0 auto; }
.muted { color: var(--muted); }
code { font: var(--mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

/* Accessible focus ring — visible only for keyboard users. */
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }
a:focus-visible, button:focus-visible, .btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; scroll-behavior: auto !important; }
    ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}

/* ---------- brand ---------- */
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--blue-500), var(--primary)); color: #fff; font-weight: 700; font-size: 16px; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }

/* ---------- app shell ---------- */
.shell { display: flex; min-height: 100vh; min-height: 100dvh; }
/* Sidebar is pinned to the viewport so it never scrolls with the page. */
.sidebar { width: 245px; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; padding: 14px 12px;
    padding-top: calc(14px + var(--sa-top)); padding-left: calc(12px + var(--sa-left));
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; overflow-y: auto;
    border-right: 1px solid var(--sidebar-border, #2c2d38);
    transition: transform var(--t-base) var(--ease);
    /* Paces: scrollbar hidden by default, a thin styled thumb reveals on hover. */
    scrollbar-width: thin; scrollbar-color: transparent transparent; }
.sidebar:hover { scrollbar-color: rgba(255, 255, 255, .18) transparent; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: transparent; border-radius: 999px; transition: background var(--t-base) var(--ease); }
.sidebar:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .18); }
.sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, .3); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 8px 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; }
/* Paces uppercase section-title divider (non-clickable) */
.menu-title { padding: 16px 10px 6px; font-size: 10px; font-weight: 700; text-transform: uppercase;
    letter-spacing: .1em; color: var(--sidebar-muted); pointer-events: none; user-select: none; }
.nav-group { margin-top: 2px; }
/* collapsible parent — Paces submenu-parent look (sentence case, item-styled) */
.nav-section-btn { display: flex; align-items: center; gap: 11px; width: 100%;
    background: none; border: none; cursor: pointer; padding: 9px 10px; border-radius: var(--r-md);
    font-size: 14px; font-weight: 600; color: var(--sidebar-text); font-family: inherit;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.nav-section-btn > span { flex: 1 1 auto; text-align: left; }
.nav-section-btn:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }
.nav-chev { width: 15px; height: 15px; flex: 0 0 auto; opacity: .8; transition: transform var(--t-base) var(--ease); }
.nav-chev.is-open { transform: rotate(180deg); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 1px 0 2px; }
.nav-sub .nav-link { padding-left: 40px; font-size: 13px; font-weight: 500; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: var(--r-md);
    color: var(--sidebar-text); text-decoration: none; font-weight: 600; position: relative;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.nav-link:hover { background: var(--sidebar-hover-bg); color: var(--sidebar-hover-text); }
.nav-link.is-active { background: var(--sidebar-2); color: var(--sidebar-active-text); }
.nav-link.is-active::before { content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 18px; border-radius: 3px; background: var(--primary); }
.nav-link.is-active .nav-icon { color: var(--primary); opacity: 1; }
.nav-icon { width: 18px; height: 18px; flex: 0 0 auto; opacity: .85; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px 8px; margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, .08); }
a.sidebar-user { text-decoration: none; border-radius: 8px; transition: background var(--t-fast); }
a.sidebar-user:hover { background: rgba(255, 255, 255, .05); }
.sidebar-user-meta { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { color: var(--sidebar-muted); font-size: 12px; }

.avatar { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff; font-size: 12px; font-weight: 600; flex: 0 0 auto; }

.main { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; margin-left: 248px; }
.topbar { height: 60px; display: flex; align-items: center; gap: 14px; padding: 0 24px;
    padding-top: var(--sa-top); padding-right: calc(24px + var(--sa-right));
    background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar-title { font-size: 16px; font-weight: 650; margin: 0; flex: 1 1 auto; letter-spacing: -.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
    border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; transition: background var(--t-fast), color var(--t-fast); }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-toggle { display: none; }

.lang { display: inline-flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 3px; }
.lang-link { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted);
    text-decoration: none; padding: 4px 8px; border-radius: 5px; font-weight: 600; }
.lang-link.is-active { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-sm); }

.user-menu { position: relative; }
.avatar-btn { background: none; border: none; padding: 0; cursor: pointer; }
.menu { position: absolute; right: 0; top: 48px; min-width: 210px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); padding: 6px; z-index: 50; }
.menu-head { padding: 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-name { font-weight: 600; font-size: 13px; }
.menu-item { display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; border-radius: 7px;
    background: none; border: none; color: var(--text); font: inherit; text-align: left; cursor: pointer; text-decoration: none; transition: background var(--t-fast); }
.menu-item:hover { background: var(--surface-2); }
.menu-icon { width: 17px; height: 17px; color: var(--muted); }

.content { padding: 28px 24px 40px; max-width: 1180px; width: 100%; }

/* scrim behind the mobile drawer — never intercepts clicks unless the drawer is open
   (it covers the viewport at opacity 0, so without pointer-events:none it would swallow
   every click, including on desktop where the drawer is never shown). */
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 35;
    opacity: 0; pointer-events: none; transition: opacity var(--t-base) var(--ease); }

/* ---------- mobile bottom navigation (phones) ---------- */
.bottomnav { display: none; }
.bottomnav-item { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    flex: 1 1 0; min-width: 0; padding: 6px 4px; color: var(--muted); text-decoration: none;
    background: none; border: none; font: inherit; cursor: pointer; min-height: 48px; transition: color var(--t-fast); }
.bottomnav-item .icon, .bottomnav-item .nav-icon { width: 23px; height: 23px; }
.bottomnav-label { font-size: 10.5px; font-weight: 600; letter-spacing: .01em; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bottomnav-item.is-active { color: var(--primary); }

/* ---------- page heading ---------- */
.page-head { margin-bottom: 22px; }
.page-head.with-action { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 680; letter-spacing: -.02em; margin: 0; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.page-back { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 500; margin-bottom: 8px; }
.page-back:hover { color: var(--primary); }

/* utilities */
.narrow { max-width: 560px; }
.text-right { text-align: right; }
.search-bar { margin-bottom: 16px; }
.search-bar .input { max-width: 280px; }
.confirm-input { max-width: 280px; }
.mt-2 { margin-top: 12px; }

/* ---------- empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px;
    padding: 48px 24px; color: var(--muted); }
.empty-icon { display: inline-grid; place-items: center; width: 56px; height: 56px; border-radius: var(--r-full);
    background: var(--surface-2); color: var(--subtle); }
.empty-icon .icon { width: 28px; height: 28px; }
.empty-title { font-size: 16px; font-weight: 650; color: var(--text); margin: 4px 0 0; }
.empty-text { font-size: 13.5px; max-width: 360px; margin: 0; }
.empty .btn { margin-top: 6px; }

/* ---------- toasts (transient feedback; ARIA live) ---------- */
.toasts { position: fixed; z-index: 80; right: 16px; bottom: calc(16px + var(--sa-bottom));
    display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; align-items: flex-start; gap: 10px; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-left: 3px solid var(--primary); border-radius: var(--r-md);
    box-shadow: var(--shadow-lg); padding: 12px 14px; font-size: 13.5px;
    animation: toast-in var(--t-slow) var(--ease-out); }
.toast.ok { border-left-color: var(--ok-text); }
.toast.err { border-left-color: var(--err-text); }
.toast-icon { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.toast.ok .toast-icon { color: var(--ok-text); }
.toast.err .toast-icon { color: var(--err-text); }
.toast-body { flex: 1 1 auto; min-width: 0; }
.toast-close { background: none; border: none; color: var(--subtle); font-size: 19px; line-height: 1; cursor: pointer; padding: 0 2px; margin: -2px -2px 0 4px; flex: 0 0 auto; }
.toast-close:hover { color: var(--text); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- KPI stat cards (Paces) ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; background: var(--surface);
    border: 0; border-radius: var(--r-lg); padding: 20px; box-shadow: var(--card-shadow); transition: box-shadow var(--t-base); }
.stat:hover { box-shadow: var(--shadow-md); }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--subtle); }
.stat-value { font-size: 24px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; margin: 12px 0 10px; color: var(--text); overflow-wrap: anywhere; }
.stat-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--subtle); flex-wrap: wrap; }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 700; }
.stat-delta svg { width: 15px; height: 15px; }
.stat-delta.up { color: var(--c-success); }
.stat-delta.down { color: var(--c-danger); }
.stat-hint, .stat-since { font-size: 12.5px; color: var(--subtle); }
.stat-spark { width: 100%; height: 34px; margin-top: 12px; }
.stat-spark svg { width: 100%; height: 100%; display: block; }
/* icon chip: 36px circle, hue @ 15% bg + solid hue icon */
.stat-chip { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-full); flex: 0 0 auto; }
.stat-chip .icon { width: 20px; height: 20px; }
.tone-blue,   .tone-primary   { background: rgba(35, 109, 201, .15);  color: var(--c-primary); }
.tone-violet, .tone-secondary { background: rgba(123, 112, 239, .15); color: var(--c-secondary); }
.tone-emerald,.tone-success   { background: rgba(2, 188, 156, .16);   color: #069e83; }
.tone-amber,  .tone-warning   { background: rgba(249, 191, 89, .2);   color: #c68a1f; }
.tone-info                    { background: rgba(91, 195, 225, .18);  color: #2f9dbf; }
.tone-danger                  { background: rgba(247, 87, 126, .15);  color: var(--c-danger); }
/* sparkline colour follows the card tone */
.spark.tone-blue, .spark.tone-primary { color: var(--c-primary); }
.spark.tone-success, .spark.tone-emerald { color: var(--c-success); }
.spark.tone-danger { color: var(--c-danger); }
.spark.tone-info { color: var(--c-info); }
.spark.tone-warning, .spark.tone-amber { color: var(--c-warning); }
.spark.tone-secondary, .spark.tone-violet { color: var(--c-secondary); }

/* ---------- cards ---------- */
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.card { background: var(--surface); border: 0; border-radius: var(--r-lg); box-shadow: var(--card-shadow); }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-title { margin: 0; font-size: 15px; font-weight: 650; }
.card-body { padding: 20px; }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.checklist li { display: flex; align-items: center; gap: 10px; color: var(--text); }
.check-icon { width: 18px; height: 18px; color: #059669; flex: 0 0 auto; }

.kv { margin: 0; }
.kv > div { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.kv > div:first-child { border-top: none; }
.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; font-weight: 500; }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 13px; }
.label .req { color: var(--err-text); margin-left: 2px; }
.help { font-size: 12px; color: var(--subtle); }
.input { font: var(--font); height: 42px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
    background: var(--surface); color: var(--text); transition: border-color var(--t-fast), box-shadow var(--t-fast); width: 100%; }
.input::placeholder { color: var(--subtle); }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring-soft); }
.input:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
.input.has-error { border-color: var(--err-border); }
.input.has-error:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
textarea.textarea { font: var(--font); height: auto; min-height: 120px; padding: 10px 12px; resize: vertical; }
/* A textarea using the .input class must not inherit the fixed input height. */
textarea.input { height: auto; min-height: 104px; padding: 10px 12px; line-height: 1.55; resize: vertical; }
textarea.input[rows="2"] { min-height: 60px; }

/* filter pills (chips on top of a list) */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 99px; font-size: 13px; font-weight: 500;
    background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; transition: background var(--t-fast), border-color var(--t-fast); min-height: 36px; }
.pill:hover { border-color: var(--border-strong); }
.pill.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill-count { font-size: 11px; opacity: .7; font-weight: 600; }

/* filter bar (faceted filters with explicit Apply) */
.filter-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar .field { min-width: 160px; }

/* segmented control */
.segmented { display: inline-flex; background: var(--surface-2); border-radius: var(--r-md); padding: 3px; gap: 2px; }
.segmented-item { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; font-size: 13px;
    font-weight: 600; color: var(--muted); text-decoration: none; border: none; background: none; cursor: pointer; font-family: inherit; }
.segmented-item.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* modules admin */
.module-head { display: flex; align-items: center; gap: 14px; }
.module-icon { display: inline-flex; width: 38px; height: 38px; border-radius: 9px; align-items: center; justify-content: center;
    background: var(--surface-2); color: var(--muted); flex: none; }
.module-meta { flex: 1 1 auto; min-width: 0; }
.module-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.module-sub { font-size: 13px; margin-top: 2px; }
.module-actions { flex: none; }
.module-danger { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border); display: flex; flex-direction: column; gap: 8px; }
.module-danger .input { max-width: 220px; }

.select-wrap { display: inline-flex; position: relative; }
.select { appearance: none; -webkit-appearance: none; font: var(--font); height: 42px; padding: 0 38px 0 12px;
    border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); color: var(--text); cursor: pointer; min-width: 220px; }
.select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring-soft); }
.select-wrap::after { content: ""; position: absolute; right: 15px; top: 50%; width: 7px; height: 7px;
    border-right: 2px solid var(--subtle); border-bottom: 2px solid var(--subtle); transform: translateY(-70%) rotate(45deg); pointer-events: none; }
.select-block { display: block; }
.select-block .select { width: 100%; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mail-test { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.mail-test .input { max-width: 300px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* translation manager */
.tr-toolbar { margin-bottom: 14px; }
.coverage-meta { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.coverage-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.coverage-fill { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s var(--ease); }
.cov-0 { width: 0; } .cov-10 { width: 10%; } .cov-20 { width: 20%; } .cov-30 { width: 30%; }
.cov-40 { width: 40%; } .cov-50 { width: 50%; } .cov-60 { width: 60%; } .cov-70 { width: 70%; }
.cov-80 { width: 80%; } .cov-90 { width: 90%; } .cov-100 { width: 100%; }
.tr-table td { vertical-align: middle; }
.tr-key { white-space: nowrap; } .tr-key code { font-size: 12px; }
.tr-source { max-width: 280px; }
.tr-save { position: sticky; bottom: 0; padding: 14px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: var(--font); font-weight: 600;
    height: 42px; padding: 0 18px; border-radius: var(--r-md); border: 1px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap;
    transition: background var(--t-fast), box-shadow var(--t-fast), border-color var(--t-fast), transform var(--t-fast); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.notice { display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-radius: var(--r-md); margin-bottom: 16px; font-size: 13px; border: 1px solid transparent; }
.notice.ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.notice.err { background: var(--err-bg); color: var(--err-text); border-color: var(--err-border); }

/* error summary (top of form on submit) */
.error-summary { border: 1px solid var(--err-border); background: var(--err-bg); border-radius: var(--r-md); padding: 14px 16px; margin-bottom: 18px; }
.error-summary-title { font-weight: 650; color: var(--err-text); font-size: 14px; margin: 0 0 6px; }
.error-summary ul { margin: 0; padding-left: 18px; color: var(--err-text); font-size: 13px; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); }
.table tbody tr { transition: background var(--t-fast); }
.table tbody tr:hover { background: var(--surface-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.cell-link { color: var(--text); font-weight: 600; text-decoration: none; }
.cell-link:hover { color: var(--primary); }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.badge-violet { background: #f5f3ff; color: #7c3aed; }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge-blue { background: #eff6ff; color: #2563eb; }
.badge-danger { background: #fef2f2; color: #dc2626; }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); }

/*
 * Responsive data-list: a .table.data-list collapses to stacked cards on phones.
 * Markup contract: each <td> carries data-label="Column name". The label shows
 * on mobile (NN/g: don't shrink a wide table; restructure it). Desktop unchanged.
 */
@media (max-width: 768px) {
    .table.data-list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .table.data-list, .table.data-list tbody, .table.data-list tr, .table.data-list td { display: block; width: 100%; }
    .table.data-list tr { border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 12px; padding: 4px 14px; background: var(--surface); }
    .table.data-list tr:hover { background: var(--surface); }
    .table.data-list td { border-bottom: 1px solid var(--border); padding: 9px 0; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; }
    .table.data-list td:last-child { border-bottom: none; }
    .table.data-list td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; text-align: left; flex: 0 0 auto; }
    .table.data-list td:empty { display: none; }
    .table.data-list .cell-user, .table.data-list .cell-actions { justify-content: flex-end; }
}

/*
 * Commerce line/data tables: a normal table on desktop; on phones each row becomes a
 * COMPACT card — a bold primary line (the first cell) + one inline muted meta line
 * (the rest) — instead of the verbose one-label-per-row stack. Feels like a native list.
 * Scoped to commerce views; the core .data-list is deliberately left untouched.
 */
@media (max-width: 768px) {
    .table.commerce-lines thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .table.commerce-lines, .table.commerce-lines tbody, .table.commerce-lines tr, .table.commerce-lines td { display: block; width: 100%; }
    .table.commerce-lines tr { border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 10px; padding: 12px 14px; background: var(--surface); }
    .table.commerce-lines tr:hover { background: var(--surface); }
    .table.commerce-lines td { border: none; padding: 0; text-align: left; }
    .table.commerce-lines td:first-child { font-weight: 600; font-size: 15px; margin-bottom: 5px; }
    .table.commerce-lines td:not(:first-child) { display: inline; font-size: 13px; color: var(--muted); }
    .table.commerce-lines td:not(:first-child)::before { content: attr(data-label) " "; font-weight: 500; }
    .table.commerce-lines td:not(:first-child, :last-child)::after { content: " · "; color: var(--subtle); }
    .table.commerce-lines td:last-child { color: var(--text); font-weight: 600; }
    .table.commerce-lines td:empty { display: none; }
}

/* Draft purchase-order line editor: a compact native list of added lines + an inline
   add-line row (variant + qty + cost + Add). Commerce-scoped. */
.po-lines { list-style: none; margin: 0 0 4px; padding: 0; }
.po-line { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.po-line:first-child { border-top: none; }
.po-line-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
.po-line-title { font-weight: 600; }
.po-line-meta { color: var(--muted); font-size: 13px; }
.po-line-amount { font-weight: 600; white-space: nowrap; }
.po-line-remove { flex: 0 0 auto; margin: 0; }
.po-add-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.po-add-line .po-add-variant { flex: 1 1 200px; }
.po-add-line .input-narrow { width: 92px; }
.ship-address { font-style: normal; line-height: 1.55; color: var(--text); }
/* Custom-fields form section (any module form) + inline field-label icon. */
.custom-fields { display: grid; gap: 12px; }
.icon-sm { width: 15px; height: 15px; vertical-align: -2px; }
.cf-icon { font-size: 15px; line-height: 1; }
.product-thumb-lg { width: 56px; height: 56px; border-radius: var(--r-md); object-fit: cover; border: 1px solid var(--border); flex: 0 0 auto; color: var(--subtle); }
.stat-link { text-decoration: none; transition: background var(--t-fast); }
.stat-link:hover { background: var(--surface-2); }
.preset-list { display: grid; gap: 8px; }
.preset-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); margin: 0; }

/* api docs */
.codeblock { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md);
    padding: 12px 14px; font-size: 12.5px; overflow-x: auto; margin: 10px 0; white-space: pre; color: var(--text); }
.endpoint { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.endpoint-path { font-size: 13px; font-weight: 600; }
.endpoint-body { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.field-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.field-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.pagination { display: flex; gap: 4px; margin-top: 16px; flex-wrap: wrap; }
.page-link { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--muted); text-decoration: none; font-size: 13px; transition: background var(--t-fast); }
.page-link:hover { background: var(--surface-2); }
.page-link.is-active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---------- checkboxes / overrides ---------- */
.checks { display: flex; flex-direction: column; gap: 9px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }

/* A picker of checkbox rows (e.g. products in a collection): no list bullets, laid out in
   responsive columns, scrollable when the list is long. */
.check-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 6px 16px; max-height: 340px; overflow-y: auto; }
.check-list li { margin: 0; }

.ov-group { margin-bottom: 16px; }
.ov-group-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.ov-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); }
.ov-name { font-size: 13px; }
.ov-pills { display: inline-flex; background: var(--surface-2); border-radius: 8px; padding: 3px; gap: 2px; flex: 0 0 auto; }
.ov-pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 5px; font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; }
.ov-pill input { position: absolute; opacity: 0; width: 0; height: 0; }
/* reactive without JS via :has() — also covers the server-rendered checked state */
.ov-pill.ov-none:has(input:checked) { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.ov-pill.ov-grant:has(input:checked) { background: #16a34a; color: #fff; }
.ov-pill.ov-deny:has(input:checked) { background: #dc2626; color: #fff; }

.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.danger-zone { border-color: #fecaca; margin-top: 16px; }
.danger-zone .card-head { border-color: #fecaca; }

/* ---------- auth (login) ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh;
    background: radial-gradient(1200px 500px at 50% -10%, #e0e7ff 0%, var(--bg) 55%);
    padding: calc(24px + var(--sa-top)) calc(24px + var(--sa-right)) calc(24px + var(--sa-bottom)) calc(24px + var(--sa-left)); }
.auth-wrap { width: 100%; max-width: 400px; }
.auth-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 28px; }
.auth-title { font-size: 20px; font-weight: 680; margin: 0; letter-spacing: -.02em; }
.auth-sub { color: var(--muted); margin: 6px 0 20px; }
.auth-alt { margin: 16px 0 0; text-align: center; font-size: 13px; }
.auth-demo { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.auth-demo-title { font-size: 12px; color: var(--muted); font-weight: 600; }
.auth-demo ul { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.auth-demo li { font-size: 12px; color: var(--subtle); }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
    .cols { grid-template-columns: 1fr; }
}
/* Phone/tablet: hide the persistent sidebar; show top-bar toggle + bottom nav.
   The sidebar becomes an off-canvas drawer opened by the top-bar button or "More". */
@media (max-width: 768px) {
    /* The off-canvas drawer parks at translateX(-100%); clamp the root scrollers so its
     * off-screen box can't add horizontal scroll (sticky topbar unaffected — it sticks to
     * the body scroller vertically). */
    html, body.app { overflow-x: hidden; }
    .nav-toggle { display: inline-grid; }
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(86vw, 320px); transform: translateX(-100%); box-shadow: none; }
    .shell.nav-open .sidebar { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .shell.nav-open .scrim { opacity: 1; pointer-events: auto; }
    .main { margin-left: 0; }
    .content { padding: 18px 16px calc(18px + var(--bottomnav-h) + var(--sa-bottom)); }
    .bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
        background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--sa-bottom);
        box-shadow: 0 -1px 3px rgba(16, 24, 40, .05); }
    .topbar { padding-left: 16px; padding-right: calc(16px + var(--sa-right)); }
    /* keep toasts above the bottom tab bar */
    .toasts { left: 16px; right: 16px; max-width: none; bottom: calc(12px + var(--bottomnav-h) + var(--sa-bottom)); }
}
html[dir="rtl"] .sidebar { transform: none; }
@media (max-width: 768px) { html[dir="rtl"] .sidebar { transform: translateX(100%); }
    html[dir="rtl"] .shell.nav-open .sidebar { transform: translateX(0); } }

/* ── CRM activities timeline ───────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.timeline-time { margin-left: auto; font-size: 12px; }
.timeline-meta { font-size: 13px; margin: 2px 0 0; }
.timeline-body { margin: 6px 0 0; white-space: pre-wrap; }
.timeline-actions { margin-top: 6px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 12.5px; }
.cell-actions { text-align: right; white-space: nowrap; }

/* ── Customer-360 profile ──────────────────────────────────────────────── */
.profile-grid { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
@media (max-width: 860px) { .profile-grid { grid-template-columns: 1fr; } }
.profile-side { display: flex; flex-direction: column; gap: 16px; }
.profile-main { min-width: 0; }
.detail-list { display: grid; grid-template-columns: 1fr; gap: 2px 0; margin: 0 0 14px; }
.detail-list dt { font-size: 12px; color: var(--muted); margin-top: 8px; }
.detail-list dd { margin: 0; font-size: 14px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.plain-list li:last-child { border-bottom: 0; }

/* Avatars — monogram circles (reuses .avatar; adds size + colour tones) */
.avatar-lg { width: 48px; height: 48px; font-size: 17px; }
.avatar-sm { width: 26px; height: 26px; font-size: 11px; }
.avatar--blue { background: var(--primary); }
.avatar--emerald { background: #047857; }
.avatar--violet { background: #7c3aed; }
.avatar--amber { background: #b45309; }
.avatar--rose { background: #e11d48; }
.avatar--slate { background: #475569; }
.avatar--cyan { background: #0e7490; }
.avatar--fuchsia { background: #c026d3; }
.profile-head { display: flex; align-items: center; gap: 14px; }
.cell-user { display: inline-flex; align-items: center; gap: 9px; text-decoration: none; }

/* ── Custom fields ─────────────────────────────────────────────────────── */
.field-error { color: var(--err-text); font-size: 12px; margin-top: 4px; }

/* ── Tenants admin (utilities) ─────────────────────────────────────────── */
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.inline-form { display: inline-block; margin: 0; }
.confirm-inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.confirm-inline-label { font-size: 13px; color: var(--muted); font-weight: 500; }
.input-narrow { max-width: 140px; }
.ta-right { text-align: right; }
.dns-table code { font-size: 12.5px; }
@media (max-width: 720px) { .field-row { grid-template-columns: 1fr; } }

/* ── Tenant branding ───────────────────────────────────────────────────── */
.brand-logo { height: 30px; width: auto; max-width: 170px; object-fit: contain; display: block; }

/* ── File inputs (logo/document upload) ────────────────────────────────────── */
.input[type="file"] { padding: .4rem .55rem; color: var(--muted); cursor: pointer; line-height: 1.6; height: auto; }
.input[type="file"]::file-selector-button {
    margin-right: .75rem; padding: .4rem .85rem; border: 1px solid var(--border-strong);
    border-radius: var(--r-sm); background: var(--surface-2); color: var(--text);
    font: inherit; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s;
}
.input[type="file"]::file-selector-button:hover { background: var(--border); border-color: var(--subtle); }

/* ── Documents preview (CSP-safe: classes, not inline styles) ───────────────── */
.doc-thumb { height: 28px; width: 28px; object-fit: cover; border-radius: 4px; vertical-align: middle; margin-right: .5rem; }
.doc-preview-img { max-width: 100%; max-height: 540px; border-radius: 8px; }
.doc-preview-frame { width: 100%; height: 600px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }

/* ── Commerce product media (CSP-safe: classes, not inline styles) ──────────── */
.media-grid { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.media-thumb { width: 120px; margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.media-thumb img { width: 120px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }
.media-upload { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.cell-thumb { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); flex-shrink: 0; }
.cell-thumb.is-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--border); color: var(--subtle); }
.cell-thumb-icon { width: 18px; height: 18px; }

/* ── Paces ecommerce product table (thumb + name/vendor, sku, stock, price, actions) ── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.table-wrap { overflow-x: auto; }
.ecom-table th.num, .ecom-table td.num { text-align: right; }
.ecom-table td.money { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.ecom-table .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.cell-product { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; max-width: 100%; }
.cell-thumb-lg { width: 44px; height: 44px; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border); flex: 0 0 auto; }
.cell-thumb-lg.is-empty { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--subtle); }
.cell-product-meta { display: flex; flex-direction: column; min-width: 0; }
.cell-product-meta .cell-link { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-sub { font-size: 12.5px; color: var(--subtle); }
.stock { font-variant-numeric: tabular-nums; font-weight: 600; }
.stock-low { color: var(--warn-text); }
.stock-out { color: var(--err-text); font-weight: 600; font-size: 12.5px; }
.col-actions { text-align: right; width: 1%; white-space: nowrap; }
.row-actions { display: inline-flex; align-items: center; gap: 2px; justify-content: flex-end; }
.row-confirm { display: inline-flex; align-items: center; gap: 2px; }
.row-confirm .inline-form { display: inline-flex; margin: 0; }
.icon-action { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: var(--r-md); color: var(--subtle); background: none; border: 0; cursor: pointer; text-decoration: none; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.icon-action:hover { background: var(--surface-2); color: var(--primary); }
.icon-action--danger:hover { background: var(--err-bg); color: var(--err-text); }
.icon-action .icon { width: 17px; height: 17px; }
@media (max-width: 768px) {
    /* keep the product cell left-aligned when the row collapses to a card */
    .table.data-list .cell-product { justify-content: flex-start; }
}

/* ── Professional product form: two-column + drag-drop uploader ────────────── */
.product-form .form-cols { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.form-main, .form-side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.form-side { position: sticky; top: 78px; }
.product-form .field { margin-bottom: 14px; }
.product-form .field:last-child { margin-bottom: 0; }
.input-affix { display: flex; align-items: stretch; border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.input-affix:focus-within { outline: 2px solid var(--ring); outline-offset: 0; border-color: var(--primary); }
.input-affix .affix { display: inline-grid; place-items: center; padding: 0 10px; background: var(--surface-2); color: var(--subtle); font-weight: 600; }
.input-affix .input { border: 0; border-radius: 0; }
.input-affix .input:focus-visible { outline: none; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text); cursor: pointer; }
.check-row input { width: 16px; height: 16px; flex: 0 0 auto; }

.card-head--row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head-link { font-size: 13px; font-weight: 600; color: var(--primary); text-decoration: none; }
.card-head-link:hover { text-decoration: underline; }
.preset-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
/* custom-field set groups (admin) */
.cf-set { margin-bottom: 20px; }
.cf-set:last-child { margin-bottom: 0; }
.cf-set-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid var(--border); }
.cf-set-title { font-size: 12px; font-weight: 700; color: var(--text); text-transform: uppercase; letter-spacing: .04em; }
.cf-set-title code { text-transform: none; font-weight: 400; }
.cf-set-empty { padding: 4px 0; }
.check-field { justify-content: flex-end; }

/* Lightweight rich-text editor */
.rte { border: 1px solid var(--border-strong); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.rte:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring-soft); }
.rte-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.rte-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 8px; border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.rte-btn:hover { background: var(--surface); color: var(--primary); }
.rte-btn b, .rte-btn i, .rte-btn u { font-size: 14px; }
.rte-sep { width: 1px; align-self: stretch; margin: 4px 4px; background: var(--border); }
.rte-editor { min-height: 140px; padding: 12px 14px; font: var(--font); color: var(--text); line-height: 1.6; outline: none; overflow-wrap: anywhere; }
.rte-editor:empty::before { content: attr(data-placeholder); color: var(--subtle); pointer-events: none; }
.rte-editor h2 { font-size: 18px; font-weight: 700; margin: 12px 0 6px; }
.rte-editor h3 { font-size: 15px; font-weight: 700; margin: 10px 0 4px; }
.rte-editor p { margin: 0 0 8px; }
.rte-editor ul, .rte-editor ol { margin: 0 0 8px; padding-left: 22px; }
.rte-editor a { color: var(--primary); text-decoration: underline; }

/* Drag & drop dropzone */
.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--r-lg); background: var(--surface-2);
    padding: 26px 18px; text-align: center; cursor: pointer; transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease); }
.dropzone:hover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.dropzone.is-dragging { border-color: var(--primary); background: var(--primary-soft); }
.dropzone-icon { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-full); background: rgba(35, 109, 201, .12); color: var(--primary); margin-bottom: 8px; }
.dropzone-icon .icon { width: 22px; height: 22px; }
.dropzone-title { font-weight: 600; margin: 0 0 2px; color: var(--text); }
.dropzone-hint { font-size: 13px; color: var(--subtle); margin: 0; }
.dropzone-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.dz-thumb { margin: 0; }
.dz-thumb img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border); display: block; background: var(--surface); }
.dz-thumb figcaption { font-size: 11px; color: var(--subtle); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dropzone-bar { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.dropzone-count { font-size: 13px; font-weight: 600; color: var(--muted); }

/* Media management grid (edit) */
.media-manage { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin-bottom: 16px; }
.media-thumb--managed { position: relative; margin: 0; }
.media-thumb--managed img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: var(--r-md); border: 1px solid var(--border); display: block; }
.media-thumb--managed form { position: absolute; top: 6px; right: 6px; margin: 0; }
.media-del { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: var(--r-full); background: rgba(15, 23, 42, .6); color: #fff; cursor: pointer; }
.media-del:hover { background: var(--err-text); }
.media-del .icon { width: 15px; height: 15px; }
.form-actions--left { justify-content: flex-start; margin-top: 12px; }
.form-actions--sticky { display: flex; justify-content: flex-end; padding: 16px 0 4px; margin-top: 4px; }
@media (max-width: 900px) {
    .product-form .form-cols { grid-template-columns: 1fr; }
    .form-side { position: static; order: -1; }
}

/* ── Barcodes & QR (codes module) ──────────────────────────────────────────── */
.codes-grid { display: grid; grid-template-columns: auto 1fr; gap: 20px; align-items: start; }
.code-qr { margin: 0; text-align: center; }
.code-qr svg { width: 140px; height: 140px; display: block; }
.code-qr figcaption, .code-bc figcaption { font-size: 12px; color: var(--subtle); margin-top: 4px; }
.code-barcodes { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.code-bc { margin: 0; }
.code-bc svg { width: 100%; max-width: 260px; height: 44px; display: block; }
@media (max-width: 640px) { .codes-grid { grid-template-columns: 1fr; } }

/* QR tools */
.qr-form { max-width: 640px; }
.qr-show { text-align: center; }
.qr-show-code svg { width: 240px; height: 240px; max-width: 100%; display: block; margin: 0 auto 16px; }
.qr-summary, .qr-dest { overflow-wrap: anywhere; }
.qr-dest.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

/* printable label sheet */
.label-sheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.label { margin: 0; border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; text-align: center; background: #fff; display: flex; flex-direction: column; gap: 6px; }
.label-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.label-bc svg { width: 100%; max-width: 100%; height: 46px; display: block; }
.label-meta { display: flex; align-items: center; justify-content: space-between; font-size: 12px; }
.label-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }
.label-price { font-weight: 700; color: var(--text); }

@media print {
    .sidebar, .topbar, .bottomnav, .scrim, .no-print, .toasts { display: none !important; }
    .main { margin: 0 !important; }
    .content { padding: 0 !important; }
    body, body.app { background: #fff; overflow: visible; }
    .label-sheet { gap: 6px; }
    .label { border-color: #ccc; break-inside: avoid; }
}

/* ── Customer 360 profile (subtle destructive action, not a big danger card) ── */
.profile-stats { margin-bottom: 1rem; }
.profile-danger { margin-top: 1.5rem; display: flex; align-items: center; gap: .5rem; }
.btn-subtle-danger { background: transparent; border: 0; color: #dc2626; font-size: 13px; font-weight: 500; padding: .35rem .5rem; border-radius: 6px; cursor: pointer; }
.btn-subtle-danger:hover { background: rgba(220, 38, 38, .08); }

/* ── Orders ─────────────────────────────────────────────────────────────────── */
.order-totals { display: grid; grid-template-columns: 1fr auto; gap: .1rem .5rem; margin: 1rem 0 0; border-top: 1px solid var(--border); padding-top: .75rem; }
.order-totals dt { color: var(--muted); font-size: 14px; }
.order-totals dd { margin: 0; text-align: right; }
.order-actions { display: flex; flex-direction: column; gap: .6rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }

/* ── Layout utilities (CSP-safe replacements for inline style attributes) ───── */
.mt-1 { margin-top: 1rem; }
.mt-sm { margin-top: .5rem; }
.mb-1 { margin-bottom: 1rem; }
.flex-1 { flex: 1; }
.gap-1 { gap: 1rem; }
.gap-sm { gap: .5rem; }
.wrap { flex-wrap: wrap; }
.w-full { width: 100%; }
.min-180 { min-width: 180px; }
.items-start { align-items: flex-start; }
.row-start { justify-content: flex-start; }
.ta-center { text-align: center; }
.brand-mark-lg { width: 48px; height: 48px; font-size: 20px; }
.brand-logo-preview { height: 48px; width: auto; border-radius: 8px; }

/* CMS Delivery API settings */
.endpoint-list { list-style: none; padding: 0; margin: .25rem 0 1rem; display: flex; flex-direction: column; gap: .4rem; }
.endpoint-list li { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.endpoint-list code { word-break: break-all; }
.detail-sub { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted, #64748b); margin: 1rem 0 .25rem; }
.detail-sub:first-child { margin-top: 0; }
code.token { word-break: break-all; }

/* CMS media preview + version list */
.cms-media-preview { display: block; max-width: 220px; max-height: 160px; border-radius: 8px; margin-bottom: .5rem; border: 1px solid var(--border, #e2e8f0); object-fit: cover; }
.version-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.version-item { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.version-when { font-size: .85rem; }

/* CMS group (nested field set) */
.cms-group { border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: .75rem 1rem 1rem; margin: 0 0 1rem; }
.cms-group > legend { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted, #64748b); padding: 0 .4rem; }
.detail-list.nested { margin-top: .25rem; padding-left: .75rem; border-left: 2px solid var(--border, #e2e8f0); }

/* CMS blocks (dynamic zone) builder */
.cms-blocks { margin: 0 0 1rem; }
.cms-blocks > .label { display: block; margin-bottom: .4rem; }
.cms-block { border: 1px solid var(--border, #e2e8f0); border-radius: 10px; margin-bottom: .6rem; overflow: hidden; }
.cms-block-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .4rem .6rem; background: var(--surface-2, #f8fafc); border-bottom: 1px solid var(--border, #e2e8f0); }
.cms-block-type { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted, #64748b); }
.cms-block-ctrls { display: flex; gap: .25rem; }
.cms-block-body { padding: .75rem .8rem; }
.cms-block-add { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .25rem; }
.cms-block-list { display: flex; flex-direction: column; gap: .6rem; }
.cms-block-display { border-left: 2px solid var(--border, #e2e8f0); padding-left: .75rem; }

/* CMS schedule card spacing */
.version-list.mb { margin-bottom: 1rem; }

/* Notification bell + dropdown */
.notif { position: relative; }
.notif-btn { position: relative; }
.notif-badge { position: absolute; top: 2px; right: 2px; min-width: 15px; height: 15px; padding: 0 3px;
    background: var(--primary, #2563eb); color: #fff; border-radius: 999px; font-size: 10px; font-weight: 700;
    line-height: 15px; text-align: center; }
.notif-menu { width: min(92vw, 340px); max-height: 70vh; overflow-y: auto; }
.notif-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notif-readall { background: none; border: none; padding: 0; cursor: pointer; font: inherit; font-size: 12px;
    color: var(--primary, #2563eb); }
.notif-empty { padding: 18px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-item { border-radius: 7px; }
.notif-item.is-unread { background: color-mix(in srgb, var(--primary, #2563eb) 8%, transparent); }
.notif-link { display: grid; gap: 2px; padding: 9px 10px; text-decoration: none; color: var(--text); }
.notif-link:hover { background: var(--surface-2); border-radius: 7px; }
.notif-item-title { font-weight: 600; font-size: 13px; }
.notif-item-body { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item-time { font-size: 11px; color: var(--muted); }
