/* =====================================================================
   dobby POS · CRM — admin-styles.css
   Same tokens & components as the Website CMS (sections 1–7), plus the CRM screens (section 8).
   Theming: [data-theme="dark"] (default) / [data-theme="light"] on <html>
   Built on Bootstrap 5.1.3 (no native color modes → custom tokens + overrides)
   ===================================================================== */

/* ---------- 1. Design tokens ----------
   CRM palette ("ocean"): deliberately different from the Website CMS (pink #FF3655 + violet),
   so users always know which app they are in. Token NAMES are the same as the CMS, so every
   shared component works unchanged: --brand = CRM blue, --violet = the secondary accent (teal). */
:root {
    --brand: #2F6BFF;
    --brand-hover: #4A80FF;
    --brand-press: #1F55E0;
    --brand-rgb: 47, 107, 255;
    --violet: #14B8A6;                 /* secondary accent: teal (name kept for the shared components) */
    --violet-rgb: 20, 184, 166;
    --success: #3FCF6E;
    --success-rgb: 63, 207, 110;
    --warning: #F5A524;
    --warning-rgb: 245, 165, 36;
    --danger: #EF4B5A;
    --danger-rgb: 239, 75, 90;

    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Commissioner', 'Inter', system-ui, sans-serif;   /* headings & the "CRM" lockup (Greek support) */
    --font-mono: ui-monospace, 'SFMono-Regular', Consolas, monospace;

    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --sidebar-w: 268px;
    --topbar-h: 72px;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

/* Dark (default) */
:root,
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #060A12;
    --frame: #0B111C;
    --panel: #080D17;
    --surface: #101826;
    --surface-2: #152033;
    --surface-3: #1D2A40;
    --input-bg: #0D1522;
    --border: rgba(148, 180, 255, .08);
    --border-strong: rgba(148, 180, 255, .15);
    --text: #E7EEF9;
    --text-muted: #93A3BC;
    --text-subtle: #5F6E86;
    --brand-text: #7AA2FF;
    --brand-soft: rgba(var(--brand-rgb), .16);
    --violet-soft: rgba(var(--violet-rgb), .15);
    --success-soft: rgba(var(--success-rgb), .14);
    --warning-soft: rgba(var(--warning-rgb), .14);
    --danger-soft: rgba(var(--danger-rgb), .14);
    --nav-active-bg: var(--brand);
    --nav-active-text: #FFFFFF;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 60px -20px rgba(0, 0, 0, .75);
    --logo-filter: none;
    --switch-knob: rgba(255, 255, 255, .55);
    --backdrop: rgba(3, 4, 6, .72);
}

/* Light */
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #E9EEF6;
    --frame: #FFFFFF;
    --panel: #F3F6FB;
    --surface: #FFFFFF;
    --surface-2: #EEF3FA;
    --surface-3: #E1E9F4;
    --input-bg: #FFFFFF;
    --border: rgba(16, 42, 90, .08);
    --border-strong: rgba(16, 42, 90, .15);
    --text: #0F1A2E;
    --text-muted: #5A6880;
    --text-subtle: #8F9BB0;
    --brand-text: #1F55E0;
    --brand-soft: rgba(var(--brand-rgb), .10);
    --violet-soft: rgba(var(--violet-rgb), .12);
    --success-soft: rgba(var(--success-rgb), .14);
    --warning-soft: rgba(var(--warning-rgb), .16);
    --danger-soft: rgba(var(--danger-rgb), .10);
    --nav-active-bg: var(--brand);
    --nav-active-text: #FFFFFF;
    --shadow-sm: 0 1px 2px rgba(16, 18, 27, .06);
    --shadow: 0 10px 30px -14px rgba(16, 18, 27, .18);
    --shadow-lg: 0 30px 60px -24px rgba(16, 18, 27, .28);
    --logo-filter: invert(1) brightness(.12);
    --switch-knob: rgba(0, 0, 0, .28);
    --backdrop: rgba(20, 22, 30, .45);
}

/* ---------- 2. Base ---------- */
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .25s var(--ease), color .25s var(--ease);
}

::selection { background: rgba(var(--brand-rgb), .3); }

a { color: var(--brand-text); text-decoration: none; }
a:hover { color: var(--brand); }

h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -.02em; font-weight: 700; }

.text-muted { color: var(--text-muted) !important; }
.text-subtle { color: var(--text-subtle) !important; }
.text-brand { color: var(--brand-text) !important; }

kbd {
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--surface-3);
    color: var(--text-muted);
    border: 1px solid var(--border);
    box-shadow: none;
}

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }

/* ---------- 3. Bootstrap overrides (theme-aware) ---------- */
.btn {
    --radius: var(--radius-sm);
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    padding: .55rem 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn:focus { box-shadow: none; }
.btn:focus-visible { box-shadow: 0 0 0 4px var(--brand-soft); }
.btn .bi { font-size: 1.05em; line-height: 1; }

.btn-primary,
.btn-brand {
    color: #fff;
    background: var(--brand);
    border-color: var(--brand);
}
.btn-primary:hover, .btn-brand:hover,
.btn-primary:focus, .btn-brand:focus { color: #fff; background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-primary:active, .btn-brand:active { background: var(--brand-press) !important; border-color: var(--brand-press) !important; }
.btn-primary:disabled, .btn-brand:disabled { color: #fff; background: var(--brand); border-color: var(--brand); opacity: .55; }

.btn-soft {
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.btn-soft:hover, .btn-soft:focus { color: var(--text); background: var(--surface-3); border-color: var(--border-strong); }

.btn-ghost { color: var(--text-muted); background: transparent; border: 1px solid transparent; }
.btn-ghost:hover, .btn-ghost:focus { color: var(--text); background: var(--surface-2); }

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover, .btn-danger:focus { background: #DC3A49; border-color: #DC3A49; color: #fff; }

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    flex: 0 0 auto;
    border-radius: var(--radius-sm);
}
.btn-icon.btn-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.btn-icon.danger:hover { color: var(--danger); background: var(--danger-soft); }

.form-label { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: .45rem; }
.form-text { color: var(--text-subtle); font-size: 12px; }

.form-control,
.form-select {
    background-color: var(--input-bg);
    border: 1px solid var(--border-strong);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: .65rem .9rem;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.form-control::placeholder { color: var(--text-subtle); }
.form-control:focus,
.form-select:focus {
    background-color: var(--input-bg);
    color: var(--text);
    border-color: rgba(var(--brand-rgb), .7);
    box-shadow: 0 0 0 4px var(--brand-soft);
}
.form-control:disabled { background-color: var(--surface-2); opacity: .7; }
textarea.form-control { resize: vertical; min-height: 120px; line-height: 1.6; }

.was-validated .form-control:invalid, .form-control.is-invalid { border-color: var(--danger); background-image: none; padding-right: .9rem; }
.was-validated .form-control:invalid:focus, .form-control.is-invalid:focus { box-shadow: 0 0 0 4px var(--danger-soft); }
.was-validated .form-control:valid, .form-control.is-valid { border-color: var(--border-strong); background-image: none; padding-right: .9rem; }
.was-validated .form-control:valid:focus { border-color: rgba(var(--brand-rgb), .7); box-shadow: 0 0 0 4px var(--brand-soft); }
.invalid-feedback { color: var(--danger); font-size: 12px; font-weight: 500; }

.form-check-input {
    background-color: var(--surface-3);
    border: 1px solid var(--border-strong);
}
.form-check-input:focus { border-color: rgba(var(--brand-rgb), .6); box-shadow: 0 0 0 4px var(--brand-soft); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-switch .form-check-input {
    width: 2.4em;
    height: 1.3em;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(255,255,255,.55)'/%3e%3c/svg%3e");
}
:root[data-theme="light"] .form-switch .form-check-input:not(:checked) {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(0,0,0,.28)'/%3e%3c/svg%3e");
}
.form-switch .form-check-input:checked,
.form-switch .form-check-input:checked:focus {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}
.form-switch .form-check-input.is-success:checked { background-color: var(--success); border-color: var(--success); }
.form-check-label { color: var(--text); cursor: pointer; }

.modal-backdrop { background-color: var(--backdrop); }
.modal-backdrop.show { opacity: 1; backdrop-filter: blur(4px); }
.modal-content {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border); padding: 1.25rem 1.5rem; gap: .9rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { border-top: 1px solid var(--border); padding: 1rem 1.5rem; gap: .5rem; }
.modal-footer > * { margin: 0; }
.modal-title { font-size: 17px; font-weight: 700; line-height: 1.3; }
.modal-subtitle { font-size: 12.5px; color: var(--text-muted); margin: 2px 0 0; }
.modal.fade .modal-dialog { transform: translateY(14px) scale(.98); transition: transform .25s var(--ease); }
.modal.show .modal-dialog { transform: none; }

.btn-close { opacity: .55; box-shadow: none !important; }
.btn-close:hover { opacity: .9; }
:root:not([data-theme="light"]) .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

.alert {
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    padding: .75rem 1rem;
    border: 1px solid transparent;
    display: flex;
    gap: .6rem;
    align-items: flex-start;
}
.alert .bi { font-size: 1.05rem; line-height: 1.3; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(var(--danger-rgb), .25); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: rgba(var(--success-rgb), .25); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(var(--warning-rgb), .25); }
.alert-info { background: var(--violet-soft); color: var(--violet); border-color: rgba(var(--violet-rgb), .25); }

.table {
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
    --bs-table-hover-bg: var(--surface-2);
    --bs-table-hover-color: var(--text);
    color: var(--text);
    border-color: var(--border);
    margin: 0;
}
/* BS 5.1 draws a 2px currentColor line between thead and tbody */
.table > :not(:first-child) { border-top: 0; }

.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }

.dropdown-menu {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: .4rem;
}
.dropdown-item { color: var(--text); border-radius: 10px; padding: .5rem .75rem; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }

/* ---------- 4. Shared components ---------- */
.brand-wordmark { height: 22px; width: auto; filter: var(--logo-filter); display: block; }

.badge-soft {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: 11.5px;
    font-weight: 600;
    padding: .25rem .6rem;
    border-radius: 999px;
    background: var(--surface-3);
    color: var(--text-muted);
    white-space: nowrap;
    line-height: 1.4;
}
.badge-soft.brand { background: var(--brand-soft); color: var(--brand-text); }
.badge-soft.violet { background: var(--violet-soft); color: var(--violet); }
.badge-soft.success { background: var(--success-soft); color: var(--success); }
.badge-soft.warning { background: var(--warning-soft); color: var(--warning); }
.badge-soft .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.card-x {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--violet));
    flex: 0 0 auto;
    letter-spacing: .02em;
}

.icon-tile {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    font-size: 19px;
    flex: 0 0 auto;
    background: var(--surface-3);
    color: var(--text);
}
.icon-tile.brand { background: var(--brand-soft); color: var(--brand-text); }
.icon-tile.violet { background: var(--violet-soft); color: var(--violet); }
.icon-tile.success { background: var(--success-soft); color: var(--success); }
.icon-tile.muted { background: var(--surface-3); color: var(--text-muted); }

/* Segmented theme toggle (reference: sun / moon pill) */
.theme-switch {
    display: inline-flex;
    padding: 4px;
    gap: 2px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.theme-switch button {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    display: grid;
    place-items: center;
    font-size: 15px;
    transition: background-color .2s, color .2s, box-shadow .2s;
}
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-pressed="true"] {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
    box-shadow: var(--shadow-sm);
}

/* Boot screen */
.boot-screen {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--bg);
    z-index: 2000;
    transition: opacity .3s;
}
.boot-screen.is-hidden { opacity: 0; pointer-events: none; }
.boot-spinner { width: 34px; height: 34px; border-width: 3px; color: var(--brand); }

@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.9); opacity: .7; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(2px); } 30%, 50%, 70% { transform: translateX(-4px); } 40%, 60% { transform: translateX(4px); } }
@keyframes shimmer { from { background-position: -400px 0; } to { background-position: 400px 0; } }

