/**
 * RSO Design System
 * Master reference: private header toolbar (.header-nav-btn, .header-icon, .header-search)
 *
 * Usage: wrap page content in .rso-ui (or .page-shell) and use .rso-* classes.
 * Legacy aliases map common patterns (small-btn, workspace-actions-menu) to these tokens.
 */

:root {
    /* Brand — toolbar */
    --rso-brand: #0099ff;
    --rso-brand-hover: #0088ee;
    --rso-brand-active: #0077cc;
    --rso-brand-soft: #eff6ff;
    --rso-brand-border: #93c5fd;
    --rso-brand-text: #0369a1;

    /* Surfaces — light workspace (page-shell) */
    --rso-text: #111827;
    --rso-text-secondary: #374151;
    --rso-text-muted: #6b7280;
    --rso-text-subtle: #9ca3af;
    --rso-border: #e5e7eb;
    --rso-border-strong: #d1d5db;
    --rso-surface: #ffffff;
    --rso-surface-soft: #f9fafb;
    --rso-surface-muted: #f3f4f6;
    --rso-bg: #f5f7fb;
    --rso-overlay: rgba(15, 23, 42, 0.55);
    --rso-chrome-bg: #0f172a;

    /* Toolbar (dark header) */
    --rso-toolbar-bg: #1e293b;
    --rso-toolbar-border: #334155;
    --rso-toolbar-text: #ffffff;
    --rso-toolbar-placeholder: #94a3b8;

    /* Semantic */
    --rso-success: #166534;
    --rso-success-soft: #f0fdf4;
    --rso-success-border: #86efac;
    --rso-warning: #b45309;
    --rso-warning-soft: #fef3c7;
    --rso-warning-border: #fde68a;
    --rso-danger: #b91c1c;
    --rso-danger-soft: #fef2f2;
    --rso-danger-border: #fecaca;

    /* Toolbar — natural height from control size (no fixed header height, no header padding) */
    --rso-toolbar-control-height: 46px;
    --rso-control-height: 38px;
    --rso-control-padding-x: 14px;
    --rso-control-font-size: 13px;
    --rso-control-font-weight: 700;
    --rso-label-font-size: 13px;
    --rso-label-font-weight: 700;
    --rso-label-margin-bottom: 6px;

    /* Radius — one family */
    --rso-radius-sm: 8px;
    --rso-radius-md: 12px;
    --rso-radius-lg: 14px;
    --rso-radius-xl: 16px;
    --rso-radius-pill: 999px;

    /* Spacing */
    --rso-space-1: 4px;
    --rso-space-2: 8px;
    --rso-space-3: 12px;
    --rso-space-4: 16px;
    --rso-space-5: 20px;
    --rso-space-6: 24px;
    --rso-space-7: 32px;
    --rso-space-8: 40px;

    /* Page Canvas — single spacing grid (24px on all outer edges + toolbar gap) */
    --rso-canvas-frame: var(--rso-space-6);
    --rso-canvas-inner: var(--rso-space-6);
    --rso-canvas-radius: var(--rso-radius-xl);
    --rso-grid-gap: var(--rso-canvas-frame);

    /* Legacy aliases */
    --rso-app-frame: var(--rso-canvas-frame);
    --rso-page-inner: var(--rso-canvas-inner);
    --rso-page-radius: var(--rso-canvas-radius);
    --page-edge-space: var(--rso-canvas-frame);
    --page-shell-padding: var(--rso-canvas-inner);
    --page-shell-radius: var(--rso-canvas-radius);

    /* Focus */
    --rso-focus-ring: 0 0 0 2px rgba(0, 153, 255, 0.15);
    --rso-shadow-menu: 0 10px 30px rgba(15, 23, 42, 0.12);
    --rso-shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.25);

    --rso-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    --rso-transition: 0.15s ease;
}

@media (max-width: 800px) {
    :root {
        --rso-canvas-frame: var(--rso-space-4);
        --rso-canvas-inner: var(--rso-space-4);
        --rso-canvas-radius: var(--rso-radius-md);
    }
}

/* ---- Page Canvas layout ----
 * Spacing grid (one token: --rso-canvas-frame = 24px):
 *   browser edge → 24px → toolbar → 24px → page container → 24px → browser edge
 *   left/right: 24px each
 */
.rso-app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
    height: 100dvh;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: var(--rso-canvas-frame);
    gap: var(--rso-grid-gap);
    background: var(--rso-chrome-bg);
}

.header {
    background: var(--rso-chrome-bg);
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    margin: 0;
    position: relative;
    z-index: 1000;
    overflow: visible;
    gap: var(--rso-space-4);
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--rso-space-4);
    flex: 1;
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    margin-left: auto;
    min-width: 0;
    flex-shrink: 0;
}

