/* ============================================================================
   ISP MANAGER SaaS · Sistema de diseño
   ----------------------------------------------------------------------------
   Los colores de marca vienen de las variables CSS inyectadas por el Theme
   Engine (--primary, --secondary, --accent, --sidebar, --gradient...).
   Cada empresa puede cambiarlos desde Configuración → Apariencia.
   ============================================================================ */

/* ---------- Variables por defecto (el Theme las sobrescribe) ---------- */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: rgba(37, 99, 235, .12);
    --secondary: #7c3aed;
    --accent: #06b6d4;
    --sidebar: #0f172a;
    --sidebar-text: #f8fafc;
    --sidebar-muted: rgba(248, 250, 252, .65);
    --sidebar-hover: rgba(248, 250, 252, .08);
    --gradient: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    --bg: #f1f5f9;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #0284c7;
    --radius: 14px;
    --radius-sm: 9px;
    --shadow: 0 6px 24px -8px rgba(15, 23, 42, .12);
    --shadow-lg: 0 24px 60px -20px rgba(15, 23, 42, .28);
    --sidebar-width: 262px;
    --sidebar-collapsed: 78px;
    --topbar-height: 64px;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4, h5 { color: var(--text); font-weight: 700; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.fw-semibold { font-weight: 600; }
.small { font-size: .84em; }

/* ---------- Layout de la app ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--sidebar);
    color: var(--sidebar-text);
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    transition: width .25s, min-width .25s;
    z-index: 1030;
    overflow-x: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); min-width: var(--sidebar-collapsed); }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--sidebar-hover);
    white-space: nowrap;
    height: var(--topbar-height);
}
.sidebar-brand .logo-box {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: var(--gradient);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 1.15rem;
    flex-shrink: 0;
    box-shadow: 0 6px 14px -4px rgba(0,0,0,.35);
}
.sidebar-brand .brand-name { font-weight: 800; font-size: 1.02rem; letter-spacing: -.2px; }
.sidebar-brand .brand-sub { font-size: .72rem; color: var(--sidebar-muted); }

/* Logo propio de la empresa: fondo claro y ajuste sin deformar. */
.sidebar-brand .logo-box-img { background: #fff; padding: 4px; box-shadow: 0 4px 12px -4px rgba(0,0,0,.35); }
.sidebar-brand .logo-box-img img { width: 100%; height: 100%; object-fit: contain; border-radius: 7px; display: block; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-hover); border-radius: 3px; }

.nav-section-title {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--sidebar-muted);
    padding: 14px 14px 6px;
    white-space: nowrap;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    margin: 2px 0;
    border-radius: 10px;
    color: var(--sidebar-muted);
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s, color .15s;
}
.nav-item i { font-size: 1.12rem; width: 22px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--sidebar-text); }
.nav-item.active {
    background: var(--gradient);
    color: #fff;
    box-shadow: 0 8px 18px -8px rgba(0,0,0,.45);
}
.nav-item .nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: .68rem;
    border-radius: 20px;
    padding: 1px 8px;
    font-weight: 700;
}

/* Módulos que existen pero NO están en el plan de la empresa (con candado) */
.nav-item-locked {
    color: var(--sidebar-muted);
    opacity: .55;
}
.nav-item-locked:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text);
    opacity: .85;
}
.nav-item-locked .nav-lock {
    margin-left: auto;
    font-size: .78rem !important;
    width: auto !important;
}

/* Botón del menú (para acciones POST como "Volver al panel SaaS") */
button.nav-item,
.nav-item-action {
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: inherit;
}
.nav-item-action {
    color: var(--accent) !important;
    font-weight: 600;
}
.nav-item-action:hover {
    background: var(--sidebar-hover);
    color: #fff !important;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--sidebar-hover);
    white-space: nowrap;
    font-size: .78rem;
    color: var(--sidebar-muted);
}

/* Sidebar colapsado: esconde textos */
.sidebar.collapsed .brand-name, .sidebar.collapsed .brand-sub,
.sidebar.collapsed .nav-text, .sidebar.collapsed .nav-badge,
.sidebar.collapsed .nav-section-title span, .sidebar.collapsed .sidebar-footer {
    display: none;
}

