/* CRM UI system — loaded after legacy styles to provide one consistent layer. */

:root {
    --ui-primary: var(--primary-color, #e30613);
    --ui-primary-hover: #c90b18;
    --ui-primary-soft: #fff0f1;
    --ui-ink: #172033;
    --ui-muted: #667085;
    --ui-subtle: #98a2b3;
    --ui-canvas: #f5f7fb;
    --ui-surface: #ffffff;
    --ui-surface-soft: #f8fafc;
    --ui-border: #e4e7ec;
    --ui-border-strong: #d0d5dd;
    --ui-sidebar: #101828;
    --ui-sidebar-soft: #1d2939;
    --ui-success: #15803d;
    --ui-warning: #b45309;
    --ui-danger: #d92d20;
    --ui-info: #175cd3;
    --ui-radius-sm: 10px;
    --ui-radius: 14px;
    --ui-radius-lg: 18px;
    --ui-shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --ui-shadow: 0 8px 24px rgba(16, 24, 40, .07);
    --ui-shadow-lg: 0 18px 45px rgba(16, 24, 40, .12);
    --ui-sidebar-width: 272px;
    --ui-content-max: 1440px;
    --ui-tap: 44px;
}

html {
    min-width: 320px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body,
body.crm-authenticated {
    min-width: 320px !important;
    background: var(--ui-canvas) !important;
    color: var(--ui-ink) !important;
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif !important;
    font-size: 15px;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

* {
    box-sizing: border-box;
}

img,
svg,
video,
canvas {
    max-width: 100%;
}

a {
    text-underline-offset: 3px;
}

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid rgba(23, 92, 211, .28) !important;
    outline-offset: 2px !important;
}

.ui-skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 3000;
    padding: 10px 14px;
    border-radius: var(--ui-radius-sm);
    background: var(--ui-ink);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-160%);
    transition: transform .18s ease;
}

.ui-skip-link:focus {
    color: #fff;
    transform: translateY(0);
}

/* Header */
body.crm-authenticated .crm-header {
    background: rgba(255, 255, 255, .96) !important;
    border-bottom: 1px solid var(--ui-border) !important;
    box-shadow: var(--ui-shadow-sm) !important;
    backdrop-filter: blur(14px);
}

body.crm-authenticated .crm-header .header-inner {
    min-height: 72px;
}

.brand {
    min-width: 0;
}

.brand-icon {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px;
    border-radius: 12px !important;
    background: var(--ui-primary) !important;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--ui-primary) 24%, transparent);
}

.brand-title {
    color: var(--ui-ink);
    font-size: 18px !important;
    font-weight: 800 !important;
    letter-spacing: -.02em;
}

.brand-subtitle {
    max-width: 520px;
    color: var(--ui-muted) !important;
    font-size: 12px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-panel {
    color: var(--ui-ink);
    font-size: 14px;
    font-weight: 650 !important;
}

.user-panel form {
    margin: 0;
}

.user-panel button,
.user-panel .push-toggle {
    min-height: 40px;
    padding: 9px 14px !important;
    border: 1px solid var(--ui-border-strong) !important;
    border-radius: var(--ui-radius-sm) !important;
    background: var(--ui-surface) !important;
    color: var(--ui-ink) !important;
    font-size: 13px;
    font-weight: 700 !important;
    box-shadow: var(--ui-shadow-sm);
}

.user-panel button:hover,
.user-panel .push-toggle:hover {
    border-color: var(--ui-primary) !important;
    color: var(--ui-primary) !important;
}

/* Navigation */
body.crm-authenticated .quick-menu-section {
    background: linear-gradient(180deg, var(--ui-sidebar) 0%, #0b1220 100%) !important;
}

body.crm-authenticated .quick-menu-title {
    color: #f9fafb !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: .08em;
    text-transform: uppercase;
}

body.crm-authenticated .quick-menu-card {
    position: relative;
    border: 1px solid transparent !important;
    border-radius: 12px !important;
    transition: background-color .16s ease, border-color .16s ease, color .16s ease !important;
}

body.crm-authenticated .quick-menu-card:hover,
body.crm-authenticated .quick-menu-card:focus-visible,
body.crm-authenticated .quick-menu-card.active {
    background: rgba(255, 255, 255, .09) !important;
    border-color: rgba(255, 255, 255, .11) !important;
}

body.crm-authenticated .quick-menu-card.active::after {
    content: "";
    position: absolute;
    top: 12px;
    right: 8px;
    bottom: 12px;
    width: 3px;
    border-radius: 999px;
    background: var(--ui-primary);
}

body.crm-authenticated .quick-menu-icon {
    background: rgba(255, 255, 255, .09) !important;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", sans-serif;
}

/* Page structure */
body.crm-authenticated main.crm-container.page {
    color: var(--ui-ink);
}

.page-head,
body.crm-authenticated .page-head {
    position: relative;
    overflow: hidden;
    padding: 22px 24px !important;
    border: 1px solid var(--ui-border) !important;
    border-left: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius-lg) !important;
    background: linear-gradient(135deg, #fff 0%, #fbfcfe 100%) !important;
    box-shadow: var(--ui-shadow-sm) !important;
}

.page-head::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--ui-primary);
}