.layout {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Flex host — clients/workspace scroll here; candidates/map use inner scroll */
.rso-page-canvas-frame,
.content,
.content-workspace-page,
.content-candidates-page,
.content-clients-page,
.content-map-page {
    flex: 1 1 0;
    min-height: 0;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    overflow-x: clip;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.content-clients-page,
.content-workspace-page {
    overflow-x: clip;
    overflow-y: auto;
}

.content-candidates-page,
.content-map-page {
    overflow: hidden;
}

/* Candidates depot browse: fit content height, don't stretch empty white area */
body.page-candidates .content-candidates-page.content-candidates-browse {
    flex: 0 1 auto;
    overflow: visible;
}

body.page-candidates .page-shell.crm-page.crm-page--browse {
    flex: 0 1 auto;
    height: auto;
    min-height: 0;
    overflow: visible;
}

body.page-candidates .page-shell.crm-page.crm-page--list,
body.page-candidates .page-shell.crm-page.crm-page--profile {
    flex: 1 1 0;
    min-height: 0;
    height: auto;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Clients + workspace pages: full-width grids inside scrollable canvas */
.page-shell.clients-page,
.page-shell.callbacks-page,
.page-shell.dashboard-page,
.page-shell.import-page,
.page-shell.active-drivers-page {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.clients-page .clients-list-view,
.clients-page .client-grid,
.clients-page .clients-toolbar,
.clients-page .status-row-wrap,
.callbacks-page .callbacks-layout,
.callbacks-page .callbacks-card,
.callbacks-page .calendar-grid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.clients-page .client-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    padding-bottom: var(--rso-space-6);
}

#depotBrowseView {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
}

#depotGrid {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Page Canvas surface — white card fills viewport height, grows with content */
.page-shell {
    background: var(--rso-bg);
    border-radius: var(--rso-canvas-radius);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: var(--rso-canvas-inner);
    flex: 0 1 auto;
    min-height: 100%;
    display: block;
    margin: 0;
    overflow: visible;
    box-sizing: border-box;
}

.rso-page-canvas {
    background: var(--rso-bg);
    border-radius: var(--rso-canvas-radius);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: var(--rso-canvas-inner);
    flex: 0 1 auto;
    min-height: 100%;
    display: block;
    margin: 0;
    overflow: visible;
    box-sizing: border-box;
}

.rso-page-canvas--flush,
.page-shell--flush {
    padding: 0;
    background: transparent;
    overflow: hidden;
    flex: 1 1 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.rso-page-canvas-frame > .map-page,
.rso-page-canvas-frame > .page-shell--flush,
.content > .map-page,
.content > .page-shell--flush {
    flex: 1 1 0;
    min-height: 0;
}

.rso-page-canvas-frame > .rso-page-canvas,
.rso-page-canvas-frame > .ce-app,
.rso-page-canvas-frame > .users-page,
.content > .rso-page-canvas,
.content > .ce-app,
.content > .users-page {
    flex: 0 1 auto;
    min-height: 100%;
}

/* ---- Scope ---- */
.rso-ui,
.page-shell,
.rso-page-canvas {
    color: var(--rso-text);
    font-family: var(--rso-font-family);
}

.rso-ui *,
.rso-ui *::before,
.rso-ui *::after,
.page-shell *,
.page-shell *::before,
.page-shell *::after,
.rso-page-canvas *,
.rso-page-canvas *::before,
.rso-page-canvas *::after {
    box-sizing: border-box;
}

/* ---- Buttons (simplified: rso-btn + modifiers) ---- */
.page-shell .rso-btn,
.page-shell .profile-pill-btn,
.page-shell .add-btn,
.page-shell .import-btn:not(.secondary):not(.green):not(.danger),
.page-shell .workflow-btn:not(.secondary):not(.send),
.page-shell .small-btn:not(.ghost):not(.secondary):not(.danger):not(.success):not(.warning),
.rso-ui .rso-btn,
.rso-ui .profile-pill-btn,
.rso-ui .add-btn,
.rso-ui .import-btn:not(.secondary):not(.green):not(.danger),
.rso-ui .workflow-btn:not(.secondary):not(.send),
.rso-ui .small-btn:not(.ghost):not(.secondary):not(.danger):not(.success):not(.warning) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--rso-space-2);
    height: var(--rso-control-height);
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--rso-radius-pill);
    background: var(--rso-brand);
    color: #fff;
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: var(--rso-control-font-weight);
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    margin: 0;
    width: auto;
    box-sizing: border-box;
    transition: background var(--rso-transition), border-color var(--rso-transition), color var(--rso-transition);
}

.page-shell .rso-btn:hover,
.page-shell .profile-pill-btn:hover,
.page-shell .add-btn:hover,
.page-shell .import-btn:not(.secondary):not(.green):not(.danger):hover,
.page-shell .workflow-btn:not(.secondary):not(.send):hover,
.page-shell .small-btn:not(.ghost):not(.secondary):not(.danger):not(.success):not(.warning):hover,
.rso-ui .rso-btn:hover,
.rso-ui .profile-pill-btn:hover,
.rso-ui .add-btn:hover,
.rso-ui .import-btn:not(.secondary):not(.green):not(.danger):hover,
.rso-ui .workflow-btn:not(.secondary):not(.send):hover,
.rso-ui .small-btn:not(.ghost):not(.secondary):not(.danger):not(.success):not(.warning):hover {
    background: var(--rso-brand-hover);
}

.page-shell .rso-btn:focus-visible,
.page-shell .profile-pill-btn:focus-visible,
.page-shell .profile-email-btn:focus-visible,
.rso-ui .rso-btn:focus-visible,
.rso-ui .profile-pill-btn:focus-visible,
.rso-ui .profile-email-btn:focus-visible {
    outline: none;
    box-shadow: var(--rso-focus-ring);
}

.page-shell .rso-btn:disabled,
.page-shell .rso-btn.is-disabled,
.page-shell .import-btn:disabled,
.rso-ui .rso-btn:disabled,
.rso-ui .rso-btn.is-disabled,
.rso-ui .import-btn:disabled {
    opacity: 0.45;
    pointer-events: none;
    cursor: not-allowed;
}

.page-shell .rso-btn.has-callback,
.page-shell .profile-pill-btn.has-callback,
.rso-ui .rso-btn.has-callback,
.rso-ui .profile-pill-btn.has-callback {
    outline: 2px solid var(--rso-brand-border);
    outline-offset: 1px;
}

.page-shell .rso-btn--outline,
.page-shell .profile-email-btn,
.page-shell .small-btn.ghost,
.page-shell .import-btn.secondary,
.page-shell .workflow-btn.secondary,
.page-shell .btn-link,
.rso-ui .rso-btn--outline,
.rso-ui .profile-email-btn,
.rso-ui .small-btn.ghost,
.rso-ui .import-btn.secondary,
.rso-ui .workflow-btn.secondary,
.rso-ui .btn-link {
    background: var(--rso-surface);
    color: var(--rso-brand);
    border: 1px solid var(--rso-border-strong);
}

.page-shell .rso-btn--outline:hover,
.page-shell .profile-email-btn:hover,
.page-shell .small-btn.ghost:hover,
.page-shell .import-btn.secondary:hover,
.page-shell .workflow-btn.secondary:hover,
.page-shell .btn-link:hover,
.rso-ui .rso-btn--outline:hover,
.rso-ui .profile-email-btn:hover,
.rso-ui .small-btn.ghost:hover,
.rso-ui .import-btn.secondary:hover,
.rso-ui .workflow-btn.secondary:hover,
.rso-ui .btn-link:hover {
    background: var(--rso-brand-soft);
    border-color: var(--rso-brand);
}

