/* =========================================
   DESIGN TOKENS (Preparados para Modo Oscuro)
   ========================================= */

/* Light Theme (Por defecto) */
:root {
    color-scheme: light;
    
    /* Superficies y Fondos (Tintes azules más marcados para quitar exceso de blanco) */
    --bg-app: oklch(0.97 0.015 250);            /* Fondo general con claro tinte azul-pizarra */
    --bg-surface: oklch(1 0 0);                 /* Blanco puro para tarjetas (contrasta mejor ahora) */
    --bg-surface-hover: oklch(0.95 0.03 250);   /* Hover con azul más notorio */
    --bg-element: oklch(0.92 0.04 250);         /* Elementos activos o seleccionados */

    /* Textos y Tinta */
    --text-main: oklch(0.18 0.02 250);          /* Casi negro con subtono azul marino */
    --text-muted: oklch(0.45 0.03 250);         /* Gris-azulado medio */
    --text-inverse: oklch(1 0 0);               /* Blanco */

    /* Bordes y Separadores */
    --border-subtle: oklch(0.90 0.02 250);      /* Bordes con un toque azul marino claro */
    --border-strong: oklch(0.80 0.04 250);      /* Bordes fuertes azulados */

    /* Acciones Primarias (Azul SaaS Vibrante) */
    --action-primary-bg: oklch(0.55 0.15 250);  /* Azul corporativo fuerte */
    --action-primary-hover: oklch(0.45 0.15 250); /* Azul más oscuro al hacer hover */
    --color-primary: var(--action-primary-bg);
    --color-accent: var(--action-primary-bg);
    
    /* Estados */
    --status-success: oklch(0.60 0.15 150);
    --status-success-bg: oklch(0.96 0.05 150);
    --status-warning: oklch(0.65 0.15 70);
    --status-warning-bg: oklch(0.96 0.05 70);
    --status-error: oklch(0.55 0.18 25);
    --status-error-bg: oklch(0.96 0.05 25);
    --status-info: oklch(0.55 0.15 250);
    --status-info-bg: oklch(0.96 0.05 250);

    /* Métrica y Layout */
    --sidebar-width: 260px;
    --topbar-height: 56px; /* Más compacto, como Linear */
    
    /* Tipografía */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;

    /* Sombras extremadamente funcionales */
    --shadow-card: 0 1px 3px oklch(0.20 0.01 255 / 0.04);
    --shadow-dropdown: 0 4px 12px oklch(0.20 0.01 255 / 0.08), 0 0 0 1px var(--border-subtle);
    --ring-focus: 0 0 0 2px var(--bg-app), 0 0 0 4px oklch(0.55 0.15 250 / 0.4); /* Foco azul translúcido */
}

/* Dark Theme (True Black with Purple Undertones) */
[data-theme="dark"] {
    color-scheme: dark;
    --bg-app: oklch(0.12 0.01 290); /* Casi negro absoluto con microscópico tinte morado */
    --bg-surface: oklch(0.15 0.015 290); /* Negro ligeramente elevado para tarjetas */
    --bg-surface-hover: oklch(0.19 0.02 290);
    --bg-element: oklch(0.22 0.03 290);
    
    --text-main: oklch(0.96 0.01 290);
    --text-muted: oklch(0.65 0.02 290);
    --text-inverse: oklch(0.96 0.01 290);

    --border-subtle: oklch(0.20 0.02 290); /* Bordes morados muy sutiles */
    --border-strong: oklch(0.30 0.04 290);

    /* Estados modo nocturno (Fondo oscuro, texto brillante) */
    --status-success: oklch(0.80 0.15 150);
    --status-success-bg: oklch(0.20 0.05 150);
    --status-warning: oklch(0.85 0.15 70);
    --status-warning-bg: oklch(0.20 0.05 70);
    --status-error: oklch(0.75 0.18 25);
    --status-error-bg: oklch(0.20 0.08 25);
    --status-info: oklch(0.80 0.15 260);
    --status-info-bg: oklch(0.20 0.05 260);

    --action-primary-bg: oklch(0.60 0.15 260); /* Indigo/Blue to complement the purple */
    --action-primary-hover: oklch(0.65 0.15 260);
    --color-primary: var(--action-primary-bg);
    --color-accent: var(--action-primary-bg);
    
    --shadow-card: none;
    --shadow-dropdown: 0 4px 12px oklch(0 0 0 / 0.3), 0 0 0 1px var(--border-subtle);
}