.page-head h1 {
    color: var(--ui-ink);
    font-size: clamp(24px, 3vw, 32px) !important;
    line-height: 1.2;
    letter-spacing: -.035em;
}

.page-head p {
    max-width: 780px;
    color: var(--ui-muted) !important;
    font-size: 14px;
}

.page-head .mb-3 {
    margin-bottom: 14px !important;
}

/* Surfaces */
:where(.panel, .crm-card, .card, .filter-card, .filters-card, .tasks-filter-card, .task-card, .table-card, .stat-card) {
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius) !important;
    background: var(--ui-surface) !important;
    box-shadow: var(--ui-shadow-sm) !important;
}

:where(.panel, .crm-card, .filter-card, .filters-card, .tasks-filter-card, .task-card, .table-card) {
    padding: clamp(16px, 2vw, 22px) !important;
}

:where(.panel, .crm-card, .card, .filter-card, .task-card):hover {
    border-color: var(--ui-border-strong) !important;
}

:where(.panel, .crm-card, .card) h2,
:where(.panel, .crm-card, .card) h3,
:where(.panel, .crm-card, .card) h4 {
    color: var(--ui-ink);
    letter-spacing: -.02em;
}

.stats-grid {
    gap: 14px !important;
}

.stat-card {
    min-width: 0;
    padding: 18px !important;
}

.stat-label,
.stat-card > span:first-child {
    color: var(--ui-muted) !important;
    font-size: 13px;
    font-weight: 650 !important;
}

.stat-value,
.stat-card > strong {
    color: var(--ui-ink);
    font-size: clamp(24px, 3vw, 32px) !important;
    font-weight: 800 !important;
    letter-spacing: -.035em;
}

/* Forms */
.form-label,
form label {
    color: #344054;
    font-size: 13px;
    font-weight: 650 !important;
}

:where(.form-control, .form-select, input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    min-height: var(--ui-tap) !important;
    border: 1px solid var(--ui-border-strong) !important;
    border-radius: var(--ui-radius-sm) !important;
    background-color: var(--ui-surface) !important;
    color: var(--ui-ink) !important;
    font-size: 15px !important;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04) !important;
}

:where(.form-control, .form-select, input, select, textarea):hover {
    border-color: #98a2b3 !important;
}

:where(.form-control, .form-select, input, select, textarea):focus {
    border-color: #84adff !important;
    box-shadow: 0 0 0 4px rgba(23, 92, 211, .12) !important;
}

body .form-control:focus,
body .form-select:focus,
body input:focus,
body select:focus,
body textarea:focus {
    border-color: #84adff !important;
    box-shadow: 0 0 0 4px rgba(23, 92, 211, .12) !important;
}

body .form-control:focus-visible,
body .form-select:focus-visible,
body input:focus-visible,
body select:focus-visible,
body textarea:focus-visible {
    outline: 0 !important;
}

textarea.form-control,
textarea {
    min-height: 112px;
    resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--ui-primary);
}

.form-text,
.helptext,
.text-muted {
    color: var(--ui-muted) !important;
}

.filter-grid {
    gap: 14px !important;
}