.page-shell .rso-btn--success,
.page-shell .import-btn.green,
.page-shell .workflow-btn.send,
.page-shell .callback-list-btn.primary,
.page-shell .small-btn.success,
.rso-ui .rso-btn--success,
.rso-ui .import-btn.green,
.rso-ui .workflow-btn.send,
.rso-ui .callback-list-btn.primary,
.rso-ui .small-btn.success {
    background: #16a34a;
    color: #fff;
    border-color: #16a34a;
}

.page-shell .rso-btn--success:hover,
.page-shell .import-btn.green:hover,
.page-shell .workflow-btn.send:hover,
.page-shell .callback-list-btn.primary:hover,
.page-shell .small-btn.success:hover,
.rso-ui .rso-btn--success:hover,
.rso-ui .import-btn.green:hover,
.rso-ui .workflow-btn.send:hover,
.rso-ui .callback-list-btn.primary:hover,
.rso-ui .small-btn.success:hover {
    background: #15803d;
    border-color: #15803d;
}

.page-shell .rso-btn--danger,
.page-shell .callback-list-btn.danger,
.page-shell .small-btn.danger,
.page-shell .import-btn.danger,
.rso-ui .rso-btn--danger,
.rso-ui .callback-list-btn.danger,
.rso-ui .small-btn.danger,
.rso-ui .import-btn.danger {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.page-shell .rso-btn--danger:hover,
.page-shell .callback-list-btn.danger:hover,
.page-shell .small-btn.danger:hover,
.page-shell .import-btn.danger:hover,
.rso-ui .rso-btn--danger:hover,
.rso-ui .callback-list-btn.danger:hover,
.rso-ui .small-btn.danger:hover,
.rso-ui .import-btn.danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.page-shell .rso-btn--sm,
.page-shell .callback-list-btn:not(.primary):not(.danger),
.page-shell .client-form-actions .small-btn,
.rso-ui .rso-btn--sm,
.rso-ui .callback-list-btn:not(.primary):not(.danger),
.rso-ui .client-form-actions .small-btn {
    height: 32px;
    padding: 0 12px;
    font-size: 12px;
}

.page-shell .rso-btn--icon,
.rso-ui .rso-btn--icon {
    gap: 4px;
    padding: 0 8px;
    height: 32px;
    font-size: 12px;
    background: transparent;
    color: var(--rso-text-muted);
    border-color: transparent;
    border-radius: var(--rso-radius-sm);
}

.page-shell .rso-btn--icon:hover,
.rso-ui .rso-btn--icon:hover {
    background: var(--rso-surface-soft);
    color: var(--rso-text);
    border-color: var(--rso-border);
}

.page-shell .rso-btn--icon.is-danger,
.rso-ui .rso-btn--icon.is-danger {
    color: var(--rso-danger);
}

.page-shell .rso-btn--icon.is-danger:hover,
.rso-ui .rso-btn--icon.is-danger:hover {
    background: var(--rso-danger-soft);
    border-color: var(--rso-danger-border);
}

/* Depot card count badges (not full buttons) */
.page-shell .depot-card-stale-btn,
.page-shell .depot-card-auto-btn,
.rso-ui .depot-card-fresh-btn,
.rso-ui .depot-card-stale-btn,
.rso-ui .depot-card-auto-btn {
    width: auto;
    min-width: 24px;
    max-width: 100%;
    margin: 0;
    cursor: pointer;
    box-shadow: none;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
    border-radius: var(--rso-radius-pill);
    font-weight: 800;
    transition: background var(--rso-transition), border-color var(--rso-transition), color var(--rso-transition);
}

.page-shell .depot-card-fresh-btn,
.rso-ui .depot-card-fresh-btn {
    padding: 4px 7px;
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
    font-size: 11px;
}

.page-shell .depot-card-fresh-btn:hover,
.rso-ui .depot-card-fresh-btn:hover {
    background: #bbf7d0;
    color: #166534;
    border-color: #86efac;
}

.page-shell .depot-card-fresh-btn.active-filter,
.rso-ui .depot-card-fresh-btn.active-filter {
    background: #15803d;
    color: #fff;
    border-color: #15803d;
}

.page-shell .depot-card-stale-btn,
.rso-ui .depot-card-stale-btn {
    padding: 4px 7px;
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-size: 11px;
}

.page-shell .depot-card-stale-btn:hover,
.rso-ui .depot-card-stale-btn:hover {
    background: #fecaca;
    color: #b91c1c;
    border-color: #fca5a5;
}

.page-shell .depot-card-stale-btn.active-filter,
.rso-ui .depot-card-stale-btn.active-filter {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.page-shell .depot-card-auto-btn,
.rso-ui .depot-card-auto-btn {
    padding: 4px 8px;
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
}

.page-shell .depot-card-auto-btn:hover,
.rso-ui .depot-card-auto-btn:hover {
    background: #bfdbfe;
    color: #1e3a8a;
    border-color: #93c5fd;
}

.page-shell .depot-card-auto-btn:disabled,
.rso-ui .depot-card-auto-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ---- Inputs, selects, search ---- */
.rso-input,
.rso-select,
.rso-textarea,
.rso-search {
    display: block;
    width: 100%;
    min-height: var(--rso-control-height);
    padding: 0 11px;
    border: 1px solid var(--rso-border-strong);
    border-radius: var(--rso-radius-sm);
    background: var(--rso-surface);
    color: var(--rso-text);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    transition: border-color var(--rso-transition), box-shadow var(--rso-transition);
}

.rso-textarea {
    min-height: 90px;
    padding: 11px;
    resize: vertical;
}

.rso-input:focus,
.rso-select:focus,
.rso-textarea:focus,
.rso-search:focus {
    outline: none;
    border-color: var(--rso-brand);
    box-shadow: var(--rso-focus-ring);
}

.rso-search {
    border-radius: var(--rso-radius-pill);
    padding: 0 16px;
}

.rso-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 32px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.rso-input:disabled,
.rso-select:disabled,
.rso-textarea:disabled,
.rso-search:disabled {
    background: var(--rso-surface-muted);
    color: var(--rso-text-muted);
    cursor: not-allowed;
    opacity: 1;
}

/* ---- Multi-select dropdown ---- */
.rso-multiselect {
    position: relative;
    width: 100%;
}

.rso-multiselect__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--rso-space-3);
    width: 100%;
    min-height: var(--rso-control-height);
    padding: 0 11px;
    border: 1px solid var(--rso-border-strong);
    border-radius: var(--rso-radius-sm);
    background: var(--rso-surface);
    color: var(--rso-text);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    margin: 0;
    transition: border-color var(--rso-transition), box-shadow var(--rso-transition);
}