/* ---------- Contenido principal ---------- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 22px;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.topbar .btn-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: background .15s;
}
.topbar .btn-icon:hover { background: var(--bg); }
.topbar .page-title { font-size: 1.08rem; font-weight: 700; }
.topbar .spacer { flex: 1; }

.user-chip { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: var(--gradient);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9rem;
}

.company-switch { position: relative; }
.company-switch .dropdown-menu {
    min-width: 300px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 8px;
}

/* ---------- Contenido ---------- */
.content { padding: 26px; max-width: 1500px; margin: 0 auto; width: 100%; }

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}
.page-header h1 { margin: 0 0 4px; font-size: 1.5rem; }
.page-header .subtitle { color: var(--text-muted); margin: 0; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.breadcrumb-sm { font-size: .8rem; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb-sm a { color: var(--text-muted); }
.breadcrumb-sm a:hover { color: var(--primary); }
.breadcrumb-sm .sep { margin: 0 6px; opacity: .5; }

/* ---------- Tarjetas ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.card-header h5, .card-header h6 { margin: 0; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 50%, var(--surface)); }

/* ---------- Tarjetas de métricas ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    position: relative;
    overflow: hidden;
}
.stat-card .stat-icon {
    width: 46px; height: 46px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 12px;
    color: #fff;
}
.stat-card .stat-value { font-size: 1.55rem; font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { color: var(--text-muted); font-size: .82rem; }
.stat-card .stat-trend { position: absolute; top: 18px; right: 18px; font-size: .78rem; }

/* Tarjeta que lleva a su consulta (dashboard) */
a.stat-link {
    display: block;
    color: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
a.stat-link:hover,
a.stat-link:focus-visible {
    transform: translateY(-2px);
    border-color: var(--primary);
    box-shadow: 0 12px 26px -12px rgba(15, 23, 42, .35);
    text-decoration: none;
    color: inherit;
}
a.stat-link:active { transform: translateY(0); }
a.stat-link:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.stat-card .stat-go {
    position: absolute;
    top: 14px;
    right: 12px;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    opacity: .55;
    transition: opacity .12s ease, transform .12s ease;
}
a.stat-link:hover .stat-go { opacity: 1; transform: translateX(2px); }

/* Fila de tabla que navega al detalle (dashboard) */
tr.row-link { cursor: pointer; }
tr.row-link:hover { background: color-mix(in srgb, var(--primary) 6%, transparent); }

/* ---------- Indicador de datos en vivo (auto-refresh) ---------- */
.live-pill {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1080;
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    border-radius: 999px;
    padding: 6px 13px;
    font-size: .78rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    transition: opacity .15s ease, border-color .15s ease;
}
.live-pill:hover { border-color: var(--primary); }
.live-pill .live-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--success, #16a34a);
    box-shadow: 0 0 0 0 rgba(22, 163, 74, .5);
    animation: live-pulse 2s infinite;
}
.live-pill.is-loading .live-dot { background: var(--primary); animation: none; }
.live-pill.is-stopped { color: var(--danger, #dc2626); border-color: var(--danger, #dc2626); }
.live-pill.is-stopped .live-dot { background: var(--danger, #dc2626); animation: none; }

@keyframes live-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, .45); }
    70%  { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
    100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

@media (max-width: 575px) {
    .live-pill { right: 10px; bottom: 76px; padding: 5px 11px; }
}

/* ---------- Tablas ---------- */
.table-responsive { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; margin: 0; }
table.table th {
    text-align: left;
    padding: 11px 14px;
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--text-muted);
    background: color-mix(in srgb, var(--bg) 55%, var(--surface));
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, var(--surface)); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px;
    border-radius: 30px;
    font-size: .74rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: #16a34a; color: #ffffff; }
.badge-warning { background: #d97706; color: #ffffff; }
.badge-danger  { background: #dc2626; color: #ffffff; }
.badge-info    { background: #0284c7; color: #ffffff; }
.badge-secondary { background: #64748b; color: #ffffff; }
.badge-dark    { background: #0f172a; color: #ffffff; }

/* Botón flotante de ayuda */
.help-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 1050;
    width: 48px; height: 48px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary, #2563eb); color: #fff;
    font-size: 1.3rem; text-decoration: none;
    box-shadow: 0 8px 20px rgba(0,0,0,.25);
    transition: transform .15s ease, background .15s ease;
}
.help-fab:hover { transform: translateY(-2px); color: #fff; }

/* ---------- Botones ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 600;
    font-size: .9rem;
    cursor: pointer;
    transition: all .15s;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-gradient { background: var(--gradient); color: #fff; box-shadow: 0 8px 20px -8px var(--secondary); }
.btn-gradient:hover { color: #fff; filter: brightness(1.06); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:hover { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { color: #fff; filter: brightness(.92); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { color: #fff; filter: brightness(.92); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .82rem; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 1rem; border-radius: 13px; }
.btn-icon-sm { width: 34px; height: 34px; padding: 0; border-radius: 9px; }

/* ---------- Formularios ---------- */
.form-label { display: block; font-weight: 600; font-size: .84rem; margin-bottom: 6px; }
.form-label .req { color: var(--danger); }
.form-control, .form-select {
    width: 100%;
    padding: 10px 13px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font-size: .92rem;
    transition: border-color .15s, box-shadow .15s;
}
.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
.form-control:disabled, .form-select:disabled { background: var(--bg); color: var(--text-muted); }
textarea.form-control { min-height: 90px; resize: vertical; }
.form-check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.form-check input { width: 17px; height: 17px; accent-color: var(--primary); }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; gap: 14px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; } }
.input-group { display: flex; gap: 8px; align-items: center; }
.input-group .form-control { flex: 1; }
.form-hint { font-size: .78rem; color: var(--text-muted); margin-top: 4px; }
/* ---------- Ayudas ocultas (botón del ojo en la barra superior · 1.7.41) ----------
   Esconde SOLO los renglones de explicación de los campos. Nunca se ocultan:
     · los números en vivo  → .form-hint-vivo (los calcula el JavaScript)
     · los avisos de color  → text-warning / text-danger / text-success
   Esto no cambia ninguna lógica: es solo texto que se deja de mostrar. */
body.sin-ayudas .form-hint:not(.form-hint-vivo):not(.text-warning):not(.text-danger):not(.text-success) { display: none !important; }
.invalid-feedback { color: var(--danger); font-size: .8rem; margin-top: 4px; display: block; }
.form-control.is-invalid { border-color: var(--danger); }

/* ---------- Alertas flash ---------- */
.flash-stack { position: fixed; top: 76px; right: 22px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.flash {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--primary);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 13px 16px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    animation: flashIn .3s ease;
}
.flash-success { border-left-color: var(--success); }
.flash-error { border-left-color: var(--danger); }
.flash-warning { border-left-color: var(--warning); }
.flash .flash-close { margin-left: auto; cursor: pointer; opacity: .5; border: 0; background: none; font-size: 1rem; }
@keyframes flashIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Utilidades ---------- */
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 10px; } .mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 10px; } .mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }
.ms-auto { margin-left: auto; }
.w-100 { width: 100%; }
.text-end { text-align: right; }
.text-center { text-align: center; }
.text-uppercase { text-transform: uppercase; letter-spacing: .6px; }
.mono { font-family: 'JetBrains Mono', Consolas, monospace; }
.nowrap { white-space: nowrap; }
.divider { border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- Paginación ---------- */
.pagination { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 34px; height: 34px; padding: 0 8px;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: .86rem;
}
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.pagination .disabled { opacity: .45; pointer-events: none; }

/* ---------- Filtros ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-bar .form-control, .filter-bar .form-select { width: auto; min-width: 150px; }
.search-box { position: relative; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-box .form-control { padding-left: 34px; }

/* ---------- Dropdown ---------- */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0; top: calc(100% + 6px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    z-index: 1100;
    overflow: hidden;
}
.dropdown-menu.show { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 10px 16px;
    border: 0; background: none;
    color: var(--text);
    font-size: .88rem;
    text-align: left;
    cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--bg); }
.dropdown-menu .dropdown-header {
    padding: 10px 16px 6px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}
.dropdown-menu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---------- Campana de notificaciones ---------- */
.bell-wrap { position: relative; }
.bell-btn { position: relative; }
.bell-badge {
    position: absolute; top: -6px; right: -6px;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 10px;
    background: #dc2626; color: #fff;
    font-size: .68rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.bell-menu { width: 360px; max-width: calc(100vw - 24px); }
.bell-list { max-height: 420px; overflow-y: auto; }
.bell-item {
    display: flex; gap: 12px; align-items: flex-start;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    text-decoration: none;
    transition: background .12s;
}
.bell-item:hover { background: var(--bg); }
.bell-item.is-new { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.bell-icon {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
}
.bell-icon.danger  { background: #fee2e2; color: #dc2626; }
.bell-icon.warning { background: #fef3c7; color: #d97706; }
.bell-icon.info    { background: #e0f2fe; color: #0284c7; }
.bell-icon.success { background: #dcfce7; color: #16a34a; }
.bell-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.bell-title { font-weight: 700; font-size: .86rem; }
.bell-text { font-size: .8rem; color: var(--text-muted); line-height: 1.35; }
.bell-time { font-size: .72rem; color: var(--text-muted); opacity: .75; }
.bell-empty { padding: 24px 16px; text-align: center; color: var(--text-muted); font-size: .88rem; }
.bell-footer { border-top: 1px solid var(--border); }
.bell-mark {
    width: 100%; padding: 10px 16px; border: 0; background: none;
    color: var(--primary); font-size: .85rem; font-weight: 600;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    cursor: pointer;
}
.bell-mark:hover { background: var(--bg); }
@media (max-width: 576px) { .bell-menu { width: calc(100vw - 24px); } }

/* ---------- Testigo de salud del cron (superadmin) ---------- */
.cron-dot { position: relative; }
.cron-dot::after {
    content: '';
    position: absolute; top: 6px; right: 6px;
    width: 9px; height: 9px; border-radius: 50%;
    border: 2px solid var(--surface);
}
.cron-dot-ok::after      { background: #16a34a; }
.cron-dot-warning::after { background: #d97706; }
.cron-dot-danger::after  { background: #dc2626; animation: cronPulseDanger 1.4s infinite; }
@keyframes cronPulseDanger { 0% { box-shadow: 0 0 0 0 rgba(220,38,38,.6); } 70% { box-shadow: 0 0 0 6px rgba(220,38,38,0); } 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); } }

/* ---------- Timeline (panel de eventos) ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 6px 0 14px; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -23px; top: 12px;
    width: 11px; height: 11px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--surface);
    box-shadow: 0 0 0 1px var(--border);
}
.timeline-item.t-success::before { background: var(--success); }
.timeline-item.t-danger::before { background: var(--danger); }
.timeline-item.t-warning::before { background: var(--warning); }
.timeline-item .t-time { font-size: .74rem; color: var(--text-muted); font-weight: 600; }
.timeline-item .t-body { margin-top: 2px; }

/* ---------- Login / Auth ---------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    background-size: cover;
    padding: 24px;
    position: relative;
}
.auth-wrap::before {
    content: '';
    position: absolute; inset: 0;
    background:
        radial-gradient(circle at 20% 15%, rgba(255,255,255,.14), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(255,255,255,.1), transparent 45%);
    pointer-events: none;
}
.auth-card {
    position: relative;
    background: rgba(255, 255, 255, .97);
    border-radius: 22px;
    box-shadow: 0 50px 110px -30px rgba(0, 0, 0, .5);
    width: 100%;
    max-width: 440px;
    padding: 38px 36px;
    animation: flashIn .4s ease;
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .logo-box {
    width: 62px; height: 62px;
    border-radius: 17px;
    background: var(--gradient);
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
    box-shadow: 0 14px 30px -10px var(--secondary);
    margin-bottom: 14px;
}
.auth-brand h1 { margin: 0 0 4px; font-size: 1.4rem; }
.auth-brand p { color: var(--text-muted); margin: 0; font-size: .9rem; }

/* ---------- Botón Google ---------- */
.btn-google {
    background: #ffffff;
    color: #1f2937;
    border: 1.5px solid #d1d5db;
    font-weight: 600;
    transition: all .15s;
}
.btn-google:hover {
    background: #f9fafb;
    color: #111827;
    border-color: #9ca3af;
    box-shadow: 0 4px 12px -4px rgba(0,0,0,.15);
}

/* ---------- Separador "o continúa con" ---------- */
.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 16px;
    color: var(--text-muted);
    font-size: .8rem;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ---------- Modo lectura (suscripción vencida) ---------- */
.readonly-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    background: rgba(217, 119, 6, .12);
    border: 1px solid rgba(217, 119, 6, .35);
    border-left: 5px solid var(--warning);
    border-radius: 12px;
    padding: 13px 18px;
    margin-bottom: 20px;
    color: var(--text);
}
.readonly-banner > i { font-size: 1.5rem; color: var(--warning); }

/* Los botones de guardado se atenúan (el servidor además los rechaza) */
.readonly-mode form:not(.allow-readonly) button[type="submit"]:not(.allow-readonly),
.readonly-mode .table-actions .btn,
.readonly-mode .page-actions .btn:not(.allow-readonly) {
    opacity: .45;
    filter: grayscale(.4);
}

/* ---------- Rejilla responsive de 2 columnas ---------- */
.grid-2 {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 20px;
    align-items: start;
}

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .sidebar { position: fixed; left: 0; transform: translateX(-100%); }
    .sidebar.mobile-open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,.4); }
    .content { padding: 18px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
    /* Las rejillas con grid-template-columns en línea colapsan a 1 columna */
    [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
}
@media (max-width: 720px) {
    .page-header { gap: 10px; }
    .page-header h1 { font-size: 1.25rem; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; justify-content: center; }
    .filter-bar, .filter-bar .search-box { width: 100%; }
    .filter-bar .form-control, .filter-bar .form-select {
        width: 100% !important;
        min-width: 100% !important;
    }
    .topbar { padding: 0 12px; gap: 8px; }
    .topbar .page-title { font-size: .95rem; }
    .card-header, .card-body, .card-footer { padding-left: 14px; padding-right: 14px; }
    .content { padding: 14px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-card .stat-value { font-size: 1.25rem; }
    .auth-card { padding: 28px 20px; border-radius: 18px; }
    .auth-wrap { padding: 14px; }
    .table-actions { gap: 4px; }
    .btn-icon-sm { width: 30px; height: 30px; }
    .pagination a, .pagination span { min-width: 30px; height: 30px; }
    .dropdown-menu { min-width: 200px; }
}
@media (max-width: 420px) {
    .stat-grid { grid-template-columns: 1fr; }
    .auth-brand .logo-box { width: 52px; height: 52px; font-size: 1.5rem; }
    .auth-brand h1 { font-size: 1.2rem; }
    .user-chip > div { display: none; }
}

/* ---------- Banner PWA (instalar / notificaciones) ---------- */
.pwa-banner {
    position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
    z-index: 1040;
    display: flex; align-items: center; gap: 12px;
    max-width: 560px; width: calc(100vw - 28px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 50px -18px rgba(0,0,0,.4);
    padding: 12px 14px;
}
.pwa-icon {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 11px;
    background: var(--gradient);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.pwa-text { flex: 1; min-width: 0; }
.pwa-text strong { display: block; font-size: .9rem; }
.pwa-text .small { color: var(--text-muted); }
.pwa-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.pwa-close { width: 30px; height: 30px; flex: 0 0 30px; }
@media (max-width: 560px) {
    .pwa-banner { flex-wrap: wrap; }
    .pwa-text { order: 2; flex-basis: 100%; }
}
