/* ═══════════════════════════════════════════
   TNODUS — Design System  (unified 5+8)
   ═══════════════════════════════════════════ */

:root {
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 56px;
    --topbar-height: 52px;
    --sidebar-bg: #0d1f35;
    --sidebar-hover: rgba(255,255,255,0.05);
    --sidebar-active: #1d71a4;
    --sidebar-text: #7a9ab5;
    --sidebar-text-hover: #c8dce8;
    --sidebar-border: rgba(255,255,255,0.07);
    --topbar-bg: #ffffff;
    --topbar-border: #e3e9f0;
    --content-bg: #f0f4f8;
    --card-bg: #ffffff;
    --card-border: #d5e0ea;
    --brand-primary: #1d71a4;
    --brand-orange: #ef5e05;
    --text-dark: #1a2f45;
    --text-muted-custom: #7a9ab5;
}

/* ─── BODY ─── */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--content-bg);
    margin: 0;
}

/* ─── LOGIN ─── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0d1f35 0%, #1d71a4 100%);
}
.login-card {
    width: 100%;
    max-width: 420px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
}
.login-card .card-body { padding: 2.5rem; }
.login-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}
.login-logo img.login-icon { height: 40px; width: auto; }
.login-logo img.login-wordmark { height: 26px; width: auto; }
.btn-tnodus {
    background: var(--brand-primary);
    color: #fff;
    border: none;
}
.btn-tnodus:hover { background: #185d8a; color: #fff; }

/* ─── SIDEBAR ─── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar-bg);
    z-index: 1040;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width 0.25s ease, transform 0.3s ease;
}

/* Brand area */
.sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 0.625rem 0 0.875rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    gap: 0.375rem;
}
.brand-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    text-decoration: none;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.brand-icon {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex-shrink: 0;
    transition: max-width 0.2s ease, opacity 0.15s ease;
    max-width: 28px;
}
.brand-logotext {
    height: 30px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    flex-shrink: 1;
    transition: max-width 0.25s ease, opacity 0.2s ease;
    overflow: hidden;
}
/* Fallback si no carga logo */
.brand-fallback {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    transition: max-width 0.25s ease, opacity 0.2s ease;
    max-width: 130px;
    overflow: hidden;
    white-space: nowrap;
}
.brand-fallback span { color: var(--brand-orange); }

/* Collapse toggle */
.sidebar-collapse-btn {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: #3a5570;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.15s, color 0.15s;
    font-size: 0.75rem;
    padding: 0;
}
.sidebar-collapse-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--sidebar-text);
}

