@import url("https://fonts.googleapis.com/css2?family=Black+Ops+One&family=Chakra+Petch:wght@400;500;600;700&display=swap");

/* Alias y color de compatibilidad: catálogo por tema, no :root. */

* {
    scrollbar-color: var(--surface-elevated) var(--bg-primary);
}

body {
    background: var(--surface-body-background);
    background-attachment: fixed;
    color: var(--text-primary);
    letter-spacing: 0.1px;
    font-family: var(--font-ui);
}

h1, h2, h3, h4, h5, h6,
.page-title,
.card-header {
    font-family: var(--font-display);
}

/* Bloques de lectura larga: la medida es común; la familia tipográfica y el
   color siguen siendo valores del tema mediante el catálogo. */
.opn-reading,
.es360-briefing-lead,
.es360-briefing-why,
.es360-briefing-evidence,
.es-alert-modal-narrative-shell,
#es-event360-executive-summary {
    font-family: var(--font-reading);
    font-size: var(--reading-size);
    line-height: var(--reading-leading);
    max-width: var(--reading-measure);
    color: var(--text-primary);
    text-wrap: pretty;
}

/* BEGIN O4-C8-MIGRATED: Oracle answer typography */
html .es-oracle-answer {
    font-family: var(--font-reading);
    font-size: var(--reading-size);
    line-height: var(--text-reading-leading);
    text-wrap: var(--text-wrap-reading);
}
/* END O4-C8-MIGRATED: Oracle answer typography */


a {
    color: var(--bs-link-color, var(--accent-blue));
}

a:hover {
    color: var(--bs-link-hover-color);
}

.sidebar {
    background: linear-gradient(180deg, var(--sidebar-gradient-start) 0%, var(--sidebar-gradient-end) 100%);
    border-right: 1px solid var(--border-subtle);
}

.brand-logo {
    color: var(--text-primary);
    background: none;
    -webkit-text-fill-color: initial;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-logo i {
    color: var(--accent-blue);
}

.sidebar .sidebar-link {
    color: var(--text-secondary);
    border-left-color: transparent;
}

.sidebar .sidebar-link i {
    color: var(--text-muted);
}

.sidebar .sidebar-link:hover,
.sidebar .sidebar-link.active {
    background: var(--sidebar-link-hover-bg);
    border-left-color: var(--accent-blue);
    color: var(--text-primary);
}

.sidebar .sidebar-link:hover i,
.sidebar .sidebar-link.active i {
    color: var(--accent-blue);
}

.sidebar-section-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 14px 16px 4px;
    user-select: none;
}

/* Subgrupo dentro de una sección del menú. Los veinte enlaces de Inteligencia
   Corporativa se leían como una lista plana; estas etiquetas dan jerarquía sin
   quitar ningún acceso. Más discretas que .sidebar-section-label para que no
   compitan con el título del módulo: el tamaño y el peso, no un color bajo AA. */
.sidebar-subsection-label {
    font-size: 0.61rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 12px 16px 2px;
    user-select: none;
}

.sidebar-subsection-toggle {
    align-items: center;
    cursor: pointer;
    display: flex;
    gap: 7px;
    pointer-events: auto;
    border-radius: 8px;
    margin-inline: 8px;
    padding-inline: 8px;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-subsection-toggle:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

.sidebar-section-toggle:hover,
.sidebar-subsection-toggle:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar-section-toggle:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: -2px;
}

.sidebar-subsection-icons {
    align-items: center;
    display: inline-flex;
    flex: 0 0 20px;
    height: 20px;
    justify-content: center;
    width: 20px;
    border: 1px solid var(--border-subtle);
    border-radius: 5px;
    background: var(--surface-control);
    color: var(--text-secondary);
}

.sidebar-subsection-icons i {
    font-size: .62rem;
    opacity: .78;
}

.sidebar-subsection-icon-closed {
    display: none;
}

.sidebar-subsection-label.is-collapsed .sidebar-subsection-icon-open {
    display: none;
}

.sidebar-subsection-label.is-collapsed .sidebar-subsection-icon-closed {
    display: inline-block;
}

.sidebar .sidebar-subsection-hidden {
    display: none !important;
}

html.sidebar-collapsed .sidebar .sidebar-subsection-label {
    display: none;
}

.sidebar-section-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    pointer-events: auto;
    border-radius: 8px;
    margin-inline: 8px;
    padding-inline: 8px;
    transition: background-color .15s ease, color .15s ease;
}

.sidebar-section-icons {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
    border-radius: 5px;
    background: var(--surface-control);
    color: var(--text-secondary);
}

.sidebar-section-icon-open,
.sidebar-section-icon-closed {
    font-size: 0.62rem;
    opacity: 0.82;
}

.sidebar-section-icon-closed {
    display: none;
}

.sidebar-section-label.is-collapsed .sidebar-section-icon-open {
    display: none;
}

.sidebar-section-label.is-collapsed .sidebar-section-icon-closed {
    display: inline-block;
}

.sidebar .sidebar-section-hidden {
    display: none !important;
}

body[data-operational-focus="true"] .sidebar .sidebar-link.opn-operational-secondary:not(.active) {
    opacity: 0.62;
}

body[data-operational-focus="true"] .sidebar .sidebar-link.opn-operational-secondary:not(.active):hover {
    opacity: 0.86;
}

.sidebar-secondary-group {
    margin: 8px 10px 0;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.02);
    overflow: hidden;
}

.sidebar-secondary-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.sidebar-secondary-group > summary::-webkit-details-marker {
    display: none;
}

.sidebar-secondary-group .sidebar-link {
    padding-left: 14px;
    padding-right: 14px;
}

body[data-operational-focus="true"] .sidebar-secondary-group {
    margin-top: 12px;
}

.sidebar-footer {
    border-top: 1px solid var(--border-subtle);
}

.sidebar-user {
    color: var(--text-secondary);
}

.main-content {
    padding: 24px 26px 32px;
}

.topbar-heading {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: var(--overlay-strong);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 1030;
}

.page-title {
    color: var(--text-primary);
    font-size: 1.52rem;
    font-weight: 650;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.91rem;
}

.breadcrumb {
    --bs-breadcrumb-divider-color: var(--text-muted);
    --bs-breadcrumb-item-active-color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    background: rgba(26, 29, 35, 0.72);
    padding: 0.38rem 0.72rem;
    width: fit-content;
    max-width: 100%;
}

.breadcrumb-item,
.breadcrumb-item a {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

.stat-card,
.card,
.card-custom,
.modal-content {
    background: linear-gradient(180deg, rgba(41, 46, 56, 0.98) 0%, rgba(35, 39, 48, 0.98) 100%);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.20);
}

.stat-card {
    display: block;
    padding: 18px;
    min-height: 124px;
    text-decoration: none;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-1px);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-value {
    color: var(--text-primary);
    font-size: 2rem;
    line-height: 1.1;
}