/* Invierte el logotipo a blanco cuando está en modo oscuro */
[data-theme="dark"] img[alt="Sistecsoft Logo"] {
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

[data-theme="dark"] .theme-logo {
    filter: invert(1) brightness(2) contrast(1.2);
}

/* =========================================
   GLOBAL RESET & BASE
   ========================================= */

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    background-color: var(--bg-app);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   SCAFFOLDING (App Shell)
   ========================================= */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    color: var(--text-main);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background-color: var(--bg-app);
}

.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.75rem;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    user-select: none;
}

.topbar-brand-name {
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.015em;
}

.topbar-brand-separator {
    color: var(--border-strong);
    font-size: 0.8125rem;
    font-weight: 300;
}

.topbar-brand-context {
    font-weight: 400;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    transition: all 0.15s ease;
}

.topbar-icon-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
    border-color: var(--border-strong);
}

.topbar-divider {
    width: 1px;
    height: 18px;
    background-color: var(--border-subtle);
    margin: 0 0.35rem;
}

.topbar-tenant-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background-color: var(--bg-app);
    border: 1px solid var(--border-subtle);
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}

/* User Menu Dropdown */
.user-menu-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 2px 8px 2px 3px;
    border-radius: 9999px;
    background: transparent;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.user-menu-trigger:hover,
.user-menu-trigger[aria-expanded="true"] {
    background-color: var(--bg-surface-hover);
    border-color: var(--border-strong);
}

.user-menu-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--bg-element);
    color: var(--text-main);
    font-size: 0.6875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.user-menu-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-main);
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-chevron {
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

.user-menu-trigger[aria-expanded="true"] .user-menu-chevron {
    transform: rotate(180deg);
}

.user-menu-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 230px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    box-shadow: var(--shadow-dropdown);
    z-index: 1050;
    padding: 0.35rem;
    display: flex;
    flex-direction: column;
    animation: userMenuFadeIn 0.12s ease-out;
}

@keyframes userMenuFadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.user-menu-header {
    padding: 0.65rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 0.15rem;
}

.user-menu-header-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--bg-element);
    color: var(--text-main);
    font-size: 0.75rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.user-menu-header-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-menu-header-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-header-role {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 1px;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}

.user-menu-item:hover {
    background-color: var(--bg-surface-hover);
}

.user-menu-logout {
    color: var(--text-muted);
}

.user-menu-logout:hover {
    background-color: oklch(0.65 0.20 25 / 0.10);
    color: var(--status-error);
}

.page-content {
    padding: 2.5rem;
    max-width: 1200px; /* Ancho contenido para lectura y escaneo */
    margin: 0 auto;
    width: 100%;
}

/* =========================================
   TIPOGRAFÍA Y JERARQUÍA
   ========================================= */

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: -0.015em;
    margin-bottom: 0.25rem;
}

.page-subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* =========================================
   COMPONENTES FUNCIONALES
   ========================================= */

/* Tarjetas (Cards) */
.card, .premium-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px; /* Bordes menos redondeados, más profesionales */
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.card-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.card-value {
    font-size: 1.75rem;
    font-weight: 500;
    color: var(--text-main);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Tablas de Datos (Altamente legibles) */
.table-container, .table-responsive {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    overflow-x: auto;
}

.data-table, .premium-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

.data-table th, .premium-table th {
    background-color: var(--bg-surface);
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
}

.data-table td, .premium-table td {
    padding: 1rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

/* Efecto hover muy discreto */
.data-table tr:hover td, .premium-table tr.table-row-hover:hover td {
    background-color: var(--bg-surface-hover);
}

.data-table tr:last-child td, .premium-table tr:last-child td {
    border-bottom: none;
}

/* Badges (Insignias para estados) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 4px; /* Cuadradas redondeadas, no píldoras */
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-active {
    background-color: var(--status-success-bg);
    color: var(--status-success);
}

.badge-inactive {
    background-color: var(--status-warning-bg);
    color: var(--status-warning);
}

.badge-error {
    background-color: var(--status-error-bg);
    color: var(--status-error);
}

/* Botones Pragmáticos */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.4rem 0.875rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background-color 0.1s ease, border-color 0.1s ease;
    text-decoration: none;
    font-family: inherit;
    line-height: 1.25rem;
}

.btn-primary {
    background-color: var(--action-primary-bg);
    color: var(--text-inverse);
    /* Inset shadow sutil para dar volumen sin drop-shadow */
    box-shadow: inset 0 1px 0 oklch(1 0 0 / 0.15); 
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--action-primary-hover);
}

.btn-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-strong);
    color: var(--text-main);
    box-shadow: 0 1px 2px oklch(0 0 0 / 0.02);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-surface-hover);
}

.btn-danger {
    background-color: var(--bg-surface);
    color: var(--status-error);
    border-color: var(--border-strong);
}