.rso-multiselect__trigger::after {
    content: "";
    width: 12px;
    height: 12px;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    transition: transform var(--rso-transition);
}

.rso-multiselect.is-open .rso-multiselect__trigger::after {
    transform: rotate(180deg);
}

.rso-multiselect__trigger:hover {
    border-color: #cbd5e1;
}

.rso-multiselect.is-open .rso-multiselect__trigger,
.rso-multiselect__trigger:focus {
    outline: none;
    border-color: var(--rso-brand);
    box-shadow: var(--rso-focus-ring);
}

.rso-multiselect__value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rso-multiselect__value.is-placeholder {
    color: var(--rso-text-muted);
    font-weight: 600;
}

.rso-multiselect__menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    z-index: 20;
    display: none;
    flex-direction: column;
    gap: 2px;
    max-height: 220px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--rso-border);
    border-radius: var(--rso-radius-md);
    background: var(--rso-surface);
    box-shadow: var(--rso-shadow-menu);
}

.rso-multiselect.is-open .rso-multiselect__menu {
    display: flex;
}

.rso-multiselect.is-menu-fixed .rso-multiselect__menu {
    position: fixed;
    top: auto;
    left: auto;
    right: auto;
    z-index: 100001;
}

.rso-multiselect__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--rso-space-3);
    min-height: 40px;
    padding: 8px 10px;
    border-radius: var(--rso-radius-sm);
    font-size: var(--rso-control-font-size);
    font-weight: 600;
    color: var(--rso-text);
    cursor: pointer;
    margin: 0;
}

.rso-multiselect__option:hover {
    background: var(--rso-brand-soft);
}

.rso-multiselect__option-label {
    flex: 1;
    min-width: 0;
}

.rso-multiselect__option .rso-switch {
    flex-shrink: 0;
}

/* ---- Compound inputs (prefix / suffix affixes) ---- */
.rso-compound {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: var(--rso-control-height);
    border: 1px solid var(--rso-border-strong);
    border-radius: var(--rso-radius-sm);
    background: var(--rso-surface);
    overflow: hidden;
    transition: border-color var(--rso-transition), box-shadow var(--rso-transition);
}

.rso-compound:hover:not(.is-disabled):not(:has(:disabled)) {
    border-color: #cbd5e1;
}

.rso-compound:focus-within {
    border-color: var(--rso-brand);
    box-shadow: var(--rso-focus-ring);
}

.rso-compound.is-disabled,
.rso-compound:has(.rso-compound__input:disabled) {
    background: var(--rso-surface-muted);
    border-color: var(--rso-border);
    cursor: not-allowed;
}

.rso-compound.is-disabled:focus-within,
.rso-compound:has(.rso-compound__input:disabled):focus-within {
    border-color: var(--rso-border);
    box-shadow: none;
}

.rso-compound.is-invalid {
    border-color: var(--rso-danger-border);
}

.rso-compound.is-invalid:focus-within {
    border-color: var(--rso-danger);
    box-shadow: 0 0 0 2px rgba(185, 28, 28, 0.12);
}

.rso-compound__affix {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-height: calc(var(--rso-control-height) - 2px);
    padding: 0 11px;
    background: var(--rso-surface-muted);
    color: var(--rso-text-muted);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: var(--rso-control-font-weight);
    line-height: 1.2;
    white-space: nowrap;
    user-select: none;
    border: none;
    border-right: 1px solid var(--rso-border);
}

.rso-compound__affix:last-child {
    border-right: none;
    border-left: 1px solid var(--rso-border);
}

.rso-compound__affix:first-child:last-child {
    border: none;
}

.rso-compound__affix--prefix {
    border-right: 1px solid var(--rso-border);
    border-left: none;
}

.rso-compound__affix--suffix {
    border-left: 1px solid var(--rso-border);
    border-right: none;
}

.rso-compound__affix--select {
    appearance: none;
    -webkit-appearance: none;
    padding: 0 28px 0 11px;
    margin: 0;
    width: auto;
    min-width: 72px;
    max-width: 120px;
    cursor: pointer;
    text-align: left;
    background-color: var(--rso-surface-muted);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M3 4.5 6 7.5 9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    color: var(--rso-text-secondary);
}

.rso-compound__affix--select:focus {
    outline: none;
}

.rso-compound__affix--select.rso-compound__affix--prefix {
    border-right: 1px solid var(--rso-border);
}

.rso-compound__affix--select.rso-compound__affix--suffix {
    border-left: 1px solid var(--rso-border);
}

.rso-compound__affix--narrow {
    min-width: 44px;
    padding: 0 10px;
}

.rso-compound__affix--wide {
    min-width: 88px;
}

.rso-compound__input {
    display: block;
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: calc(var(--rso-control-height) - 2px);
    padding: 0 11px;
    border: none;
    border-radius: 0;
    background: transparent;
    color: var(--rso-text);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
    box-shadow: none;
}

.rso-compound__input:focus {
    outline: none;
    box-shadow: none;
}

.rso-compound__input::placeholder {
    color: var(--rso-text-subtle);
    font-weight: 600;
}

.rso-compound__input:disabled {
    background: transparent;
    color: var(--rso-text-muted);
    cursor: not-allowed;
}

.rso-compound.is-disabled .rso-compound__affix,
.rso-compound:has(.rso-compound__input:disabled) .rso-compound__affix {
    color: var(--rso-text-subtle);
}

.rso-compound.is-disabled .rso-compound__affix--select,
.rso-compound:has(.rso-compound__input:disabled) .rso-compound__affix--select {
    pointer-events: none;
    opacity: 0.7;
}