.stat-card::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.035) 0%, rgba(255, 255, 255, 0) 36%);
}

.stat-card.kpi-critical {
    border-color: rgba(255, 31, 31, 0.38);
}

.stat-card.kpi-high {
    border-color: rgba(255, 138, 0, 0.35);
}

.stat-card.kpi-medium {
    border-color: rgba(255, 214, 10, 0.35);
}

.stat-card.kpi-low {
    border-color: rgba(48, 209, 88, 0.35);
}

.stat-card .stat-icon {
    border-radius: var(--radius-md);
}

.kpi-icon-critical {
    background: var(--surface-indicator-critical);
    color: var(--text-indicator-critical);
}

.kpi-icon-high {
    background: var(--surface-indicator-high);
    color: var(--text-indicator-high);
}

.kpi-icon-tracking {
    background: rgba(124, 58, 237, 0.2);
    color: #B794F6;
}

.kpi-icon-total {
    background: rgba(59, 130, 246, 0.2);
    color: #93C5FD;
}

.card .card-header,
.card-custom .card-header,
.modal-header,
.modal-footer {
    border-color: var(--border-subtle);
}

.card .card-header,
.card-custom .card-header {
    color: var(--text-primary);
    font-weight: 610;
}

.card-body {
    color: var(--text-primary);
}

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text-primary);
    --bs-table-striped-bg: rgba(160, 166, 177, 0.03);
    --bs-table-hover-bg: rgba(59, 130, 246, 0.08);
    --bs-table-hover-color: var(--text-primary);
    color: var(--text-primary);
}

.table-custom th,
.table th {
    /* BEGIN O4-A-MIGRATED: shared-table-header-border */
    border-color: var(--border-table-header) !important;
    /* END O4-A-MIGRATED: shared-table-header-border */
}

.table-hover > tbody > tr:hover > * {
    background-color: rgba(59, 130, 246, 0.08);
    color: var(--text-primary);
}

/* Event Sentinel · Centro de Eventos: improve contrast on cards */
body[data-page="event-sentinel-events"] .card,
body[data-page="event-sentinel-events"] .card-custom {
    border-color: var(--border-strong) !important;
}

body[data-page="event-sentinel-events"] .card-header,
body[data-page="event-sentinel-events"] .card-body,
body[data-page="event-sentinel-events"] .card-title,
body[data-page="event-sentinel-events"] .table,
body[data-page="event-sentinel-events"] .table td {
    color: var(--text-primary) !important;
}

body[data-page="event-sentinel-events"] .text-muted,
body[data-page="event-sentinel-events"] .small.text-muted {
    color: var(--text-secondary) !important;
}

body[data-page="alerts-list"] .alerts-table-wrap,
body[data-page="alerts-list"] .card .table-responsive {
    overflow-x: auto;
    overflow-y: hidden;
    max-width: 100%;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

body[data-page="alerts-list"] .alerts-table,
body[data-page="alerts-list"] .card .table-responsive > table.table {
    min-width: 1180px;
    table-layout: fixed;
    width: 100%;
}

body[data-page="alerts-list"] .table-custom th,
body[data-page="alerts-list"] .table-custom td {
    vertical-align: middle;
    overflow-wrap: anywhere;
}

body[data-page="alerts-list"] .alerts-table th {
    white-space: normal;
    line-height: 1.15;
}

body[data-page="alerts-list"] .alerts-status-cell,
body[data-page="alerts-list"] .alerts-sla-cell,
body[data-page="alerts-list"] .alerts-phase-cell,
body[data-page="alerts-list"] .alerts-actions-cell {
    white-space: nowrap;
}

body[data-page="alerts-list"] .alerts-actions-cell {
    width: 7.5rem;
    min-width: 7.5rem;
    overflow-wrap: normal;
}

body[data-page="alerts-list"] .alerts-actions-cell .btn,
body[data-page="alerts-list"] .alerts-actions-cell .opn-table-action-btn {
    white-space: nowrap;
    overflow-wrap: normal;
}

body[data-page="alerts-list"] .alerts-status-cell {
    min-width: 118px;
}

body[data-page="alerts-list"] .alerts-sla-cell {
    min-width: 96px;
}

body[data-page="alerts-list"] .alerts-phase-cell {
    min-width: 96px;
}

body[data-page="alerts-list"] .alerts-status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 96px;
    max-width: 132px;
    padding: 0.42rem 0.72rem;
    line-height: 1;
    white-space: nowrap;
    text-align: center;
}

body[data-page="alerts-list"] .alerts-date-cell {
    white-space: normal;
    line-height: 1.2;
}

