/*
 * 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).
 */
: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;

    /* ── semantic (themeable surface) ────────────────────────────────────── */
    --bg: var(--slate-50);
    --surface: #ffffff;
    --surface-2: var(--slate-100);
    --surface-hover: #f6f8fb;
    --sidebar: var(--slate-950);
    --sidebar-2: #111a2e;
    --sidebar-text: var(--slate-300);
    --sidebar-muted: var(--slate-400);  /* WCAG AA: 5.9:1 on the dark sidebar (slate-500 was 3.9) */
    --border: var(--slate-200);
    --border-strong: var(--slate-300);
    --text: var(--slate-900);
    --muted: var(--slate-600);          /* AA: ~7:1 on surfaces */
    --subtle: var(--slate-500);         /* AA: ~4.6:1 on white (slate-400 failed at 2.8) */
    --primary: var(--blue-600);
    --primary-hover: var(--blue-700);
    --primary-soft: var(--blue-50);
    --accent: var(--blue-600);
    --ring: rgba(37, 99, 235, .35);
    --ring-soft: rgba(37, 99, 235, .15);

    /* status */
    --ok-bg: #ecfdf5; --ok-text: #047857; --ok-border: #a7f3d0;
    --warn-bg: #fffbeb; --warn-text: #b45309; --warn-border: #fde68a;
    --err-bg: #fef2f2; --err-text: #b91c1c; --err-border: #fecaca;
    --info-bg: #eff6ff; --info-text: #1d4ed8; --info-border: #bfdbfe;

    /* ── 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 ───────────────────────────────────────────────────────────── */
    --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px; --r-full: 999px;

    /* ── elevation ───────────────────────────────────────────────────────── */
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 4px 8px rgba(16, 24, 40, .06);

    /* ── 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 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, 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; }
.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: 248px; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; padding: 16px 12px;
    padding-top: calc(16px + var(--sa-top)); padding-left: calc(12px + var(--sa-left));
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 30; overflow-y: auto;
    transition: transform var(--t-base) var(--ease); }
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: #fff; padding: 6px 8px 16px; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
.nav-group { margin-top: 6px; border-top: 1px solid rgba(255, 255, 255, .06); padding-top: 6px; }
.nav-section-btn { display: flex; align-items: center; justify-content: space-between; width: 100%;
    background: none; border: none; cursor: pointer; padding: 9px 10px; border-radius: 8px;
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--sidebar-muted); font-family: inherit; }
.nav-section-btn:hover { background: rgba(255, 255, 255, .06); color: var(--sidebar-text); }
.nav-chev { width: 14px; height: 14px; transition: transform var(--t-base) var(--ease); }
.nav-chev.is-open { transform: rotate(180deg); }
.nav-sub { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-link { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 8px;
    color: var(--sidebar-text); text-decoration: none; font-weight: 500; transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease); }
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-link.is-active { background: rgba(37, 99, 235, .22); color: #fff; box-shadow: inset 2px 0 0 var(--blue-500); }
.nav-icon { width: 19px; height: 19px; opacity: .9; }
.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; } }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { display: flex; gap: 14px; align-items: flex-start; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-xl); padding: 18px; box-shadow: var(--shadow-sm); transition: box-shadow var(--t-base), transform var(--t-base); }
.stat:hover { box-shadow: var(--shadow-md); }
.stat-icon { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 10px; flex: 0 0 auto; }
.stat-icon .icon { width: 22px; height: 22px; }
.tone-blue { background: #eff6ff; color: #2563eb; }
.tone-violet { background: #f5f3ff; color: #7c3aed; }
.tone-emerald { background: #ecfdf5; color: #059669; }
.tone-amber { background: #fffbeb; color: #d97706; }
.stat-body { display: flex; flex-direction: column; min-width: 0; }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin: 2px 0; overflow-wrap: anywhere; }
.stat-hint { font-size: 12px; color: var(--subtle); }

/* ---------- cards ---------- */
.cols { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-sm); }
.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; }

/* 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; }
}

/* 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); }

.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) {
    .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: #059669; }
.avatar--violet { background: #7c3aed; }
.avatar--amber { background: #d97706; }
.avatar--rose { background: #e11d48; }
.avatar--slate { background: #475569; }
.avatar--cyan { background: #0891b2; }
.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; }

/* ── 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; }