/* ---------- 5. Login ---------- */
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
    padding: 14px;
    gap: 14px;
}
.auth-brand {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius-xl);
    padding: 44px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #fff;
    background:
        radial-gradient(60% 50% at 85% 10%, rgba(var(--violet-rgb), .45), transparent 70%),
        radial-gradient(70% 60% at 10% 100%, rgba(var(--brand-rgb), .65), transparent 70%),
        linear-gradient(160deg, #1A0E16 0%, #0C0D12 60%, #120A10 100%);
}
.auth-brand::after {
    content: '';
    position: absolute;
    right: -60px;
    bottom: -40px;
    width: 420px;
    height: 420px;
    background: url('../images/dobby-auth.png') center / contain no-repeat;
    opacity: .07;
    pointer-events: none;
}
.auth-brand .brand-wordmark { filter: none; height: 28px; }
.auth-brand h2 { color: #fff; font-size: clamp(28px, 3.2vw, 42px); line-height: 1.12; font-weight: 800; letter-spacing: -.035em; max-width: 14ch; margin: 0 0 16px; }
.auth-brand p { color: rgba(255, 255, 255, .7); max-width: 42ch; font-size: 15px; margin: 0; }
.auth-features { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 12px; position: relative; z-index: 1; }
.auth-features li { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, .85); font-size: 14px; }
.auth-features .bi {
    width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
    background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .1);
}
.auth-brand-foot { color: rgba(255, 255, 255, .45); font-size: 12.5px; position: relative; z-index: 1; }

.auth-panel {
    border-radius: var(--radius-xl);
    background: var(--frame);
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px;
}
.auth-panel-top { display: flex; justify-content: space-between; align-items: center; }
.auth-card { width: 100%; max-width: 400px; margin: auto; padding: 32px 0; animation: fadeUp .4s var(--ease); }
.auth-logo {
    width: 76px;
    height: 76px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: var(--brand) url('../images/dobby-auth.png') center / 70% no-repeat;
}
.auth-card h1 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; margin: 0 0 6px; text-align: center; }
.auth-card .lead-text { color: var(--text-muted); margin: 0 0 28px; text-align: center; }
.auth-card.is-shaking { animation: shake .45s; }
.auth-note { margin-top: 22px; font-size: 12.5px; color: var(--text-subtle); display: flex; gap: .5rem; align-items: center; }

.input-icon { position: relative; }
.input-icon > .bi:first-child {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    pointer-events: none;
    font-size: 16px;
}
.input-icon .form-control { padding-left: 44px; height: 48px; }
.input-icon .input-action {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--text-subtle);
    border-radius: 10px;
}
.input-icon .input-action:hover { color: var(--text); background: var(--surface-2); }
.input-icon.has-action .form-control { padding-right: 48px; }
.caps-warning { font-size: 12px; color: var(--warning); margin-top: 6px; display: none; }
.caps-warning.show { display: flex; gap: .35rem; align-items: center; }

.btn-lg-block { width: 100%; height: 48px; font-size: 15px; }

/* ---------- 6. App shell ---------- */
.app {
    min-height: 100vh;
    padding: 14px;
}
.app-frame {
    min-height: calc(100vh - 28px);
    background: var(--frame);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    grid-template-rows: var(--topbar-h) minmax(0, 1fr);
    grid-template-areas: "top top" "side main";
    box-shadow: var(--shadow);
}

/* Topbar */
.topbar {
    grid-area: top;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 20px 0 22px;
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--frame);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.topbar-brand {
    width: calc(var(--sidebar-w) - 38px);
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}
.topbar-brand .env-tag { margin-left: 2px; }
/* Theme-specific logo: white wordmark on dark, logo.png (brand color, no filter) on light */
.topbar-brand .logo-on-light { display: none; filter: none; }
:root[data-theme="light"] .topbar-brand .logo-on-dark { display: none; }
:root[data-theme="light"] .topbar-brand .logo-on-light { display: block; }

.quick-search { position: relative; flex: 1 1 auto; max-width: 440px; margin: 0 auto; }
.quick-search .form-control {
    height: 42px;
    border-radius: 999px;
    background: var(--surface-2);
    border-color: var(--border);
    padding-left: 42px;
    padding-right: 56px;
}
.quick-search > .bi { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }
.quick-search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); }
.quick-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    display: none;
    max-height: 320px;
    overflow: auto;
    z-index: 40;
}
.quick-results.show { display: block; animation: fadeUp .15s var(--ease); }
.quick-results a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    color: var(--text);
}
.quick-results a .bi { color: var(--text-muted); width: 18px; text-align: center; }
.quick-results a small { margin-left: auto; color: var(--text-subtle); font-size: 11.5px; }
.quick-results a.is-active, .quick-results a:hover { background: var(--surface-2); }
.quick-results .empty { padding: 14px; text-align: center; color: var(--text-subtle); font-size: 13px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-divider { width: 1px; height: 26px; background: var(--border-strong); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 4px; }
.user-chip .meta { line-height: 1.2; }
.user-chip .name { font-weight: 600; font-size: 13.5px; }
.user-chip .role { font-size: 11.5px; color: var(--text-muted); text-transform: capitalize; }
.menu-toggle { display: none; }

/* Sidebar */
.sidebar {
    grid-area: side;
    padding: 8px 16px 18px 18px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h) - 30px);
    overflow-y: auto;
}
.workspace-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.workspace-card .title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.workspace-card .sub { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 4px; }

.nav-group { display: flex; flex-direction: column; gap: 3px; }
.nav-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: var(--text-subtle);
    padding: 0 12px 6px;
}
.nav-link-x {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 42px;
    padding: 0 12px;
    border-radius: 14px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    transition: background-color .15s, color .15s, box-shadow .2s;
    position: relative;
}
.nav-link-x .bi { font-size: 17px; width: 20px; text-align: center; }
.nav-link-x:hover { color: var(--text); background: var(--surface-2); }
.nav-link-x.active {
    background: var(--nav-active-bg);
    color: var(--nav-active-text);
    font-weight: 600;
    box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .5);
}
.nav-count {
    margin-left: auto;
    min-width: 22px;
    height: 20px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    display: inline-grid;
    place-items: center;
    background: var(--violet-soft);
    color: var(--violet);
}
.nav-count:empty { display: none; }
.nav-link-x.active .nav-count { background: var(--brand); color: #fff; }
.nav-soon {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-subtle);
    border: 1px dashed var(--border-strong);
    border-radius: 999px;
    padding: 1px 7px;
}
.nav-link-x.active .nav-soon { color: inherit; opacity: .6; }

.sidebar-foot { margin-top: auto; }
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface-2);
}
.sidebar-user .meta { min-width: 0; line-height: 1.25; }
.sidebar-user .name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .btn-icon { margin-left: auto; }

.sidebar-backdrop { display: none; }

/* Main content */
.main {
    grid-area: main;
    min-width: 0;
    background: var(--panel);
    border-radius: var(--radius-lg);
    margin: 0 14px 14px 0;
    border: 1px solid var(--border);
    padding: 26px 28px 40px;
}

.view { display: none; }
.view.active { display: block; animation: fadeUp .3s var(--ease); }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-subtle); margin-bottom: 6px; }
.crumbs .bi { font-size: 10px; }
.crumbs .current { color: var(--text-muted); font-weight: 500; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.035em; margin: 0; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-desc { color: var(--text-muted); margin: 6px 0 0; max-width: 60ch; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { padding: 18px; display: flex; align-items: center; gap: 14px; }
.stat-card .label { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat-card .value { font-size: 24px; font-weight: 800; letter-spacing: -.03em; line-height: 1.15; font-variant-numeric: tabular-nums; }

/* Toolbar inside list card */
.list-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.search-input { position: relative; flex: 1 1 240px; max-width: 340px; }
.search-input .bi { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); }
.search-input .form-control { padding-left: 38px; height: 40px; background: var(--surface-2); border-color: var(--border); }

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.segmented button {
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: 9px;
    transition: background-color .15s, color .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
:root:not([data-theme="light"]) .segmented button.active { background: var(--surface-3); }

.toolbar-hint { margin-left: auto; font-size: 12.5px; color: var(--text-subtle); display: flex; align-items: center; gap: 6px; }

.save-indicator {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
}
.save-indicator.saving { display: inline-flex; background: var(--surface-3); color: var(--text-muted); }
.save-indicator.saved { display: inline-flex; background: var(--success-soft); color: var(--success); }
.save-indicator.error { display: inline-flex; background: var(--danger-soft); color: var(--danger); }
.save-indicator .spinner-border { width: 12px; height: 12px; border-width: 2px; }

/* CMS table */
.table-cms thead th {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--text-subtle);
    padding: 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table-cms tbody td { padding: 14px 12px; border-color: var(--border); vertical-align: middle; }
.table-cms tbody tr:last-child td { border-bottom: 0; }
.table-cms tbody tr { transition: background-color .15s; }
.table-cms tbody tr:hover { background: var(--surface-2); }
.table-cms .col-handle { width: 44px; padding-left: 18px; padding-right: 0; }
.table-cms .col-order { width: 64px; }
.table-cms .col-status { width: 150px; }
.table-cms .col-actions { width: 110px; padding-right: 18px; }

.drag-handle {
    width: 28px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: var(--text-subtle);
    cursor: grab;
    font-size: 16px;
    transition: color .15s, background-color .15s;
    touch-action: none;
}
.drag-handle:hover { color: var(--text); background: var(--surface-3); }
.drag-handle:active { cursor: grabbing; }
.is-drag-disabled .drag-handle { opacity: .25; cursor: not-allowed; pointer-events: none; }

.order-badge {
    min-width: 30px;
    height: 26px;
    padding: 0 8px;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    background: var(--surface-3);
    color: var(--text-muted);
}

.row-title {
    border: 0;
    background: none;
    padding: 0;
    color: var(--text);
    font-weight: 600;
    font-size: 14px;
    text-align: left;
    line-height: 1.4;
}
.row-title:hover { color: var(--brand-text); }
.row-sub {
    color: var(--text-muted);
    font-size: 12.5px;
    margin-top: 3px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: 680px;
}
.status-cell { display: flex; align-items: center; gap: 8px; }
.status-cell .form-check { margin: 0; min-height: 0; padding-left: 2.6em; }
.status-cell .status-text { font-size: 12.5px; font-weight: 600; }
.status-cell .status-text.on { color: var(--success); }
.status-cell .status-text.off { color: var(--text-subtle); }
.row-actions { display: inline-flex; gap: 4px; }

/* Sortable states */
.sortable-ghost { background: var(--brand-soft) !important; }
.sortable-ghost td { opacity: .55; }
.sortable-chosen { background: var(--surface-2); }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }
tr.row-flash { animation: rowFlash 1.2s var(--ease); }
@keyframes rowFlash { 0% { background: rgba(var(--brand-rgb), .18); } 100% { background: transparent; } }

/* Skeleton */
.skeleton {
    display: block;
    height: 12px;
    border-radius: 6px;
    background: linear-gradient(90deg, var(--surface-2) 0, var(--surface-3) 40%, var(--surface-2) 80%);
    background-size: 800px 100%;
    animation: shimmer 1.3s linear infinite;
}

/* Empty / error states */
.empty-state { text-align: center; padding: 56px 20px; }
.empty-state .icon-tile { width: 56px; height: 56px; border-radius: 18px; font-size: 24px; margin: 0 auto 16px; }
.empty-state h3 { font-size: 16px; margin: 0 0 6px; }
.empty-state p { color: var(--text-muted); margin: 0 auto 18px; max-width: 42ch; }

/* Modal bits */
.field-head { display: flex; justify-content: space-between; align-items: baseline; }
.char-count { font-size: 11.5px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.char-count.warn { color: var(--warning); }
.switch-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-radius: var(--radius);
    background: var(--surface-2);
    border: 1px solid var(--border);
}
.switch-card .title { font-weight: 600; font-size: 14px; }
.switch-card .desc { font-size: 12.5px; color: var(--text-muted); }
.switch-card .form-check { margin: 0; min-height: 0; }
.switch-card .form-switch .form-check-input { width: 2.8em; height: 1.5em; margin: 0; }
.modal-hint { margin-right: auto !important; font-size: 12px; color: var(--text-subtle); }
.switch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }

/* Language tabs (bilingual content: *_gr / *_en) */
.lang-tabs { display: flex; width: fit-content; }
.lang-tabs button { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; }
.lang-code {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--surface-3);
    color: var(--text-muted);
}
.lang-tabs button.active .lang-code { background: var(--brand-soft); color: var(--brand-text); }
.lang-error { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); }
.lang-tabs button.has-error .lang-error { display: inline-block; }