body[data-page="alerts-list"] .alerts-reason-copy,
body[data-page="alerts-list"] .alerts-coverage-note {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

body[data-page="alerts-list"] .alerts-reason-copy {
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

body[data-page="alerts-list"] .alerts-coverage-note {
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

body[data-page="alerts-list"] .alerts-icon-action {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    align-items: center;
    justify-content: center;
    padding: 0;
}

@media (max-width: 1500px) {
    body[data-page="alerts-list"] .alerts-table,
    body[data-page="alerts-list"] .card .table-responsive > table.table {
        min-width: 100%;
        font-size: 0.86rem;
    }

    body[data-page="alerts-list"] .alerts-table col:nth-child(4),
    body[data-page="alerts-list"] .alerts-table col:nth-child(5),
    body[data-page="alerts-list"] .alerts-table col:nth-child(6),
    body[data-page="alerts-list"] .alerts-table col:nth-child(9),
    body[data-page="alerts-list"] .alerts-table col:nth-child(10),
    body[data-page="alerts-list"] .alerts-table th:nth-child(4),
    body[data-page="alerts-list"] .alerts-table td:nth-child(4),
    body[data-page="alerts-list"] .alerts-table th:nth-child(5),
    body[data-page="alerts-list"] .alerts-table td:nth-child(5),
    body[data-page="alerts-list"] .alerts-table th:nth-child(6),
    body[data-page="alerts-list"] .alerts-table td:nth-child(6),
    body[data-page="alerts-list"] .alerts-table th:nth-child(9),
    body[data-page="alerts-list"] .alerts-table td:nth-child(9),
    body[data-page="alerts-list"] .alerts-table th:nth-child(10),
    body[data-page="alerts-list"] .alerts-table td:nth-child(10) {
        display: none;
    }

    body[data-page="alerts-list"] .alerts-table col:nth-child(1) { width: 13%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(2) { width: 18%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(3) { width: 11%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(7) { width: 14%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(8) { width: 12%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(11) { width: 20%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(12) { width: 12%; }

    body[data-page="alerts-list"] .alerts-status-cell,
    body[data-page="alerts-list"] .alerts-sla-cell {
        min-width: 0;
        white-space: normal;
    }

    body[data-page="alerts-list"] .alerts-actions-cell {
        width: 7.5rem;
        min-width: 7.5rem;
        white-space: nowrap;
        overflow-wrap: normal;
    }

    body[data-page="alerts-list"] .alerts-actions-cell .btn,
    body[data-page="alerts-list"] .alerts-actions-cell .opn-table-action-btn {
        white-space: nowrap;
        overflow-wrap: normal;
    }

    body[data-page="alerts-list"] .alerts-status-badge {
        min-width: 0;
        max-width: 100%;
        white-space: normal;
        line-height: 1.15;
    }
}

@media (max-width: 1100px) {
    body[data-page="alerts-list"] .alerts-table,
    body[data-page="alerts-list"] .card .table-responsive > table.table {
        font-size: 0.82rem;
    }

    body[data-page="alerts-list"] .alerts-table col:nth-child(8),
    body[data-page="alerts-list"] .alerts-table th:nth-child(8),
    body[data-page="alerts-list"] .alerts-table td:nth-child(8) {
        display: none;
    }

    body[data-page="alerts-list"] .alerts-table col:nth-child(1) { width: 15%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(2) { width: 22%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(3) { width: 13%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(7) { width: 15%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(11) { width: 23%; }
    body[data-page="alerts-list"] .alerts-table col:nth-child(12) { width: 12%; }

    body[data-page="alerts-list"] .alerts-actions-cell {
        width: 7.5rem;
        min-width: 7.5rem;
        white-space: nowrap;
        overflow-wrap: normal;
    }

    body[data-page="alerts-list"] .alerts-reason-copy {
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
}

.opn-structured-text {
    display: grid;
    gap: 0.4rem;
    margin-top: 0.2rem;
}

.opn-structured-text-title {
    color: var(--text-primary);
    font-weight: 700;
}

.opn-structured-text-p {
    margin: 0;
    color: var(--text-secondary);
}

.opn-structured-text-list {
    margin: 0;
    padding-left: 1.1rem;
    color: var(--text-secondary);
}

.table tbody tr[data-href],
.table tbody tr[data-open-href] {
    cursor: pointer;
}

.table tbody tr.opn-row-clickable {
    cursor: pointer;
}

.table tbody tr.opn-row-clickable > td:first-child {
    position: relative;
    padding-left: 1.25rem;
}

.table tbody tr.opn-row-clickable > td:first-child::before {
    content: "↗";
    position: absolute;
    left: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-blue);
    font-size: 0.72rem;
    line-height: 1;
    opacity: 0.42;
    transition: transform 0.18s ease, opacity 0.18s ease;
    pointer-events: none;
}

.table tbody tr.opn-row-clickable:hover > td:first-child::before {
    opacity: 0.9;
    transform: translate(2px, -50%);
}

.table tbody tr.opn-row-clickable td.opn-row-selectable {
    cursor: text;
    user-select: text;
}

.sortable {
    cursor: pointer;
}

.score-cell,
.trend-score-cell {
    min-width: 130px;
}

.trend-score-cell {
    display: inline-flex;
    flex-direction: column;
    gap: 3px;
}

.trend-score-cell small {
    color: var(--text-secondary);
}

.form-control,
.form-select,
textarea {
    background-color: var(--input-bg);
    border-color: var(--border-subtle);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.form-control::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

.form-control:focus,
.form-select:focus,
textarea:focus {
    color: var(--text-primary);
    border-color: var(--accent-blue);
    background-color: var(--input-focus-bg);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-select option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
}

.form-label {
    color: var(--text-secondary);
    font-size: 0.81rem;
    font-weight: 520;
}

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

.btn {
    border-radius: var(--radius-sm);
    font-weight: 560;
    border-width: 1px;
}

.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: var(--text-action-primary-readable);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background: var(--action-primary-bg-hover) !important;
    border-color: var(--action-primary-bg-hover) !important;
    color: var(--text-action-primary-readable) !important;
}

.btn-outline-info {
    color: var(--text-action-outline-readable);
    border-color: rgba(59, 130, 246, 0.52);
}

.btn-outline-info:hover,
.btn-outline-info:focus,
.btn-outline-info:active {
    color: #FFFFFF !important;
    border-color: var(--accent-blue) !important;
    background: rgba(59, 130, 246, 0.22) !important;
}

.btn-outline-light,
.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-strong);
    background: rgba(26, 29, 35, 0.72);
}

.btn-outline-light:hover,
.btn-outline-light:focus,
.btn-outline-light:active,
.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active {
    color: var(--text-primary) !important;
    background: rgba(47, 52, 64, 0.88) !important;
    border-color: rgba(160, 166, 177, 0.46) !important;
}

.btn-danger {
    background: var(--risk-critical);
    border-color: var(--risk-critical);
    color: #FFFFFF;
}

.btn-danger:hover,
.btn-danger:focus,
.btn-danger:active {
    background: #D80D0D !important;
    border-color: #D80D0D !important;
}

.btn-outline-danger {
    color: var(--risk-critical);
    border-color: rgba(255, 31, 31, 0.52);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus,
.btn-outline-danger:active {
    color: #FFFFFF !important;
    background: rgba(255, 31, 31, 0.22) !important;
    border-color: var(--risk-critical) !important;
}

.btn-outline-success {
    color: var(--risk-low);
    border-color: rgba(48, 209, 88, 0.5);
}

.btn-outline-success:hover,
.btn-outline-success:focus,
.btn-outline-success:active {
    color: #FFFFFF !important;
    background: rgba(48, 209, 88, 0.22) !important;
    border-color: var(--risk-low) !important;
}

.support-chat-toggle {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 54px;
    height: 54px;
    border: 1px solid rgba(59, 130, 246, 0.56);
    border-radius: 50%;
    background: var(--accent-blue);
    color: #fff;
    box-shadow: var(--shadow-lg);
    z-index: 1060;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.support-chat-toggle:hover,
.support-chat-toggle:focus {
    background: #2563EB;
    border-color: #60A5FA;
}

body[data-page^="event-sentinel"] .support-chat-toggle,
body[data-page^="event-sentinel"] .support-chat-panel {
    display: none !important;
}

.support-chat-panel {
    position: fixed;
    right: 22px;
    bottom: 88px;
    width: min(420px, calc(100vw - 28px));
    max-height: min(680px, calc(100vh - 114px));
    background: var(--surface-floating-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-floating-panel);
    z-index: 1060;
    overflow: hidden;
}

.support-chat-header,
.support-chat-actions,
.support-chat-form {
    padding: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.support-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.support-chat-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.support-chat-messages {
    padding: 12px;
    height: min(360px, calc(100vh - 330px));
    min-height: 220px;
    overflow: auto;
}

.support-chat-message {
    display: flex;
    margin-bottom: 10px;
}

.support-chat-message > div {
    max-width: 86%;
    border-radius: var(--radius-md);
    padding: 9px 11px;
    font-size: 0.9rem;
    line-height: 1.38;
    border: 1px solid var(--border-subtle);
}

.support-chat-message.assistant {
    justify-content: flex-start;
}

.support-chat-message.assistant > div {
    background: rgba(160, 166, 177, 0.09);
    color: var(--text-primary);
}

.support-chat-message.user {
    justify-content: flex-end;
}

.support-chat-message.user > div {
    background: rgba(59, 130, 246, 0.24);
    border-color: rgba(59, 130, 246, 0.42);
    color: #fff;
}

.support-chat-form {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-subtle);
    border-bottom: 0;
}

.support-thinking {
    padding: 0 12px 10px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 4px;
}

.support-thinking-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent-blue);
    display: inline-block;
    animation: supportThinkingPulse 1s infinite ease-in-out;
}

.support-thinking-dot:nth-child(3) {
    animation-delay: 0.16s;
}

.support-thinking-dot:nth-child(4) {
    animation-delay: 0.32s;
}

@keyframes supportThinkingPulse {
    0%, 80%, 100% {
        transform: translateY(0);
        opacity: 0.45;
    }
    40% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

.support-onboarding-overlay {
    position: fixed;
    inset: 0;
    background: rgba(4, 6, 10, 0.62);
    z-index: 1070;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

body.support-onboarding-active .support-onboarding-overlay {
    background: transparent;
}

body.support-onboarding-active .support-onboarding-overlay::before {
    content: "";
    position: fixed;
    inset: 0;
    left: 265px;
    background: rgba(4, 6, 10, 0.56);
}

.support-onboarding-card {
    width: min(560px, 100%);
    background: var(--surface-floating-panel);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-floating-panel);
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* Los paneles flotantes de ayuda cableaban un degradado oscuro sin variante
   clara, así que en light_red salía un modal oscuro sobre una página blanca
   (visto en producción en la guía «Ayuda ENS»). Se corrigen los tres que
   estaban sin cubrir, siguiendo el mismo patrón que .card/.modal-content. */
.support-onboarding-title {
    color: var(--text-primary);
    font-size: 1.25rem;
    margin: 0;
}

.support-onboarding-body {
    color: var(--text-secondary);
    margin: 14px 0 18px;
    line-height: 1.48;
}

.support-onboarding-highlight {
    position: relative;
    z-index: 1071;
    outline: 3px solid rgba(59, 130, 246, 0.85);
    outline-offset: 3px;
    box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.16);
    animation: supportOnboardingFocusPulse 1.1s ease-in-out infinite;
}

.sidebar .support-onboarding-highlight {
    background: rgba(59, 130, 246, 0.2) !important;
    border-left-color: var(--accent-blue) !important;
    color: var(--text-primary) !important;
}

.sidebar .support-onboarding-highlight i {
    color: var(--accent-blue) !important;
}

@keyframes supportOnboardingFocusPulse {
    0%, 100% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.12);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 0 12px rgba(59, 130, 246, 0.25);
        opacity: 0.96;
    }
}

@media (max-width: 575.98px) {
    .support-chat-toggle {
        right: 14px;
        bottom: 14px;
    }

    .support-chat-panel {
        right: 14px;
        bottom: 76px;
    }

    .support-chat-form {
        flex-direction: column;
    }
}

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

.badge.bg-secondary {
    background: rgba(107, 114, 128, 0.35) !important;
    color: #D1D5DB;
}

.badge-risk-low {
    background: rgba(48, 209, 88, 0.16);
    color: var(--risk-low);
}

.badge-risk-medium {
    background: rgba(255, 214, 10, 0.16);
    color: var(--risk-medium);
}

.badge-risk-high {
    background: rgba(255, 138, 0, 0.16);
    color: var(--risk-high);
}

.badge-risk-critical {
    background: rgba(255, 31, 31, 0.17);
    color: var(--risk-critical);
}

.badge-status {
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 630;
}

.badge-status.nueva,
.badge-status.new {
    background: rgba(59, 130, 246, 0.18);
    color: #93C5FD;
}

.badge-status.en-revision,
.badge-status.en_revision,
.badge-status.en-investigacion,
.badge-status.en_investigacion,
.badge-status.review,
.badge-status.active {
    background: rgba(255, 214, 10, 0.17);
    color: var(--risk-medium);
}

.badge-status.triage {
    background: rgba(59, 130, 246, 0.22);
    color: #BFDBFE;
}

.badge-status.escalada,
.badge-status.escalada-rrhh,
.badge-status.escalada_rrhh,
.badge-status.escalada-legal,
.badge-status.escalada_legal,
.badge-status.escalada-seguridad,
.badge-status.escalada_seguridad,
.badge-status.escalated,
.badge-status.critical {
    background: rgba(255, 31, 31, 0.17);
    color: var(--risk-critical);
}

.badge-status.mitigada,
.badge-status.completed,
.badge-status.cerrada,
.badge-status.closed {
    background: rgba(48, 209, 88, 0.17);
    color: var(--risk-low);
}

.badge-status.descartada,
.badge-status.dismissed,
.badge-status.falso-positivo,
.badge-status.falso_positivo,
.badge-status.false-positive {
    background: rgba(107, 114, 128, 0.33);
    color: #D1D5DB;
}

.score-bar {
    height: 8px;
    border-radius: 999px;
    background: rgba(160, 166, 177, 0.2);
    overflow: hidden;
}

.score-fill {
    border-radius: 999px;
}

.timeline-item {
    border-left: 2px solid rgba(160, 166, 177, 0.22);
}

.timeline-item::before {
    background: var(--accent-blue);
    box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.14);
}

.filter-grid {
    gap: 12px;
}

body[data-page="employees-list"] .employees-filter-panel {
    overflow: hidden;
    border-color: var(--border-filter-panel);
    background: var(--surface-filter-panel);
}

body[data-page="employees-list"] .employees-filter-panel .card-body {
    padding: 22px 24px 24px;
}

body[data-page="employees-list"] .employees-filter-header {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    padding-bottom: 18px;
    margin-bottom: 18px;
    border-bottom: 1px solid rgba(160, 166, 177, 0.14);
}

body[data-page="employees-list"] .employees-filter-eyebrow {
    margin-bottom: 5px;
    color: var(--accent-pink);
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

body[data-page="employees-list"] .employees-filter-title {
    margin: 0;
    color: var(--text-primary);
    font-size: clamp(1.15rem, 1.4vw, 1.45rem);
    font-weight: 800;
}

body[data-page="employees-list"] .employees-filter-copy {
    max-width: 680px;
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

body[data-page="employees-list"] .employees-filter-meta {
    display: inline-flex;
    min-width: 190px;
    flex-direction: column;
    gap: 2px;
    padding: 10px 14px;
    border: 1px solid var(--border-filter-meta);
    border-radius: 16px;
    background: var(--surface-filter-meta);
    text-align: right;
}

body[data-page="employees-list"] .employees-filter-meta span {
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

body[data-page="employees-list"] .employees-filter-meta strong {
    color: var(--text-primary);
    font-size: 0.9rem;
}

body[data-page="employees-list"] .employees-filter-grid {
    display: grid;
    grid-template-columns: minmax(280px, 1.3fr) repeat(3, minmax(190px, 1fr));
    gap: 18px 16px;
    align-items: end;
}

body[data-page="employees-list"] .employees-filter-field {
    min-width: 0;
}

body[data-page="employees-list"] .employees-filter-field .form-label {
    display: flex;
    align-items: center;
    min-height: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.78rem;
    font-weight: 750;
}

body[data-page="employees-list"] .employees-filter-field .form-control,
body[data-page="employees-list"] .employees-filter-field .form-select {
    min-height: 48px;
    border-color: var(--border-filter-control);
    border-radius: 14px;
    background-color: var(--surface-filter-control);
    font-size: 0.95rem;
}

body[data-page="employees-list"] .employees-filter-field .form-control:focus,
body[data-page="employees-list"] .employees-filter-field .form-select:focus {
    border-color: var(--accent-pink);
    box-shadow: 0 0 0 3px rgba(236, 48, 92, 0.18);
}

body[data-page="employees-list"] .employees-filter-actions {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    margin-top: 22px;
    padding: 16px;
    border: 1px solid var(--border-filter-actions);
    border-radius: 18px;
    background: var(--surface-filter-actions);
}

body[data-page="employees-list"] .employees-filter-actions-copy {
    display: flex;
    min-width: 190px;
    flex-direction: column;
    gap: 2px;
}

body[data-page="employees-list"] .employees-filter-actions-copy span {
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 800;
}

body[data-page="employees-list"] .employees-filter-actions-copy small {
    color: var(--text-secondary);
}

body[data-page="employees-list"] .employees-filter-shortcuts {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

body[data-page="employees-list"] .employees-filter-shortcuts .btn {
    min-height: 40px;
    padding-inline: 16px;
    border-radius: 13px;
    font-weight: 750;
}

@media (max-width: 1400px) {
    body[data-page="employees-list"] .employees-filter-grid {
        grid-template-columns: minmax(260px, 1.25fr) repeat(3, minmax(170px, 1fr));
    }
}

@media (max-width: 992px) {
    body[data-page="employees-list"] .employees-filter-header,
    body[data-page="employees-list"] .employees-filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    body[data-page="employees-list"] .employees-filter-meta {
        width: 100%;
        text-align: left;
    }

    body[data-page="employees-list"] .employees-filter-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body[data-page="employees-list"] .employees-filter-shortcuts {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    body[data-page="employees-list"] .employees-filter-panel .card-body {
        padding: 18px;
    }

    body[data-page="employees-list"] .employees-filter-grid {
        grid-template-columns: 1fr;
    }

    body[data-page="employees-list"] .employees-filter-actions-copy,
    body[data-page="employees-list"] .employees-filter-shortcuts {
        width: 100%;
    }

    body[data-page="employees-list"] .employees-filter-shortcuts {
        flex-direction: column;
    }

    body[data-page="employees-list"] .employees-filter-shortcuts .btn {
        width: 100%;
    }
}

/* Tabla empleados: densidad operable en escritorio y cards en móvil */
body[data-page="employees-list"] .employees-table-wrap {
    overflow-x: auto;
    max-width: 100%;
    scrollbar-gutter: stable;
    -webkit-overflow-scrolling: touch;
}

body[data-page="employees-list"] #employees-table-root {
    min-width: 1100px;
    table-layout: fixed;
    width: 100%;
}

body[data-page="employees-list"] #employees-table-root th,
body[data-page="employees-list"] #employees-table-root td {
    vertical-align: middle;
    overflow-wrap: break-word;
}

body[data-page="employees-list"] #employees-table-root .employees-col-actions,
body[data-page="employees-list"] #employees-table-root td.opn-actions-cell {
    width: 7.5rem;
    min-width: 7.5rem;
    white-space: nowrap;
    overflow-wrap: normal;
}

body[data-page="employees-list"] .employees-mobile-list {
    display: none;
}

body[data-page="employees-list"] .employees-mobile-card {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
}

body[data-page="employees-list"] .employees-mobile-card + .employees-mobile-card {
    border-top: 0;
}

body[data-page="employees-list"] .employees-mobile-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem 0.75rem;
    margin: 0.7rem 0;
}

body[data-page="employees-list"] .employees-mobile-meta span {
    display: block;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

body[data-page="employees-list"] .employees-filter-mobile-bar {
    display: none;
}

@media (max-width: 1500px) {
    body[data-page="employees-list"] #employees-table-root {
        min-width: 100%;
        font-size: 0.86rem;
    }

    body[data-page="employees-list"] #employees-table-root .employees-col-role,
    body[data-page="employees-list"] #employees-table-root td:nth-child(3),
    body[data-page="employees-list"] #employees-table-root .employees-col-score,
    body[data-page="employees-list"] #employees-table-root td:nth-child(5) {
        display: none;
    }
}

@media (max-width: 767.98px) {
    body[data-page="employees-list"] .employees-filter-header,
    body[data-page="employees-list"] .employees-filter-actions-copy {
        display: none;
    }

    body[data-page="employees-list"] .employees-filter-panel .card-body {
        padding: 12px;
    }

    body[data-page="employees-list"] .employees-filter-mobile-bar {
        display: flex;
        justify-content: flex-end;
        margin-bottom: 10px;
    }

    body[data-page="employees-list"] .employees-filter-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    body[data-page="employees-list"] .employees-filter-field .form-control,
    body[data-page="employees-list"] .employees-filter-field .form-select {
        min-height: 42px;
        border-radius: 10px;
        font-size: 0.9rem;
    }

    body[data-page="employees-list"]:not(.employees-filters-expanded) .employees-filter-extra,
    body[data-page="employees-list"]:not(.employees-filters-expanded) .employees-filter-actions {
        display: none;
    }

    body[data-page="employees-list"] .employees-table-wrap {
        display: none;
    }

    body[data-page="employees-list"] .employees-mobile-list {
        display: block;
    }

    /* La alineación la dan align-items-start/-md-center en la plantilla:
       Bootstrap marca sus utilidades como importantes y aquí no se compite. */
    body[data-page="employees-list"] #employees-pagination-bar {
        flex-direction: column;
        gap: 0.75rem;
    }
}

.empty-state {
    border: 1px dashed rgba(160, 166, 177, 0.35);
    color: var(--text-secondary);
    background: rgba(26, 29, 35, 0.55);
    border-radius: var(--radius-md);
}

.widget-list li {
    border-bottom: 1px solid rgba(160, 166, 177, 0.14);
}

.kpi-risk.low { color: var(--risk-low); }
.kpi-risk.medium { color: var(--risk-medium); }
.kpi-risk.high { color: var(--risk-high); }
.kpi-risk.critical { color: var(--risk-critical); }

.border-subtle {
    border-color: var(--border-subtle) !important;
}

.pagination .page-link {
    background: var(--bg-secondary);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

.pagination .page-item.active .page-link {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
}

.pagination .page-link:hover,
.pagination .page-link:focus {
    color: var(--text-primary);
    border-color: var(--accent-blue);
}

.custom-toast {
    color: var(--text-primary);
    background: rgba(26, 29, 35, 0.94);
    border-color: var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transition: opacity 220ms ease, transform 220ms ease, max-height 220ms ease, margin 220ms ease, padding 220ms ease;
}

.custom-toast.is-entering {
    opacity: 0;
    transform: translateY(-8px);
}

.custom-toast.is-leaving {
    opacity: 0;
    transform: translateY(-8px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
}

.custom-toast.success { border-color: rgba(48, 209, 88, 0.55); }
.custom-toast.warning { border-color: rgba(255, 214, 10, 0.55); }
.custom-toast.danger { border-color: rgba(255, 31, 31, 0.55); }
.custom-toast.info { border-color: rgba(59, 130, 246, 0.55); }

@media (max-width: 991px) {
    body.support-onboarding-active .support-onboarding-overlay::before {
        left: 0;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 265px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.24s ease;
        z-index: 1040;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open #sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .main-content {
        margin-left: 0;
    }

    .main-content {
        padding: 16px;
    }

    .topbar {
        align-items: flex-start;
        flex-wrap: wrap;
        margin-bottom: 14px;
    }

    .topbar-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .page-title {
        font-size: 1.3rem;
    }


}

/* ============================================ */
/* MODAL IMPROVEMENTS - Structured Sections    */
/* ============================================ */

.modal-header {
    background: linear-gradient(135deg, var(--surface-elevated), var(--card-bg));
    border-bottom: 2px solid var(--border-strong);
    padding: 1.25rem;
}

.modal-header .modal-title {
    font-weight: 600;
    font-size: 1.1rem;
    letter-spacing: 0.3px;
}

.modal-body {
    background: var(--card-bg);
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-footer {
    background: var(--surface-elevated);
    border-top: 1px solid var(--border-subtle);
    padding: 1rem 1.5rem;
}

/* Modal section headers for logical grouping */
.modal-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-section-title:first-child {
    margin-top: 0;
}

/* Form styling improvements */
.form-label {
    font-weight: 550;
    color: var(--text-primary);
}

.form-label small {
    color: var(--text-muted);
    font-weight: normal;
}

.form-control, .form-select {
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    box-shadow: 0 0 0 3px var(--focus-ring);
}

/* BEGIN O4-C4-MIGRATED: shared-context-navigation-and-statuses */
html:root .page-title,
html:root .card-header,
html:root .topbar-heading {
    color: var(--text-heading);
}

html:root .breadcrumb {
    background: var(--surface-context);
    border-color: var(--border-context);
    --bs-breadcrumb-divider-color: var(--text-context-divider);
    --bs-breadcrumb-item-active-color: var(--text-context-active);
}

html:root .breadcrumb-item,
html:root .breadcrumb-item a {
    color: var(--text-context);
    font-weight: var(--font-weight-context-item);
}

html:root .breadcrumb-item.active {
    color: var(--text-context-active);
    font-weight: var(--font-weight-context-active);
}

html:root .breadcrumb-item:hover,
html:root .breadcrumb-item a:hover {
    color: var(--text-context-hover);
}

html:root .sidebar {
    box-shadow: var(--shadow-navigation);
}

html:root .sidebar .sidebar-link {
    color: var(--text-navigation);
}

html:root .sidebar .sidebar-link i {
    color: var(--text-navigation-icon);
}

html:root .sidebar .sidebar-link:hover,
html:root .sidebar .sidebar-link.active {
    background: var(--surface-navigation-hover);
    color: var(--text-navigation-active);
}

html:root .sidebar .sidebar-link:hover {
    border-left-color: var(--accent-navigation);
}

html:root .sidebar .sidebar-link.active {
    background: var(--surface-navigation-active);
    border-left-color: var(--border-navigation-active);
}

html:root .sidebar .sidebar-link:hover i,
html:root .sidebar .sidebar-link.active i {
    color: var(--accent-navigation);
}

html:root .badge {
    color: var(--text-status-badge-base);
}

html:root .badge.bg-success {
    background: var(--surface-status-badge-success) !important;
    color: var(--text-status-badge-success);
    font-weight: 600;
}

html:root .badge.bg-danger {
    background: var(--surface-status-badge-danger) !important;
    color: var(--text-status-badge-emphasis);
    font-weight: 600;
}

html:root .badge.bg-warning {
    background: var(--surface-status-badge-warning) !important;
    color: var(--text-status-badge-warning);
    font-weight: 600;
}

html:root .badge.bg-info {
    background: var(--surface-status-badge-info) !important;
    color: var(--text-status-badge-info);
    font-weight: 600;
}

html:root .badge.bg-secondary {
    background: var(--surface-status-badge-secondary) !important;
    color: var(--text-status-badge-secondary);
    font-weight: 600;
}

html:root .badge.bg-primary {
    background: var(--surface-status-badge-primary) !important;
    color: var(--text-status-badge-emphasis);
    font-weight: 600;
}
/* END O4-C4-MIGRATED: shared-context-navigation-and-statuses */

/* BEGIN O4-C2-MIGRATED: shared-primitives-cards-tables-forms-actions */
html:root .stat-card,
html:root .card,
html:root .card-custom {
    background: var(--surface-card);
    border-color: var(--border-card);
    box-shadow: var(--shadow-card);
}

html:root .modal-content {
    background: var(--surface-modal-primitive);
    border-color: var(--border-modal-primitive);
    box-shadow: var(--shadow-modal-primitive);
}

html:root .stat-card:hover,
html:root .card-custom:hover {
    border-color: var(--border-card-hover);
    box-shadow: var(--shadow-card-hover);
}

html:root .table-custom th,
html:root .table th {
    background: var(--surface-table-header) !important;
    color: var(--text-table-header) !important;
}

html:root .table td {
    color: var(--text-control);
    border-color: var(--border-table-cell) !important;
}

html:root .table-hover > tbody > tr:hover > * {
    background-color: var(--surface-table-row-hover) !important;
}

html:root .form-control,
html:root textarea {
    background: var(--surface-input);
    border-color: var(--border-input);
    color: var(--text-input);
    box-shadow: var(--shadow-input);
}

html:root .form-select {
    background-image: var(--surface-input-select-image);
    border-color: var(--border-input);
    color: var(--text-input);
    box-shadow: var(--shadow-input);
}

html:root .form-control::placeholder,
html:root textarea::placeholder {
    color: var(--text-input-placeholder);
    opacity: var(--input-placeholder-opacity);
}

html:root .form-control:focus,
html:root textarea:focus {
    background: var(--surface-input-focus);
    border-color: var(--border-input-focus);
    box-shadow: var(--shadow-input-focus);
}

html:root .form-select:focus {
    background-color: var(--surface-select-focus);
    background-image: var(--surface-input-select-focus-image);
    border-color: var(--border-input-focus);
    box-shadow: var(--shadow-select-focus);
}

html:root .btn-primary {
    background: var(--surface-action-primary-default);
    border-color: var(--border-action-primary-default);
    color: var(--text-action-primary-readable);
    box-shadow: var(--shadow-action-primary-default);
}

html:root .btn-primary:hover,
html:root .btn-primary:focus,
html:root .btn-primary:active {
    background: var(--action-primary-bg-hover) !important;
    border-color: var(--action-primary-bg-hover) !important;
    color: var(--text-action-primary-readable) !important;
    box-shadow: var(--shadow-action-primary-hover);
}

/* El selector de cambio de contraseña es un control de contorno; el azul de
   Bootstrap sobre el fondo claro no alcanza AA. El rol ya contempla ambos
   catálogos y no cambia la acción ni su geometría. */
#profile-password-save-btn {
    color: var(--text-action-outline-readable) !important;
}

/* END O4-C2-MIGRATED: shared-primitives-cards-tables-forms-actions */

/* BEGIN O4-C4-MIGRATED: shared-outline-controls */
html:root .btn-outline-light,
html:root .btn-outline-secondary {
    background: var(--surface-action-outline);
    border-color: var(--border-action-outline);
    color: var(--text-action-outline);
}

html:root .btn-outline-light:hover,
html:root .btn-outline-light:focus,
html:root .btn-outline-light:active,
html:root .btn-outline-secondary:hover,
html:root .btn-outline-secondary:focus,
html:root .btn-outline-secondary:active {
    background: var(--surface-action-outline-hover) !important;
    border-color: var(--border-action-outline-hover) !important;
    color: var(--text-action-outline-hover) !important;
}
/* END O4-C4-MIGRATED: shared-outline-controls */

/* BEGIN O4-C6-MIGRATED: shared-tables-links-statuses-admin-modal */
/* Bootstrap utilities keep their contract; the catalogue supplies the values. */
html:root a {
    color: var(--text-link);
}

html:root a:hover {
    color: var(--text-link-hover);
}

/* La tinta del enlace debe heredar el estado de la banda de salud; la regla
   genérica de enlaces no puede convertir una advertencia en azul de enlace. */
html:root .cc-health-banner .cc-health-link,
html:root .cc-health-banner .cc-health-link:hover {
    color: inherit;
}

html:root .bg-black.bg-opacity-25 {
    background-color: var(--surface-utility-contrast) !important;
    border-color: var(--border-utility-contrast) !important;
    color: var(--text-primary);
}

html:root .table-dark {
    background-color: var(--surface-table-dark) !important;
    border-color: var(--border-table-dark);
}

html:root .table-dark thead {
    background-color: var(--surface-table-dark-header) !important;
}

html:root .badge.bg-secondary-subtle,
html:root .badge.border-secondary,
html:root #layout-role-pill {
    background: var(--surface-badge-neutral) !important;
    border-color: var(--border-badge-neutral) !important;
    color: var(--text-badge-neutral) !important;
    font-weight: var(--weight-badge-neutral);
    letter-spacing: var(--tracking-badge-neutral);
}

html:root .badge-status.nueva,
html:root .badge-status.new {
    background: var(--surface-badge-status-info);
    color: var(--text-badge-status-info);
}

html:root .badge-status.triage {
    background: var(--surface-badge-status-info-strong);
    color: var(--text-badge-status-info-strong);
}

html:root .badge-status.en-revision,
html:root .badge-status.en_revision,
html:root .badge-status.en-investigacion,
html:root .badge-status.en_investigacion,
html:root .badge-status.review,
html:root .badge-status.active {
    background: var(--surface-badge-status-warning);
    color: var(--text-badge-status-warning);
}

html:root .badge-status.descartada,
html:root .badge-status.dismissed,
html:root .badge-status.falso-positivo,
html:root .badge-status.falso_positivo,
html:root .badge-status.false-positive {
    background: var(--surface-badge-status-neutral);
    color: var(--text-badge-status-neutral);
}

html:root .badge-risk-low {
    background: var(--surface-badge-severity-low);
    color: var(--text-badge-severity-low);
    border-color: var(--border-badge-severity-low);
    box-shadow: var(--shadow-badge-severity-low);
}

html:root .badge-risk-medium {
    background: var(--surface-badge-severity-medium);
    color: var(--text-badge-severity-medium);
    border-color: var(--border-badge-severity-medium);
    box-shadow: var(--shadow-badge-severity-medium);
}

html:root .badge-risk-high {
    background: var(--surface-badge-severity-high);
    color: var(--text-badge-severity-high);
    border-color: var(--border-badge-severity-high);
    box-shadow: var(--shadow-badge-severity-high);
}

html:root .badge-risk-critical,
html:root .badge-status.escalada,
html:root .badge-status.escalada-rrhh,
html:root .badge-status.escalada_rrhh,
html:root .badge-status.escalada-legal,
html:root .badge-status.escalada_legal,
html:root .badge-status.escalada-seguridad,
html:root .badge-status.escalada_seguridad,
html:root .badge-status.escalated,
html:root .badge-status.critical {
    background: var(--surface-badge-severity-critical);
    color: var(--text-badge-severity-critical);
    border-color: var(--border-badge-severity-critical);
    box-shadow: var(--shadow-badge-severity-critical);
}

html:root .badge-status.mitigada,
html:root .badge-status.completed,
html:root .badge-status.cerrada,
html:root .badge-status.closed {
    background: var(--surface-badge-status-closed);
    color: var(--text-badge-status-closed);
}

html:root #admin-user-modal .modal-content.text-light {
    color: var(--text-modal-content) !important;
}

html:root #admin-user-modal,
html:root #admin-user-modal .modal-header,
html:root #admin-user-modal .modal-footer,
html:root #admin-user-modal label,
html:root #admin-user-modal .form-label,
html:root #admin-user-modal .form-check-label,
html:root #admin-user-modal .text-light {
    color: var(--text-modal-root) !important;
}

html:root #admin-user-modal .text-muted {
    color: var(--text-modal-muted) !important;
}

html:root #admin-user-modal .form-control,
html:root #admin-user-modal .form-select {
    background-color: var(--surface-form-color) !important;
    color: var(--text-modal-root) !important;
    border-color: var(--border-form-strong) !important;
}

html:root #admin-user-modal .form-control::placeholder {
    color: var(--text-form-placeholder) !important;
}

html:root #admin-user-modal .border-secondary {
    border-color: var(--border-utility-contrast) !important;
}

html:root #admin-user-modal .form-check-input {
    background-color: var(--surface-form-check) !important;
    border-color: var(--border-form-check) !important;
}

html:root #admin-user-modal .form-check-input:checked {
    background-color: var(--surface-form-check-checked) !important;
    border-color: var(--surface-form-check-checked) !important;
}
/* END O4-C6-MIGRATED: shared-tables-links-statuses-admin-modal */

/* BEGIN O4-C7-MIGRATED: remaining shared theme primitives */
html:root .border-secondary-subtle {
    border-color: var(--border-indicator-neutral) !important;
}

html:root .custom-toast {
    background: var(--surface-feedback-toast);
    color: var(--text-feedback-toast);
    border-color: var(--border-feedback-toast);
    box-shadow: var(--shadow-feedback-toast);
}

html:root .custom-toast.success {
    border-color: var(--border-feedback-success);
    box-shadow: var(--shadow-feedback-success);
}

html:root .custom-toast.warning {
    border-color: var(--border-feedback-warning);
    box-shadow: var(--shadow-feedback-warning);
}

html:root .custom-toast.danger {
    border-color: var(--border-feedback-danger);
    box-shadow: var(--shadow-feedback-danger);
}

html:root .custom-toast.info {
    border-color: var(--border-feedback-info);
    box-shadow: var(--shadow-feedback-info);
}

html:root #admin-user-modal .modal-content {
    background: var(--surface-modal-form) !important;
    border-color: var(--border-modal-form) !important;
    box-shadow: var(--shadow-modal-form) !important;
}
/* END O4-C7-MIGRATED: remaining shared theme primitives */