/* Preset affix widths (optional helpers) */
.rso-compound--vat .rso-compound__affix--prefix { min-width: 44px; }
.rso-compound--currency .rso-compound__affix--prefix { min-width: 40px; }
.rso-compound--percent .rso-compound__affix--suffix { min-width: 40px; }
.rso-compound--phone .rso-compound__affix--select.rso-compound__affix--prefix { min-width: 72px; }
.rso-compound--website .rso-compound__affix--prefix { min-width: 72px; font-size: 12px; }
.rso-compound--unit .rso-compound__affix--select.rso-compound__affix--suffix { min-width: 88px; }

.rso-compound-field {
    margin-bottom: var(--rso-space-3);
}

.rso-compound-field .rso-label {
    margin-bottom: var(--rso-label-margin-bottom);
}

.rso-compound-field .rso-help {
    margin-top: var(--rso-space-1);
}

.rso-field {
    margin-bottom: var(--rso-space-3);
}

.rso-label {
    display: block;
    font-size: var(--rso-label-font-size);
    font-weight: var(--rso-label-font-weight);
    color: var(--rso-text-secondary);
    margin-bottom: var(--rso-label-margin-bottom);
}

.rso-help {
    display: block;
    margin-top: var(--rso-space-1);
    font-size: 12px;
    color: var(--rso-text-muted);
    line-height: 1.45;
}

.rso-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--rso-space-3);
}

.rso-form-grid .full {
    grid-column: 1 / -1;
}

/* ---- Checkbox & radio ---- */
.rso-check,
.rso-radio {
    display: inline-flex;
    align-items: center;
    gap: var(--rso-space-2);
    font-size: var(--rso-control-font-size);
    font-weight: 600;
    color: var(--rso-text-secondary);
    cursor: pointer;
    margin: 0 0 var(--rso-space-2);
}

.rso-check input,
.rso-radio input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--rso-brand);
    cursor: pointer;
}

/* ---- Toggle ---- */
.rso-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--rso-space-2);
    cursor: pointer;
    font-size: var(--rso-control-font-size);
    font-weight: 600;
    color: var(--rso-text-secondary);
}

.rso-toggle input {
    appearance: none;
    width: 40px;
    height: 22px;
    border-radius: var(--rso-radius-pill);
    background: var(--rso-border-strong);
    position: relative;
    cursor: pointer;
    transition: background var(--rso-transition);
    margin: 0;
}

.rso-toggle input::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform var(--rso-transition);
}

.rso-toggle input:checked {
    background: var(--rso-brand);
}

.rso-toggle input:checked::after {
    transform: translateX(18px);
}

/* Toolbar-style switch (Applications menu) */
.rso-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    width: 46px;
    height: 28px;
    cursor: pointer;
    margin: 0;
}

.rso-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    margin: 0;
}

.rso-switch__track {
    position: absolute;
    inset: 0;
    border-radius: var(--rso-radius-pill);
    background: #d1d5db;
    transition: background var(--rso-transition);
}

.rso-switch__track::before {
    content: "";
    position: absolute;
    width: 22px;
    height: 22px;
    left: 3px;
    top: 3px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.18);
    transition: transform var(--rso-transition);
}

.rso-switch input:checked + .rso-switch__track {
    background: var(--rso-brand);
}

.rso-switch input:checked + .rso-switch__track::before {
    transform: translateX(18px);
}

.rso-switch input:disabled + .rso-switch__track {
    opacity: 0.45;
    cursor: not-allowed;
}

.rso-switch input:focus-visible + .rso-switch__track {
    box-shadow: 0 0 0 2px rgba(0, 153, 255, 0.25);
}

/* ---- Tabs ---- */
.rso-tabs {
    display: flex;
    align-items: center;
    gap: var(--rso-space-2);
    margin: 0 0 var(--rso-space-3);
    padding: 0 0 var(--rso-space-3);
    border-bottom: 1px solid var(--rso-border);
    overflow-x: auto;
}

.rso-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--rso-control-height);
    padding: 0 var(--rso-space-3);
    border: 1px solid var(--rso-border);
    border-radius: var(--rso-radius-pill);
    background: var(--rso-surface-muted);
    color: var(--rso-text-secondary);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: var(--rso-control-font-weight);
    white-space: nowrap;
    cursor: pointer;
    margin: 0;
    width: auto;
    transition: background var(--rso-transition), border-color var(--rso-transition), color var(--rso-transition);
}

.rso-tab:hover {
    border-color: var(--rso-brand-border);
    background: var(--rso-brand-soft);
    color: var(--rso-brand-text);
}

.rso-tab.is-active,
.rso-tab.active {
    background: var(--rso-text);
    border-color: var(--rso-text);
    color: #fff;
}

/* ---- Badges ---- */
.rso-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: var(--rso-radius-pill);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.3;
}

.rso-badge--primary {
    background: var(--rso-warning-soft);
    color: #92400e;
}

.rso-badge--info {
    background: var(--rso-brand-soft);
    color: var(--rso-brand-text);
    border: 1px solid var(--rso-brand-border);
}

.rso-badge--neutral {
    background: var(--rso-surface-muted);
    color: var(--rso-text-muted);
    border: 1px solid var(--rso-border);
}

/* ---- Cards ---- */
.rso-card {
    border: 1px solid var(--rso-border);
    border-radius: var(--rso-radius-lg);
    background: var(--rso-surface);
    padding: var(--rso-space-4) var(--rso-space-5);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.rso-card.is-highlight {
    background: linear-gradient(180deg, #f8fbff 0%, #fff 72%);
    border-color: var(--rso-brand-border);
}

.rso-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--rso-space-3);
    margin-bottom: var(--rso-space-3);
}

.rso-card__main {
    flex: 1;
    min-width: 0;
}

.rso-card__actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.rso-card__title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: var(--rso-text);
    line-height: 1.3;
}

.rso-card__subtitle {
    margin: 4px 0 0;
    color: var(--rso-text-muted);
    font-size: var(--rso-control-font-size);
    line-height: 1.45;
}

/* ---- Action menus (Actions ▼) ---- */
.rso-actions-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--rso-space-3);
    width: 100%;
    margin: 0 0 var(--rso-space-3);
}

.rso-actions-menu {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}