/* Featured (homepage) star toggle */
.table-cms .col-featured { width: 90px; }
.star-toggle {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--text-subtle);
    font-size: 17px;
    display: inline-grid;
    place-items: center;
    transition: color .15s, background-color .15s, transform .15s;
}
.star-toggle:hover { background: var(--surface-3); color: var(--text); }
.star-toggle.on { color: var(--warning); }
.star-toggle.on:hover { background: var(--warning-soft); color: var(--warning); }
.star-toggle:active { transform: scale(.9); }
.star-toggle:disabled { opacity: .5; }
.row-sub .lang-code { margin-right: 6px; }

/* ---------- Hardware module ---------- */
.stat-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.toolbar-select { width: auto; min-width: 210px; height: 40px; padding-top: 0; padding-bottom: 0; background-color: var(--surface-2); border-color: var(--border); }
.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239A9CAB' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    /* the shared input padding above would otherwise put the text under the arrow */
    padding-right: 2.5rem;
    background-position: right .85rem center;
    background-size: 14px 10px;
    text-overflow: ellipsis;
}
.form-select-sm { padding-right: 2rem; background-position: right .6rem center; background-size: 12px 9px; }
.form-select option { background: var(--surface); color: var(--text); }

.table-cms .col-product { min-width: 240px; }
.table-cms .col-count { width: 110px; }
.count-link { text-decoration: none; transition: filter .15s; }
.count-link:hover { filter: brightness(1.2); color: var(--violet); }
.product-sub { display: flex; align-items: center; gap: 8px; -webkit-line-clamp: unset; }
.product-sub .cat-tag { padding: 1px 8px; font-size: 11px; }
.table-cms .col-price { width: 120px; }
.table-cms .col-avail { width: 140px; }

.product-cell { display: flex; align-items: center; gap: 12px; min-width: 0; }
.product-thumb {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    border-radius: 12px;
    background: var(--surface-3) center / cover no-repeat;
    border: 1px solid var(--border);
    display: grid;
    place-items: center;
    color: var(--text-subtle);
    font-size: 18px;
}
.product-meta { min-width: 0; }
.sku { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-subtle); }

.price { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.price .per { font-size: 11.5px; font-weight: 500; color: var(--text-subtle); margin-left: 2px; }
.price-old { display: block; font-size: 11.5px; font-weight: 500; color: var(--text-subtle); text-decoration: line-through; }
.price .badge-soft { margin-left: 6px; padding: 1px 6px; font-size: 10.5px; }

.avail-toggle { border: 0; background: none; padding: 0; }
.avail-toggle:disabled { opacity: .5; }
.avail-toggle .badge-soft { cursor: pointer; transition: filter .15s; }
.avail-toggle:hover .badge-soft { filter: brightness(1.15); }

/* Modal: right column + sections */
.side-panel { padding: 18px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.side-panel .switch-card { background: var(--surface); }
:root:not([data-theme="light"]) .side-panel .form-control,
:root:not([data-theme="light"]) .side-panel .form-select { background-color: var(--input-bg); }
.form-section { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--border-strong); }
.form-section-title { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin-bottom: 12px; display: flex; gap: 6px; align-items: center; }
.form-section-title .text-subtle { text-transform: none; letter-spacing: 0; font-weight: 500; }

.input-group-text {
    background: var(--surface-3);
    border: 1px solid var(--border-strong);
    color: var(--text-muted);
    font-size: 13px;
    border-radius: var(--radius-sm);
}
.input-group-prefix .input-group-text { font-family: var(--font-mono); font-size: 12px; }
.input-group > .form-control:focus { z-index: 3; }

/* Image list editor */
.image-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.image-list:empty { display: none; }
.image-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}
.image-item .drag-handle { width: 22px; }
.image-item .thumb {
    width: 52px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 8px;
    background: var(--surface-3) center / cover no-repeat;
    display: grid;
    place-items: center;
    color: var(--text-subtle);
}
.image-item .thumb.is-broken { color: var(--danger); }
.image-item .url { flex: 1; min-width: 0; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-item .main-tag { font-size: 10.5px; }
.image-list.sortable-active .image-item { cursor: grabbing; }

/* Upload: mode switch, dropzone, staging card */
.image-mode { display: flex; width: 100%; }
.image-mode button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 18px 14px;
    margin-bottom: 8px;
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-muted);
    text-align: center;
    cursor: pointer;
    transition: border-color .15s, background-color .15s, color .15s;
}
.dropzone .bi { font-size: 24px; color: var(--brand-text); }
.dropzone strong { color: var(--text); }
.dropzone small { font-size: 11.5px; color: var(--text-subtle); }
.dropzone:hover, .dropzone.is-over { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.dropzone:focus-within { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }

.upload-staging {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: var(--radius);
    background: var(--surface);
    border: 1px solid rgba(var(--brand-rgb), .35);
}
.upload-staging.d-none { display: none; }
.upload-staging .thumb {
    width: 64px;
    height: 64px;
    border-radius: 10px;
    background: var(--surface-3) center / cover no-repeat;
}
.upload-staging .form-label { font-size: 12px; margin-bottom: 4px; }
.upload-staging .form-control { padding-top: .45rem; padding-bottom: .45rem; }
.upload-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 6px; }
.upload-hint-error { color: var(--danger) !important; }
.upload-hint-error .btn-link { color: inherit; font-weight: 700; font-size: inherit; padding: 0; vertical-align: baseline; text-decoration: underline; }

/* Dashboard */
.hero-card {
    position: relative;
    overflow: hidden;
    padding: 28px;
    margin-bottom: 18px;
    background:
        radial-gradient(60% 120% at 100% 0%, rgba(var(--violet-rgb), .22), transparent 60%),
        radial-gradient(50% 120% at 0% 100%, rgba(var(--brand-rgb), .20), transparent 60%),
        var(--surface);
}
.hero-card h2 { font-size: 24px; font-weight: 800; margin: 10px 0 6px; letter-spacing: -.03em; }
.hero-card p { color: var(--text-muted); margin: 0; max-width: 60ch; }
.hero-card::after {
    content: '';
    position: absolute;
    right: 24px;
    top: 50%;
    width: 140px;
    height: 140px;
    transform: translateY(-50%);
    background: url('../images/dobby-auth.png') center / contain no-repeat;
    opacity: .08;
    filter: var(--logo-filter);
}
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.module-tile {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    color: var(--text);
    transition: transform .2s var(--ease), border-color .2s, box-shadow .2s;
}
.module-tile:hover { color: var(--text); transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow); }
.module-tile .tile-top { display: flex; justify-content: space-between; align-items: flex-start; }
.module-tile h3 { font-size: 15px; margin: 0 0 3px; }
.module-tile p { font-size: 12.5px; color: var(--text-muted); margin: 0; }
.module-tile .tile-cta { font-size: 12.5px; font-weight: 600; color: var(--text-muted); display: flex; align-items: center; gap: 4px; margin-top: auto; }
.module-tile:hover .tile-cta { color: var(--brand-text); }
.section-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; margin: 26px 0 12px; }

/* Toasts */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 1100; display: flex; flex-direction: column; gap: 10px; }
.toast-cms {
    min-width: 300px;
    max-width: 380px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 12px 12px 14px;
}
.toast-cms .icon-tile { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }
.toast-cms .toast-msg { flex: 1; font-size: 13.5px; padding-top: 5px; }
.toast-cms .btn-close { margin-top: 4px; font-size: 11px; }
.toast-cms.danger .icon-tile { background: var(--danger-soft); color: var(--danger); }
.toast-cms.warning .icon-tile { background: var(--warning-soft); color: var(--warning); }

/* ---------- Offers module ---------- */
.seg-count { font-size: 11px; font-weight: 700; color: var(--text-subtle); margin-left: 2px; }
.seg-count:empty { display: none; }
.segmented button.active .seg-count { color: var(--brand-text); }
.segmented-scroll { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented-scroll::-webkit-scrollbar { display: none; }
.segmented-scroll button { white-space: nowrap; }

.table-cms .col-discount { width: 84px; }
#ofTable .col-product { min-width: 170px; }
.table-cms .col-period { width: 200px; }
.table-cms .col-targets { width: 150px; }
.table-cms .col-state { width: 150px; }
#ofTable .col-actions { width: 120px; }
.table-cms tr.is-muted .row-title, .table-cms tr.is-muted .period { color: var(--text-muted); }
.table-cms tr.is-muted .discount-badge { filter: grayscale(1); opacity: .6; }

.discount-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    background: var(--brand-soft);
    color: var(--brand-text);
}
.period { font-size: 13px; font-weight: 600; }
.period .bi { font-size: 11px; color: var(--text-subtle); margin: 0 2px; }
.target-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.target-chip { cursor: help; }
.state-badge { font-size: 11px; }
.offer-mobile-meta { display: none; font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.offer-mobile-meta strong { color: var(--brand-text); }

.btn-xs { padding: 3px 9px; font-size: 12px; border-radius: 8px; }
.duration-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 12px; }
.text-warning-x { color: var(--warning); }

/* Target picker */
.target-panel { display: flex; flex-direction: column; height: 100%; }
.target-tabs { display: flex; width: 100%; }
.target-tabs button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.target-toolbar { display: flex; gap: 4px; align-items: center; margin-bottom: 8px; }
.target-toolbar .search-input { flex: 1; max-width: none; }
.target-toolbar .search-input .form-control { height: 36px; background: var(--surface); }
.target-list {
    list-style: none;
    margin: 0 0 8px;
    padding: 4px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    max-height: 340px;
    min-height: 120px;
    overflow-y: auto;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--border);
}
.target-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color .12s;
}
.target-item:hover { background: var(--surface-2); }
.target-item.is-checked { background: var(--brand-soft); }
.target-item .form-check-input { margin: 0; flex: 0 0 auto; }
.t-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.t-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-meta { display: flex; gap: 6px; align-items: center; font-size: 11.5px; }
.t-meta:empty { display: none; }
.t-meta .badge-soft { padding: 0 6px; font-size: 10.5px; }
.overlap { color: var(--warning); cursor: help; }
.t-price { text-align: right; font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.t-price .price-old { display: block; font-size: 11px; }
.t-price strong { color: var(--brand-text); }
.t-price .per { font-size: 11px; color: var(--text-subtle); margin-left: 2px; }
.target-empty { padding: 28px 10px; text-align: center; color: var(--text-subtle); font-size: 13px; }

/* ---------- Blog module ---------- */
.table-cms .col-author { width: 170px; }
.table-cms .col-date { width: 150px; }
#blogTable:not(.sort-mode) .col-handle { display: none; }
.post-thumb { width: 64px; height: 46px; border-radius: 10px; }
.author { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.avatar-xs { width: 24px; height: 24px; font-size: 10px; }

.blog-loading { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.blog-loading.d-none { display: none; }
.blog-title-input { font-weight: 700; font-size: 18px; }

/* Quill, themed with the CMS tokens */
.editor-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--input-bg); overflow: hidden; }
.editor-wrap:focus-within { border-color: rgba(var(--brand-rgb), .7); box-shadow: 0 0 0 4px var(--brand-soft); }
.editor-wrap .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--border); background: var(--surface-2); padding: 6px 8px; font-family: var(--font); }
.editor-wrap .ql-container.ql-snow { border: 0; font-family: var(--font); font-size: 15px; }
.editor-wrap .ql-editor { min-height: 320px; max-height: 60vh; color: var(--text); line-height: 1.7; padding: 16px 18px; }
.editor-wrap .ql-editor.ql-blank::before { color: var(--text-subtle); font-style: normal; left: 18px; }
.editor-wrap .ql-editor h2 { font-size: 1.45em; margin: .8em 0 .4em; }
.editor-wrap .ql-editor h3 { font-size: 1.2em; margin: .8em 0 .4em; }
.editor-wrap .ql-editor img { max-width: 100%; border-radius: 10px; margin: .4em 0; }
.editor-wrap .ql-editor blockquote { border-left: 3px solid var(--brand); padding-left: 14px; color: var(--text-muted); }
.editor-wrap .ql-editor a { color: var(--brand-text); }
.editor-wrap .ql-snow .ql-stroke { stroke: var(--text-muted); }
.editor-wrap .ql-snow .ql-fill { fill: var(--text-muted); }
.editor-wrap .ql-snow .ql-picker { color: var(--text-muted); }
.editor-wrap .ql-snow button:hover .ql-stroke, .editor-wrap .ql-snow button.ql-active .ql-stroke,
.editor-wrap .ql-snow .ql-picker-label:hover .ql-stroke, .editor-wrap .ql-snow .ql-picker-label.ql-active .ql-stroke { stroke: var(--brand-text); }
.editor-wrap .ql-snow button:hover .ql-fill, .editor-wrap .ql-snow button.ql-active .ql-fill { fill: var(--brand-text); }
.editor-wrap .ql-snow .ql-picker-label:hover, .editor-wrap .ql-snow .ql-picker-label.ql-active,
.editor-wrap .ql-snow .ql-picker-item:hover, .editor-wrap .ql-snow .ql-picker-item.ql-selected { color: var(--brand-text); }
.editor-wrap .ql-snow .ql-picker-options { background: var(--surface); border-color: var(--border-strong) !important; border-radius: 10px; box-shadow: var(--shadow); }
.editor-wrap .ql-snow .ql-tooltip { background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); z-index: 5; }
.editor-wrap .ql-snow .ql-tooltip input[type=text] { background: var(--input-bg); color: var(--text); border: 1px solid var(--border-strong); border-radius: 8px; }
.editor-wrap .ql-snow .ql-tooltip a { color: var(--brand-text); }