.btn-danger:hover:not(:disabled) {
    background-color: var(--status-error-bg);
    border-color: var(--status-error);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn:focus-visible {
    outline: none;
    box-shadow: var(--ring-focus);
}

/* Formularios directos */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    margin-bottom: 0.35rem;
}

.form-control, .form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-main);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    transition: border-color 0.1s ease, box-shadow 0.1s ease;
    font-family: inherit;
}

.form-control:focus, .form-input:focus {
    border-color: var(--action-primary-bg);
    outline: none;
    box-shadow: 0 0 0 1px var(--action-primary-bg); /* Foco limpio, no resplandor */
}

select.form-control option, select.form-input option {
    background-color: var(--bg-surface);
    color: var(--text-main);
}

/* Utilidades */
.header-section, .flex-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.font-mono {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-muted);
}

a {
    color: var(--text-main);
    text-decoration: underline;
    text-underline-offset: 2px;
}
a:hover {
    color: var(--action-primary-hover);
}
/* Botón / Enlace 'Volver a...' moderno y táctil (SaaS Linear / Stripe style) */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    text-decoration: none;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
    margin-bottom: 0.75rem;
    user-select: none;
    cursor: pointer;
    width: fit-content;
}

.back-link svg,
.back-link .back-icon {
    flex-shrink: 0;
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.back-link:hover {
    color: var(--text-main);
    background-color: var(--bg-surface-hover);
    border-color: var(--border-strong);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
    text-decoration: none;
}

.back-link:hover svg,
.back-link:hover .back-icon {
    transform: translateX(-3px);
}

.back-link:active {
    transform: scale(0.97);
}

.back-link:focus-visible {
    outline: none;
    box-shadow: var(--ring-focus);
}

/* Skeleton functional */
.skeleton-loader {
    background-color: var(--bg-element);
    border-radius: 4px;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Errores del sistema */
#blazor-error-ui {
    background: var(--status-error-bg);
    color: var(--status-error);
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.75rem 1.5rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 0.875rem;
    border-top: 1px solid var(--status-error);
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
}

/* =========================================
   CONFIG TABS — Página de Configuración
   ========================================= */

.config-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border-subtle);
    margin-bottom: 1.75rem;
    padding-bottom: 0;
}

.config-tab {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
}

.config-tab:hover {
    color: var(--text-main);
    background: var(--bg-surface-hover);
}

.config-tab.active {
    color: var(--action-primary-bg);
    border-bottom-color: var(--action-primary-bg);
    background: transparent;
    font-weight: 600;
}

.config-tab-panel {
    display: none;
}

.config-tab-panel.active {
    display: block;
}

.config-section-title {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin: 0 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.config-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
    line-height: 1.4;
}

/* =========================================
   TOOLTIPS — Minimalist Floating Helpers
   ========================================= */

.has-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    color: var(--text-muted);
    vertical-align: middle;
    margin-left: 0.35rem;
    opacity: 0.65;
    transition: opacity 0.15s ease, color 0.15s ease;
}

.has-tooltip:hover,
.has-tooltip:focus-visible {
    opacity: 1;
    color: var(--action-primary-bg, #3b82f6);
}

.has-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 7px);
    left: 50%;
    transform: translateX(-50%) translateY(3px);
    background: #0f172a;
    color: #f8fafc;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 0.45rem 0.75rem;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 10px 20px -5px rgba(0, 0, 0, 0.35);
    white-space: normal;
    width: max-content;
    max-width: 280px;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
    z-index: 1000;
}

.has-tooltip:hover::after,
.has-tooltip:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

.has-tooltip::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 1px);
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px 5px 0 5px;
    border-style: solid;
    border-color: #0f172a transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 1001;
    pointer-events: none;
}

.has-tooltip:hover::before,
.has-tooltip:focus-visible::before {
    opacity: 1;
    visibility: visible;
}

/* =========================================
   BADGES — WARM-UP & MADUREZ
   ========================================= */

.badge-warmup {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.22rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    line-height: 1.2;
    border: 1px solid transparent;
    cursor: default;
    user-select: none;
}

.badge-warmup-compact {
    padding: 0.15rem 0.45rem;
    font-size: 0.6875rem;
    gap: 0.25rem;
}

.badge-warmup-maduro {
    background-color: var(--status-success-bg);
    color: var(--status-success);
    border-color: color-mix(in srgb, var(--status-success) 25%, transparent);
}

.badge-warmup-fase2 {
    background-color: var(--status-warning-bg);
    color: var(--status-warning);
    border-color: color-mix(in srgb, var(--status-warning) 25%, transparent);
}

.badge-warmup-fase1 {
    background-color: var(--status-error-bg);
    color: var(--status-error);
    border-color: color-mix(in srgb, var(--status-error) 25%, transparent);
}