/* Buttons */
.btn,
button:not(.matrix-cell-btn) {
    min-height: 40px;
    border-radius: var(--ui-radius-sm) !important;
    font-size: 14px;
    font-weight: 700 !important;
    line-height: 1.25;
    transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease, border-color .12s ease !important;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn-primary,
.btn-danger {
    border-color: var(--ui-primary) !important;
    background: var(--ui-primary) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px color-mix(in srgb, var(--ui-primary) 18%, transparent);
}

.btn-primary:hover,
.btn-danger:hover {
    border-color: var(--ui-primary-hover) !important;
    background: var(--ui-primary-hover) !important;
}

.btn-dark,
.btn-secondary {
    border-color: var(--ui-sidebar-soft) !important;
    background: var(--ui-sidebar-soft) !important;
    color: #fff !important;
}

.btn-outline-secondary {
    border-color: var(--ui-border-strong) !important;
    background: #fff !important;
    color: #344054 !important;
}

.btn-outline-secondary:hover {
    border-color: #98a2b3 !important;
    background: var(--ui-surface-soft) !important;
    color: var(--ui-ink) !important;
}

.btn-sm {
    min-height: 34px;
}

.btn:disabled,
button:disabled {
    cursor: not-allowed;
    opacity: .55;
}

/* Feedback */
.alert {
    border: 1px solid transparent !important;
    border-radius: var(--ui-radius) !important;
    font-size: 14px;
    box-shadow: var(--ui-shadow-sm);
}

.alert-danger { border-color: #fecdca !important; background: #fef3f2 !important; color: #912018 !important; }
.alert-success { border-color: #abefc6 !important; background: #ecfdf3 !important; color: #05603a !important; }
.alert-warning { border-color: #fedf89 !important; background: #fffaeb !important; color: #93370d !important; }
.alert-info { border-color: #b2ddff !important; background: #eff8ff !important; color: #1849a9 !important; }

.badge {
    padding: 5px 9px;
    border-radius: 999px;
    font-weight: 650;
}

/* Tables */
.ui-table-scroll,
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--ui-border);
    border-radius: var(--ui-radius);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.ui-table-scroll > table,
.table-responsive > table {
    margin-bottom: 0 !important;
}

:where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) {
    width: 100%;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    background: var(--ui-surface) !important;
    color: var(--ui-ink) !important;
    font-size: 14px;
}

:where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) thead th {
    border-color: var(--ui-border) !important;
    background: #f2f4f7 !important;
    color: #475467 !important;
    font-size: 12px !important;
    font-weight: 750 !important;
    letter-spacing: .02em;
    line-height: 1.35;
    text-transform: none;
    white-space: nowrap;
}

:where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) th,
:where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) td {
    padding: 12px 14px !important;
    border-color: var(--ui-border) !important;
    vertical-align: middle;
}

:where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) tbody tr:hover > * {
    background-color: #f9fafb !important;
}

:where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) tbody tr:last-child > * {
    border-bottom: 0;
}

/* Pagination and tabs */
.pagination {
    gap: 6px;
    flex-wrap: wrap;
}

.page-link {
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ui-border) !important;
    border-radius: 9px !important;
    color: #344054;
    font-weight: 650;
}

.page-item.active .page-link {
    border-color: var(--ui-primary) !important;
    background: var(--ui-primary) !important;
}

.nav-tabs {
    gap: 6px;
    border-bottom-color: var(--ui-border);
}

.nav-tabs .nav-link {
    min-height: 40px;
    border-radius: 10px 10px 0 0;
    color: var(--ui-muted);
    font-weight: 650;
}

.nav-tabs .nav-link.active {
    color: var(--ui-primary);
}

/* Dialogs and media */
.modal-content {
    border: 1px solid var(--ui-border) !important;
    border-radius: var(--ui-radius-lg) !important;
    box-shadow: var(--ui-shadow-lg) !important;
}

.modal-header,
.modal-footer {
    border-color: var(--ui-border) !important;
}

audio,
video {
    width: 100%;
    border-radius: var(--ui-radius-sm);
}

/* Page-specific components aligned to the shared system. */
body.crm-authenticated :where(
    .attention-card,
    .sales-kpi,
    .sales-panel,
    .sales-action-card,
    .sales-mini-stat,
    .leader-kpi,
    .leader-panel,
    .leader-insight-card,
    .academy-category-card,
    .academy-learn-card,
    .academy-lesson-card,
    .academy-panel,
    .planner-task
) {
    border-color: var(--ui-border) !important;
    border-radius: var(--ui-radius) !important;
    box-shadow: var(--ui-shadow-sm) !important;
}