/* Inline image insert panel */
.editor-insert { padding: 14px; margin-bottom: 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px dashed rgba(var(--brand-rgb), .45); }
.editor-insert.d-none { display: none; }
.dropzone-compact { padding: 12px; flex-direction: row; justify-content: center; gap: 10px; flex-wrap: wrap; }
.dropzone-compact .bi { font-size: 18px; }

/* SEO collapsible */
.seo-details > summary { cursor: pointer; list-style: none; }
.seo-details > summary::-webkit-details-marker { display: none; }
.seo-details > summary::after { content: '\F282'; font-family: 'bootstrap-icons'; margin-left: auto; transition: transform .2s; }
.seo-details[open] > summary::after { transform: rotate(180deg); }

/* Publishing panel */
.status-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.status-option { position: relative; margin: 0; cursor: pointer; }
.status-option input { position: absolute; opacity: 0; pointer-events: none; }
.status-option > span {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition: border-color .15s, background-color .15s;
}
.status-option > span .bi { font-size: 16px; color: var(--text-muted); margin-bottom: 2px; }
.status-option strong { font-size: 13px; }
.status-option small { font-size: 11.5px; color: var(--text-subtle); }
.status-option:hover > span { border-color: var(--border-strong); }
.status-option.is-checked > span { border-color: rgba(var(--brand-rgb), .7); background: var(--brand-soft); }
.status-option.is-checked > span .bi { color: var(--brand-text); }
.status-option input:focus-visible + span { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }
.publish-summary { margin-top: 12px; font-size: 12.5px; color: var(--text-muted); line-height: 1.5; }
.publish-summary:empty { display: none; }

/* Cover */
.cover-preview {
    aspect-ratio: 16 / 9;
    border-radius: var(--radius-sm);
    background: var(--surface) center / cover no-repeat;
    border: 1px dashed var(--border-strong);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-subtle);
    font-size: 12.5px;
}
.cover-preview .bi { font-size: 26px; }
.cover-preview.has-image { border-style: solid; border-color: var(--border); }
.cover-path { font-family: var(--font-mono); font-size: 11px; color: var(--text-subtle); margin-top: 4px; word-break: break-all; }
.cover-path:empty { display: none; }

/* Unsaved changes */
.unsaved-bar {
    margin-right: auto !important;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
    color: var(--warning);
    animation: fadeUp .2s var(--ease);
}
.unsaved-bar ~ .modal-hint { display: none; }