/* Settings shell */
.settings-side-nav {
    background: color-mix(in srgb, var(--bg-secondary) 82%, transparent);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    max-height: calc(100vh - 8.75rem);
    overflow: auto;
    padding: .75rem;
    position: sticky;
    top: 5.75rem;
    max-width: 100%;
    width: 18rem;
    z-index: 5;
}

.settings-side-nav.settings-side-nav-pending {
    visibility: hidden;
}

.page-wrapper:has(> .settings-side-nav) {
    display: grid;
    gap: 1rem;
    grid-template-columns: 18rem minmax(0, 1fr);
}

.page-wrapper:has(> .settings-side-nav) > nav[aria-label="breadcrumb"] {
    grid-column: 1 / -1;
}

.page-wrapper:has(> .settings-side-nav) > .settings-side-nav {
    grid-column: 1;
    grid-row: 1 / span 30;
}

.page-wrapper:has(> .settings-side-nav):has(> nav[aria-label="breadcrumb"]) > .settings-side-nav {
    grid-row: 2 / span 30;
}

.page-wrapper:has(> .settings-side-nav) > :not(nav[aria-label="breadcrumb"]):not(.settings-side-nav) {
    grid-column: 2;
}

.settings-side-header {
    align-items: center;
    display: flex;
    gap: .75rem;
    justify-content: flex-start;
    margin-bottom: .75rem;
}