body.crm-authenticated :where(.attention-card, .sales-kpi, .leader-kpi) {
    background: var(--ui-surface) !important;
}

body.crm-authenticated :where(.attention-card, .sales-kpi, .leader-kpi) span {
    color: var(--ui-muted) !important;
    font-size: 12px !important;
    font-weight: 650 !important;
}

body.crm-authenticated :where(.attention-card, .sales-kpi, .leader-kpi) strong {
    color: var(--ui-ink);
    font-weight: 800 !important;
    letter-spacing: -.03em;
}

body.crm-authenticated :where(.task-tab, .sales-tab, .academy-tab) {
    min-height: 40px;
    border-color: var(--ui-border-strong) !important;
    border-radius: var(--ui-radius-sm) !important;
    background: var(--ui-surface) !important;
    color: #344054 !important;
    font-size: 13px;
    font-weight: 700 !important;
}

body.crm-authenticated :where(.task-tab.active, .sales-tab.is-active, .academy-tab.active) {
    border-color: var(--ui-sidebar-soft) !important;
    background: var(--ui-sidebar-soft) !important;
    color: #fff !important;
}

body.crm-authenticated .task-text {
    border-color: var(--ui-border) !important;
    border-radius: var(--ui-radius-sm) !important;
    background: var(--ui-surface-soft) !important;
    color: var(--ui-ink);
}

body.crm-authenticated .academy-dashboard-pro {
    max-width: var(--ui-content-max) !important;
    padding: 0 0 24px !important;
}