/* ---------- Users module ---------- */
.table-cms .col-role { width: 120px; }
.table-cms .col-login { width: 100px; }
.table-cms .col-last { width: 160px; }
.avatar.role-admin { background: linear-gradient(135deg, var(--brand), #ff7a8f); }
.avatar.role-editor { background: linear-gradient(135deg, var(--violet), #b3a8ff); }
.avatar.role-customer { background: linear-gradient(135deg, #1fa77a, var(--success)); }
.avatar.has-img { background: var(--surface-3) center / cover no-repeat; }
.you-tag { margin-left: 6px; padding: 0 7px; font-size: 10.5px; vertical-align: 2px; }
.text-verified { color: var(--success); font-size: 12px; }
.login-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 7px;
    margin-right: 4px;
    border-radius: 8px;
    font-size: 11.5px;
    background: var(--surface-3);
    color: var(--text-muted);
}
.login-methods { display: inline-flex; }

.role-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.role-options .status-option input:disabled + span { opacity: .55; cursor: not-allowed; }

.pw-meter { height: 4px; border-radius: 4px; background: var(--surface-3); margin-top: 8px; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--danger); transition: width .25s var(--ease), background-color .25s; }
.pw-meter[data-score="2"] span { background: var(--warning); }
.pw-meter[data-score="3"] span { background: #8bd450; }
.pw-meter[data-score="4"] span { background: var(--success); }

.biz-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.biz-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.biz-item .icon-tile { width: 32px; height: 32px; border-radius: 10px; font-size: 15px; }
.biz-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.biz-main strong { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.biz-main small { font-size: 11.5px; color: var(--text-subtle); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.biz-item .form-select { width: auto; min-width: 130px; }
.biz-empty { padding: 14px; text-align: center; font-size: 13px; color: var(--text-subtle); }
.biz-add { display: flex; gap: 6px; }
.biz-add .form-control { max-width: 150px; }
.biz-add .form-select { max-width: 170px; }

/* ---------- 7. Responsive ---------- */
@media (max-width: 1399.98px) {
    /* Laptop with sidebar (≤1399): secondary columns live in the modal / state badge */
    #blogTable .col-author, #blogTable .cell-author, #blogTable .col-date, #blogTable .cell-date { display: none; }
    .table-cms .col-avail, .table-cms td.cell-avail { display: none; }
    .table-cms .col-product { min-width: 180px; }
    #ofTable .col-targets, #ofTable td:nth-child(4) { display: none; }
    #usrTable .col-last, #usrTable .cell-last { display: none; }
    #hwTable .col-order, #hwTable td.cell-order { display: none; }
}

@media (max-width: 1099.98px) {
    .status-cell .status-text { display: none; }
    .state-badge { white-space: normal; text-align: left; }
    /* Offers: discount + period move under the title */
    #ofTable th:nth-child(2), #ofTable td:nth-child(2), #ofTable th:nth-child(3), #ofTable td:nth-child(3) { display: none; }
    #ofTable .col-product { min-width: 0; }
    .offer-mobile-meta { display: block; }
}

@media (max-width: 1199.98px) {
    .stat-grid { gap: 10px; }
    #usrTable .col-login, #usrTable .cell-login { display: none; }
    .toolbar-hint { display: none; }
}

@media (max-width: 991.98px) {
    .auth { grid-template-columns: 1fr; padding: 0; }
    .auth-brand { display: none; }
    .auth-panel { border-radius: 0; border: 0; min-height: 100vh; }

    .app { padding: 0; }
    .app-frame {
        border-radius: 0;
        border: 0;
        min-height: 100vh;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: "top" "main";
    }
    .topbar { border-radius: 0; padding: 0 14px; gap: 10px; border-bottom: 1px solid var(--border); }
    .topbar-brand { width: auto; }
    .topbar-brand .env-tag { display: none; }
    .menu-toggle { display: inline-flex; }
    .quick-search { display: none; }
    .user-chip .meta, .topbar-divider { display: none; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        height: 100vh;
        width: min(300px, 86vw);
        background: var(--frame);
        z-index: 1050;
        padding-top: 18px;
        transform: translateX(-100%);
        transition: transform .28s var(--ease);
        border-right: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
    }
    .app.sidebar-open .sidebar { transform: none; }
    .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: var(--backdrop);
        z-index: 1040;
        opacity: 0;
        pointer-events: none;
        transition: opacity .25s;
    }
    .app.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

    .main { margin: 0; border-radius: 0; border: 0; padding: 20px 16px 32px; }

    /* Tablet: drop one secondary column per wide table */
    #blogTable .col-author, #blogTable .cell-author { display: none; }
    .table-cms .col-avail, .table-cms td.cell-avail { display: none; }
    #ofTable .col-targets, #ofTable td:nth-child(4) { display: none; }
}

@media (max-width: 767.98px) {
    .page-title { font-size: 23px; }
    .page-head { align-items: flex-start; }
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
    .stat-card .icon-tile { width: 34px; height: 34px; font-size: 16px; border-radius: 10px; }
    .stat-card .value { font-size: 20px; }
    .list-toolbar { padding: 12px; }
    .search-input { max-width: none; flex-basis: 100%; }
    .table-cms .col-order, .table-cms td.cell-order { display: none; }
    .table-cms .col-status { width: auto; }
    .status-cell .status-text { display: none; }
    .row-sub { display: none; }
    .row-sub.product-sub { display: flex; }
    .product-sub .sku { display: none; }
    .table-cms .col-product { min-width: 0; }
    .table-cms .col-price { width: auto; }
    .price-old, .price .badge-soft { display: none; }
    .table-cms .col-actions { width: auto; padding-right: 12px; font-size: 0; }
    .table-cms .col-handle { padding-left: 10px; }
    .row-actions [data-action="edit"] { display: none; }   /* the title already opens the editor */
    .table-cms .col-featured { width: auto; font-size: 0; }
    .switch-grid { grid-template-columns: 1fr; }
    .stat-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .toolbar-select { flex: 1 1 auto; min-width: 0; }
    .table-cms .col-avail, .table-cms td.cell-avail { display: none; }
    .product-thumb { display: none; }
    .table-cms .col-status { font-size: 0; }
    .table-cms tbody td { padding-left: 8px; padding-right: 8px; }
    .product-sub { flex-wrap: wrap; }
    #ofTable th:nth-child(2), #ofTable td:nth-child(2), #ofTable th:nth-child(3), #ofTable td:nth-child(3),
    #ofTable .col-targets, #ofTable td:nth-child(4) { display: none; }
    #ofTable .col-product { min-width: 0; }
    .offer-mobile-meta { display: block; }
    #ofTable [data-action="duplicate"] { display: none; }
    #blogTable .col-author, #blogTable .cell-author { display: none; }
    #blogTable .col-date, #blogTable .cell-date { display: none; }
    #usrTable .col-login, #usrTable .cell-login, #usrTable .col-last, #usrTable .cell-last { display: none; }
    #usrTable .avatar { display: none; }
    .role-options { grid-template-columns: 1fr; }
    .biz-add { flex-wrap: wrap; }
    .biz-item { flex-wrap: wrap; }
    .status-options { grid-template-columns: 1fr 1fr; }
    .table-cms .col-period { width: auto; }
    .period { white-space: normal; }
    .table-cms .col-state { width: auto; font-size: 0; }
    .target-tabs button { font-size: 0; gap: 4px; }
    .target-tabs button .bi, .target-tabs button .seg-count { font-size: 14px; }
    .hero-card::after { display: none; }
    .toast-stack { left: 12px; right: 12px; bottom: 12px; }
    .toast-cms { max-width: none; min-width: 0; }
    .modal-hint { display: none; }
}

/* =====================================================================
   8. CRM
   ===================================================================== */

/* ---------- 8.0 CRM identity & login ----------
   The CRM must never be mistaken for the Website CMS: own palette (section 1), own display font,
   the "CRM" mark next to the wordmark everywhere, and a different login layout (one centred form card). */
h1, h2, h3, .page-title, .stat-card .value, .dash-kv .v, .kpi-tile .v { font-family: var(--font-display); }

.crm-lockup { display: inline-flex; align-items: center; gap: 10px; }
.crm-lockup .brand-wordmark { height: 22px; }
.crm-mark {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 13px;
    letter-spacing: .14em;
    line-height: 1;
    padding: 6px 9px 6px 11px;
    border-radius: 7px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--violet));
    box-shadow: 0 6px 16px -8px rgba(var(--brand-rgb), .8);
}
.topbar-brand .crm-lockup .brand-wordmark { height: 20px; }

.crm-workspace { gap: 12px; }
.crm-workspace .icon-tile { width: 38px; height: 38px; border-radius: 10px; font-size: 17px; background: var(--brand); color: #fff; }
.crm-workspace .title { font-family: var(--font-display); font-size: 15px; }
/* User colors (users.color) can be very dark: a ring keeps the avatar visible on dark surfaces */
.avatar { box-shadow: 0 0 0 2px var(--border-strong); }
/* Dashboard hero: no CMS mascot watermark — the CRM grid pattern instead */
.hero-card::after { display: none; }
.hero-card { background: radial-gradient(60% 140% at 100% 0%, rgba(var(--brand-rgb), .22), transparent 60%), radial-gradient(40% 120% at 0% 100%, rgba(var(--violet-rgb), .16), transparent 60%), linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 32px 32px, linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 32px 32px, var(--surface); }

.boot-lockup { display: flex; flex-direction: column; align-items: center; gap: 22px; }
.boot-lockup .brand-wordmark { height: 26px; }

/* Login: full-bleed grid background, top bar with the lockup, form card + pipeline panel */
.crm-auth { position: relative; min-height: 100vh; display: flex; flex-direction: column; padding: 22px clamp(16px, 4vw, 56px); overflow: hidden; }
.crm-auth-bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(45% 50% at 50% 35%, rgba(var(--brand-rgb), .26), transparent 70%),
        radial-gradient(35% 40% at 50% 90%, rgba(var(--violet-rgb), .16), transparent 70%),
        linear-gradient(var(--border) 1px, transparent 1px) 0 0 / 44px 44px,
        linear-gradient(90deg, var(--border) 1px, transparent 1px) 0 0 / 44px 44px,
        var(--bg);
}
.crm-auth > *:not(.crm-auth-bg) { position: relative; z-index: 1; }
.crm-auth-top { display: flex; align-items: center; justify-content: space-between; }
.crm-auth-top .brand-wordmark { height: 26px; }
.crm-auth-top .crm-mark { font-size: 14px; }
.crm-auth-body {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
    gap: clamp(28px, 6vw, 96px);
    align-items: center;
    padding: 28px 0;
}
.crm-auth.is-single .crm-auth-body { grid-template-columns: minmax(0, 460px); justify-content: center; }

.crm-login-card {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-top: 3px solid var(--brand);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 34px 32px 26px;
    animation: fadeUp .4s var(--ease);
}
.crm-login-card.is-shaking { animation: shake .45s; }
.crm-login-head { margin-bottom: 24px; }
.crm-login-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -.03em; margin: 14px 0 6px; }
.crm-login-head p { color: var(--text-muted); margin: 0; }
.crm-word { color: var(--brand-text); }
.crm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 6px;
    color: var(--violet);
    background: var(--violet-soft);
    text-transform: uppercase;
    letter-spacing: .06em;
}
.crm-login-card .input-icon .form-control { height: 50px; background: var(--input-bg); }
.crm-login-card .btn-lg-block { height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 700; }
.crm-login-card .btn-lg-block .bi { font-size: 22px; }

.crm-auth-foot { font-size: 12.5px; color: var(--text-subtle); }

@media (max-width: 991.98px) {
    .crm-auth-body { grid-template-columns: minmax(0, 1fr); justify-items: center; }
    .crm-login-card { width: 100%; max-width: 460px; }
}
@media (max-width: 575.98px) {
    .crm-auth { padding: 16px; }
    .crm-login-card { padding: 26px 20px 20px; }
    .crm-login-head h1 { font-size: 26px; }
    .crm-auth-top .brand-wordmark { height: 22px; }
}

/* ---------- 8.1 Shell additions ---------- */
.perm-hidden { display: none !important; }            /* App.applyPermissions: hidden, never just disabled */
.btn-reset { border: 0; background: none; padding: 0; color: inherit; font: inherit; text-align: inherit; }
.user-chip.btn-reset { border-radius: 999px; padding: 4px 10px 4px 4px; transition: background-color .15s; }
.user-chip.btn-reset:hover, .user-chip.btn-reset[aria-expanded="true"] { background: var(--surface-2); }
.user-chip .chip-caret { font-size: 11px; color: var(--text-subtle); }
.dropdown-item-text:empty { display: none; }
.nav-link-x > span:first-of-type { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Confirm + preview modals */
.modal-confirm { max-width: 460px; }
.confirm-icon { width: 52px; height: 52px; border-radius: 16px; font-size: 22px; }
.confirm-body .form-label { font-size: 12.5px; }
.preview-content { height: min(88vh, 1000px); }
.preview-content [data-preview-body] { display: flex; background: var(--surface-2); min-height: 0; flex: 1; }
.preview-frame { border: 0; width: 100%; flex: 1; background: #fff; }
.preview-image { max-width: 100%; max-height: 100%; margin: auto; object-fit: contain; padding: 12px; }

/* Upload staging: file (PDF) thumbnail */
.upload-staging .thumb.is-file { display: grid; place-items: center; font-size: 26px; color: var(--brand-text); }

/* Status pill in the color of a customer status (color comes validated from App.util.color) */
.status-pill {
    --pill: var(--text-subtle);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: 11.5px;
    font-weight: 600;
    padding: .22rem .6rem;
    border-radius: 999px;
    white-space: nowrap;
    color: var(--text);
    background: color-mix(in srgb, var(--pill) 16%, transparent);
    border: 1px solid color-mix(in srgb, var(--pill) 34%, transparent);
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--pill); flex: 0 0 auto; }

.badge-soft.danger { background: var(--danger-soft); color: var(--danger); }
.icon-tile.warning { background: var(--warning-soft); color: var(--warning); }
.icon-tile.danger { background: var(--danger-soft); color: var(--danger); }
.text-success-x { color: var(--success) !important; }
.text-danger-x { color: var(--danger) !important; }
.text-warning-x { color: var(--warning) !important; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.skeleton-card { padding: 18px; }

/* Back link on detail pages */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 10px; }
.back-link:hover { color: var(--text); }

/* Progress (onboarding, targets): bar = actual, marker = time elapsed */
.progress-x { position: relative; height: 8px; border-radius: 99px; background: var(--surface-3); }
.progress-x > .bar { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--violet), var(--brand)); transition: width .4s var(--ease); max-width: 100%; }
.progress-x > .bar.is-done { background: var(--success); }
.progress-x > .marker { position: absolute; top: -4px; width: 2px; height: 16px; border-radius: 2px; background: var(--text-muted); transform: translateX(-1px); }

/* ---------- 8.2 Dashboard ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px; }
.dash-card { padding: 18px; display: flex; flex-direction: column; min-width: 0; grid-column: span 4; }
.dash-card.span-6 { grid-column: span 6; }
.dash-card.span-8 { grid-column: span 8; }
.dash-card.span-12 { grid-column: span 12; }
.dash-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.dash-card-head .icon-tile { width: 36px; height: 36px; border-radius: 11px; font-size: 16px; }
.dash-card-head h3 { font-size: 15px; margin: 0; }
.dash-card-head .sub { font-size: 12px; color: var(--text-muted); }
.dash-card-head .more { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.dash-card-head .more:hover { color: var(--brand-text); }
.dash-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dash-kv > div, .dash-kv > a { padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); min-width: 0; color: var(--text); }
.dash-kv > a:hover { border-color: var(--border-strong); color: var(--text); }
.dash-kv .k { font-size: 12px; color: var(--text-muted); }
.dash-kv .v { font-size: 19px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dash-kv .v.danger { color: var(--danger); }
.dash-kv .wide { grid-column: 1 / -1; }

.agenda { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.agenda li > a, .agenda li > .agenda-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    transition: border-color .15s, background-color .15s;
}
.agenda li > a:hover { border-color: var(--border-strong); background: var(--surface-3); color: var(--text); }
.agenda .when { flex: 0 0 auto; min-width: 52px; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 13px; }
.agenda .when.is-late { color: var(--danger); }
.agenda .what { min-width: 0; flex: 1; }
.agenda .what strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda .what small { display: block; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agenda .end { flex: 0 0 auto; }
.agenda .agenda-pill { display: block; margin-top: 5px; }
.min-w-0 { min-width: 0; }
.dash-card-head > .min-w-0 { flex: 1; }
.agenda-empty { padding: 18px 10px; text-align: center; color: var(--text-subtle); font-size: 13px; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); }

.kpi-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kpi-tile { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.kpi-tile .k { font-size: 12px; color: var(--text-muted); display: flex; gap: 4px; align-items: center; }
.kpi-tile .v { font-size: 20px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi-group-title { font-size: 12px; font-weight: 700; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .07em; margin: 16px 0 8px; }
.kpi-group-title:first-child { margin-top: 0; }

.target-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.target-row:last-child { border-bottom: 0; }
.target-row .name { font-weight: 600; font-size: 13.5px; }
.target-row .meta { font-size: 12px; color: var(--text-muted); }
.target-row .pct { font-weight: 800; font-variant-numeric: tabular-nums; }
.target-row .progress-x { grid-column: 1 / -1; }

/* ---------- 8.4 Lists (server-side) ---------- */
.list-pager { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.list-pager:empty { display: none; }
.pager-info { font-size: 12.5px; color: var(--text-muted); }
.pager-size .form-select { width: auto; height: 32px; padding-top: 0; padding-bottom: 0; background-color: var(--surface-2); }
.pager-nav { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.pager-page { font-size: 12.5px; font-weight: 600; color: var(--text-muted); font-variant-numeric: tabular-nums; min-width: 54px; text-align: center; }
.table-cms th[data-sort] { cursor: pointer; user-select: none; }
.table-cms th[data-sort]:hover { color: var(--text); }
.table-cms th[data-sort]::after { content: '\F282'; font-family: 'bootstrap-icons'; font-size: 9px; margin-left: 4px; opacity: .35; }
.table-cms th[aria-sort="ascending"]::after { content: '\F286'; opacity: 1; color: var(--brand-text); }
.table-cms th[aria-sort="descending"]::after { content: '\F282'; opacity: 1; color: var(--brand-text); }
.table-cms tr.is-muted td { opacity: .7; }
.cell-strong { font-weight: 600; font-size: 13.5px; }
.link-phone { display: inline-flex; gap: 4px; align-items: center; color: var(--text-muted); }
.link-phone:hover { color: var(--brand-text); }
a.row-title { display: inline-block; }
.filter-panel { padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filter-panel .form-label { font-size: 12px; margin-bottom: 4px; color: var(--text-muted); }
.filter-panel .form-control, .filter-panel .form-select { height: 38px; padding-top: .3rem; padding-bottom: .3rem; }
.date-range { display: flex; align-items: center; gap: 6px; }
.date-range .form-control { height: 40px; width: 150px; background: var(--surface-2); }
.stat-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat-btn { border: 1px solid var(--border); text-align: left; color: var(--text); transition: border-color .15s, box-shadow .15s; }
.stat-btn:hover { border-color: var(--border-strong); }
.stat-btn.is-active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* Status chips (filter) + pill button (change status) */
.status-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.status-chip {
    --pill: var(--text-subtle);
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 999px;
    font-size: 12.5px; font-weight: 600;
    color: var(--text-muted); background: var(--surface); border: 1px solid var(--border);
    transition: background-color .15s, border-color .15s, color .15s;
}
.status-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--pill); }
.status-chip .count { font-size: 11px; color: var(--text-subtle); font-variant-numeric: tabular-nums; }
.status-chip:hover { color: var(--text); border-color: var(--border-strong); }
.status-chip.is-active { color: var(--text); background: color-mix(in srgb, var(--pill) 18%, var(--surface)); border-color: color-mix(in srgb, var(--pill) 55%, transparent); }
.status-chip[data-status=""].is-active { background: var(--nav-active-bg); color: var(--nav-active-text); border-color: transparent; }
.pill-btn { border: 0; background: none; padding: 0; display: inline-flex; align-items: center; gap: 4px; color: var(--text-subtle); border-radius: 999px; }
.pill-btn .bi { font-size: 10px; }
.pill-btn:hover .status-pill { filter: brightness(1.15); }
.pill-btn:hover { color: var(--text); }

/* Status modal */
.status-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.status-choice { --pill: var(--text-subtle); cursor: pointer; }
.status-choice > span {
    display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border-radius: 10px;
    font-weight: 600; font-size: 13px; border: 1px solid var(--border-strong); background: var(--surface-2);
}
.status-choice .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--pill); }
.status-choice input:checked + span { border-color: var(--pill); background: color-mix(in srgb, var(--pill) 18%, var(--surface)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pill) 25%, transparent); }
.status-choice input:focus-visible + span { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }

/* Quick call */
.call-contact { display: flex; gap: 10px; align-items: flex-end; }
.call-dial { white-space: nowrap; height: 42px; display: inline-flex; align-items: center; gap: 6px; }
.outcome-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.outcome-option { cursor: pointer; }
.outcome-box {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 86px; padding: 10px 6px; border-radius: var(--radius); text-align: center;
    font-size: 12.5px; font-weight: 600; background: var(--surface-2); border: 1.5px solid var(--border-strong);
    transition: border-color .12s, background-color .12s, transform .12s;
}
.outcome-box .bi { font-size: 20px; }
.outcome-box kbd { position: absolute; top: 6px; right: 6px; font-size: 10px; padding: 0 5px; }
.outcome-option:hover .outcome-box { border-color: var(--text-subtle); }
.outcome-option input:focus-visible + .outcome-box { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }
.outcome-option.tone-success .bi { color: var(--success); }
.outcome-option.tone-warning .bi { color: var(--warning); }
.outcome-option.tone-danger .bi { color: var(--danger); }
.outcome-option.tone-violet .bi { color: var(--violet); }
.outcome-option.is-checked .outcome-box { border-color: var(--brand); background: var(--brand-soft); transform: translateY(-1px); }
.quick-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-muted); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; }
.chip-btn:hover { color: var(--text); border-color: var(--brand); }