.rso-actions-menu__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: var(--rso-control-height);
    padding: 0 var(--rso-control-padding-x);
    border: 1px solid var(--rso-border-strong);
    border-radius: var(--rso-radius-pill);
    background: var(--rso-surface);
    color: var(--rso-text-secondary);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: var(--rso-control-font-weight);
    white-space: nowrap;
    cursor: pointer;
    margin: 0;
    width: auto;
    transition: border-color var(--rso-transition), background var(--rso-transition);
}

.rso-actions-menu__trigger:hover {
    border-color: var(--rso-brand-border);
    background: #f8fbff;
}

.rso-actions-menu__list {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 250px;
    background: var(--rso-surface);
    border: 1px solid var(--rso-border);
    border-radius: var(--rso-radius-md);
    box-shadow: var(--rso-shadow-menu);
    padding: 6px;
    z-index: 30;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rso-actions-menu__list[hidden] {
    display: none !important;
}

.rso-actions-menu__item {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    border-radius: var(--rso-radius-sm);
    background: transparent;
    color: var(--rso-text);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: block;
    margin: 0;
}

.rso-actions-menu__item:hover {
    background: var(--rso-surface-muted);
}

.rso-actions-menu__item.is-danger {
    color: var(--rso-danger);
}

.rso-actions-menu__item.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.rso-actions-menu__separator {
    height: 1px;
    background: var(--rso-border);
    margin: 6px 4px;
}

.rso-actions-menu__log-item {
    font-weight: 700;
}

/* ---- Modals ---- */
.modal-bg,
.rso-modal-bg,
.depot-modal-bg,
.users-admin-submodal,
.ce-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--rso-overlay);
    z-index: 99999;
    align-items: center;
    justify-content: center;
    padding: var(--rso-space-4);
    opacity: 0;
    transition: opacity 0.2s ease;
    overflow-y: auto;
}

.modal-bg[aria-hidden="true"],
.rso-modal-bg[aria-hidden="true"],
.depot-modal-bg[aria-hidden="true"],
.users-admin-submodal[aria-hidden="true"],
.ce-modal[aria-hidden="true"] {
    display: none !important;
}

.depot-modal-bg {
    z-index: 999999;
}

.users-admin-submodal {
    z-index: 100010;
}

.modal-bg.show,
.rso-modal-bg.show,
.rso-modal-bg.is-open,
.depot-modal-bg.show,
.users-admin-submodal.show,
.ce-modal.show,
.ce-modal.is-open {
    display: flex;
}

.modal-bg.show:not(.is-visible),
.rso-modal-bg.show:not(.is-visible),
.rso-modal-bg.is-open:not(.is-visible),
.depot-modal-bg.show:not(.is-visible),
.users-admin-submodal.show:not(.is-visible),
.ce-modal.show:not(.is-visible),
.ce-modal.is-open:not(.is-visible) {
    pointer-events: none;
}

.modal-bg.show.is-visible,
.rso-modal-bg.show.is-visible,
.rso-modal-bg.is-open.is-visible,
.depot-modal-bg.show.is-visible,
.users-admin-submodal.show.is-visible,
.ce-modal.show.is-visible,
.ce-modal.is-open.is-visible {
    opacity: 1;
}

.modal-bg.is-closing,
.rso-modal-bg.is-closing,
.depot-modal-bg.is-closing,
.users-admin-submodal.is-closing,
.ce-modal.is-closing {
    opacity: 0;
    pointer-events: none;
}

.rso-modal,
.modal-bg > .modal,
.rso-modal-bg > .rso-modal,
.depot-modal-bg > .depot-modal,
.users-admin-submodal > .modal,
.ce-modal > .ce-modal__dialog,
.ce-modal > .cc-modal-dialog {
    transform: scale(0.98) translateY(6px);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.modal-bg.show.is-visible > .modal,
.rso-modal-bg.show.is-visible > .rso-modal,
.rso-modal-bg.is-open.is-visible > .rso-modal,
.depot-modal-bg.show.is-visible > .depot-modal,
.users-admin-submodal.show.is-visible > .modal,
.ce-modal.show.is-visible > .ce-modal__dialog,
.ce-modal.show.is-visible > .cc-modal-dialog,
.ce-modal.is-open.is-visible > .ce-modal__dialog,
.ce-modal.is-open.is-visible > .cc-modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

.modal-bg.is-closing > .modal,
.rso-modal-bg.is-closing > .rso-modal,
.depot-modal-bg.is-closing > .depot-modal,
.users-admin-submodal.is-closing > .modal,
.ce-modal.is-closing > .ce-modal__dialog,
.ce-modal.is-closing > .cc-modal-dialog {
    transform: scale(0.98) translateY(6px);
    opacity: 0;
}

.rso-modal {
    background: var(--rso-surface);
    color: var(--rso-text);
    width: min(640px, 94vw);
    max-height: 90vh;
    border-radius: var(--rso-radius-xl);
    box-shadow: var(--rso-shadow-modal);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rso-modal--discard {
    width: min(480px, 94vw);
}

.rso-discard-modal {
    z-index: 100002;
}

.rso-modal__head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--rso-space-4);
    padding: var(--rso-space-6) var(--rso-space-6) var(--rso-space-4);
    border-bottom: 1px solid var(--rso-border);
}

.rso-modal__eyebrow {
    margin: 0 0 4px;
    color: var(--rso-brand);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rso-modal__head h2,
.rso-modal__head h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
}

.rso-modal__body {
    padding: var(--rso-space-6);
    overflow-y: auto;
    flex: 1;
}

.rso-modal__body p {
    margin: 0;
    color: var(--rso-text-secondary);
    line-height: 1.5;
}

.rso-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--rso-space-2);
    padding: var(--rso-space-4) var(--rso-space-6) var(--rso-space-6);
}

.rso-modal__close {
    background: transparent;
    border: none;
    color: var(--rso-text);
    font-size: 24px;
    line-height: 1;
    padding: 0;
    width: auto;
    margin: 0;
    cursor: pointer;
}

/* ---- Legacy aliases (migrate pages incrementally) ---- */
.page-shell .workspace-actions-menu-btn,
.rso-ui .workspace-actions-menu-btn,
.page-shell .rso-actions-menu__trigger,
.rso-ui .rso-actions-menu__trigger {
    height: var(--rso-control-height);
    padding: 0 var(--rso-control-padding-x);
    border-radius: var(--rso-radius-pill);
}