body.crm-authenticated .academy-hero-learning {
    border-color: var(--ui-border) !important;
    border-left: 4px solid var(--ui-primary) !important;
    border-radius: var(--ui-radius-lg) !important;
    background: linear-gradient(135deg, #fff 0%, #fff8f8 55%, #f8fafc 100%) !important;
    box-shadow: var(--ui-shadow-sm) !important;
}

body.crm-authenticated .academy-kicker,
body.crm-authenticated .academy-link-arrow {
    color: var(--ui-primary) !important;
}

body.crm-authenticated .sales-panel,
body.crm-authenticated .leader-panel {
    background: var(--ui-surface) !important;
}

body.crm-authenticated .sales-empty {
    border-color: var(--ui-border-strong) !important;
    border-radius: var(--ui-radius) !important;
    background: var(--ui-surface-soft) !important;
    color: var(--ui-muted) !important;
}

body.crm-authenticated .sales-action-card {
    background: var(--ui-surface-soft) !important;
}

body.crm-authenticated .client-summary-hero {
    border-radius: var(--ui-radius-lg) !important;
    background: linear-gradient(135deg, var(--ui-sidebar) 0%, #243653 100%) !important;
    box-shadow: var(--ui-shadow) !important;
}

/* Authentication pages */
.login-page {
    min-height: 100dvh !important;
    padding: 24px !important;
    background:
        radial-gradient(circle at 12% 10%, rgba(227, 6, 19, .12), transparent 32%),
        linear-gradient(145deg, #f8fafc, #eef2f7) !important;
}

.login-card {
    width: min(100%, 460px) !important;
    padding: clamp(24px, 5vw, 36px) !important;
    border: 1px solid rgba(255, 255, 255, .7) !important;
    border-radius: 22px !important;
    background: rgba(255, 255, 255, .96) !important;
    box-shadow: var(--ui-shadow-lg) !important;
}

.login-brand-title {
    color: var(--ui-ink) !important;
    font-size: 26px !important;
    letter-spacing: -.035em;
}

.login-brand-subtitle {
    color: var(--ui-muted) !important;
}

/* Desktop shell */
@media (min-width: 769px) {
    body.crm-authenticated .quick-menu-section {
        width: var(--ui-sidebar-width) !important;
        padding: 24px 16px !important;
    }

    body.crm-authenticated .crm-header {
        width: calc(100% - var(--ui-sidebar-width)) !important;
        margin-left: var(--ui-sidebar-width) !important;
    }

    body.crm-authenticated .crm-header .header-inner {
        width: min(100%, var(--ui-content-max)) !important;
        max-width: var(--ui-content-max) !important;
        margin-inline: auto !important;
        padding: 14px 28px !important;
    }

    body.crm-authenticated main.crm-container.page,
    body.crm-authenticated .crm-container.page {
        width: calc(100% - var(--ui-sidebar-width)) !important;
        margin-left: var(--ui-sidebar-width) !important;
        padding: 28px !important;
    }

    body.crm-authenticated main.crm-container.page > *,
    body.crm-authenticated .crm-container.page > * {
        width: min(100%, var(--ui-content-max)) !important;
        max-width: var(--ui-content-max) !important;
        margin-inline: auto !important;
    }

    body.crm-authenticated main.crm-container.page > .dashboard-mode-note,
    body.crm-authenticated .crm-container.page > .dashboard-mode-note {
        display: flex !important;
        width: min(100%, var(--ui-content-max)) !important;
        max-width: var(--ui-content-max) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}

/* Tablet and mobile */
@media (max-width: 768px) {
    body.crm-authenticated {
        padding-bottom: calc(74px + env(safe-area-inset-bottom)) !important;
    }

    body.crm-authenticated .crm-header {
        position: sticky !important;
        top: 0;
        z-index: 1100 !important;
        width: 100% !important;
        padding: 0 !important;
    }

    body.crm-authenticated .crm-header .header-inner,
    body.crm-authenticated .header-inner {
        min-height: 60px;
        padding: 9px 14px !important;
        gap: 10px !important;
    }

    .brand {
        gap: 9px !important;
    }

    .brand-icon {
        width: 38px !important;
        height: 38px !important;
        min-width: 38px;
        font-size: 20px !important;
    }

    .brand-title {
        max-width: 46vw;
        font-size: 15px !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .brand-subtitle,
    .user-panel > span,
    .user-panel .push-toggle {
        display: none !important;
    }

    .user-panel {
        gap: 6px !important;
    }

    .user-panel button {
        min-width: 44px;
        min-height: 40px;
        padding: 8px 10px !important;
        font-size: 12px;
    }

    body.crm-authenticated .quick-menu-section {
        position: static !important;
        width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 12px 0 !important;
        overflow: hidden !important;
        box-shadow: none !important;
    }

    body.crm-authenticated .quick-menu-section .crm-container {
        padding: 0 14px !important;
    }

    body.crm-authenticated .quick-menu-title {
        margin: 0 0 8px !important;
        padding: 0 !important;
        border: 0 !important;
        font-size: 11px !important;
    }

    body.crm-authenticated .quick-menu-grid {
        display: flex !important;
        gap: 8px !important;
        width: 100% !important;
        padding: 0 0 4px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
    }

    body.crm-authenticated .quick-menu-grid::-webkit-scrollbar {
        display: none;
    }

    body.crm-authenticated .quick-menu-card {
        display: grid !important;
        flex: 0 0 156px !important;
        grid-template-columns: 34px minmax(0, 1fr) !important;
        gap: 9px !important;
        min-width: 156px !important;
        min-height: 58px !important;
        padding: 9px 10px !important;
        background: rgba(255, 255, 255, .07) !important;
        color: #fff !important;
        scroll-snap-align: start;
    }

    body.crm-authenticated .quick-menu-icon {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        font-size: 16px !important;
    }

    body.crm-authenticated .quick-menu-name {
        color: #fff !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
    }

    body.crm-authenticated .quick-menu-desc {
        display: none !important;
    }

    body.crm-authenticated main.crm-container.page,
    body.crm-authenticated .crm-container.page,
    body.crm-authenticated .page {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 14px 12px 20px !important;
    }

    .page-head,
    body.crm-authenticated .page-head {
        padding: 17px 16px !important;
        margin-bottom: 12px !important;
        border-radius: var(--ui-radius) !important;
    }

    .page-head h1 {
        font-size: 23px !important;
    }

    .page-head p {
        font-size: 13px;
    }

    :where(.panel, .crm-card, .card, .filter-card, .filters-card, .tasks-filter-card, .task-card, .table-card) {
        padding: 15px !important;
        border-radius: 12px !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .stat-card {
        padding: 14px !important;
    }

    .stat-value,
    .stat-card > strong {
        font-size: 24px !important;
    }

    .filter-grid,
    .row.filter-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .btn,
    button:not(.matrix-cell-btn),
    :where(.form-control, .form-select, input:not([type="checkbox"]):not([type="radio"]), select) {
        min-height: var(--ui-tap) !important;
    }

    .d-flex:has(> .btn) {
        flex-wrap: wrap;
    }

    .d-flex:has(> .btn) > .btn {
        flex: 1 1 auto;
    }

    .ui-table-scroll,
    .table-responsive {
        margin-inline: 0;
        border-radius: 12px;
    }

    :where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) {
        min-width: 680px;
        font-size: 13px;
    }

    :where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) th,
    :where(.table, .sales-table, .leader-summary-table, .matrix-table, .academy-table, .suot-register-table) td {
        padding: 10px 11px !important;
    }

    .mobile-card-table.ui-mobile-cards {
        min-width: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    .mobile-card-table.ui-mobile-cards thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }

    .mobile-card-table.ui-mobile-cards tbody,
    .mobile-card-table.ui-mobile-cards tr,
    .mobile-card-table.ui-mobile-cards td {
        display: block;
        width: 100%;
    }

    .mobile-card-table.ui-mobile-cards tbody {
        display: grid;
        gap: 10px;
    }

    .mobile-card-table.ui-mobile-cards tr {
        overflow: hidden;
        border: 1px solid var(--ui-border);
        border-radius: 12px;
        background: #fff;
        box-shadow: var(--ui-shadow-sm);
    }

    .mobile-card-table.ui-mobile-cards td {
        display: grid;
        grid-template-columns: minmax(104px, 38%) minmax(0, 1fr);
        gap: 12px;
        padding: 10px 12px !important;
        border: 0 !important;
        border-bottom: 1px solid var(--ui-border) !important;
        text-align: left !important;
        overflow-wrap: anywhere;
    }

    .mobile-card-table.ui-mobile-cards td:last-child {
        border-bottom: 0 !important;
    }

    .mobile-card-table.ui-mobile-cards td::before {
        content: attr(data-ui-label);
        color: var(--ui-muted);
        font-size: 11px;
        font-weight: 750;
        line-height: 1.35;
        text-transform: uppercase;
    }

    body.crm-authenticated .crm-mobile-tabbar {
        gap: 2px !important;
        padding: 7px 8px calc(7px + env(safe-area-inset-bottom)) !important;
        border-color: var(--ui-border) !important;
        background: rgba(255, 255, 255, .97) !important;
        backdrop-filter: blur(14px);
    }

    body.crm-authenticated .crm-mobile-tabbar a {
        min-height: 50px !important;
        color: var(--ui-muted) !important;
        font-size: 10px !important;
    }

    body.crm-authenticated .crm-mobile-tabbar a.active {
        color: var(--ui-primary) !important;
        background: var(--ui-primary-soft) !important;
    }

    body.crm-authenticated .crm-mobile-tabbar-main,
    body.crm-authenticated .crm-mobile-tabbar-main.active {
        background: var(--ui-primary) !important;
        color: #fff !important;
        box-shadow: 0 8px 18px color-mix(in srgb, var(--ui-primary) 22%, transparent) !important;
    }

    .modal-dialog {
        margin: 12px !important;
    }

    body.crm-authenticated :where(.sales-period-form, .leader-filter) {
        display: grid !important;
        grid-template-columns: 1fr !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    body.crm-authenticated :where(.sales-period-form, .leader-filter) label,
    body.crm-authenticated :where(.sales-period-form, .leader-filter) input,
    body.crm-authenticated :where(.sales-period-form, .leader-filter) select,
    body.crm-authenticated :where(.sales-period-form, .leader-filter) button {
        width: 100% !important;
        min-width: 0 !important;
    }

    body.crm-authenticated :where(.sales-dashboard-grid, .sales-action-card, .academy-layout, .academy-hero-learning) {
        grid-template-columns: 1fr !important;
    }

    body.crm-authenticated :where(.sales-kpi-grid, .leader-kpi-grid, .academy-categories) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@media (max-width: 420px) {
    .login-page {
        padding: 12px !important;
    }

    .login-card {
        padding: 22px 18px !important;
        border-radius: 18px !important;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    body.crm-authenticated :where(.sales-kpi-grid, .leader-kpi-grid, .academy-categories) {
        grid-template-columns: 1fr !important;
    }

    .mobile-card-table.ui-mobile-cards td {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    body.crm-authenticated .crm-mobile-tabbar strong {
        max-width: 58px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}

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