.settings-side-title {
    align-items: center;
    color: var(--text-primary);
    display: flex;
    font-size: 1.05rem;
    font-weight: 800;
    gap: .55rem;
}

.settings-side-search {
    margin-bottom: .55rem;
}

.settings-side-search .input-group-text,
.settings-side-search .form-control {
    background: color-mix(in srgb, var(--bg-secondary) 86%, transparent);
    border-color: var(--border-subtle);
    color: var(--text-secondary);
}

.settings-side-search .form-control::placeholder {
    color: var(--text-muted);
}

.settings-side-section {
    border-top: 1px solid var(--border-subtle);
    padding: .7rem 0 .15rem;
}

.settings-side-section:first-of-type {
    border-top: 0;
}

.settings-side-toggle {
    align-items: center;
    background: transparent;
    border: 0;
    color: inherit;
    display: flex;
    justify-content: space-between;
    padding: 0 .45rem .25rem;
    text-align: left;
    width: 100%;
}

.settings-side-toggle i {
    color: var(--text-muted);
    font-size: .8rem;
    transition: transform .18s ease;
}

.settings-side-section.is-collapsed .settings-side-toggle i {
    transform: rotate(-90deg);
}

.settings-side-label {
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .04em;
    margin: 0;
    text-transform: uppercase;
}