/* =========================================
   BADGES — ESTADO DE CANAL
   ========================================= */

.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.22rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    border: 1px solid transparent;
    user-select: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.badge-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Activo / Conectado: Verde */
.badge-status-activo {
    background-color: var(--status-success-bg);
    color: var(--status-success);
    border-color: color-mix(in srgb, var(--status-success) 25%, transparent);
}
.badge-status-activo .badge-status-dot {
    background-color: var(--status-success);
    box-shadow: 0 0 6px color-mix(in srgb, var(--status-success) 50%, transparent);
}

/* Inactivo: Amarillo / Ámbar */
.badge-status-inactivo {
    background-color: var(--status-warning-bg);
    color: var(--status-warning);
    border-color: color-mix(in srgb, var(--status-warning) 25%, transparent);
}
.badge-status-inactivo .badge-status-dot {
    background-color: var(--status-warning);
}

/* Desconectado: Slate / Neutro */
.badge-status-desconectado {
    background-color: var(--bg-element);
    color: var(--text-muted);
    border-color: var(--border-subtle);
}
.badge-status-desconectado .badge-status-dot {
    background-color: var(--text-muted);
    opacity: 0.7;
}

/* Error: Rojo */
.badge-status-error {
    background-color: var(--status-error-bg);
    color: var(--status-error);
    border-color: color-mix(in srgb, var(--status-error) 25%, transparent);
}
.badge-status-error .badge-status-dot {
    background-color: var(--status-error);
    box-shadow: 0 0 6px color-mix(in srgb, var(--status-error) 50%, transparent);
}

/* Anulado: Fondo neutro, texto tachado */
.badge-status-anulado {
    background-color: var(--bg-app);
    color: var(--text-muted);
    border-color: var(--border-subtle);
    border-style: dashed;
    text-decoration: line-through;
    opacity: 0.8;
}
.badge-status-anulado .badge-status-dot {
    background-color: var(--text-muted);
    opacity: 0.4;
}

/* Default / Desconocido */
.badge-status-default {
    background-color: var(--bg-element);
    color: var(--text-main);
    border-color: var(--border-subtle);
}
.badge-status-default .badge-status-dot {
    background-color: var(--text-muted);
}

/* =========================================
   SISTEMA DE NOTIFICACIONES Y ALERTAS
   ========================================= */

.notification-bell-container {
    position: relative;
    display: inline-block;
}

.notification-bell-btn {
    padding: 0;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: transparent;
    border: 1px solid var(--border-subtle);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.notification-bell-btn:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
    border-color: var(--border-strong);
}

.notification-badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background-color: var(--status-error);
    color: var(--text-inverse);
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    box-shadow: 0 0 0 2px var(--bg-surface);
    animation: notificationPulse 2s infinite;
}

@keyframes notificationPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.notification-popover {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 480px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    box-shadow: var(--shadow-dropdown);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: notificationDropdownIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes notificationDropdownIn {
    from {
        opacity: 0;
        transform: translateY(-6px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.notification-popover-header {
    padding: 0.875rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
}

.notification-popover-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification-popover-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notification-popover-body {
    overflow-y: auto;
    max-height: 380px;
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    background-color: var(--bg-surface);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.notification-item:hover {
    background-color: var(--bg-surface-hover);
}

.notification-item.unread {
    background-color: color-mix(in srgb, var(--bg-element) 40%, var(--bg-surface));
}

.notification-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.notification-item-icon.critica {
    background-color: var(--status-error-bg);
    color: var(--status-error);
}

.notification-item-icon.advertencia {
    background-color: var(--status-warning-bg);
    color: var(--status-warning);
}

.notification-item-icon.informativa {
    background-color: var(--status-info-bg);
    color: var(--status-info);
}

.notification-item-content {
    flex: 1;
    min-width: 0;
}

.notification-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.notification-item-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.notification-item-time {
    font-size: 0.6875rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.notification-item-msg {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-empty {
    padding: 2.5rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.notification-empty-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--bg-element);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

/* Floating Toasts */
.notification-toasts-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 400px;
    width: calc(100vw - 3rem);
    pointer-events: none;
}

.notification-toast {
    pointer-events: auto;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2), 0 0 0 1px var(--border-subtle);
    padding: 0.875rem 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    animation: toastSlideIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.notification-toast.critica {
    border-left: 3px solid var(--status-error);
}

.notification-toast.advertencia {
    border-left: 3px solid var(--status-warning);
}

.notification-toast.informativa {
    border-left: 3px solid var(--status-info);
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    .notification-badge-count,
    .notification-popover,
    .notification-toast {
        animation: none !important;
    }
}

.empresa-id-mobile,
.canal-id-mobile {
    display: none;
}