.page-shell .tab-btn,
.page-shell .contacts-inner-tab,
.rso-ui .tab-btn,
.rso-ui .contacts-inner-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: var(--rso-control-height);
    padding: 0 var(--rso-space-3);
    border: 1px solid var(--rso-border);
    border-radius: var(--rso-radius-pill);
    background: var(--rso-surface-muted);
    color: var(--rso-text-secondary);
    font-family: inherit;
    font-size: var(--rso-control-font-size);
    font-weight: var(--rso-control-font-weight);
    white-space: nowrap;
    cursor: pointer;
    margin: 0;
    width: auto;
    transition: background var(--rso-transition), border-color var(--rso-transition), color var(--rso-transition);
}

.page-shell .tab-btn:hover,
.page-shell .contacts-inner-tab:hover,
.rso-ui .tab-btn:hover,
.rso-ui .contacts-inner-tab:hover {
    border-color: var(--rso-brand-border);
    background: var(--rso-brand-soft);
    color: var(--rso-brand-text);
}

.page-shell .tab-btn.active,
.page-shell .contacts-inner-tab.active,
.rso-ui .tab-btn.active,
.rso-ui .contacts-inner-tab.active {
    background: var(--rso-text);
    border-color: var(--rso-text);
    color: #fff;
}

.page-shell .profile-tabs,
.page-shell .contacts-inner-tabs,
.rso-ui .profile-tabs,
.rso-ui .contacts-inner-tabs {
    display: flex;
    align-items: center;
    gap: var(--rso-space-2);
    margin: 0 0 var(--rso-space-3);
    padding: 0 0 var(--rso-space-3);
    border-bottom: 1px solid var(--rso-border);
    overflow-x: auto;
    flex-shrink: 0;
}

.page-shell .client-contact-action-btn,
.rso-ui .client-contact-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px;
    border: 1px solid transparent;
    border-radius: var(--rso-radius-sm);
    background: transparent;
    color: var(--rso-text-muted);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    margin: 0;
    width: auto;
}

.page-shell .field label,
.rso-ui .field label {
    font-size: var(--rso-label-font-size);
    font-weight: var(--rso-label-font-weight);
    color: var(--rso-text-secondary);
    margin-bottom: var(--rso-label-margin-bottom);
}

.page-shell .field input,
.page-shell .field select,
.page-shell .field textarea,
.rso-ui .field input,
.rso-ui .field select,
.rso-ui .field textarea {
    width: 100%;
    padding: 11px;
    border: 1px solid var(--rso-border-strong);
    border-radius: var(--rso-radius-sm);
    font-size: var(--rso-control-font-size);
    margin: 0;
}

.page-shell .modal-bg,
.rso-ui .modal-bg {
    background: var(--rso-overlay);
}

.page-shell .modal,
.rso-ui .modal {
    border-radius: var(--rso-radius-xl);
}

@media (prefers-reduced-motion: reduce) {
    .rso-btn,
    .rso-tab,
    .rso-actions-menu__trigger,
    .rso-toggle input::after,
    .rso-compound,
    .modal-bg,
    .rso-modal-bg,
    .depot-modal-bg,
    .users-admin-submodal,
    .ce-modal,
    .modal-bg > .modal,
    .rso-modal-bg > .rso-modal,
    .depot-modal-bg > .depot-modal,
    .users-admin-submodal > .modal,
    .ce-modal > .ce-modal__dialog,
    .ce-modal > .cc-modal-dialog {
        transition: none;
    }
}

/* ---- Private header toolbar ---- */
.header-search {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 150px;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    height: calc(40px + 6px);
    padding: 3px;
    margin-left: var(--rso-space-4);
    border: 1px solid rgba(51, 65, 85, 0.75);
    border-radius: var(--rso-radius-pill);
    background: rgba(30, 41, 59, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    box-sizing: border-box;
    transition: flex var(--rso-transition), width var(--rso-transition), max-width var(--rso-transition), border-color var(--rso-transition), background var(--rso-transition);
}

.header-search:focus-within,
.header-search.has-value {
    flex: 1 1 auto;
    width: 100%;
    min-width: 150px;
    max-width: none;
    border-color: var(--rso-brand-border);
    background: rgba(15, 23, 42, 0.82);
    box-shadow: 0 0 0 2px rgba(0, 153, 255, 0.18);
}

.header-search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--rso-toolbar-placeholder);
    pointer-events: none;
    z-index: 1;
}

.header-search-icon svg {
    display: block;
    width: 18px;
    height: 18px;
}

.header-search-input {
    display: block;
    width: 100%;
    height: 40px;
    padding: 0 14px 0 36px;
    margin: 0;
    border: none;
    border-radius: var(--rso-radius-pill);
    background: transparent;
    color: var(--rso-toolbar-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.2;
    box-sizing: border-box;
}

.header-search-input::placeholder {
    color: var(--rso-toolbar-placeholder);
}

.header-search-input:focus {
    outline: none;
}

.header-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 1200;
    max-height: 360px;
    overflow-y: auto;
    background: var(--rso-surface);
    border: 1px solid var(--rso-border);
    border-radius: var(--rso-radius-md);
    box-shadow: var(--rso-shadow-menu);
    color: var(--rso-text);
}

.header-search-results.is-open,
.header-search-results.show {
    display: block;
}

.header-search-group {
    padding: 8px 0;
    border-bottom: 1px solid var(--rso-border);
}

.header-search-group:last-child {
    border-bottom: none;
}

.header-search-group-label {
    padding: 4px 14px 6px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--rso-text-subtle);
}

.header-search-item {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    margin: 0;
    box-sizing: border-box;
}

.header-search-item:hover,
.header-search-item.is-active {
    background: var(--rso-brand-soft);
}

.header-search-item strong {
    display: block;
    font-size: 14px;
    color: var(--rso-text);
}

.header-search-item small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    color: var(--rso-text-muted);
}

.header-search-result {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
    width: 100%;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--rso-border);
    background: var(--rso-surface);
    color: var(--rso-text);
    text-align: left;
    cursor: pointer;
    margin: 0;
    box-sizing: border-box;
}