.settings-side-links {
    display: grid;
    gap: .12rem;
}

.settings-side-section.is-collapsed .settings-side-links {
    display: none;
}

.settings-side-section.is-hidden {
    display: none;
}

.settings-side-link {
    align-items: center;
    border-radius: 8px;
    color: var(--text-secondary);
    display: flex;
    gap: .65rem;
    min-height: 2.35rem;
    padding: .45rem .55rem;
    text-decoration: none;
}

.settings-side-link i {
    color: var(--text-muted);
    flex: 0 0 1.2rem;
    font-size: 1rem;
    text-align: center;
}

.settings-side-link span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.settings-side-link:hover,
.settings-side-link.active {
    background: var(--sidebar-link-hover-bg);
    color: var(--sidebar-link-active-color);
}

.settings-side-link:hover i,
.settings-side-link.active i {
    color: var(--sidebar-link-active-color);
}

@media (max-width: 1199.98px) {
    .page-wrapper:has(> .settings-side-nav) {
        display: block;
    }

    .settings-side-nav {
        margin-bottom: 1rem;
        max-height: none;
        position: relative;
        top: auto;
        width: 100%;
    }
}

.sentinel-activity-timeline {
    display: grid;
    gap: .75rem;
}

.sentinel-activity-stage {
    display: grid;
    gap: .75rem;
    grid-template-columns: 2rem minmax(0, 1fr);
}

.sentinel-activity-stage-icon {
    align-items: center;
    background: var(--sidebar-link-hover-bg);
    border: 1px solid var(--border-subtle);
    border-radius: 999px;
    color: var(--sidebar-link-active-color);
    display: inline-flex;
    height: 2rem;
    justify-content: center;
    width: 2rem;
}

.sentinel-activity-stage-body {
    background: color-mix(in srgb, var(--bg-secondary) 70%, transparent);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    min-width: 0;
    padding: .75rem;
}

.sentinel-activity-raw {
    background: color-mix(in srgb, var(--bg-secondary) 86%, black);
    border: 1px solid var(--border-subtle);
    max-height: 24rem;
    overflow: auto;
    white-space: pre-wrap;
}

.sentinel-activity-tabs .btn {
    min-width: 7.4rem;
}

#sentinel-tab-activity-panel .card .h5 {
    font-variant-numeric: tabular-nums;
    letter-spacing: 0;
}
/* ============================================ */


.brand-logo-symbol {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    object-fit: contain;
}