/* Nav */
.sidebar-nav {
    padding: 0.4rem 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.sidebar-section {
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.3px;
    color: #3a5570;
    padding: 0.9rem 1rem 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.2s ease, max-height 0.25s ease;
    max-height: 40px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 1rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.825rem;
    transition: color 0.15s ease, background 0.15s ease;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}
.sidebar-link:hover {
    color: #f5a06a;
    background: rgba(239,94,5,0.13);
}
.sidebar-link.active {
    color: #fff;
    background: var(--sidebar-active);
}
.sidebar-link i {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
}
.sidebar-link .link-text {
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.25s ease, opacity 0.2s ease;
    max-width: 180px;
}
.sidebar-link .link-badge {
    position: absolute;
    top: 5px;
    right: 6px;
    font-size: 0.58rem;
    padding: 1px 5px;
    border-radius: 10px;
    background: var(--brand-orange);
    color: #fff;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

/* User panel */
.sidebar-user {
    padding: 0.5rem 0.875rem;
    border-top: 1px solid var(--sidebar-border);
    flex-shrink: 0;
    display: flex;
    align-items: stretch;
    gap: 0.625rem;
    overflow: hidden;
    min-width: 0;
}
.sidebar-user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--brand-orange);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: center;
    cursor: default;
}
.sidebar-user-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    transition: max-width 0.25s ease, opacity 0.2s ease;
    max-width: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.05rem;
}
.sidebar-user-name {
    color: #e2eaf2;
    font-size: 0.775rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-role {
    color: var(--sidebar-text);
    font-size: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-empresa {
    color: #4a7fa8;
    font-size: 0.6rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-logout {
    color: #7a9ab5;
    font-size: 1rem;
    text-decoration: none;
    flex-shrink: 0;
    transition: opacity 0.2s ease, max-width 0.25s ease;
    max-width: 28px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    padding: 0 2px;
    border-radius: 4px;
}
.sidebar-user-logout:hover { color: #fc8181; background: rgba(252,129,129,0.08); }

/* ─── COLLAPSED STATE (toggle manual) ─── */
@media (min-width: 992px) {
    body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-width); }
    body.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed-width); }

    /* Brand: expandido = logo, colapsado = icono */
    .sidebar .brand-icon { max-width: 0; opacity: 0; overflow: hidden; }
    .sidebar .brand-link { justify-content: flex-start; padding-left: 1rem; }

    /* Colapsado: botón absoluto para que el icono se centre libremente */
    body.sidebar-collapsed .sidebar .sidebar-brand {
        padding: 0;
        position: relative;
    }
    body.sidebar-collapsed .sidebar .sidebar-collapse-btn {
        position: absolute;
        right: 4px;
        top: 50%;
        transform: translateY(-50%);
        width: 18px;
        min-width: 18px;
        font-size: 0.6rem;
    }
    body.sidebar-collapsed .sidebar .brand-link {
        width: 100%;
        justify-content: center;
        padding-left: 0;
        overflow: visible;
    }
    body.sidebar-collapsed .sidebar .brand-icon    { max-width: 28px; opacity: 1; overflow: visible; }
    body.sidebar-collapsed .sidebar .brand-logotext,
    body.sidebar-collapsed .sidebar .brand-fallback { max-width: 0; opacity: 0; pointer-events: none; }

    /* Secciones: separador cuando está colapsado */
    body.sidebar-collapsed .sidebar .sidebar-section {
        pointer-events: none;
        color: transparent;
        position: relative;
        opacity: 1;
    }
    body.sidebar-collapsed .sidebar .sidebar-section::after {
        content: '';
        position: absolute;
        left: 0.75rem;
        right: 0.75rem;
        top: 50%;
        height: 1px;
        background: rgba(255,255,255,0.08);
    }
    body.sidebar-collapsed .sidebar .sidebar-link .link-text { max-width: 0; opacity: 0; }
    body.sidebar-collapsed .sidebar .sidebar-link .link-badge { opacity: 0; }
    body.sidebar-collapsed .sidebar .sidebar-user-info  { max-width: 0; opacity: 0; }
    body.sidebar-collapsed .sidebar .sidebar-user-logout { max-width: 0; opacity: 0; }
    body.sidebar-collapsed .sidebar .sidebar-link { justify-content: center; padding-left: 0; padding-right: 0; }
    body.sidebar-collapsed .sidebar .sidebar-link i { width: auto; }
}

