.company-branding-head {
    align-items: flex-end;
}

.company-branding-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, .75fr);
    gap: 1.25rem;
    align-items: start;
}

.company-branding-form-card,
.company-branding-live-preview,
.company-branding-rules,
.company-branding-restore-card {
    overflow: hidden;
}

.company-branding-panel-head {
    margin-bottom: 1.15rem;
}

.company-branding-fields {
    margin-bottom: 1.25rem;
}

.company-branding-assets {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.company-branding-asset-card {
    border: 1px solid rgba(79, 144, 196, .26);
    border-radius: 18px;
    background: linear-gradient(180deg, #fff 0%, #f8fcff 100%);
    padding: 1rem;
    min-width: 0;
}

.company-branding-asset-head {
    display: flex;
    justify-content: space-between;
    gap: .75rem;
    align-items: flex-start;
    margin-bottom: .9rem;
}

.company-branding-asset-head span:first-child {
    display: block;
    color: #387095;
    font-size: .74rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.company-branding-asset-head h3 {
    margin: .18rem 0 0;
    color: #0d3553;
    font-size: 1rem;
}

.company-branding-logo-preview,
.company-branding-icon-preview {
    display: grid;
    place-items: center;
    min-height: 116px;
    margin-bottom: .85rem;
    border: 1px dashed rgba(66, 137, 188, .36);
    border-radius: 15px;
    background:
        linear-gradient(45deg, rgba(218, 237, 248, .55) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(218, 237, 248, .55) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(218, 237, 248, .55) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(218, 237, 248, .55) 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}

.company-branding-logo-preview img {
    width: auto;
    max-width: min(100%, 340px);
    max-height: 86px;
    object-fit: contain;
}

.company-branding-icon-preview img {
    width: 82px;
    height: 82px;
    border-radius: 18px;
    object-fit: contain;
    background: #fff;
    box-shadow: 0 10px 24px rgba(18, 72, 110, .16);
}

.company-branding-file {
    padding: .62rem;
    background: #fff;
}

.company-branding-default-toggle {
    display: flex;
    gap: .55rem;
    align-items: flex-start;
    margin-top: .7rem;
    color: #365b75;
    font-size: .85rem;
    line-height: 1.4;
}

.company-branding-default-toggle input {
    margin-top: .16rem;
}

.company-branding-scope-note {
    margin-top: 1rem;
    padding: .95rem 1rem;
    border: 1px solid rgba(80, 151, 204, .25);
    border-radius: 15px;
    background: #f1f9ff;
    color: #315873;
}

.company-branding-scope-note strong {
    display: block;
    margin-bottom: .22rem;
    color: #0b4f7d;
}

.company-branding-scope-note p {
    margin: 0;
    line-height: 1.55;
}

.company-branding-actions {
    margin-top: 1.15rem;
}

.company-branding-side {
    display: grid;
    gap: 1rem;
}

.company-branding-header-preview {
    display: flex;
    gap: .7rem;
    align-items: center;
    padding: .8rem;
    border-radius: 15px;
    background: linear-gradient(135deg, #eef9ff 0%, #fff 100%);
    border: 1px solid rgba(91, 168, 216, .24);
}

.company-branding-header-logo {
    display: grid;
    place-items: center;
    width: 74px;
    height: 48px;
    flex: 0 0 74px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid rgba(89, 158, 205, .2);
}

.company-branding-header-logo img {
    max-width: 64px;
    max-height: 38px;
    object-fit: contain;
}

.company-branding-header-preview strong,
.company-branding-header-preview small {
    display: block;
    overflow-wrap: anywhere;
}

.company-branding-header-preview strong {
    color: #0b4269;
}

.company-branding-header-preview small {
    margin-top: .14rem;
    color: #55718a;
    line-height: 1.35;
}

.company-branding-browser-preview,
.company-branding-portal-preview {
    margin-top: .75rem;
    padding: .75rem .85rem;
    border-radius: 13px;
    border: 1px solid rgba(91, 153, 195, .2);
    background: #fff;
    color: #365a73;
}

.company-branding-browser-preview {
    display: flex;
    align-items: center;
    gap: .55rem;
}

.company-branding-browser-preview img {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    object-fit: contain;
}

.company-branding-portal-preview span,
.company-branding-portal-preview strong {
    display: block;
}

.company-branding-portal-preview span {
    color: #678096;
    font-size: .8rem;
}

.company-branding-portal-preview strong {
    margin-top: .12rem;
    color: #0e4c75;
}

.company-branding-rules ul {
    margin: 0;
    padding-left: 1.15rem;
    color: #46667d;
}

.company-branding-rules li + li {
    margin-top: .45rem;
}

.company-branding-restore-card {
    border-color: rgba(190, 108, 79, .25);
}

.company-branding-restore-button {
    width: 100%;
}

.brand-inline-logo,
.clean-login-corner-brand img,
.portal-brand-inline img {
    object-fit: contain;
}

@media (max-width: 1080px) {
    .company-branding-grid {
        grid-template-columns: 1fr;
    }

    .company-branding-side {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .company-branding-live-preview {
        grid-column: 1 / -1;
    }
}

@media (max-width: 760px) {
    .company-branding-head {
        align-items: stretch;
    }

    .company-branding-assets,
    .company-branding-side {
        grid-template-columns: 1fr;
    }

    .company-branding-live-preview {
        grid-column: auto;
    }

    .company-branding-asset-head {
        flex-direction: column;
    }

    .company-branding-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .company-branding-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* EMP.2 R1 · Paletas institucionales controladas */
body[data-brand-theme] {
    --portal-ink: var(--color-primary-deep);
    --portal-blue: var(--color-primary);
    --portal-blue-strong: var(--color-primary-dark);
    --portal-sky: var(--color-primary-soft);
}

body[data-brand-theme] .topbar,
body[data-brand-theme] .portal-topbar {
    border-color: rgba(var(--branding-primary-rgb), .18);
}

body[data-brand-theme] .btn-primary,
body[data-brand-theme] button.btn-primary,
body[data-brand-theme] .brand-inline-mark,
body[data-brand-theme] .portal-brand-inline .brand-inline-mark {
    background: linear-gradient(135deg, var(--branding-accent), var(--color-primary-dark));
    border-color: var(--color-primary-dark);
}

body[data-brand-theme] .page-head,
body[data-brand-theme] .panel-card,
body[data-brand-theme] .dashboard-card,
body[data-brand-theme] .report-card {
    box-shadow: 0 18px 42px rgba(var(--branding-primary-rgb), .08);
}

body[data-brand-theme] .guest-body-final,
body[data-brand-theme].guest-body-final {
    background:
        radial-gradient(circle at 10% 14%, rgba(var(--branding-accent-rgb), .12), transparent 26%),
        radial-gradient(circle at 82% 74%, rgba(var(--branding-primary-rgb), .07), transparent 22%),
        linear-gradient(135deg, var(--branding-surface) 0%, #ffffff 52%, var(--color-primary-soft) 100%);
}

body[data-brand-theme].portal-body {
    background:
        radial-gradient(circle at 8% 0%, rgba(var(--branding-accent-rgb), .22), transparent 30%),
        radial-gradient(circle at 92% 12%, rgba(var(--branding-primary-rgb), .12), transparent 24%),
        linear-gradient(135deg, var(--branding-surface) 0%, #ffffff 43%, var(--color-primary-soft) 100%) !important;
}

.company-branding-theme-section {
    margin: 0 0 1.15rem;
    padding: 1rem;
    border: 1px solid rgba(var(--branding-primary-rgb), .18);
    border-radius: 18px;
    background: linear-gradient(180deg, #fff 0%, var(--branding-surface) 100%);
}

.company-branding-theme-section h3 {
    margin: 0;
    color: var(--color-primary-deep);
    font-size: 1rem;
}

.company-branding-theme-section > p {
    margin: .3rem 0 .85rem;
    color: var(--color-gray-700);
    font-size: .88rem;
}

.company-branding-theme-options {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: .7rem;
}

.company-branding-theme-option {
    position: relative;
    display: grid;
    gap: .58rem;
    min-width: 0;
    padding: .75rem;
    border: 1px solid rgba(82, 112, 135, .20);
    border-radius: 15px;
    background: #fff;
    cursor: pointer;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.company-branding-theme-option:hover {
    transform: translateY(-2px);
    border-color: var(--theme-primary);
    box-shadow: 0 12px 24px rgba(var(--branding-primary-rgb), .10);
}

.company-branding-theme-option:has(input:checked) {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary) 16%, transparent);
}

.company-branding-theme-option input {
    position: absolute;
    inset: 8px 8px auto auto;
}

.company-branding-theme-swatches {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 3px;
    height: 28px;
    overflow: hidden;
    border-radius: 9px;
}

.company-branding-theme-swatches span:nth-child(1) { background: var(--theme-deep); }
.company-branding-theme-swatches span:nth-child(2) { background: var(--theme-primary); }
.company-branding-theme-swatches span:nth-child(3) { background: var(--theme-accent); }
.company-branding-theme-swatches span:nth-child(4) { background: var(--theme-soft); }

.company-branding-theme-option strong {
    color: #21384a;
    font-size: .82rem;
    padding-right: 1.2rem;
}

.company-branding-theme-option small {
    color: #60788b;
    font-size: .72rem;
    line-height: 1.35;
}

.company-branding-assets {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.company-branding-document-preview {
    margin-top: .75rem;
    padding: .85rem;
    border-radius: 13px;
    border: 1px solid rgba(var(--branding-primary-rgb), .20);
    background: #fff;
}

.company-branding-document-preview-head {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding-bottom: .7rem;
    border-bottom: 2px solid var(--color-primary);
}

.company-branding-document-preview-head img {
    width: 78px;
    height: 38px;
    object-fit: contain;
    object-position: left center;
}

.company-branding-document-preview-head strong,
.company-branding-document-preview-head span {
    display: block;
}

.company-branding-document-preview-head strong {
    color: var(--color-primary-deep);
    font-size: .82rem;
}

.company-branding-document-preview-head span {
    margin-top: .12rem;
    color: var(--color-gray-600);
    font-size: .7rem;
}

.company-branding-document-preview-body {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .4rem;
    margin-top: .7rem;
}

.company-branding-document-preview-body span {
    height: 10px;
    border-radius: 999px;
    background: var(--color-primary-soft);
}

.company-branding-document-preview-body span:first-child {
    background: var(--color-primary);
}

@media (max-width: 1240px) {
    .company-branding-theme-options {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .company-branding-assets {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .company-branding-theme-options,
    .company-branding-assets {
        grid-template-columns: 1fr;
    }
}

/* La hoja del login se carga después; estos selectores tienen mayor especificidad. */
html body.guest-body-clean-r351[data-brand-theme] {
    background:
        radial-gradient(circle at 6% 7%, rgba(var(--branding-accent-rgb), .20), transparent 27%),
        radial-gradient(circle at 93% 88%, rgba(var(--branding-primary-rgb), .13), transparent 26%),
        linear-gradient(135deg, var(--branding-surface) 0%, #ffffff 48%, var(--color-primary-soft) 100%) !important;
    color: var(--color-primary-deep) !important;
}

html body.guest-body-clean-r351[data-brand-theme] .clean-login-showcase {
    border-color: rgba(var(--branding-primary-rgb), .10);
    background: linear-gradient(140deg, rgba(255,255,255,.42), color-mix(in srgb, var(--color-primary-soft) 72%, white));
}

html body.guest-body-clean-r351[data-brand-theme] .clean-login-eyebrow,
html body.guest-body-clean-r351[data-brand-theme] .clean-login-copy h1,
html body.guest-body-clean-r351[data-brand-theme] .auth-card-header h2 {
    color: var(--color-primary-deep) !important;
}

html body.guest-body-clean-r351[data-brand-theme] .clean-login-pills span,
html body.guest-body-clean-r351[data-brand-theme] .auth-actions .btn-primary,
html body.guest-body-clean-r351[data-brand-theme] button.btn-primary {
    border-color: rgba(var(--branding-primary-rgb), .18) !important;
}

html body.guest-body-clean-r351[data-brand-theme] .auth-actions .btn-primary,
html body.guest-body-clean-r351[data-brand-theme] button.btn-primary {
    background: linear-gradient(135deg, var(--branding-accent), var(--color-primary-dark)) !important;
    color: #fff !important;
}

html body.portal-body[data-brand-theme] {
    background:
        radial-gradient(circle at 8% 0%, rgba(var(--branding-accent-rgb), .22), transparent 30%),
        radial-gradient(circle at 92% 12%, rgba(var(--branding-primary-rgb), .12), transparent 24%),
        linear-gradient(135deg, var(--branding-surface) 0%, #fff 43%, var(--color-primary-soft) 100%) !important;
}

/* EMP.2 R2 · Aplicación integral de la paleta en la interfaz autenticada.
   Cambia componentes institucionales; no sustituye colores semánticos. */
body.app-body[data-brand-theme] {
    --branding-border: color-mix(in srgb, var(--color-primary) 24%, #d9e4ec);
    --branding-border-strong: color-mix(in srgb, var(--color-primary) 42%, #cbd8e2);
    --branding-panel: color-mix(in srgb, var(--branding-surface) 72%, #ffffff);
    --branding-panel-soft: color-mix(in srgb, var(--color-primary-soft) 64%, #ffffff);
    --branding-panel-strong: color-mix(in srgb, var(--color-primary-soft) 86%, #ffffff);
    --branding-shadow: 0 18px 42px rgba(var(--branding-primary-rgb), .10);
    background:
        radial-gradient(circle at 5% 0%, rgba(var(--branding-accent-rgb), .09), transparent 26%),
        radial-gradient(circle at 96% 16%, rgba(var(--branding-primary-rgb), .07), transparent 23%),
        linear-gradient(180deg, var(--branding-surface) 0%, #ffffff 36%, var(--branding-surface) 100%) !important;
}

/* Encabezado, navegación y menús */
body[data-brand-theme] .topbar,
body[data-brand-theme] .portal-topbar {
    background: linear-gradient(180deg, #ffffff 0%, var(--branding-panel) 100%) !important;
    border-bottom-color: var(--branding-border) !important;
    box-shadow: 0 12px 30px rgba(var(--branding-primary-rgb), .08) !important;
}

body[data-brand-theme] .topbar--grouped-menu .main-nav--grouped {
    border-color: var(--branding-border) !important;
    background: color-mix(in srgb, var(--branding-surface) 62%, rgba(255,255,255,.92)) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.92), 0 10px 24px rgba(var(--branding-primary-rgb), .07) !important;
}

body[data-brand-theme] .global-menu-toggle,
body[data-brand-theme] .global-profile-trigger {
    border-color: var(--branding-border) !important;
    background: linear-gradient(180deg, #ffffff 0%, var(--branding-panel-soft) 100%) !important;
}

body[data-brand-theme] .topbar--grouped-menu .global-nav-link:hover,
body[data-brand-theme] .topbar--grouped-menu .global-nav-trigger:hover,
body[data-brand-theme] .topbar--grouped-menu .global-nav-group:focus-within > .global-nav-trigger,
body[data-brand-theme] .global-profile-trigger:hover,
body[data-brand-theme] .global-profile-menu.is-open > .global-profile-trigger {
    background: var(--branding-panel-strong) !important;
    color: var(--color-primary-dark) !important;
}

body[data-brand-theme] .topbar--grouped-menu .global-nav-link.is-active,
body[data-brand-theme] .topbar--grouped-menu .global-nav-group.is-active > .global-nav-trigger,
body[data-brand-theme] .topbar--grouped-menu .global-nav-group.is-open > .global-nav-trigger {
    background: linear-gradient(135deg, var(--branding-accent) 0%, var(--color-primary-dark) 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 9px 20px rgba(var(--branding-primary-rgb), .24) !important;
}

body[data-brand-theme] .global-nav-dropdown,
body[data-brand-theme] .global-profile-dropdown,
body[data-brand-theme] .global-mobile-drawer {
    border-color: var(--branding-border) !important;
    background: color-mix(in srgb, var(--branding-surface) 18%, rgba(255,255,255,.985)) !important;
    box-shadow: 0 24px 60px rgba(var(--branding-primary-rgb), .18) !important;
}

body[data-brand-theme] .topbar--grouped-menu .global-nav-child {
    border-color: color-mix(in srgb, var(--color-primary) 15%, #dfe7ed) !important;
    background: linear-gradient(180deg, #ffffff 0%, var(--branding-panel) 100%) !important;
}

body[data-brand-theme] .topbar--grouped-menu .global-nav-child:hover,
body[data-brand-theme] .topbar--grouped-menu .global-nav-child.is-active,
body[data-brand-theme] .topbar--grouped-menu .global-profile-action:hover {
    border-color: var(--branding-border-strong) !important;
    background: var(--branding-panel-strong) !important;
}

body[data-brand-theme] .topbar--grouped-menu .global-nav-child.is-active {
    box-shadow: inset 4px 0 0 var(--color-primary) !important;
}

/* Banners, encabezados y contenedores institucionales */
body[data-brand-theme] .page-head,
body[data-brand-theme] .support-module-banner,
body[data-brand-theme] .security-clean-banner,
body[data-brand-theme] .technical-compact-head,
body[data-brand-theme] .service-form-section-head,
body[data-brand-theme] .reminders-section-head,
body[data-brand-theme] .call-indicators-panel-head,
body[data-brand-theme] .r3-panel-head,
body[data-brand-theme] .vista360-panel-head,
body[data-brand-theme] .compact-panel-head {
    border-color: var(--branding-border) !important;
    background: linear-gradient(135deg, #ffffff 0%, var(--branding-panel-soft) 100%) !important;
    box-shadow: var(--branding-shadow) !important;
}

body[data-brand-theme] .page-head {
    position: relative;
    overflow: hidden;
}

body[data-brand-theme] .page-head::before,
body[data-brand-theme] .support-module-banner::before,
body[data-brand-theme] .security-clean-banner::before {
    background: linear-gradient(180deg, var(--branding-accent), var(--color-primary-dark)) !important;
}

body[data-brand-theme] .panel-card,
body[data-brand-theme] .dashboard-card,
body[data-brand-theme] .report-card,
body[data-brand-theme] .quick-card,
body[data-brand-theme] .detail-main-card,
body[data-brand-theme] .detail-section,
body[data-brand-theme] .entity-block,
body[data-brand-theme] .form-card,
body[data-brand-theme] .service-form-section,
body[data-brand-theme] .vista360-panel,
body[data-brand-theme] .r2-panel,
body[data-brand-theme] .call-indicators-panel,
body[data-brand-theme] .security-user-form-panel,
body[data-brand-theme] .security-user-policy-card,
body[data-brand-theme] .equipment-technical-file-card,
body[data-brand-theme] .local-files-wide,
body[data-brand-theme] .section-accordion,
body[data-brand-theme] .panel-card-nested {
    border-color: var(--branding-border) !important;
    background: linear-gradient(180deg, #ffffff 0%, var(--branding-panel) 100%) !important;
    box-shadow: var(--branding-shadow) !important;
}

body[data-brand-theme] .metric-card:not(.metric-card-alert),
body[data-brand-theme] .mini-stat-card:not([class*="danger"]):not([class*="warning"]):not([class*="success"]),
body[data-brand-theme] .insight-card:not([class*="danger"]):not([class*="warning"]):not([class*="success"]),
body[data-brand-theme] .r2-metric:not([class*="danger"]):not([class*="warning"]):not([class*="success"]) {
    border-color: var(--branding-border) !important;
    background: linear-gradient(145deg, #ffffff 0%, var(--branding-panel-soft) 100%) !important;
    box-shadow: 0 12px 28px rgba(var(--branding-primary-rgb), .08) !important;
}

body[data-brand-theme] .section-accordion-summary,
body[data-brand-theme] .reminders-collapse-button,
body[data-brand-theme] .r2-toggle {
    border-color: var(--branding-border) !important;
    background: linear-gradient(180deg, #ffffff 0%, var(--branding-panel-soft) 100%) !important;
}

body[data-brand-theme] .section-accordion[open] > .section-accordion-summary,
body[data-brand-theme] .reminders-collapsible[open] > .reminders-section-head,
body[data-brand-theme] details[open] > summary:not([class*="danger"]):not([class*="warning"]) {
    border-color: var(--branding-border-strong) !important;
    background: var(--branding-panel-strong) !important;
    box-shadow: inset 4px 0 0 var(--color-primary) !important;
}

/* Botones y acciones: la paleta se concentra aquí, sin recolorear el texto general. */
body[data-brand-theme] .btn-primary,
body[data-brand-theme] button.btn-primary,
body[data-brand-theme] input.btn-primary,
body[data-brand-theme] .btn-static,
body[data-brand-theme] .quick-360-immediate-btn:not(:disabled) {
    background: linear-gradient(135deg, var(--branding-accent) 0%, var(--color-primary-dark) 100%) !important;
    border-color: var(--color-primary-dark) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 22px rgba(var(--branding-primary-rgb), .22) !important;
}

body[data-brand-theme] .btn-primary:hover,
body[data-brand-theme] button.btn-primary:hover,
body[data-brand-theme] .btn-static:hover,
body[data-brand-theme] .quick-360-immediate-btn:not(:disabled):hover {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-deep) 100%) !important;
    border-color: var(--color-primary-deep) !important;
    transform: translateY(-1px);
}

body[data-brand-theme] .btn-outline:not(.btn-danger-soft),
body[data-brand-theme] .btn-secondary,
body[data-brand-theme] .btn-soft-utility,
body[data-brand-theme] .btn-grid-secondary-action,
body[data-brand-theme] .btn-quick-360,
body[data-brand-theme] .wa-btn-soft {
    border-color: var(--branding-border-strong) !important;
    background: linear-gradient(180deg, #ffffff 0%, var(--branding-panel-soft) 100%) !important;
    color: var(--color-primary-dark) !important;
    box-shadow: 0 7px 16px rgba(var(--branding-primary-rgb), .07) !important;
}

body[data-brand-theme] .btn-outline:not(.btn-danger-soft):hover,
body[data-brand-theme] .btn-secondary:hover,
body[data-brand-theme] .btn-soft-utility:hover,
body[data-brand-theme] .btn-grid-secondary-action:hover,
body[data-brand-theme] .btn-quick-360:hover,
body[data-brand-theme] .wa-btn-soft:hover {
    border-color: var(--color-primary) !important;
    background: var(--branding-panel-strong) !important;
    color: var(--color-primary-deep) !important;
}

body[data-brand-theme] .text-action,
body[data-brand-theme] .table-link {
    border-color: color-mix(in srgb, var(--color-primary) 26%, transparent) !important;
    background: var(--branding-panel-soft) !important;
    color: var(--color-primary-dark) !important;
}

body[data-brand-theme] .text-action:hover,
body[data-brand-theme] .table-link:hover {
    background: var(--branding-panel-strong) !important;
    color: var(--color-primary-deep) !important;
}

/* Filtros, búsquedas, campos y pestañas activas */
body[data-brand-theme] .filter-toolbar,
body[data-brand-theme] .equipment-filter-toolbar,
body[data-brand-theme] .filters-grid,
body[data-brand-theme] .filter-toolbar-stacked,
body[data-brand-theme] .workbench-toolbar-inline-fixed {
    border-color: var(--branding-border) !important;
    background: linear-gradient(180deg, #ffffff 0%, var(--branding-panel) 100%) !important;
    box-shadow: 0 12px 28px rgba(var(--branding-primary-rgb), .07) !important;
}

body[data-brand-theme] .field-input:focus,
body[data-brand-theme] .field-textarea:focus,
body[data-brand-theme] .filter-toolbar input:focus,
body[data-brand-theme] .filter-toolbar select:focus,
body[data-brand-theme] .filter-field input:focus,
body[data-brand-theme] .filter-field select:focus,
body[data-brand-theme] input:focus-visible,
body[data-brand-theme] select:focus-visible,
body[data-brand-theme] textarea:focus-visible {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--branding-primary-rgb), .14) !important;
    outline: none !important;
}

body[data-brand-theme] [role="tab"][aria-selected="true"],
body[data-brand-theme] button[aria-pressed="true"]:not([class*="danger"]):not([class*="warning"]),
body[data-brand-theme] .is-active.btn:not(.btn-danger-soft),
body[data-brand-theme] .filter-pill.is-active,
body[data-brand-theme] .tab-button.is-active,
body[data-brand-theme] .palette-tab.is-active {
    border-color: var(--color-primary) !important;
    background: linear-gradient(135deg, var(--branding-accent), var(--color-primary-dark)) !important;
    color: #ffffff !important;
    box-shadow: 0 8px 18px rgba(var(--branding-primary-rgb), .18) !important;
}

/* Tablas: encabezados, marco y selección visual. */
body[data-brand-theme] .table-shell,
body[data-brand-theme] .table-shell-wide,
body[data-brand-theme] .table-shell-scroll-x {
    border-color: var(--branding-border) !important;
    background: #ffffff !important;
    box-shadow: 0 14px 32px rgba(var(--branding-primary-rgb), .08) !important;
}

body[data-brand-theme] .crm-table thead th,
body[data-brand-theme] .table-shell table thead th,
body[data-brand-theme] table.report-table thead th,
body[data-brand-theme] table.data-table thead th {
    border-bottom-color: var(--branding-border-strong) !important;
    background: linear-gradient(180deg, var(--branding-panel-strong) 0%, var(--color-primary-soft) 100%) !important;
    color: var(--color-primary-deep) !important;
}

body[data-brand-theme] .crm-table tbody tr:hover,
body[data-brand-theme] .table-shell table tbody tr:hover {
    background: color-mix(in srgb, var(--color-primary-soft) 66%, #ffffff) !important;
}

body[data-brand-theme] .crm-table tbody tr.is-selected,
body[data-brand-theme] .table-shell table tbody tr.is-selected,
body[data-brand-theme] tr[aria-selected="true"] {
    background: var(--branding-panel-strong) !important;
    box-shadow: inset 4px 0 0 var(--color-primary) !important;
}

/* Vista rápida, formularios y elementos auxiliares institucionales. */
body[data-brand-theme] .quick-360-drawer,
body[data-brand-theme] .quick-360-detail-panel,
body[data-brand-theme] .security-toggle-card,
body[data-brand-theme] .visit-create-step,
body[data-brand-theme] .trajectory-field,
body[data-brand-theme] .r2-field,
body[data-brand-theme] .detail-kv-item,
body[data-brand-theme] .detail-form-item {
    border-color: var(--branding-border) !important;
}

body[data-brand-theme] .quick-360-head,
body[data-brand-theme] .quick-360-detail-head,
body[data-brand-theme] .security-user-section-head {
    background: linear-gradient(135deg, var(--branding-panel-strong), #ffffff) !important;
    border-color: var(--branding-border) !important;
}

/* No intervenir en colores con significado operativo. */
body[data-brand-theme] .alert-danger,
body[data-brand-theme] .alert-success,
body[data-brand-theme] .tone-badge-warning,
body[data-brand-theme] .tone-badge-success,
body[data-brand-theme] .tone-badge-danger,
body[data-brand-theme] .status-positive,
body[data-brand-theme] .status-neutral,
body[data-brand-theme] [class*="status-danger"],
body[data-brand-theme] [class*="status-warning"],
body[data-brand-theme] [class*="status-success"],
body[data-brand-theme] [class*="risk-danger"],
body[data-brand-theme] [class*="risk-warning"],
body[data-brand-theme] [class*="risk-success"] {
    /* Se conservan las reglas semánticas originales de crm.css y de cada módulo. */
}

@media (max-width: 760px) {
    body[data-brand-theme] .page-head,
    body[data-brand-theme] .filter-toolbar,
    body[data-brand-theme] .panel-card,
    body[data-brand-theme] .dashboard-card,
    body[data-brand-theme] .report-card {
        box-shadow: 0 10px 24px rgba(var(--branding-primary-rgb), .08) !important;
    }
}

/* EMP.3 R2 · Nomenclatura configurable de identificadores */
.company-branding-identifiers {
    margin-top: 1.25rem;
    padding: 1.15rem;
    border: 1px solid color-mix(in srgb, var(--color-primary) 22%, #dbe5ef);
    border-radius: 18px;
    background: linear-gradient(180deg, #fff 0%, var(--branding-surface, #f6f9fc) 100%);
}

.company-branding-identifiers-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}

.company-branding-identifiers-head > div > span {
    color: var(--color-primary);
    font-size: .76rem;
    font-weight: 800;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.company-branding-identifiers-head h3 {
    margin: .12rem 0 .25rem;
    color: #163047;
}

.company-branding-identifiers-head p,
.company-branding-identifier-notice p {
    margin: 0;
    color: #607386;
    line-height: 1.5;
}

.company-branding-identifier-notice {
    margin-bottom: 1rem;
    padding: .8rem .9rem;
    border-left: 4px solid var(--color-primary);
    border-radius: 10px;
    background: var(--color-primary-soft);
}

.company-branding-identifier-notice strong {
    display: block;
    margin-bottom: .15rem;
    color: var(--color-primary-dark);
}

.company-branding-identifiers-table-wrap {
    overflow-x: auto;
    border: 1px solid #dce6ef;
    border-radius: 14px;
    background: #fff;
}

.company-branding-identifiers-table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

.company-branding-identifiers-table th,
.company-branding-identifiers-table td {
    padding: .72rem .75rem;
    border-bottom: 1px solid #e6edf3;
    vertical-align: middle;
    text-align: left;
}

.company-branding-identifiers-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    color: #fff;
    background: var(--color-primary-dark);
    font-size: .76rem;
    letter-spacing: .035em;
    text-transform: uppercase;
}

.company-branding-identifiers-table tbody tr:nth-child(even) {
    background: color-mix(in srgb, var(--color-primary-soft) 42%, #fff);
}

.company-branding-identifiers-table tbody tr:last-child td {
    border-bottom: 0;
}

.company-branding-identifiers-table td:first-child {
    min-width: 230px;
}

.company-branding-identifiers-table td:first-child strong,
.company-branding-identifiers-table td:first-child small {
    display: block;
}

.company-branding-identifiers-table td:first-child strong {
    color: #173149;
}

.company-branding-identifiers-table td:first-child small {
    margin-top: .16rem;
    color: #708297;
    line-height: 1.35;
}

.company-branding-identifiers-table .field-input,
.company-branding-identifiers-table .field-select {
    min-width: 92px;
    padding: .54rem .62rem;
}

.company-branding-identifiers-table .identifier-prefix {
    width: 112px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
}

.company-branding-identifiers-table .identifier-digits {
    width: 74px;
}

.identifier-padding-toggle {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-weight: 700;
    color: #30485d;
}

.identifier-not-applicable {
    color: #7d8c99;
    font-size: .84rem;
}

.identifier-preview {
    display: inline-block;
    min-width: 116px;
    padding: .46rem .58rem;
    border: 1px solid color-mix(in srgb, var(--color-primary) 24%, #dbe5ef);
    border-radius: 9px;
    color: var(--color-primary-dark);
    background: var(--color-primary-soft);
    font-size: .84rem;
    font-weight: 800;
    white-space: nowrap;
}

@media (max-width: 760px) {
    .company-branding-identifiers {
        padding: .85rem;
    }

    .company-branding-identifiers-head {
        display: block;
    }

    .company-branding-identifiers-head .status-pill-soft {
        display: inline-flex;
        margin-top: .65rem;
    }
}

/* EMP.4 R2 · Identidad dentro de Seguridad y parámetros operativos responsive */
.company-branding-head-emp4 {
    align-items: center;
    border-color: color-mix(in srgb, var(--color-primary) 18%, #dbe6ef);
}

.company-branding-summary-emp4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .85rem;
    margin: 1rem 0;
}

.company-branding-summary-emp4 article {
    min-width: 0;
    padding: .95rem 1rem;
    border: 1px solid color-mix(in srgb, var(--color-primary) 16%, #dce6ef);
    border-radius: 17px;
    background: linear-gradient(160deg, #fff 0%, var(--branding-surface, #f7fbff) 100%);
    box-shadow: 0 12px 28px rgba(var(--branding-primary-rgb), .07);
}

.company-branding-summary-emp4 span,
.company-branding-summary-emp4 strong,
.company-branding-summary-emp4 small {
    display: block;
    overflow-wrap: anywhere;
}

.company-branding-summary-emp4 span {
    color: var(--color-primary);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .075em;
    text-transform: uppercase;
}

.company-branding-summary-emp4 strong {
    margin-top: .32rem;
    color: #17344d;
    font-size: 1.05rem;
    line-height: 1.25;
}

.company-branding-summary-emp4 small {
    margin-top: .28rem;
    color: #667b8f;
    font-size: .76rem;
    line-height: 1.4;
}

.company-branding-help-card-emp4 {
    overflow: hidden;
}

.company-branding-help-list-emp4 {
    display: grid;
    gap: .65rem;
}

.company-branding-help-list-emp4 > div {
    display: grid;
    gap: .18rem;
    padding: .72rem .8rem;
    border: 1px solid color-mix(in srgb, var(--color-primary) 14%, #dce6ef);
    border-radius: 13px;
    background: color-mix(in srgb, var(--color-primary-soft) 44%, #fff);
}

.company-branding-help-list-emp4 strong {
    color: var(--color-primary-dark);
    font-size: .84rem;
}

.company-branding-help-list-emp4 span {
    color: #62788b;
    font-size: .76rem;
    line-height: 1.42;
}

.system-settings-head-emp4 {
    align-items: center;
}

.system-settings-summary-emp4 {
    margin-bottom: 1rem;
}

.system-settings-security-note {
    display: flex;
    align-items: flex-start;
    gap: .8rem;
    margin-bottom: 1rem;
    padding: .9rem 1rem;
    border: 1px solid color-mix(in srgb, var(--color-primary) 18%, #d9e5ef);
    border-left: 5px solid var(--color-primary);
    border-radius: 16px;
    background: linear-gradient(135deg, var(--color-primary-soft) 0%, #fff 78%);
    color: #36546b;
}

.system-settings-security-note-mark {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-weight: 900;
}

.system-settings-security-note strong {
    display: block;
    color: var(--color-primary-dark);
}

.system-settings-security-note p {
    margin: .25rem 0 0;
    line-height: 1.5;
}

.system-settings-security-note code {
    padding: .08rem .28rem;
    border-radius: 5px;
    background: rgba(255, 255, 255, .85);
    color: var(--color-primary-dark);
    font-weight: 800;
}

.system-settings-card-emp4 {
    overflow: hidden;
}

.system-settings-groups-emp4 {
    gap: 1rem;
}

.system-settings-group-emp4 {
    padding: 1rem;
    border-left-color: var(--branding-accent);
    background: linear-gradient(155deg, #fff 0%, color-mix(in srgb, var(--branding-surface) 70%, #fff) 100%);
}

.system-settings-group-head-emp4 {
    align-items: center;
}

.system-settings-group-head-emp4 h3 {
    font-size: 1.15rem;
}

.system-settings-group-head-emp4 p {
    max-width: 760px;
    margin: .28rem 0 0;
    color: #62788b;
    line-height: 1.5;
}

.system-settings-group-head-emp4 > small {
    padding: .38rem .62rem;
    border: 1px solid color-mix(in srgb, var(--color-primary) 16%, #dce6ef);
    border-radius: 999px;
    background: #fff;
    color: var(--color-primary-dark);
    white-space: nowrap;
}

.system-settings-guidance {
    padding: .72rem .85rem;
    border: 1px solid color-mix(in srgb, var(--branding-accent) 22%, #dce6ef);
    border-radius: 13px;
    background: color-mix(in srgb, var(--color-primary-soft) 55%, #fff);
}

.system-settings-guidance strong {
    display: block;
    color: var(--color-primary-dark);
    font-size: .8rem;
}

.system-settings-guidance p {
    margin: .18rem 0 0;
    color: #587086;
    font-size: .8rem;
    line-height: 1.45;
}

.system-settings-grid-emp4 {
    gap: .85rem;
}

.system-setting-field {
    min-width: 0;
    padding: .9rem;
    border: 1px solid color-mix(in srgb, var(--color-primary) 13%, #dce6ef);
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(var(--branding-primary-rgb), .045);
}

.system-setting-field-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .7rem;
    margin-bottom: .55rem;
}

.system-setting-field-head > div {
    min-width: 0;
}

.system-setting-type {
    display: block;
    margin-bottom: .25rem;
    color: var(--color-primary);
    font-size: .67rem;
    font-weight: 900;
    letter-spacing: .075em;
    text-transform: uppercase;
}

.system-setting-caution {
    display: block;
    margin-top: .55rem;
    padding: .52rem .62rem;
    border-radius: 10px;
    background: #fff7ed;
    color: #9a4a12;
    font-size: .74rem;
    line-height: 1.4;
}

.system-setting-toggle-emp4 {
    position: relative;
    min-height: 116px;
    padding: .95rem 4.7rem .95rem .95rem;
    border-color: color-mix(in srgb, var(--color-primary) 15%, #dce6ef);
    box-shadow: 0 8px 20px rgba(var(--branding-primary-rgb), .045);
}

.system-setting-toggle-copy {
    min-width: 0;
}

.system-setting-toggle-emp4 input[type="checkbox"] {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none;
}

.system-setting-switch {
    position: absolute;
    top: 50%;
    right: 1rem;
    width: 48px;
    height: 28px;
    transform: translateY(-50%);
    border: 1px solid #b8c7d4;
    border-radius: 999px;
    background: #dce5ec;
    transition: background .18s ease, border-color .18s ease;
}

.system-setting-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 3px 8px rgba(15, 23, 42, .18);
    transition: transform .18s ease;
}

.system-setting-toggle-emp4:has(input:checked) {
    border-color: color-mix(in srgb, var(--color-primary) 36%, #cbd8e4);
    background: linear-gradient(145deg, #fff 0%, color-mix(in srgb, var(--color-primary-soft) 48%, #fff) 100%);
}

.system-setting-toggle-emp4:has(input:checked) .system-setting-switch {
    border-color: var(--color-primary-dark);
    background: var(--color-primary);
}

.system-setting-toggle-emp4:has(input:checked) .system-setting-switch::after {
    transform: translateX(20px);
}

.system-setting-toggle-emp4:has(input:focus-visible) {
    outline: 3px solid color-mix(in srgb, var(--color-primary) 25%, transparent);
    outline-offset: 2px;
}

.system-setting-toggle-emp4:has(input:disabled) {
    cursor: default;
    opacity: .78;
}

.system-settings-actions-emp4 {
    position: sticky;
    bottom: 0;
    z-index: 4;
    margin: 0 -1rem -1rem;
    padding: .9rem 1rem;
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(10px);
}

@media (max-width: 1180px) {
    .company-branding-summary-emp4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .company-branding-head-emp4,
    .system-settings-head-emp4 {
        align-items: stretch;
    }

    .company-branding-summary-emp4,
    .system-settings-summary-emp4 {
        grid-template-columns: 1fr !important;
    }

    .company-branding-summary-emp4 article,
    .system-settings-group-emp4,
    .system-setting-field {
        border-radius: 14px;
    }

    .system-settings-security-note {
        display: grid;
        grid-template-columns: 30px minmax(0, 1fr);
        padding: .8rem;
    }

    .system-settings-group-head-emp4 {
        display: grid;
    }

    .system-settings-group-head-emp4 > small {
        justify-self: start;
    }

    .system-setting-toggle-emp4 {
        min-height: 126px;
        padding-right: 4.4rem;
    }

    .system-settings-actions-emp4 {
        position: static;
        display: grid;
        grid-template-columns: 1fr;
        margin: 0;
        padding: .9rem 0 0;
        background: transparent;
        backdrop-filter: none;
    }

    .system-settings-actions-emp4 .btn,
    .company-branding-head-emp4 .page-actions-inline .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 460px) {
    .company-branding-summary-emp4 article,
    .system-settings-group-emp4,
    .system-setting-field,
    .system-setting-toggle-emp4 {
        padding: .78rem;
    }

    .system-setting-toggle-emp4 {
        padding-right: 4rem;
    }

    .system-setting-switch {
        right: .75rem;
        width: 44px;
        height: 26px;
    }

    .system-setting-switch::after {
        width: 18px;
        height: 18px;
    }

    .system-setting-toggle-emp4:has(input:checked) .system-setting-switch::after {
        transform: translateX(18px);
    }
}