/* ---------- 8.5 Customer card ---------- */
.cust-head { padding: 20px 22px; }
.cust-head-top { display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.cust-head-id { display: flex; gap: 14px; min-width: 0; flex: 1 1 360px; }
.cust-avatar {
    --pill: var(--brand);
    width: 54px; height: 54px; flex: 0 0 auto; border-radius: 14px; display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 800; font-size: 19px; color: #fff;
    background: linear-gradient(135deg, var(--pill), color-mix(in srgb, var(--pill) 55%, var(--brand)));
}
.cust-head .page-title { font-size: 25px; }
.cust-meta { color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.cust-meta .sep { color: var(--text-subtle); }
.cust-tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.cust-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cust-head-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-top: 18px; }
.head-stat { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); min-width: 0; }
.head-stat .k { font-size: 12px; color: var(--text-muted); }
.head-stat .v { font-weight: 700; font-size: 16px; margin-top: 2px; }
.head-stat .s { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.head-people { grid-column: span 2; }
.head-people .v { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; font-weight: 500; }
.person-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.person-chip small { color: var(--text-subtle); font-size: 11px; }
.avatar.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

.card-tabs { display: flex; gap: 4px; margin: 18px 0 14px; overflow-x: auto; padding-bottom: 2px; border-bottom: 1px solid var(--border); }
.card-tab {
    display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
    border: 0; background: none; color: var(--text-muted); font-weight: 600; font-size: 13.5px;
    padding: 10px 12px; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.card-tab:hover { color: var(--text); }
.card-tab.active { color: var(--brand-text); border-bottom-color: var(--brand); }
.card-pane:focus { outline: none; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0 0 6px; }
.detail-grid dt { font-size: 11.5px; font-weight: 600; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .05em; }
.detail-grid dd { margin: 2px 0 0; font-size: 13.5px; overflow-wrap: anywhere; }
.note-block { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border-left: 3px solid var(--violet); }
.note-title { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.note-text, .tl-text, .mini-card-note { white-space: pre-wrap; overflow-wrap: anywhere; }
.alert-info-x { background: var(--violet-soft); color: var(--text); border: 1px solid rgba(var(--violet-rgb), .25); display: flex; gap: 8px; align-items: center; }

.composer { display: flex; flex-direction: column; gap: 8px; }
.composer textarea { min-height: 72px; }
.composer-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 17px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; display: flex; gap: 12px; padding: 8px 0; }
.tl-icon { position: relative; z-index: 1; width: 36px !important; height: 36px !important; border-radius: 11px !important; font-size: 15px !important; box-shadow: 0 0 0 4px var(--surface); }
.tl-body { flex: 1; min-width: 0; padding-top: 2px; }
.tl-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.tl-title { font-size: 13.5px; }
.tl-head time { font-size: 12px; color: var(--text-subtle); margin-left: auto; white-space: nowrap; }
.tl-actions { display: inline-flex; gap: 2px; }
.tl-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.tl-text { margin-top: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13.5px; }
.kind-comment .tl-text { border-left: 3px solid var(--violet); }
.diff-list { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 3px; font-size: 12.5px; }
.diff-list li { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.diff-list .k { color: var(--text-muted); font-weight: 600; }
.diff-list .old { color: var(--text-subtle); text-decoration: line-through; }
.diff-list .new { color: var(--text); }
.diff-list .bi { font-size: 10px; color: var(--text-subtle); }

.pane-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.mini-list { display: grid; gap: 8px; }
.mini-card { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.mini-card-head { display: flex; align-items: center; gap: 8px; }
.mini-card-lines { margin-top: 6px; display: grid; gap: 3px; font-size: 13px; color: var(--text-muted); }
.mini-card-lines a { color: var(--text-muted); }
.mini-card-lines a:hover { color: var(--brand-text); }
.mini-card-note { margin-top: 8px; font-size: 12.5px; color: var(--text-muted); }
.asg-add { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.asg-add .form-select { width: auto; min-width: 180px; }

@media (max-width: 1399.98px) {
    #custTable .col-updated, #callsTable .col-notes { display: none; }
}
@media (max-width: 1199.98px) {
    #custTable .col-owner { display: none; }
    .stat-grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 991.98px) {
    #custTable .col-place { display: none; }
    .outcome-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) {
    .cust-head-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .head-people { grid-column: 1 / -1; }
    .cust-head { padding: 16px; }
    .detail-grid { grid-template-columns: minmax(0, 1fr); }
    .cust-head-actions { width: 100%; }
    .cust-head-actions .btn-brand { flex: 1; }
    .stat-grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .date-range { width: 100%; }
    .date-range .form-control { width: auto; flex: 1 1 0; min-width: 0; }
}
@media (max-width: 575.98px) {
    /* card layout shows every column again, with its label */
    #custTable td.col-place, #custTable td.col-owner, #custTable td.col-updated, #callsTable td.col-notes { display: flex; }
    .outcome-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .outcome-box { min-height: 70px; }
    .call-contact { flex-direction: column; align-items: stretch; }
    .status-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
    .status-chip { flex: 0 0 auto; }
    .pager-nav { margin-left: 0; width: 100%; justify-content: space-between; }
}

/* ---------- 8.6 Appointments & calendar ---------- */
/* Radio groups drawn as segmented controls (<label><input class="visually-hidden"><span>) */
.seg-wrap { flex-wrap: wrap; }
.seg-wrap label { margin: 0; cursor: pointer; }
.seg-wrap label > span { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 9px; font-weight: 600; font-size: 12.5px; color: var(--text-muted); }
.seg-wrap label:hover > span { color: var(--text); }
.seg-wrap label.active > span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
:root:not([data-theme="light"]) .seg-wrap label.active > span { background: var(--surface-3); }
.seg-wrap input:focus-visible + span { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 1px; }
.seg-scroll { max-width: 100%; min-width: 0; overflow-x: auto; }
.list-toolbar > * { min-width: 0; }
.seg-scroll button { white-space: nowrap; }

.choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { margin: 0; cursor: pointer; }
.choice > span { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px; font-weight: 600; font-size: 13px; border: 1.5px solid var(--border-strong); background: var(--surface-2); }
.choice.is-checked > span { border-color: var(--brand); background: var(--brand-soft); }
.choice input:focus-visible + span { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }

.people-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.person-toggle { display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 5px; border-radius: 999px; cursor: pointer; margin: 0;
    border: 1.5px solid var(--border-strong); background: var(--surface-2); font-size: 13px; font-weight: 500; }
.person-toggle.is-checked { border-color: var(--brand); background: var(--brand-soft); }
.person-toggle:focus-within { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }

/* Customer picker */
.customer-picker { position: relative; }
.customer-picker .input-icon .form-control { height: 44px; }
.customer-picker .form-control.is-locked { background: var(--surface-2); }
.picker-results { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0; display: none; max-height: 300px; overflow: auto;
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 4px; }
.picker-results.show { display: block; }
.picker-results button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; width: 100%; border: 0; background: none; text-align: left; padding: 8px 10px; border-radius: 9px; color: var(--text); }
.picker-results button .status-pill { grid-row: 1 / span 2; grid-column: 2; align-self: center; }
.picker-results button.is-active, .picker-results button:hover { background: var(--surface-2); }
.picker-name { font-weight: 600; font-size: 13.5px; }
.picker-sub { font-size: 12px; color: var(--text-muted); }
.picker-empty { padding: 12px; text-align: center; color: var(--text-subtle); font-size: 13px; }

/* Appointment list (grouped per day) */
.appt-days { padding: 6px 18px 18px; }
.appt-day { margin-top: 14px; }
.appt-day-title { font-size: 13px; font-weight: 700; color: var(--text-muted); text-transform: capitalize; display: flex; gap: 8px; align-items: center; margin: 0 0 8px; }
.appt-day.is-today .appt-day-title { color: var(--brand-text); }
.appt-row {
    --who: var(--violet);
    display: grid; grid-template-columns: 64px minmax(0, 1fr) auto auto auto; gap: 12px; align-items: center;
    width: 100%; text-align: left; color: var(--text);
    padding: 10px 12px; margin-bottom: 6px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--who);
}
button.appt-row:hover { border-color: var(--border-strong); border-left-color: var(--who); }
.appt-row.is-done { opacity: .72; }
.appt-time { border: 0; background: none; padding: 0; color: var(--text); display: flex; flex-direction: column; font-variant-numeric: tabular-nums; text-align: left; }
.appt-time strong { font-size: 14.5px; }
.appt-time small { font-size: 11.5px; color: var(--text-muted); }
.appt-main { min-width: 0; display: flex; flex-direction: column; }
.appt-main .row-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-people { display: flex; }
.appt-people .avatar + .avatar, .appt-people span + span .avatar { margin-left: -6px; }
.appt-status { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* Calendar */
.cal-toolbar { gap: 10px 16px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { font-size: 16px; margin: 0 0 0 8px; text-transform: capitalize; white-space: nowrap; }
.cal-filters { display: flex; align-items: center; gap: 14px; margin-left: auto; flex-wrap: wrap; }
.cal-filters .form-select { width: auto; min-width: 170px; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 10px 18px 0; font-size: 12.5px; color: var(--text-muted); }
.cal-legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }
.cal-body { padding: 10px 0 0; }
.cal-grid { --days: 7; }
.cal-head, .cal-scroll { display: grid; grid-template-columns: 56px minmax(0, 1fr); }
.cal-head { grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.cal-day-head { padding: 6px 4px 8px; text-align: center; display: flex; flex-direction: column; font-size: 12px; color: var(--text-muted); text-transform: capitalize; }
.cal-day-head strong { font-size: 18px; color: var(--text); font-family: var(--font-display); }
.cal-day-head.is-today strong { color: #fff; background: var(--brand); border-radius: 10px; width: 34px; margin: 2px auto 0; }
.cal-scroll { max-height: 640px; overflow-y: auto; position: relative; }
.cal-hours { position: relative; }
.cal-hour { position: relative; border-top: 1px solid var(--border); }
.cal-hour span { position: absolute; top: -8px; right: 8px; font-size: 11px; color: var(--text-subtle); background: var(--surface); padding: 0 2px; font-variant-numeric: tabular-nums; }
.cal-hour:first-child span { display: none; }
.cal-cols { display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr));
    background-image: linear-gradient(var(--border) 1px, transparent 1px); background-size: 100% 56px; }
.cal-col { position: relative; border-left: 1px solid var(--border); }
.cal-col.is-today { background: color-mix(in srgb, var(--brand) 5%, transparent); }
.cal-col.can-create { cursor: copy; }
.cal-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); z-index: 3; }
.cal-now::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.cal-event {
    --who: var(--violet);
    position: absolute; z-index: 2; overflow: hidden; text-align: left; cursor: pointer;
    display: flex; flex-direction: column; gap: 1px; padding: 4px 6px;
    border: 0; border-left: 3px solid var(--who); border-radius: 7px;
    background: color-mix(in srgb, var(--who) 22%, var(--surface)); color: var(--text); font-size: 11.5px; line-height: 1.25;
    box-shadow: var(--shadow-sm);
}
.cal-event:hover, .cal-event:focus-visible { z-index: 4; background: color-mix(in srgb, var(--who) 34%, var(--surface)); }
.cal-event.kind-wo { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--who) 10%, transparent) 6px 12px); }
.cal-event.is-done { opacity: .6; }
.ev-time { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ev-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-sub { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-list-row { cursor: pointer; }

@media (max-width: 991.98px) {
    .cal-filters { margin-left: 0; width: 100%; }
}
@media (max-width: 767.98px) {
    .cal-view-week { display: none; }
    .cal-title { font-size: 14px; margin-left: 4px; }
    .appt-row { grid-template-columns: 56px minmax(0, 1fr) auto; }
    .appt-row .appt-status { grid-column: 2 / -1; justify-content: flex-start; }
    .appt-row .appt-people { grid-column: 3; grid-row: 1; }
    .appt-row .row-actions { grid-column: 3; grid-row: 2; justify-content: flex-end; }
    .appt-days { padding: 4px 12px 14px; }
}

/* ---------- 8.7 Quotes ---------- */
.q-head { padding: 20px 22px; }
.q-head-main { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.q-head .page-title { font-size: 24px; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.q-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 14px; margin-top: 14px; align-items: start; }
.q-side { position: sticky; top: calc(var(--topbar-h) + 8px); }
.q-add { display: flex; gap: 6px; flex-wrap: wrap; }

.q-lines { padding: 6px 12px 12px; }
.q-lines-list { display: grid; gap: 8px; }
.q-line { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.q-line.is-monthly { border-left: 3px solid var(--violet); }
.q-line:not(.is-monthly) { border-left: 3px solid var(--brand); }
.q-line-row {
    display: grid; align-items: end; gap: 8px; padding: 10px;
    grid-template-columns: 22px 22px minmax(160px, 1fr) 70px 64px 110px 120px 104px auto;
}
.q-line-row .drag-handle { height: 30px; width: 22px; align-self: center; }
.q-no { align-self: center; font-size: 12px; color: var(--text-subtle); text-align: center; }
.q-desc { min-width: 0; }
.q-type { font-size: 11.5px; color: var(--text-muted); font-weight: 600; margin-bottom: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.q-type .badge-soft { padding: 0 6px; font-size: 10.5px; }
.q-title { font-weight: 600; }
.q-cell { display: flex; flex-direction: column; gap: 3px; margin: 0; min-width: 0; }
.q-cell > span { font-size: 11px; color: var(--text-subtle); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.q-cell-price .num, .q-cell-net strong { font-size: 13.5px; line-height: 31px; }
.q-cell-price small { font-size: 11px; color: var(--text-subtle); }
.q-cell-net { text-align: right; }
.q-cell-net small { font-size: 11px; line-height: 1; }
.q-cell-disc .btn { min-width: 32px; padding: 0 8px; }
.q-line-actions { display: flex; gap: 2px; align-self: center; }
.q-line-more { padding: 0 10px 10px 56px; }
.q-line-calc { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.q-err { padding: 0 10px 8px; font-size: 12.5px; color: var(--danger); }
.q-line .form-control-sm, .q-line .form-select-sm, .q-disc .form-control-sm, .q-disc .form-select-sm { background-color: var(--input-bg); }
.q-line .form-control:disabled, .q-disc .form-control:disabled { background: transparent; border-color: transparent; padding-left: 0; opacity: 1; }

.q-discounts { padding: 6px 12px 12px; display: grid; gap: 8px; }
.q-disc { padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.q-disc-items { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.q-totals { padding: 16px 18px; }
.q-tot-row { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: 13.5px; border-bottom: 1px dashed var(--border); }
.q-tot-row:last-child { border-bottom: 0; }
.q-tot-row.is-discount .num { color: var(--success); }
.q-tot-row.is-strong { font-weight: 700; }
.q-tot-row.is-grand { font-size: 18px; font-weight: 800; font-family: var(--font-display); padding-top: 10px; color: var(--brand-text); }
.q-save { margin-top: 14px; display: grid; gap: 6px; }
.dirty-dot { font-size: 12px; font-weight: 600; color: var(--warning); display: inline-flex; align-items: center; gap: 6px; }
.dirty-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--warning); }

.cat-list { display: grid; gap: 8px; }
.cat-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 10px 12px;
    border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.cat-price { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-variant-numeric: tabular-nums; }
.cat-price small { font-size: 11px; color: var(--text-subtle); }
.cat-price .badge-soft { padding: 0 6px; font-size: 10.5px; }
.cat-item [data-cat-add].is-added { background: var(--success-soft); color: var(--success); }

/* Not enough room for one row: description on top, the numbers underneath */
@media (max-width: 1599.98px) {
    .q-line-row { grid-template-columns: 22px 22px repeat(5, minmax(0, 1fr)) auto;
        grid-template-areas: "h n d d d d d a" ". . q m p x t ."; }
    .q-line-row .drag-handle { grid-area: h; }
    .q-line-row .q-no { grid-area: n; }
    .q-line-row .q-desc { grid-area: d; }
    .q-line-row .q-cell-qty { grid-area: q; }
    .q-line-row .q-cell-months { grid-area: m; }
    .q-line-row .q-cell-price { grid-area: p; }
    .q-line-row .q-cell-disc { grid-area: x; }
    .q-line-row .q-cell-net { grid-area: t; }
    .q-line-row .q-line-actions { grid-area: a; align-self: start; }
}
@media (max-width: 1399.98px) {
    .q-layout { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 1199.98px) {
    .q-layout { grid-template-columns: minmax(0, 1fr); }
    .q-side { position: static; }
}
@media (max-width: 767.98px) {
    .q-line-row { grid-template-columns: 22px repeat(2, minmax(0, 1fr)) auto;
        grid-template-areas: "h d d a" ". q m ." ". p x ." ". t t ."; }
    .q-line-row .q-no, .q-line-row .q-cell-empty { display: none; }
    .q-line-row .q-cell-net { text-align: left; }
    .q-line-more { padding-left: 10px; }
    .cat-item { grid-template-columns: minmax(0, 1fr) auto; }
    .cat-item .cat-price { grid-column: 1; grid-row: 2; align-items: flex-start; flex-direction: row; gap: 6px; }
    .cat-item [data-cat-add] { grid-row: 1 / span 2; grid-column: 2; }
}

/* ---------- 8.8 Users & roles ---------- */
.color-picker { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.color-swatch, .color-custom { --c: var(--brand); margin: 0; cursor: pointer; position: relative; }
.color-swatch > span { display: block; width: 30px; height: 30px; border-radius: 9px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .15); }
.color-swatch.is-checked > span, .color-custom.is-checked { outline: 2px solid var(--text); outline-offset: 2px; }
.color-swatch input:focus-visible + span { outline: 2px solid rgba(var(--brand-rgb), .65); outline-offset: 2px; }
.color-custom { width: 30px; height: 30px; border-radius: 9px; overflow: hidden; border: 1px dashed var(--border-strong);
    background: conic-gradient(#ef4b5a, #f5a524, #3fcf6e, #14b8a6, #2f6bff, #8b5cf6, #ef4b5a); }
.color-custom.is-checked { background: var(--c); border-style: solid; }
.color-custom input { opacity: 0; width: 100%; height: 100%; cursor: pointer; }

.perm-legend { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.perm-legend .search-input { max-width: 220px; }
.perm-legend .search-input .form-control { height: 32px; }
.perm-state { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; margin-right: 4px; font-size: 12px; }
.perm-state.from-role { background: var(--surface-3); color: var(--text-muted); }
.perm-state.grant { background: var(--success-soft); color: var(--success); }
.perm-state.deny { background: var(--danger-soft); color: var(--danger); }
.perm-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.perm-group h3 { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 0 0 6px; }
.perm-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px dashed var(--border); }
.perm-row:first-of-type { border-top: 0; }
.perm-row:not(.is-on) .perm-desc { color: var(--text-muted); }
.perm-desc { font-size: 13px; font-weight: 500; }
.perm-row code, .perm-matrix code { font-size: 11px; color: var(--text-subtle); }
.perm-role { font-size: 11.5px; color: var(--text-subtle); white-space: nowrap; }
.perm-role.yes { color: var(--success); }
.perm-seg button { font-size: 11.5px; padding: 4px 8px; }
.perm-seg button:disabled { opacity: .35; cursor: not-allowed; }
.perm-seg button[data-effect="grant"].active { background: var(--success-soft); color: var(--success); }
.perm-seg button[data-effect="deny"].active { background: var(--danger-soft); color: var(--danger); }

.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 14px; }
.role-card { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; text-align: left; color: var(--text); border: 1px solid var(--border); }
.role-card:hover { border-color: var(--border-strong); }
.role-card .icon-tile { width: 34px; height: 34px; font-size: 15px; border-radius: 10px; }
.role-card.is-super { border-color: rgba(var(--brand-rgb), .35); }
.role-card-stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--text-muted); }
.role-mobile-pick { display: none; }

.matrix-wrap { overflow: auto; max-height: 70vh; }
.perm-matrix { margin: 0; border-collapse: separate; border-spacing: 0; --bs-table-bg: transparent; }
.perm-matrix th, .perm-matrix td { border-bottom: 1px solid var(--border); padding: 8px 10px; vertical-align: middle; }
.perm-matrix thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); font-size: 12px; font-weight: 700; color: var(--text-muted);
    text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border-strong); }
.perm-matrix .m-perm { position: sticky; left: 0; z-index: 2; background: var(--surface); min-width: 280px; max-width: 360px; text-align: left; font-weight: 500; }
.perm-matrix thead .m-perm { z-index: 4; }
.perm-matrix .m-role { min-width: 120px; }
.perm-matrix .m-group th, .perm-matrix .m-group td { background: var(--surface-2); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.perm-matrix .m-group th { position: sticky; left: 0; z-index: 2; }
.perm-matrix td { text-align: center; }
.perm-matrix .m-cell .form-check-input { width: 1.2em; height: 1.2em; margin: 0; cursor: pointer; }
.perm-matrix .m-cell .form-check-input:disabled { opacity: .7; }
.perm-matrix .m-cell.is-changed { background: var(--warning-soft); }
.perm-matrix tbody tr:hover th.m-perm, .perm-matrix tbody tr:hover td { background-color: var(--surface-2); }
.m-all { font-size: 11px; padding: 2px 8px; text-transform: none; letter-spacing: 0; }

@media (max-width: 991.98px) {
    .perm-groups { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
    .role-mobile-pick { display: block; flex: 1 1 auto; }
    .perm-matrix .m-perm { min-width: 0; max-width: none; position: static; }
    .perm-row { grid-template-columns: minmax(0, 1fr); }
    .perm-row .perm-seg { justify-self: start; }
}

/* ---------- 8.9 Finance ---------- */
.table-cms .col-check { width: 36px; padding-left: 18px; }
.table-cms .col-check .form-check-input { margin: 0; cursor: pointer; }
.table-cms tr.is-selected td { background: var(--brand-soft); }
.bulk-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 18px; border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--brand) 8%, var(--surface)); font-size: 13px; position: sticky; top: var(--topbar-h); z-index: 5; }

.alloc-list { display: grid; gap: 6px; margin-top: 8px; }
.alloc-head, .alloc-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 90px 150px; gap: 10px; align-items: center; }
.alloc-head { font-size: 11px; font-weight: 700; color: var(--text-subtle); text-transform: uppercase; letter-spacing: .05em; padding: 0 10px; }
.alloc-row { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.alloc-row .badge-soft { padding: 0 6px; font-size: 10.5px; }
.alloc-row.is-static { grid-template-columns: minmax(0, 1fr) 0 auto 0; }
.alloc-row [data-alloc-amount] { max-width: 110px; }

.aging-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.aging-tile { padding: 14px 16px; border-top: 3px solid var(--success); }
.aging-tile.is-late { border-top-color: var(--warning); }
.aging-tile.is-very-late { border-top-color: var(--danger); }
.aging-tile.is-total { border-top-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--surface)); }
.aging-tile .k { font-size: 12px; color: var(--text-muted); }
.aging-tile .v { font-size: 19px; font-weight: 800; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.aging-tile .s { font-size: 12px; color: var(--danger); }

@media (max-width: 1399.98px) {
    #chTable .col-inv, #rcvTable .col-bucket:nth-child(3), #rcvTable .col-bucket:nth-child(4) { display: none; }
}
@media (max-width: 1199.98px) {
    .aging-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    #chTable .col-src { display: none; }
}
@media (max-width: 767.98px) {
    .alloc-head { display: none; }
    .alloc-row { grid-template-columns: minmax(0, 1fr) auto; }
    .alloc-row > :nth-child(2) { display: none; }
    .alloc-row > :nth-child(4) { grid-column: 1 / -1; }
    .alloc-row [data-alloc-amount] { max-width: none; }
    .aging-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .bulk-bar { top: 64px; }
}
@media (max-width: 575.98px) {
    #chTable td.col-inv, #chTable td.col-src, #rcvTable td.col-bucket { display: flex !important; }
    .table-cards td.col-check { display: none; }
    .table-cards tr.is-selected { border-color: var(--brand); }
}

/* ---------- 8.10 Expenses, inventory, VAT, attachments ---------- */
.att-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.att-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); }
.att-icon { width: 34px; height: 34px; flex: 0 0 auto; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-size: 16px; }
.mw-100 { max-width: 100%; }
.dropzone-compact { padding: 10px; flex-direction: row; justify-content: center; gap: 8px; flex-wrap: wrap; }
.dropzone-compact .bi { font-size: 18px; }