/* ─── SIDEBAR OVERLAY ─── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1035;
}
.sidebar-overlay.show { display: block; }

/* ─── MAIN CONTENT ─── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.25s ease;
}

/* ─── TOP HEADER ─── */
.top-header {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-shrink: 0;
}
.top-header-left { display: flex; align-items: center; gap: 0.75rem; }
.top-header-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-dark);
}
.top-header-title .sep { color: #b9c8d6; font-weight: 400; margin: 0 0.25rem; }
.top-header-title .sub { color: #7a8a99; font-weight: 400; font-size: 0.8rem; }
/* Texto oscuro para cualquier h5/h6 o clase Bootstrap dentro del top-header claro (estilo A) */
.top-header h1, .top-header h2, .top-header h3,
.top-header h4, .top-header h5, .top-header h6 { color: var(--text-dark) !important; margin: 0; }
.top-header .text-dark  { color: var(--text-dark) !important; }
.top-header .text-muted { color: #7a8a99 !important; }
.top-header .fw-semibold, .top-header .fw-bold { color: var(--text-dark); }
.top-header-actions { display: flex; align-items: center; gap: 0.5rem; }
.th-btn {
    width: 32px; height: 32px;
    border-radius: 7px;
    background: #f0f4f8;
    border: 1px solid #e3e9f0;
    color: #5d7085;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0;
}
.th-btn:hover { background: #e3ecf3; color: var(--text-dark); }
.th-btn.primary { background: var(--brand-orange); border-color: var(--brand-orange); color: #fff; }
.th-btn.primary:hover { background: #c94e04; }
.th-badge {
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(239,94,5,0.1);
    color: #c94e04;
    border: 0.5px solid rgba(239,94,5,0.3);
    font-weight: 500;
}
.th-hamburger {
    background: transparent;
    border: none;
    color: #5d7085;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

/* ─── TOP HEADER: botones Bootstrap adaptados al fondo claro (estilo A) ─── */
/* Hamburger mobile */
.top-header .btn-link { color: #5d7085 !important; }
.top-header .btn-link:hover { color: var(--text-dark) !important; }

/* Acción PRINCIPAL (crear/nuevo) — naranja corporativo sólido */
.top-header .btn-success {
    background: var(--brand-orange);
    border-color: var(--brand-orange);
    color: #fff !important;
}
.top-header .btn-success:hover,
.top-header .btn-success:focus {
    background: #c94e04;
    border-color: #c94e04;
    color: #fff !important;
}

/* Acción SECUNDARIA de la misma gama — naranja en contorno (otra tonalidad) */
.top-header .btn-outline-success {
    background: transparent;
    border-color: rgba(239,94,5,0.55);
    color: var(--brand-orange) !important;
}
.top-header .btn-outline-success:hover,
.top-header .btn-outline-success:focus {
    background: var(--brand-orange);
    border-color: var(--brand-orange);
    color: #fff !important;
}

/* Botón acción secundaria — azul corporativo */
.top-header .btn-outline-primary {
    border-color: rgba(29,113,164,0.45);
    color: var(--brand-primary);
    background: transparent;
}
.top-header .btn-outline-primary:hover,
.top-header .btn-outline-primary:focus {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

/* Botón volver / neutro */
.top-header .btn-outline-secondary {
    border-color: #d5e0ea;
    color: #5d7085;
    background: transparent;
}
.top-header .btn-outline-secondary:hover,
.top-header .btn-outline-secondary:focus {
    background: #f0f4f8;
    border-color: #b9c8d6;
    color: var(--text-dark);
}

/* Botón peligro / admin */
.top-header .btn-outline-danger {
    border-color: rgba(220,53,69,0.4);
    color: #dc3545;
    background: transparent;
}
.top-header .btn-outline-danger:hover {
    background: rgba(220,53,69,0.08);
    border-color: rgba(220,53,69,0.6);
    color: #b02a37;
}

/* Botón oscuro (historial, etc.) */
.top-header .btn-outline-dark {
    border-color: #d5e0ea;
    color: #5d7085;
    background: transparent;
}
.top-header .btn-outline-dark:hover {
    background: #f0f4f8;
    border-color: #b9c8d6;
    color: var(--text-dark);
}

/* Tamaño uniforme para todos los btn-sm en top-header */
.top-header .btn-sm {
    font-size: 0.78rem;
    padding: 0.28rem 0.65rem;
    border-radius: 6px;
}

/* Móvil + tablet vertical: top-header en 2 filas centradas (título arriba, acciones abajo) */
@media (max-width: 767.98px) {
    .top-header {
        height: auto;
        min-height: var(--topbar-height);
        flex-wrap: wrap;
        align-items: center;
        padding: 0.4rem 0.875rem;
        row-gap: 0.45rem;
        column-gap: 0.4rem;
    }
    /* Fila 1: el título (con su hamburguesa), centrado */
    .top-header > *:first-child {
        flex: 1 1 100%;
        min-width: 0;
        justify-content: center;
        text-align: center;
    }
    /* Fila 2: las acciones, agrupadas y centradas */
    .top-header > .th-actions {
        flex: 1 1 100%;
        justify-content: center;
        flex-wrap: wrap;
    }
    /* Fallback si el JS aún no ha agrupado las acciones en .th-actions */
    .top-header > *:not(:first-child):not(.th-actions) { margin: 0 auto; }
}

/* Móvil estrecho: achicar botones y ocultar su texto (solo iconos) */
@media (max-width: 575.98px) {
    .top-header .btn-sm {
        font-size: 0.72rem;
        padding: 0.22rem 0.5rem;
    }
    .top-header .btn-sm .d-none-xs { display: none !important; }
}

/* ─── PAGE CONTENT ─── */
.page-content {
    padding: 1.25rem;
    flex: 1;
}

/* ─── KPI CARDS ─── */
.kpi-card {
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-left: 3px solid var(--brand-primary);
    border-radius: 8px;
    padding: 0.875rem 1rem;
    height: 100%;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(29,113,164,0.12);
}
.kpi-card.kpi-warn {
    border-left-color: var(--brand-orange);
    background: #fffaf7;
}
.kpi-card .kpi-label {
    font-size: 0.67rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--brand-primary);
    margin-bottom: 0.25rem;
}
.kpi-card.kpi-warn .kpi-label { color: #b84800; }
.kpi-card .kpi-value {
    font-size: 1.85rem;
    font-weight: 600;
    line-height: 1;
    color: var(--text-dark);
}
.kpi-card.kpi-warn .kpi-value { color: var(--brand-orange); }
.kpi-card .kpi-sub {
    font-size: 0.7rem;
    color: var(--text-muted-custom);
    margin-top: 0.2rem;
}

/* ─── DASH CARDS (charts / tables) ─── */
.dash-card {
    background: var(--card-bg);
    border: 0.5px solid var(--card-border);
    border-radius: 8px;
    height: 100%;
    display: flex;
    flex-direction: column;
}
.dash-card-header {
    padding: 0.7rem 1rem;
    border-bottom: 0.5px solid var(--card-border);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}
.dash-card-header i { color: var(--brand-primary); font-size: 0.95rem; }
.dash-card-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}
.dash-card-body.align-start { align-items: flex-start; justify-content: flex-start; }

/* ─── WIDGET WRAPPERS (sortable) ─── */
.dash-widget-wrap { transition: opacity 0.2s; }
.dash-widget-wrap.widget-hidden { display: none !important; }

/* Edit/drag mode */
.dash-editing .kpi-card,
.dash-editing .dash-card {
    outline: 2px dashed var(--brand-primary);
    outline-offset: 3px;
    cursor: grab;
}
.dash-editing .kpi-card:active,
.dash-editing .dash-card:active { cursor: grabbing; }
.sortable-ghost { opacity: 0.25; }
.sortable-drag .kpi-card,
.sortable-drag .dash-card { box-shadow: 0 8px 24px rgba(0,0,0,0.15); }

/* ─── CONFIG OFFCANVAS ─── */
.offcanvas-tnodus .offcanvas-header {
    background: var(--topbar-bg);
    color: #e2eaf2;
    border-bottom: 1px solid var(--topbar-border);
}
.offcanvas-tnodus .offcanvas-header .btn-close { filter: invert(1) brightness(0.7); }
.offcanvas-tnodus .offcanvas-title { font-size: 0.875rem; font-weight: 600; }

.config-list { list-style: none; padding: 0; margin: 0; }
.config-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.25rem;
    border-bottom: 0.5px solid #e8f0f6;
}
.config-item:last-child { border-bottom: none; }
.config-handle {
    cursor: grab;
    color: #b0c8d8;
    line-height: 1;
    padding: 2px 4px;
}
.config-handle:active { cursor: grabbing; }
.config-name { flex: 1; font-size: 0.8rem; color: var(--text-dark); }
.config-item.sortable-ghost { opacity: 0.3; background: #edf4fb; border-radius: 4px; }

/* ─── TABLES & BADGES (inherited) ─── */
.badge { font-size: 0.7rem; font-weight: 500; }
.table { font-size: 0.84rem; }
.table thead th {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6a9ab8;
    border-top: none;
}
.table-hover tbody tr:hover { background: #f4f8fb; }

/* ─── STAT CARD (legacy compat) ─── */
.stat-card { border: none; border-radius: 10px; }
.stat-card .stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
}

/* ─── FORMS / INPUTS ─── */
.form-control:focus, .form-select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.2rem rgba(29,113,164,0.2);
}
.btn-primary {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
}
.btn-primary:hover, .btn-primary:focus {
    background: #185d8a;
    border-color: #185d8a;
}

/* ─── SCROLLBAR GLOBAL ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c8d8e4; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a8bece; }

/* ─── BOTÓN COLAPSO visible en desktop ─── */
@media (min-width: 992px) {
    .sidebar-collapse-btn { display: flex !important; }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width) !important;
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .sidebar-collapse-btn { display: none !important; }
    /* En mobile: solo mostrar logotext, ocultar icono */
    .sidebar .brand-icon { display: none !important; }
    .sidebar .brand-logotext,
    .sidebar .brand-fallback { max-width: 160px !important; opacity: 1 !important; }
    /* Undo collapse on mobile — always show full sidebar when shown */
    body.sidebar-collapsed .sidebar { width: var(--sidebar-width) !important; }
    body.sidebar-collapsed .brand-logotext,
    body.sidebar-collapsed .brand-fallback { max-width: 160px; opacity: 1; }
    body.sidebar-collapsed .sidebar-section { opacity: 1; pointer-events: auto; }
    body.sidebar-collapsed .sidebar-link .link-text { max-width: 180px; opacity: 1; }
    body.sidebar-collapsed .sidebar-link .link-badge { opacity: 1; }
    body.sidebar-collapsed .sidebar-link { justify-content: flex-start; padding: 0.55rem 1rem; }
    body.sidebar-collapsed .sidebar-link i { width: 18px; }
    body.sidebar-collapsed .sidebar-user-info { max-width: 150px; opacity: 1; }
    body.sidebar-collapsed .sidebar-user-logout { max-width: 28px; opacity: 1; }
}

/* ─── MOBILE PEQUEÑO (<576px) ─── */
@media (max-width: 575.98px) {
    /* Título dashboard: nombre empresa en segunda fila */
    .top-header-title {
        display: flex;
        flex-direction: column;
        gap: 0;
        line-height: 1.2;
    }
    .top-header-title .sep { display: none; }
    .top-header-title .sub { font-size: 0.68rem; }

    /* Tablas: scroll horizontal contenido, columnas no forzadas */
    .table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table { min-width: 0; }
    /* Reducir padding de celdas en mobile */
    .table td, .table th { padding: 0.4rem 0.5rem; font-size: 0.78rem; }

    /* Cards con padding reducido */
    .page-content { padding: 0.75rem; }
    .kpi-card { padding: 0.625rem 0.75rem; }
}

/* ─── BOTONES btn-success GLOBALES → naranja corporativo ─── */
/* Aplica en modales, tarjetas, y cualquier lugar fuera del top-header */
.btn-success {
    background-color: var(--brand-orange) !important;
    border-color: var(--brand-orange) !important;
    color: #fff !important;
}
.btn-success:hover, .btn-success:focus, .btn-success:active {
    background-color: #c94e04 !important;
    border-color: #c94e04 !important;
    color: #fff !important;
}
/* Deshabilitado: gris (en vez del naranja atenuado) */
.btn-success:disabled, .btn-success.disabled {
    background-color: #ccd4dd !important;
    border-color: #ccd4dd !important;
    color: #fff !important;
    opacity: 1;
    cursor: not-allowed;
}
.btn-outline-success {
    background-color: transparent !important;
    border-color: var(--brand-orange) !important;
    color: var(--brand-orange) !important;
}
.btn-outline-success:hover, .btn-outline-success:focus {
    background-color: var(--brand-orange) !important;
    border-color: var(--brand-orange) !important;
    color: #fff !important;
}

/* ═══════════════════════════════════════════
   DASHBOARD V2 — tarjetas modulares (estilo A)
   ═══════════════════════════════════════════ */

/* KPI como enlace clicable */
a.kpi-card { display: block; text-decoration: none; color: inherit; }
.kpi-card.kpi-bad .kpi-value { color: #c0392b; }
.kpi-card.kpi-bad .kpi-label { color: #922b21; }
.kpi-card.kpi-good .kpi-value { color: #1e8449; }

/* Sistema de variantes */
.card-variant.variant-hidden { display: none !important; }
.modular-zone-title { color: #6a9ab8; letter-spacing: .5px; }

/* Cabecera de tarjeta: nota y enlace a la derecha */
.dash-card-header { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.dw-header-note { margin-left: auto; font-size: 0.66rem; font-weight: 400; color: #a5b3c0; }
.dw-header-link { margin-left: auto; font-size: 0.7rem; font-weight: 500; color: var(--brand-primary); text-decoration: none; }
.dw-header-link:hover { color: var(--brand-orange); }

/* ── Mapa de calor criticidad × riesgo ── */
.dw-heat { display: grid; grid-template-columns: 70px repeat(5, 1fr); gap: 4px; font-size: 0.7rem; }
.dw-heat-lbl { display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; color: #7a8a99; font-size: 0.66rem; }
.dw-heat-cell {
    min-height: 52px; border-radius: 8px; padding: 4px 6px;
    display: flex; flex-direction: column; gap: 2px; justify-content: center;
    text-decoration: none; transition: transform .12s ease, box-shadow .12s ease;
}
.dw-heat-cell:hover { transform: scale(1.03); box-shadow: 0 4px 12px rgba(0,0,0,0.12); z-index: 1; }
.dw-heat-cell span {
    background: rgba(255,255,255,0.3); border-radius: 5px; padding: 1px 6px;
    font-size: 0.62rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dw-heat-more { font-style: normal; opacity: 0.85; }
.dw-heat-ok  { background: #2e9e5b; }
.dw-heat-mid { background: #e0a417; }
.dw-heat-bad { background: #d35446; }
.dw-heat-na  { background: #e8eef4; pointer-events: none; }
.dw-heat-ax  { text-align: center; color: #7a8a99; padding-top: 4px; font-size: 0.62rem; }

/* ── Para hoy ── */
.dw-today { display: flex; gap: 0.8rem; padding: 0.65rem 0; border-bottom: 1px solid #edf2f7; align-items: center; }
.dw-today:last-child { border-bottom: none; }
.dw-today-ico {
    width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 0.95rem; font-weight: 700;
}
.dw-ico-bad  { background: #fbe4e1; color: #c0392b; }
.dw-ico-warn { background: #fdf3dc; color: #c77700; }
.dw-ico-info { background: #e2eff7; color: var(--brand-primary); }
.dw-today-tx { flex: 1; font-size: 0.8rem; min-width: 0; }
.dw-today-tx small { display: block; color: #a5b3c0; font-size: 0.68rem; margin-top: 1px; }
.dw-btn {
    font-size: 0.7rem; padding: 0.25rem 0.7rem; border-radius: 8px;
    border: 1px solid #d5e0ea; color: #26323f; background: #fff; flex-shrink: 0;
}
.dw-btn:hover { background: var(--brand-orange); border-color: var(--brand-orange); color: #fff; }

/* ── Cartera por bandas — bloques ── */
.dw-bands { display: flex; gap: 0.7rem; width: 100%; }
.dw-band { flex: 1; text-align: center; padding: 0.9rem 0.4rem; border-radius: 12px; text-decoration: none; transition: transform .12s ease; }
.dw-band:hover { transform: translateY(-3px); }
.dw-band-l { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.dw-band-c { font-size: 0.68rem; opacity: 0.85; margin-top: 2px; }
.dw-bgA { background: #d9f2e4; color: #14663b; }
.dw-bgB { background: #e9f4d3; color: #4c6b14; }
.dw-bgC { background: #fdf3dc; color: #8a6100; }
.dw-bgD { background: #fbe4e1; color: #922b21; }
.dw-bgN { background: #eef1f5; color: #7a8a99; }

/* ── Cartera por bandas — barra apilada ── */
.dw-stack { display: flex; width: 100%; height: 42px; border-radius: 10px; overflow: hidden; }
.dw-stack > div {
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 0.7rem; font-weight: 700; min-width: 34px;
}
.dw-sA { background: #2e9e5b; } .dw-sB { background: #7fb541; }
.dw-sC { background: #e0a417; } .dw-sD { background: #d35446; }
.dw-sN { background: #c3ccd6; color: #5d6b79; }
.dw-legend { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.7rem; font-size: 0.68rem; color: #7a8a99; }
.dw-dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; }

/* ── Feed de alertas ── */
.dw-feed { display: flex; gap: 0.7rem; padding: 0.55rem 0; border-bottom: 1px solid #edf2f7; align-items: flex-start; }
.dw-feed:last-child { border-bottom: none; }
.dw-feed-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0; }
.dw-dot-r { background: #d35446; } .dw-dot-a { background: #e0a417; } .dw-dot-b { background: var(--brand-primary); }
.dw-feed-tx { font-size: 0.8rem; min-width: 0; }
.dw-feed-tx small { display: block; color: #a5b3c0; font-size: 0.68rem; }

/* ── Score por marco (barras) ── */
.dw-dom { margin-bottom: 0.8rem; font-size: 0.78rem; }
.dw-dom:last-child { margin-bottom: 0; }
.dw-dom-r { display: flex; justify-content: space-between; color: #5d7085; margin-bottom: 3px; }
.dw-dom-r b { color: var(--text-dark); font-variant-numeric: tabular-nums; }
.dw-bar { height: 6px; background: #edf2f7; border-radius: 3px; overflow: hidden; }
.dw-bar i { display: block; height: 100%; border-radius: 3px; }

/* ── Cola de trabajo ── */
.dw-table th { font-size: 0.65rem; text-transform: uppercase; letter-spacing: .05em; color: #a5b3c0; }
.dw-pill { font-size: 0.64rem; padding: 2px 8px; border-radius: 12px; font-weight: 700; }
.dw-pill-bad  { background: #fbe4e1; color: #c0392b; }
.dw-pill-warn { background: #fdf3dc; color: #c77700; }
.dw-pill-mut  { background: #eef1f5; color: #7a8a99; }
.dw-link { font-size: 0.76rem; color: var(--brand-primary); text-decoration: none; font-weight: 500; }
.dw-link:hover { color: var(--brand-orange); }

/* ── Próximos vencimientos ── */
.dw-venc { display: flex; gap: 0.8rem; padding: 0.55rem 0; border-bottom: 1px solid #edf2f7; align-items: center; text-decoration: none; color: inherit; }
.dw-venc:last-child { border-bottom: none; }
.dw-venc:hover .dw-venc-tx { color: var(--brand-primary); }
.dw-venc-fecha {
    width: 46px; height: 46px; border-radius: 10px; flex-shrink: 0;
    background: #eef1f5; color: #5d7085;
    display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.dw-venc-fecha b { font-size: 0.95rem; }
.dw-venc-fecha small { font-size: 0.55rem; }
.dw-venc-pronto { background: #fdf3dc; color: #c77700; }
.dw-venc-tx { font-size: 0.78rem; min-width: 0; }
.dw-venc-tx small { display: block; color: #a5b3c0; font-size: 0.66rem; }

/* ── Admin: Selector de ámbito Empresarial / Personal ── */
.scope-switcher {
    border: 1px solid #e0e3e8;
    border-radius: 12px;
    background: var(--card-bg);
}
.scope-switcher-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    padding: 1.5rem 1rem;
}
.scope-switcher-kicker {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #a5b3c0;
}
.scope-switch-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}
.scope-label {
    font-size: 1.15rem;
    font-weight: 700;
    color: #b4bfca;
    cursor: pointer;
    transition: color 0.15s;
    user-select: none;
}
.scope-label.active { color: var(--text-dark); }
.scope-label i { margin-right: 0.4rem; }

/* Switch grande — Empresarial (off) = azul · Personal (on) = naranja */
.scope-switch { padding: 0; margin: 0; min-height: 0; }
.scope-switch .form-check-input {
    width: 4.25rem;
    height: 2.1rem;
    margin: 0;
    cursor: pointer;
    /* Knob siempre blanco (también en el estado sin marcar) */
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
    background-color: var(--brand-primary, #1d71a4);
    border-color: var(--brand-primary, #1d71a4);
    box-shadow: none;
}
.scope-switch .form-check-input:checked {
    background-color: var(--brand-orange, #ef5e05);
    border-color: var(--brand-orange, #ef5e05);
}
.scope-switch .form-check-input:focus {
    box-shadow: 0 0 0 0.2rem rgba(29,113,164,0.15);
}

/* Paneles de ámbito */
.scope-hidden { display: none !important; }

.scope-empty {
    text-align: center;
    color: #a5b3c0;
    padding: 4rem 1rem;
}
.scope-empty i { font-size: 2.5rem; display: block; margin-bottom: 0.75rem; }

/* ── Admin: Tarjetas expandibles ── */
.admin-section-card {
    border: 1px solid #e0e3e8;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
}
.admin-section-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.admin-section-card.expanded { box-shadow: 0 4px 16px rgba(0,0,0,0.1); }

.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    background: var(--card-bg);
    cursor: pointer;
    user-select: none;
}
.admin-section-header:hover { background: #f9fafb; }
.admin-section-card.expanded .admin-section-header { background: #f0f4f9; }

.admin-section-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    color: var(--text-dark);
}
.admin-section-title i { font-size: 1.1rem; }

.admin-section-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: #7a8a99;
}
.admin-section-count .badge { font-size: 0.7rem; padding: 0.25rem 0.5rem; }

.admin-section-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    color: #7a8a99;
    transition: transform 0.2s;
}
.admin-section-card.expanded .admin-section-toggle { transform: rotate(180deg); }

.admin-section-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}
.admin-section-card.expanded .admin-section-content {
    max-height: 1200px;
    padding: 1.25rem;
    border-top: 1px solid #e0e3e8;
}

.admin-section-content form,
.admin-section-content .list-group,
.admin-section-content .table-responsive {
    margin-bottom: 1rem;
}

.admin-section-footer {
    display: none;
    padding-top: 0.5rem;
    border-top: 1px solid #e0e3e8;
    margin-top: 1rem;
}
.admin-section-card.expanded .admin-section-footer { display: block; }

/* Donut CSS (variante estilo prototipo C) */
.dw-donut-wrap { display: flex; align-items: center; gap: 1rem; }
.dw-donut {
    width: 84px; height: 84px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    /* el conic-gradient se define inline con el % real */
}
.dw-donut .dw-donut-in {
    width: 60px; height: 60px; border-radius: 50%; background: var(--card-bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    font-weight: 800; font-size: 0.95rem; line-height: 1.1; color: var(--text-dark);
}
.dw-donut .dw-donut-in small { font-size: 0.5rem; color: #a5b3c0; font-weight: 400; }
.dw-donut-leyenda { font-size: 0.72rem; color: #7a8a99; }
.dw-donut-leyenda b { display: block; font-size: 0.95rem; color: var(--text-dark); }

/* Mobile: mapa de calor compacto y bandas envueltas */
@media (max-width: 575.98px) {
    .dw-heat { grid-template-columns: 52px repeat(5, 1fr); }
    .dw-heat-cell span { display: none; }
    .dw-heat-cell::after { content: ''; }
    .dw-heat-cell { min-height: 30px; }
    .dw-bands { flex-wrap: wrap; }
    .dw-band { min-width: 30%; }
}

/* ═══════════ Campana de notificaciones (barra superior) ═══════════ */
.th-notif { display: inline-flex; }
/* Píldora de notificaciones (mismo aspecto que .th-badge de alertas) */
.th-notif-pill {
    display: inline-flex;
    align-items: center;
    font-family: inherit;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}
.th-notif-pill:hover { filter: brightness(0.97); }
/* Sin notificaciones: gris */
.th-notif-pill-empty {
    background: #eef1f5;
    color: #5d7085;
    border-color: #d5deea;
}

/* ═══════════ Ojo mostrar/ocultar contraseña (mantener pulsado) ═══════════ */
.pw-wrap { position: relative; }
.pw-wrap > input { padding-right: 2.5rem; }
.pw-eye {
    position: absolute;
    top: 0; right: 0;
    height: 100%;
    width: 2.5rem;
    padding: 0;
    border: 0;
    background: transparent;
    color: #6a7889;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}
.pw-eye:hover { color: var(--text-dark, #253a50); }
.pw-eye:active { color: var(--brand-primary, #1d71a4); }
/* Cuando el input va dentro de un input-group (p. ej. el login), el wrapper debe
   comportarse como un .form-control: ocupar el hueco y no envolverse en móvil. */
.input-group > .pw-wrap { flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group > .pw-wrap > .form-control {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

/* Disparador de ayuda "Cómo puntúa" (popover al hover) */
.info-puntua { cursor: help; font-weight: 600; white-space: nowrap; }
.info-puntua:hover { text-decoration: underline; }
.popover-puntua { max-width: 340px; }
.th-notif-menu {
    width: 360px;
    max-width: 92vw;
    border: 1px solid #e3e9f0;
    border-radius: 12px;
    box-shadow: 0 12px 34px rgba(20,50,80,.16);
    overflow: hidden;
}
.th-notif-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid #eef2f6;
}
.th-notif-list { max-height: 340px; overflow-y: auto; }
.th-notif-empty { text-align: center; color: #8a99a8; padding: 1.8rem 1rem; }
.th-notif-empty i { font-size: 1.6rem; display: block; margin-bottom: 0.3rem; }
.th-notif-item {
    display: flex; gap: 0.65rem; align-items: flex-start;
    padding: 0.65rem 0.9rem;
    text-decoration: none;
    color: var(--text-dark, #253a50);
    border-bottom: 1px solid #f2f5f8;
}
.th-notif-item:last-child { border-bottom: 0; }
.th-notif-item:hover { background: #f5f9fc; }
.th-notif-item.unread { background: #eef6fd; }
.th-notif-item.unread:hover { background: #e5f1fb; }
.th-notif-ic {
    flex: 0 0 auto;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
    background: #eaf1f8; color: var(--brand-primary, #1d71a4);
    font-size: 0.9rem;
}
.th-notif-item.unread .th-notif-ic { background: #dcebfa; }
.th-notif-body { display: flex; flex-direction: column; min-width: 0; }
.th-notif-title { font-weight: 600; font-size: 0.82rem; line-height: 1.2; }
.th-notif-msg { font-size: 0.76rem; color: #6a7889; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-notif-time { font-size: 0.7rem; color: #9aa7b4; margin-top: 2px; }
.th-notif-foot {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.55rem 0.9rem;
    border-top: 1px solid #eef2f6;
    background: #fafcfe;
}
.th-notif-foot .btn-link { text-decoration: none; font-weight: 600; }

/* Página de notificaciones */
.notif-page-list .notif-ic {
    flex: 0 0 auto;
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 9px;
    background: #eaf1f8; color: var(--brand-primary, #1d71a4);
}
.notif-page-list .notif-unread { background: #f4f9fe; }
.notif-page-list .notif-unread .notif-ic { background: #dcebfa; }
.min-w-0 { min-width: 0; }