.header-search-result:last-child {
    border-bottom: none;
}

.header-search-result:hover,
.header-search-result.active {
    background: var(--rso-brand-soft);
}

.header-search-result-name {
    display: block;
    font-weight: 700;
    color: var(--rso-text);
}

.header-search-result-meta {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    font-weight: 600;
    color: var(--rso-text-muted);
}

.header-search-result-phone {
    color: var(--rso-text-muted);
    font-weight: 700;
    white-space: nowrap;
}

.header-search-empty,
.header-search-hint {
    padding: 14px;
    font-size: 13px;
    color: var(--rso-text-muted);
}

.header-nav-link {
    text-decoration: none;
    color: inherit;
}

.header-toolbar-cluster {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
}

.header-toolbar-apps,
.header-toolbar-utilities,
.header-toolbar-user {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: rgba(30, 41, 59, 0.72);
    border: 1px solid rgba(51, 65, 85, 0.75);
    border-radius: var(--rso-radius-pill);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.header-toolbar-user #headerToolbarUserActions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.header-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    padding: 0 14px;
    border: none;
    border-radius: var(--rso-radius-pill);
    background: transparent;
    color: var(--rso-toolbar-text);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    margin: 0;
    width: auto;
    cursor: pointer;
    transition: background var(--rso-transition), color var(--rso-transition), box-shadow var(--rso-transition);
}

.header-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: var(--rso-radius-pill);
    background: transparent;
    color: var(--rso-toolbar-text);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--rso-transition), color var(--rso-transition), box-shadow var(--rso-transition);
}

a.header-icon {
    text-decoration: none;
}

.header-toolbar-apps .header-nav-btn:hover,
.header-toolbar-apps .header-icon:hover,
.header-toolbar-utilities .header-icon:hover,
.header-toolbar-user .header-icon:hover,
.header-toolbar-user .header-nav-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.header-nav-btn.active,
.header-icon.active {
    background: var(--rso-brand);
    color: #fff;
    box-shadow: 0 2px 10px rgba(0, 153, 255, 0.32);
}

.header-toolbar-apps .header-nav-btn + a.header-icon,
.header-toolbar-apps .header-nav-btn + button.header-icon {
    margin-left: 4px;
}

.header-toolbar-apps .header-nav-btn + a.header-icon::before,
.header-toolbar-apps .header-nav-btn + button.header-icon::before {
    content: "";
    position: absolute;
    left: -3px;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 22px;
    background: rgba(148, 163, 184, 0.35);
    pointer-events: none;
}

.header-icon-glyph {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.header-icon-glyph svg {
    display: block;
    width: 20px;
    height: 20px;
}

.header-alert .header-icon-glyph svg {
    color: currentColor;
}

.header-alert-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px rgba(30, 41, 59, 0.95);
}

.logo img {
    display: block;
    height: 42px;
    width: auto;
}

/* ---- Site-wide workspace alignment ---- */
html {
    -webkit-text-size-adjust: 100%;
    width: 100%;
}

body {
    margin: 0;
    width: 100%;
}

.rso-app-shell {
    box-sizing: border-box;
}

.page-shell,
.rso-page-canvas {
    color: var(--rso-text);
    line-height: 1.45;
}

.page-shell h1,
.rso-page-canvas h1 {
    color: var(--rso-text);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.page-shell h2,
.page-shell h3,
.rso-page-canvas h2,
.rso-page-canvas h3 {
    color: var(--rso-text);
    line-height: 1.25;
}

.page-shell p,
.rso-page-canvas p {
    color: var(--rso-text-muted);
}

/* Keep toolbar/header controls compact; workspace buttons stay auto-width */
.page-shell button,
.page-shell input[type="button"],
.page-shell input[type="submit"],
.page-shell input[type="reset"],
.rso-page-canvas button {
    font-family: inherit;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

.page-shell input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="file"]),
.page-shell select,
.page-shell textarea,
.rso-page-canvas input:not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="file"]),
.rso-page-canvas select,
.rso-page-canvas textarea {
    font-family: inherit;
    box-sizing: border-box;
}

.page-shell table,
.rso-page-canvas table {
    width: 100%;
    border-collapse: collapse;
}

.page-shell th,
.page-shell td,
.rso-page-canvas th,
.rso-page-canvas td {
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--rso-border);
    color: var(--rso-text);
}

.page-shell th,
.rso-page-canvas th {
    color: var(--rso-text-secondary);
    background: var(--rso-surface-soft);
    font-weight: 700;
    font-size: 13px;
}

.page-shell a,
.rso-page-canvas a {
    color: var(--rso-brand);
}

/* Shared page header rhythm */
.page-shell .dashboard-head,
.page-shell .import-head,
.page-shell .callbacks-head,
.page-shell .crm-head,
.page-shell .map-head {
    margin-bottom: var(--rso-space-5);
}

.page-shell .dashboard-head h1,
.page-shell .import-head h1,
.page-shell .callbacks-head h1,
.page-shell .crm-head h1,
.page-shell .map-head h1 {
    margin: 0;
    font-size: clamp(26px, 3vw, 32px);
    font-weight: 800;
}

.page-shell .dashboard-head p,
.page-shell .import-head p,
.page-shell .callbacks-head p,
.page-shell .crm-head p,
.page-shell .map-head p {
    margin: 8px 0 0;
}

/* Card surfaces inside workspace pages */
.page-shell .import-card,
.page-shell .dashboard-card,
.page-shell .call-hero-card,
.page-shell .callback-card,
.page-shell .list-card,
.page-shell .depot-card {
    background: var(--rso-surface);
    border: 1px solid var(--rso-border);
}

@media (max-width: 800px) {
    .header {
        flex-wrap: wrap;
        row-gap: var(--rso-space-3);
    }

    .header-left,
    .header-actions {
        width: 100%;
    }

    .header-search {
        margin-left: var(--rso-space-3);
    }

    .header-search:focus-within,
    .header-search.has-value {
        flex: 1 1 auto;
        width: 100%;
        max-width: none;
    }

    .header-toolbar-cluster {
        justify-content: flex-start;
    }
}