.exp-lines { display: grid; gap: 6px; }
.exp-line { display: grid; grid-template-columns: 150px minmax(0, 1fr) 70px 100px 70px 90px auto; gap: 6px; align-items: center;
    padding: 6px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.exp-line select[name="catalog_hardware_id"] { grid-column: 2 / -1; }
.exp-line:has(select[name="catalog_hardware_id"]) .exp-line-title { grid-column: 1 / 3; }
.exp-line-net { text-align: right; font-size: 13px; color: var(--text-muted); }
.exp-line .form-control-sm, .exp-line .form-select-sm { background-color: var(--input-bg); }
.table-cms .col-cat { max-width: 200px; }

.vat-periods { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; padding: 14px 18px 18px; }
.vat-card { padding: 14px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-2); border-left: 4px solid var(--warning); }
.vat-card.is-submitted { border-left-color: var(--violet); }
.vat-card.is-paid { border-left-color: var(--success); }
.vat-card.is-open { background: repeating-linear-gradient(135deg, var(--surface-2) 0 14px, color-mix(in srgb, var(--warning) 5%, var(--surface-2)) 14px 28px); }
.vat-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.vat-figs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; margin: 12px 0; }
.vat-figs dt { font-size: 11.5px; color: var(--text-subtle); font-weight: 600; }
.vat-figs dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.vat-figs .is-pay dd { color: var(--danger); font-size: 17px; }
.vat-figs .is-credit dd { color: var(--success); font-size: 17px; }
.vat-card-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

@media (max-width: 1199.98px) {
    .exp-line { grid-template-columns: 140px minmax(0, 1fr) 64px 90px 64px auto; }
    .exp-line .exp-line-net { display: none; }
    #expTable .col-cat, #invTable .col-price { display: none; }
}
@media (max-width: 767.98px) {
    .exp-line { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
    .exp-line select[name="item_kind"] { grid-column: 1 / -2; }
    .exp-line .exp-line-title, .exp-line select[name="catalog_hardware_id"] { grid-column: 1 / -1; }
    .vat-periods { grid-template-columns: minmax(0, 1fr); padding: 12px; }
}
@media (max-width: 575.98px) {
    #expTable td.col-cat, #invTable td.col-price { display: flex !important; }
}

/* ---------- 8.11 Onboarding & work orders ---------- */
.onb-summary { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.onb-progress, .onb-missing { padding: 14px 16px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); }
.onb-pct { font-family: var(--font-display); font-weight: 800; font-size: 22px; }
.onb-progress .progress-x { height: 10px; margin-top: 8px; }
.onb-missing ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--text-muted); }
.onb-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.onb-step { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.onb-step.is-done { border-color: rgba(var(--success-rgb), .3); }
.onb-step.is-not_applicable { opacity: .7; }
.onb-step-ic { font-size: 18px; color: var(--text-subtle); }
.onb-step.is-done .onb-step-ic { color: var(--success); }
.onb-step-name { font-weight: 600; font-size: 13.5px; }
.onb-seg button { font-size: 11.5px; padding: 4px 8px; }
.onb-file { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.onb-step.is-file { align-items: flex-start; }
.onb-layout { display: grid; grid-template-columns: minmax(0, 420px) minmax(0, 1fr); gap: 14px; align-items: start; }
.onb-layout #onbTable tbody tr { cursor: pointer; }
.onb-detail { position: sticky; top: calc(var(--topbar-h) + 8px); }

.wo-head { padding: 20px 22px; }
.wo-head .page-title a:hover { color: var(--brand-text) !important; }
.wo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.wo-address { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius);
    background: var(--brand-soft); color: var(--text); border: 1px solid rgba(var(--brand-rgb), .3); }
.wo-address .bi { grid-row: 1 / span 2; font-size: 22px; color: var(--brand-text); }
.wo-address span { font-weight: 600; }
.wo-address small { color: var(--text-muted); }
.wo-items { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.wo-items li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.wo-items li.is-done span span { text-decoration: line-through; color: var(--text-muted); }
.wo-check { display: grid; gap: 6px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); }
.wo-form-items { display: grid; gap: 6px; }
.wo-form-item { display: grid; grid-template-columns: minmax(0, 1fr) 80px auto; gap: 6px; align-items: center; }

.wo-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
.wo-card { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--violet); display: flex; flex-direction: column; }
.wo-card.is-in_progress { border-left-color: var(--brand); box-shadow: 0 0 0 1px rgba(var(--brand-rgb), .25); }
.wo-card.is-unassigned { border-left-color: var(--warning); }
.wo-card.is-completed { border-left-color: var(--success); opacity: .85; }
.wo-card.is-partially_completed, .wo-card.is-not_completed { border-left-color: var(--danger); opacity: .85; }
.wo-card-link { display: block; padding: 12px 14px 8px; color: var(--text); }
.wo-card-link:hover { color: var(--text); }
.wo-card-top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.wo-when { font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }
.wo-card-title { font-size: 16px; margin: 6px 0 2px; }
.wo-card-addr { margin-top: 6px; font-size: 13px; color: var(--text-muted); }
.wo-card-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 0 14px 12px; margin-top: auto; }
.wo-card-actions .badge-soft { margin-right: auto; }
.mw-sections { display: grid; gap: 18px; }
.mw-section-title { font-size: 14px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; display: flex; gap: 8px; align-items: center; margin: 0 0 10px; }

@media (max-width: 1199.98px) {
    .onb-layout { grid-template-columns: minmax(0, 1fr); }
    .onb-detail { position: static; }
    .wo-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
    .onb-summary { grid-template-columns: minmax(0, 1fr); }
    .onb-step { flex-wrap: wrap; }
    .onb-step .onb-seg { width: 100%; }
    .onb-step .onb-seg button { flex: 1; }
    .wo-cards { grid-template-columns: minmax(0, 1fr); }
    /* big touch targets for technicians in the field */
    .wo-card-actions .btn { padding: 9px 14px; font-size: 14px; }
    .wo-head .q-actions { width: 100%; }
    .wo-head .q-actions .btn-brand { flex: 1; padding: 11px; font-size: 15px; }
    .mw-head .page-desc { text-transform: capitalize; }
}

/* ---------- 8.12 Documents & financial reports ---------- */
.doc-head { padding: 20px 22px; display: flex; gap: 16px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.doc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 340px); gap: 14px; margin-top: 14px; align-items: start; }
.doc-side { display: grid; gap: 14px; }
.doc-frame { width: 100%; min-height: 160px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); display: block; }
.doc-editor { display: grid; gap: 8px; }
.doc-editor-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.doc-editor .editor-wrap { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--input-bg); }
.code-area { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; line-height: 1.55; min-height: 320px; }
.doc-edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 240px); gap: 14px; align-items: start; }
.ph-panel { padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); max-height: 60vh; overflow: auto; }
.ph-group + .ph-group { margin-top: 10px; }
.ph-title { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-subtle); margin-bottom: 6px; }
.ph-chip { display: inline-flex; margin: 0 4px 4px 0; padding: 3px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.ph-chip:hover { border-color: rgba(var(--brand-rgb), .6); color: var(--brand-text); }

.rp-tabs { max-width: 100%; }
.rp-tabs button .bi { margin-right: 4px; }
.rp-options { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin-bottom: 14px; }
.rp-tile { padding: 14px 16px; }
.rp-tile .k { font-size: 12.5px; color: var(--text-muted); }
.rp-tile .v { font-family: var(--font-display); font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin-top: 2px; }
.rp-tile .s { font-size: 12px; color: var(--text-subtle); margin-top: 2px; }
.rp-tile.is-success .v { color: var(--success); }
.rp-tile.is-danger .v { color: var(--danger); }
.rp-tile.is-warning .v { color: var(--warning); }
.rp-chart { position: relative; height: 300px; }
#rpTable tfoot .rp-total td { border-top: 2px solid var(--border-strong); font-weight: 700; }

@media (max-width: 1199.98px) {
    .doc-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
    .doc-edit-grid { grid-template-columns: minmax(0, 1fr); }
    .ph-panel { max-height: 220px; }
    .doc-head .q-actions { width: 100%; }
    .rp-chart { height: 240px; }
    .rp-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rp-tile { padding: 12px; }
    .rp-tile .v { font-size: 17px; }
    .rp-options { width: 100%; }
    .rp-options .toolbar-select { flex: 1 1 auto; }
}

/* ---------- 8.13 Administration ---------- */
.col-drag { width: 34px; }
.table-cms td.col-preview { max-width: 360px; }
.table-cms tr.is-group td { background: var(--surface-2); }
.table-cms tr.is-group .row-title { font-weight: 700; }
.table-cms tr.is-child .cell-main { padding-left: 30px; }
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px rgba(0, 0, 0, .06); vertical-align: middle; }
.tr-list { display: grid; gap: 8px; }
.tr-row { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.tr-from { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13.5px; padding-top: 3px; }
.tr-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tr-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-muted); }
.tr-chip.is-on { border-color: rgba(var(--brand-rgb), .7); background: var(--brand-soft); color: var(--text); font-weight: 600; }
.tr-chip:disabled { cursor: default; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settings-wide { grid-column: 1 / -1; }
.settings-bar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 14px; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }
@media (max-width: 991.98px) {
    .settings-grid { grid-template-columns: minmax(0, 1fr); }
    .tr-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767.98px) {
    .table-cms tr.is-child .cell-main { padding-left: 0; }
    .table-cards tr:has(> td.col-drag) { position: relative; }
    .table-cards td.col-drag { position: absolute; top: 8px; right: 8px; width: auto; padding: 0 !important; border: 0 !important; }
    .table-cards td.col-drag:empty { display: none; }
    .settings-bar .btn { flex: 1; }
}

/* ---------- 8.3 Responsive (CRM) — tables become cards, modals fullscreen ---------- */
@media (max-width: 1199.98px) {
    .dash-card, .dash-card.span-8 { grid-column: span 6; }
}
@media (max-width: 767.98px) {
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
    .dash-card, .dash-card.span-6, .dash-card.span-8, .dash-card.span-12 { grid-column: auto; }
}
@media (max-width: 575.98px) {
    /* <table class="table table-cms table-cards"> + <td data-label="…"> ; the main cell: <td class="cell-main"> */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tbody tr { border: 1px solid var(--border); border-radius: var(--radius); margin: 10px 0; padding: 10px 12px; background: var(--surface); }
    .table-cards tbody td { border: 0 !important; padding: 4px 0 !important; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
    .table-cards tbody td[data-label]::before { content: attr(data-label); color: var(--text-subtle); font-size: 12px; text-align: left; flex: 0 0 auto; }
    .table-cards tbody td.cell-main { display: block; text-align: left; padding-bottom: 6px !important; }
    .table-cards .row-sub { display: block; }
    .table-cards-wrap { padding: 0 10px; }
    .modal-dialog:not(.modal-confirm) { margin: 0; max-width: none; min-height: 100%; }
    .modal-dialog:not(.modal-confirm) .modal-content { min-height: 100vh; border-radius: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- HTML email editor (components/html-editor.js) and the email attachments (email-composer.js, message-templates.js) ---------- */
.html-editor { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.html-editor-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.html-editor-tools { display: flex; gap: 2px; }
.html-editor-frame { display: block; width: 100%; border: 0; background: #f3f4f7; }
.html-editor-code { border: 0; border-radius: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; line-height: 1.5; resize: vertical; white-space: pre; }
.html-editor-code:focus { box-shadow: none; }
.email-attachments { display: flex; flex-direction: column; gap: 8px; }
.email-att { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; margin: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.email-att > .bi { font-size: 18px; color: var(--brand-text); margin-top: 1px; }
.email-att > .form-check-input { margin-top: 4px; flex-shrink: 0; }
label.email-att { cursor: pointer; }
.email-att.is-missing { opacity: .65; cursor: default; }
.email-att.is-missing > .bi { color: var(--text-subtle); }
