/* ============================================================
   TURNERO WEB - Municipio de Ambato
   Main CSS - Modern Design System
   ============================================================ */

/* --- CSS Custom Properties --- */
:root {
    --primary: #1e3a5f;
    --primary-light: #2a5298;
    --primary-dark: #0f2240;
    --secondary: #2ecc71;
    --secondary-dark: #27ae60;
    --accent: #f39c12;
    --accent-dark: #e67e22;
    --danger: #e74c3c;
    --info: #3498db;
    --warning: #f1c40f;

    --bg-sidebar: #0f2240;
    --bg-sidebar-hover: rgba(255,255,255,0.08);
    --bg-sidebar-active: rgba(255,255,255,0.15);
    --bg-card: #ffffff;
    --bg-page: #f0f4f8;
    /* Superficies secundarias: usadas donde antes había un color fijo
       (white, #f8fafc, #f0f4f8...) para fondos de tarjeta/hover/input —
       centralizarlas aquí es lo que permite que el modo oscuro las invierta
       sin tener que tocar cada regla que las usaba. */
    --bg-surface: #ffffff;
    --bg-surface-alt: #f8fafc;
    --bg-surface-hover: #f0f4f8;
    --border-color: #e2e8f0;
    --border-color-soft: #eef2f7;

    --text-sidebar: rgba(255,255,255,0.85);
    --text-sidebar-muted: rgba(255,255,255,0.45);
    --text-primary: #1a2332;
    --text-muted: #6b7a8d;

    /* Texto de los badges de estado (.estado-*, .prioridad-*): colores
       oscuros con buen contraste sobre su fondo rgba(...,0.1-0.15) claro.
       En modo oscuro ese mismo fondo rgba cae sobre una base oscura y esos
       tonos pierden casi todo el contraste — se aclaran en el bloque
       [data-theme=dark] de abajo. */
    --badge-warning-text: #b7881a;
    --badge-info-text: #2471a3;
    --badge-neutral-text: #6b7a8d;

    /* Anillo de foco de inputs: azul muy sutil sobre fondo claro; en modo
       oscuro ese mismo tono se ve como un artefacto apagado sobre el fondo
       ya oscuro de la tarjeta, así que se aclara para seguir leyéndose
       como "resaltado" y no como una mancha. */
    --focus-ring: rgba(30,58,95,0.1);

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --topbar-height: 64px;

    --shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
    --shadow-card: 0 2px 12px rgba(30,58,95,0.08);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
}

/* --- Modo oscuro ---
   Se activa por [data-theme="dark"] en <html> (elegido manualmente y
   persistido en localStorage) o, si el usuario no eligió nada todavía,
   por prefers-color-scheme del sistema operativo/navegador. El sidebar
   ya era oscuro en ambos modos (--bg-sidebar no cambia); lo que se
   invierte es el fondo de página y las superficies de tarjeta/input. */
html[data-theme="dark"] {
    --bg-card: #16202e;
    --bg-page: #0b1420;
    --bg-surface: #16202e;
    --bg-surface-alt: #1c2836;
    --bg-surface-hover: #22303f;
    --border-color: #2a3a4d;
    --border-color-soft: #22303f;

    --text-primary: #e6edf5;
    --text-muted: #93a3b8;

    --badge-warning-text: #e0b84d;
    --badge-info-text: #6bb0e0;
    --badge-neutral-text: #9aa8b8;
    --focus-ring: rgba(107,163,230,0.25);

    --shadow-sm: 0 1px 4px rgba(0,0,0,0.35);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-card: 0 2px 12px rgba(0,0,0,0.3);

    /* Bootstrap define su propio color de texto vía estas variables
       (--bs-body-color, --bs-emphasis-color) en :root, con más peso que la
       simple herencia de `body { color: var(--text-primary) }` — varios de
       sus componentes (.dropdown-menu, .table, .list-group...) las usan
       directamente. Sin sobreescribirlas aquí, esos componentes quedan con
       texto oscuro fijo (#212529) e ilegible sobre fondo oscuro. */
    --bs-body-color: var(--text-primary);
    --bs-body-color-rgb: 230, 237, 245;
    --bs-emphasis-color: var(--text-primary);
    --bs-secondary-color: var(--text-muted);
    --bs-border-color: var(--border-color);
    --bs-body-bg: var(--bg-page);
    --bs-tertiary-bg: var(--bg-surface-alt);
}

@media (prefers-color-scheme: dark) {
    html:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg-card: #16202e;
        --bg-page: #0b1420;
        --bg-surface: #16202e;
        --bg-surface-alt: #1c2836;
        --bg-surface-hover: #22303f;
        --border-color: #2a3a4d;
        --border-color-soft: #22303f;

        --text-primary: #e6edf5;
        --text-muted: #93a3b8;

        --badge-warning-text: #e0b84d;
        --badge-info-text: #6bb0e0;
        --badge-neutral-text: #9aa8b8;
        --focus-ring: rgba(107,163,230,0.25);

        --shadow-sm: 0 1px 4px rgba(0,0,0,0.35);
        --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
        --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
        --shadow-card: 0 2px 12px rgba(0,0,0,0.3);

        --bs-body-color: var(--text-primary);
        --bs-body-color-rgb: 230, 237, 245;
        --bs-emphasis-color: var(--text-primary);
        --bs-secondary-color: var(--text-muted);
        --bs-border-color: var(--border-color);
        --bs-body-bg: var(--bg-page);
        --bs-tertiary-bg: var(--bg-surface-alt);
    }
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-page);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    /* 100vh en móviles mide el viewport SIN descontar la barra de
       direcciones del navegador, así que puede ser más alto que el
       espacio realmente visible -- eso empuja el sidebar-footer (nombre
       de usuario + cerrar sesión) fuera de la pantalla sin dar ninguna
       pista de que hay que hacer scroll. 100dvh sigue el viewport visible
       real; 100vh queda como fallback para navegadores sin soporte. */
    height: 100vh;
    height: 100dvh;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: var(--transition);
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: var(--topbar-height);
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, var(--secondary), #1abc9c);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
    color: white;
    box-shadow: 0 2px 8px rgba(46,204,113,0.4);
}

.brand-text {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.brand-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 11px;
    color: var(--text-sidebar-muted);
    white-space: nowrap;
    line-height: 1.2;
}

.sidebar-toggle-btn {
    width: 28px;
    height: 28px;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 6px;
    color: var(--text-sidebar-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

.sidebar.collapsed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    /* Sin esto, un flex item puede crecer más allá del espacio del padre
       en vez de encoger y activar su propio scroll -- empujando
       sidebar-footer (fixed abajo por flex-shrink:0) fuera de la vista. */
    min-height: 0;
    padding: 12px 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-sidebar-muted);
    padding: 16px 20px 6px;
    white-space: nowrap;
    overflow: hidden;
    transition: var(--transition);
}

.sidebar.collapsed .nav-section-title {
    opacity: 0;
    height: 0;
    padding: 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: var(--text-sidebar);
    text-decoration: none;
    border-radius: 0;
    margin: 2px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}

.nav-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: var(--transition-fast);
}

.nav-item span {
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition);
    overflow: hidden;
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: #ffffff;
    transform: translateX(2px);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(46,204,113,0.2), rgba(46,204,113,0.08));
    color: #2ecc71;
    font-weight: 600;
    border-left: 3px solid #2ecc71;
    padding-left: 17px;
}

.nav-item.active i { color: #2ecc71; }

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 11px;
    margin: 2px 8px;
}

.sidebar.collapsed .nav-item span {
    width: 0;
    opacity: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.1);
    flex-shrink: 0;
    overflow: hidden;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    min-width: 0;
}

.user-avatar-sb {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.user-role-badge {
    font-size: 10px;
    color: var(--text-sidebar-muted);
    white-space: nowrap;
    line-height: 1.3;
    text-transform: capitalize;
}

.btn-logout {
    width: 32px;
    height: 32px;
    background: rgba(231,76,60,0.15);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(231,76,60,0.8);
    text-decoration: none;
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.btn-logout:hover {
    background: rgba(231,76,60,0.3);
    color: #e74c3c;
}

.sidebar.collapsed .user-details {
    opacity: 0;
    width: 0;
}

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

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.topbar-toggle-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-page);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: var(--transition-fast);
}

.topbar-toggle-btn:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.topbar-breadcrumb {
    flex: 1;
}

.topbar-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-time-wrap {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
    background: var(--bg-page);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

.topbar-user-btn {
    text-decoration: none;
    /* Un <button> no hereda `color` del padre como lo haría un <div>/<a>, y
       trae su propio background-color de user-agent (gris claro fijo) —
       sin esto, el ícono (ya corregido a color claro en modo oscuro) queda
       claro sobre un fondo que también sigue claro: invisible. Antes solo
       el botón de tema tenía este reset puesto inline; ahora es parte de
       la clase para que alcance también a la campana y cualquier otro
       botón de la topbar. */
    color: var(--text-primary);
    background: transparent;
    border: none;
    cursor: pointer;
}

.topbar-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: white;
    transition: var(--transition-fast);
}

.topbar-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(30,58,95,0.3);
}

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
    flex: 1;
    padding: 28px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-card);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color-soft);
    padding: 18px 24px;
    font-weight: 600;
    font-size: 15px;
    color: var(--text-primary);
}

.card-body { padding: 24px; }

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card.stat-warning::before { background: linear-gradient(90deg, var(--accent), #f1c40f); }
.stat-card.stat-success::before { background: linear-gradient(90deg, var(--secondary), #1abc9c); }
.stat-card.stat-info::before { background: linear-gradient(90deg, var(--info), #2980b9); }
.stat-card.stat-danger::before { background: linear-gradient(90deg, var(--danger), #c0392b); }

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 16px;
}

.stat-icon.bg-primary { background: rgba(30,58,95,0.1); color: var(--primary); }
.stat-icon.bg-warning { background: rgba(243,156,18,0.12); color: var(--accent); }
.stat-icon.bg-success { background: rgba(46,204,113,0.12); color: var(--secondary); }
.stat-icon.bg-info { background: rgba(52,152,219,0.12); color: var(--info); }
.stat-icon.bg-danger { background: rgba(231,76,60,0.12); color: var(--danger); }

.stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 6px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================================
   TURN NUMBER DISPLAY
   ============================================================ */
.turno-numero-display {
    font-size: 72px;
    font-weight: 900;
    color: var(--primary);
    line-height: 1;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
}

.turno-codigo-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-size: 42px;
    font-weight: 800;
    padding: 16px 36px;
    border-radius: var(--radius-lg);
    letter-spacing: 4px;
    box-shadow: 0 8px 32px rgba(30,58,95,0.3);
    text-align: center;
}

/* ============================================================
   STATUS BADGES
   ============================================================ */
.badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.estado-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.estado-esperando { background: rgba(241,196,15,0.15); color: var(--badge-warning-text); }
.estado-llamado { background: rgba(52,152,219,0.12); color: var(--badge-info-text); }
.estado-atendiendo { background: rgba(30,58,95,0.1); color: var(--primary); }
.estado-completado { background: rgba(46,204,113,0.12); color: var(--secondary-dark); }
.estado-cancelado { background: rgba(231,76,60,0.1); color: var(--danger); }
.estado-ausente { background: rgba(107,122,141,0.12); color: var(--badge-neutral-text); }
.estado-transferido { background: rgba(52,152,219,0.12); color: var(--badge-info-text); }

/* Ventanilla.estado_display: 'activa' | 'pausa' | 'inactiva' — reutiliza el
   mismo componente .estado-badge pero nunca tuvo sus propios colores; sin
   clase coincidente caía al gris por defecto del navegador para <span>,
   invisible en modo oscuro y apenas visible en claro. */
.estado-activa { background: rgba(46,204,113,0.12); color: var(--secondary-dark); }
.estado-pausa { background: rgba(243,156,18,0.15); color: var(--badge-warning-text); }
.estado-inactiva { background: rgba(107,122,141,0.12); color: var(--badge-neutral-text); }
.estado-pendiente { background: rgba(231,76,60,0.12); color: var(--danger); }

.prioridad-normal { background: rgba(107,122,141,0.1); color: var(--badge-neutral-text); }
.prioridad-preferencial { background: rgba(52,152,219,0.12); color: var(--badge-info-text); }
.prioridad-urgente { background: rgba(231,76,60,0.1); color: var(--danger); }

/* ============================================================
   TABLES
   ============================================================ */
.table-modern {
    width: 100%;
    border-collapse: collapse;
}

.table-modern thead th {
    background: var(--bg-surface-alt);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 12px 16px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}

.table-modern tbody tr {
    border-bottom: 1px solid var(--border-color-soft);
    transition: var(--transition-fast);
}

.table-modern tbody tr:hover {
    background: var(--bg-surface-alt);
}

.table-modern tbody td {
    padding: 13px 16px;
    vertical-align: middle;
    font-size: 13.5px;
    /* Bootstrap fija su --bs-body-color (#212529, oscuro fijo) con más
       peso que la simple herencia de `body { color: var(--text-primary) }`
       — sin esto, el texto de cualquier <div> suelto dentro de una celda
       (sin su propio color inline) queda casi invisible en modo oscuro. */
    color: var(--text-primary);
}

.table-modern tbody tr:last-child { border-bottom: none; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    font-weight: 500;
    border-radius: var(--radius-sm);
    padding: 8px 18px;
    font-size: 13.5px;
    transition: var(--transition-fast);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    box-shadow: 0 2px 8px rgba(30,58,95,0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(30,58,95,0.35);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-dark));
    color: white;
    box-shadow: 0 2px 8px rgba(46,204,113,0.25);
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(46,204,113,0.35);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #c0392b);
    color: white;
}

.btn-danger:hover {
    transform: translateY(-1px);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    color: white;
}

.btn-warning:hover {
    transform: translateY(-1px);
    color: white;
}

.btn-outline-primary {
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

.btn-lg { padding: 12px 28px; font-size: 15px; border-radius: var(--radius-md); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xl { padding: 16px 40px; font-size: 17px; border-radius: var(--radius-md); font-weight: 700; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control, .form-select {
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-card);
    transition: var(--transition-fast);
}

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

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-control-lg {
    padding: 13px 16px;
    font-size: 15px;
    border-radius: var(--radius-md);
}

/* ============================================================
   PUBLIC NAVBAR
   ============================================================ */
.navbar-public {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
    padding: 0;
    height: 70px;
    position: relative;
    box-shadow: 0 2px 20px rgba(0,0,0,0.25);
    overflow: visible;
}

.navbar-brand-pub {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    padding: 12px 0;
}

.brand-pub-icon {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
}

.brand-pub-text {
    display: flex;
    flex-direction: column;
}

.brand-pub-title {
    font-size: 16px;
    font-weight: 700;
    color: white;
    line-height: 1.2;
}

.brand-pub-sub {
    font-size: 11px;
    color: rgba(255,255,255,0.65);
    line-height: 1.2;
}

.nav-link-pub {
    color: rgba(255,255,255,0.85) !important;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: var(--transition-fast);
}

.nav-link-pub:hover, .nav-link-pub.active {
    background: rgba(255,255,255,0.12);
    color: white !important;
}

.btn-pub-primary {
    background: var(--secondary);
    color: white;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 600;
    transition: var(--transition-fast);
    border: none;
}

.btn-pub-primary:hover {
    background: var(--secondary-dark);
    color: white;
    transform: translateY(-1px);
}

.btn-pub-outline {
    border: 1.5px solid rgba(255,255,255,0.4);
    color: rgba(255,255,255,0.9);
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.btn-pub-outline:hover {
    border-color: white;
    color: white;
    background: rgba(255,255,255,0.1);
}

/* ============================================================
   PANTALLA (Public Display Board)
   ============================================================ */
.pantalla-wrapper {
    background: #050d1a;
    min-height: 100vh;
    color: white;
    font-family: 'Inter', sans-serif;
}

.pantalla-header {
    background: linear-gradient(135deg, #0a1628, #1e3a5f);
    padding: 20px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid rgba(46,204,113,0.3);
}

.pantalla-logo {
    font-size: 22px;
    font-weight: 800;
    color: white;
    display: flex;
    align-items: center;
    gap: 14px;
}

.pantalla-logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2ecc71, #1abc9c);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.pantalla-clock {
    font-size: 42px;
    font-weight: 800;
    color: #2ecc71;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

.pantalla-date {
    font-size: 14px;
    color: rgba(255,255,255,0.5);
    text-align: right;
}

.pantalla-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: calc(100vh - 100px);
}

.pantalla-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.4);
    padding: 20px 30px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* Turn card on pantalla */
.pantalla-turno-card {
    display: flex;
    align-items: center;
    padding: 16px 30px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    gap: 20px;
    transition: var(--transition);
    animation: fadeInUp 0.4s ease;
}

.pantalla-turno-card.llamado {
    background: rgba(46,204,113,0.08);
    border-left: 4px solid #2ecc71;
}

.pantalla-ventanilla-num {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #1e3a5f, #2a5298);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 900;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.pantalla-codigo {
    font-size: 38px;
    font-weight: 900;
    color: #2ecc71;
    letter-spacing: 3px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.pantalla-codigo.pulsing {
    animation: pulseTurno 1.5s ease-in-out infinite;
}

.pantalla-ventanilla-nombre {
    font-size: 13px;
    color: rgba(255,255,255,0.5);
    margin-top: 4px;
}

.pantalla-vacia {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 30px;
    opacity: 0.3;
}

/* Proximos list */
.pantalla-proximo-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 30px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    transition: var(--transition);
}

.pantalla-proximo-item:first-child {
    background: rgba(243,156,18,0.1);
    border-left: 3px solid var(--accent);
}

.pantalla-proximo-codigo {
    font-size: 28px;
    font-weight: 800;
    color: rgba(255,255,255,0.9);
    letter-spacing: 2px;
    font-variant-numeric: tabular-nums;
}

.pantalla-proximo-num {
    font-size: 12px;
    color: rgba(255,255,255,0.3);
    font-weight: 700;
}

/* ============================================================
   OPERADOR PANEL
   ============================================================ */
.operador-header-card {
    --op-accent: var(--primary);
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--op-accent);
    box-shadow: var(--shadow-sm);
    padding: 14px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.operador-header-identity {
    display: flex;
    align-items: center;
    gap: 12px;
}

.operador-header-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--op-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    color: white;
}

.operador-header-text { line-height: 1.3; }

.operador-header-nombre {
    font-size: 15px;
    font-weight: 800;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.operador-header-servicio {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--op-accent);
}

.operador-header-servicio.sin-servicio {
    color: var(--accent);
}

.operador-header-estado {
    font-size: 12px !important;
    padding: 5px 12px !important;
}

.operador-header-divider {
    width: 1px;
    align-self: stretch;
    background: var(--border-color-soft);
}

.operador-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    flex: 1;
}

.operador-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.operador-header-btn {
    border-radius: var(--radius-sm) !important;
    font-weight: 600;
    transition: filter 0.15s ease;
}

.operador-header-btn:hover {
    filter: brightness(0.96);
}

.operador-header-pendiente {
    background: rgba(243,156,18,0.12);
    color: var(--accent);
    border-radius: var(--radius-sm);
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.operador-header-conn {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

@media (max-width: 900px) {
    .operador-header-card { flex-direction: column; align-items: stretch; }
    .operador-header-divider { display: none; }
    .operador-header-conn { margin-left: 0; }
}

.operador-panel {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    height: calc(100vh - var(--topbar-height) - 56px);
}

.turno-actual-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.turno-actual-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-muted);
}

.turno-actual-empty .empty-icon {
    width: 80px;
    height: 80px;
    background: var(--bg-surface-hover);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: #c5d0db;
}

.turno-actual-codigo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-size: 56px;
    font-weight: 900;
    padding: 20px 40px;
    border-radius: var(--radius-lg);
    letter-spacing: 6px;
    box-shadow: 0 8px 32px rgba(30,58,95,0.25);
    text-align: center;
    line-height: 1;
    transition: background 0.4s ease, box-shadow 0.4s ease;
}

/* Color del contenedor del código según el tiempo de atención transcurrido
   frente al tiempo máximo del trámite (ver initCronometroOperador en
   main.js) -- sin trámite asociado se queda con el degradado azul de
   arriba. Es el indicador principal: grande y visible de un vistazo, sin
   necesitar un punto/badge aparte. */
.turno-actual-codigo.turno-codigo-verde {
    background: linear-gradient(135deg, #219150, #2ecc71);
    box-shadow: 0 8px 32px rgba(46,204,113,0.35);
}

.turno-actual-codigo.turno-codigo-naranja {
    background: linear-gradient(135deg, #d3830f, #f39c12);
    box-shadow: 0 8px 32px rgba(243,156,18,0.35);
}

.turno-actual-codigo.turno-codigo-rojo {
    background: linear-gradient(135deg, #c0392b, #e74c3c);
    box-shadow: 0 8px 32px rgba(231,76,60,0.4);
    animation: pulseRojoFondo 1.2s infinite;
}

@keyframes pulseRojoFondo {
    0%, 100% { box-shadow: 0 8px 32px rgba(231,76,60,0.4); }
    50% { box-shadow: 0 8px 48px rgba(231,76,60,0.7); }
}

/* Ventanilla sin turno en curso -- ni verde/naranja/rojo (esos son sobre
   tiempo de atención), un gris neutro para "no hay nada que medir". */
.turno-actual-codigo.turno-codigo-libre {
    background: linear-gradient(135deg, #94a3b8, #cbd5e1);
    box-shadow: none;
    color: var(--text-primary);
}

.turno-actual-codigo.turno-codigo-pausa {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    box-shadow: 0 8px 24px rgba(243,156,18,0.25);
}

/* Versión compacta del contenedor de código para el resumen de ventanillas
   del dashboard del supervisor (tarjetas chicas, muchas por pantalla) --
   mismo comportamiento de color que la del panel del operador (pantalla
   completa), solo con tipografía y padding reducidos. */
.ventanilla-resumen-codigo {
    font-size: 20px;
    padding: 8px 12px;
    letter-spacing: 2px;
    border-radius: var(--radius-sm);
    width: 100%;
}

.turno-actual-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* Cronómetro del turno en atención (panel del operador): tiempo
   transcurrido y tiempo máximo del trámite, junto a la etiqueta de estado
   -- el color ya lo indica el contenedor grande del código (arriba). */
.op-cronometro-tramite {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-variant-numeric: tabular-nums;
}

.op-cronometro-valor {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
}

.op-cronometro-maximo {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-left: 1px solid var(--border-color);
    padding-left: 10px;
}

.info-item {
    background: var(--bg-surface-alt);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
}

.info-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Cola panel */
.cola-panel {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cola-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.cola-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cola-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.cola-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
    border: 1.5px solid transparent;
}

.cola-item:hover {
    background: var(--bg-surface-alt);
    border-color: var(--border-color);
}

.cola-item.urgente {
    background: rgba(231,76,60,0.04);
    border-color: rgba(231,76,60,0.15);
}

.cola-item-codigo {
    font-size: 16px;
    font-weight: 800;
    color: var(--primary);
    letter-spacing: 1px;
    font-variant-numeric: tabular-nums;
}

.cola-item-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ============================================================
   HOME PAGE
   ============================================================ */
.hero-section {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 80px 0;
    position: relative;
    overflow: hidden;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(46,204,113,0.12) 0%, transparent 70%);
    pointer-events: none;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, transparent 70%);
    pointer-events: none;
}

.hero-title {
    font-size: 48px;
    font-weight: 900;
    color: white;
    line-height: 1.15;
    margin-bottom: 20px;
}

.hero-title span {
    color: #2ecc71;
}

.hero-subtitle {
    font-size: 18px;
    color: rgba(255,255,255,0.75);
    line-height: 1.6;
    margin-bottom: 36px;
    max-width: 520px;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.9);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 24px;
}

.hero-stats {
    display: flex;
    gap: 32px;
    margin-top: 32px;
}

.hero-stat {
    text-align: center;
}

.hero-stat-value {
    font-size: 32px;
    font-weight: 800;
    color: white;
    line-height: 1;
}

.hero-stat-label {
    font-size: 12px;
    color: rgba(255,255,255,0.55);
    margin-top: 4px;
}

/* Service Cards */
.service-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px 24px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-card);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
}

.service-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--service-color, #0d6efd);
    transform: scaleX(0);
    transition: var(--transition);
}

.service-card:hover::before {
    transform: scaleX(1);
}

.service-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow-lg);
    border-color: var(--service-color, #0d6efd);
}

.service-card.selected {
    border-color: var(--service-color, #0d6efd);
    background: rgba(13,110,253,0.03);
}

.service-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    margin: 0 auto 16px;
    color: white;
    background: var(--service-color, #0d6efd);
}

.service-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.service-time {
    font-size: 12px;
    color: var(--text-muted);
}

.service-prefijo {
    position: absolute;
    top: 12px;
    right: 12px;
    background: var(--bg-surface-hover);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
}

/* ============================================================
   CONFIRMATION / TURNO STATE
   ============================================================ */
.confirm-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 48px;
    box-shadow: var(--shadow-lg);
    max-width: 520px;
    margin: 0 auto;
    text-align: center;
}

.confirm-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #2ecc71, #1abc9c);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    color: white;
    margin: 0 auto 24px;
    box-shadow: 0 8px 32px rgba(46,204,113,0.3);
    animation: bounceIn 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.confirm-turno-code {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    font-size: 52px;
    font-weight: 900;
    padding: 16px 40px;
    border-radius: var(--radius-lg);
    letter-spacing: 6px;
    margin: 16px 0;
    box-shadow: 0 8px 24px rgba(30,58,95,0.25);
    font-variant-numeric: tabular-nums;
}

.confirm-details {
    background: var(--bg-surface-alt);
    border-radius: var(--radius-md);
    padding: 20px;
    margin: 20px 0;
    text-align: left;
}

.confirm-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
}

.confirm-detail-row:last-child { border-bottom: none; }

.confirm-detail-label { color: var(--text-muted); font-weight: 500; }
.confirm-detail-value { font-weight: 700; color: var(--text-primary); }

/* ============================================================
   VENTANILLA CARDS
   ============================================================ */
.ventanilla-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    border-left: 4px solid transparent;
}

.ventanilla-card.activa { border-left-color: var(--secondary); }
.ventanilla-card.pausa { border-left-color: var(--accent); }
.ventanilla-card.inactiva { border-left-color: #c5d0db; opacity: 0.7; }

.ventanilla-number {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 900;
    color: white;
}

/* ============================================================
   LOGIN / AUTH PAGES
   ============================================================ */
.auth-wrapper {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(46,204,113,0.15), transparent 70%);
    top: -200px;
    right: -200px;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(255,255,255,0.06), transparent 70%);
    bottom: -100px;
    left: -100px;
}

.auth-card {
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    padding: 48px;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.25);
    position: relative;
    z-index: 1;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo-icon {
    width: 68px;
    height: 68px;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: white;
    margin: 0 auto 16px;
    box-shadow: 0 8px 24px rgba(30,58,95,0.25);
}

.auth-title {
    font-size: 26px;
    font-weight: 800;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 6px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
    margin-bottom: 32px;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bounceIn {
    0% { opacity: 0; transform: scale(0.3); }
    50% { opacity: 1; transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); }
}

@keyframes pulseTurno {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.02); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes callAnimation {
    0% { box-shadow: 0 0 0 0 rgba(46,204,113,0.4); }
    70% { box-shadow: 0 0 0 20px rgba(46,204,113,0); }
    100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}

.animate-fade-in { animation: fadeInUp 0.4s ease; }
.animate-slide-in { animation: slideInLeft 0.3s ease; }

.turno-llamado-animation {
    animation: callAnimation 1.5s ease-in-out infinite;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
    .operador-panel {
        grid-template-columns: 1fr 320px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
        z-index: 1050;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 32px rgba(0,0,0,0.4);
    }

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

    .operador-panel {
        grid-template-columns: 1fr;
        height: auto;
    }

    .hero-title { font-size: 34px; }
    .page-content { padding: 16px; }

    /* Topbar full-width on mobile */
    .topbar { padding: 0 16px; }
    .topbar-time-wrap { display: none; }
}

@media (max-width: 768px) {
    .pantalla-grid {
        grid-template-columns: 1fr;
    }

    .auth-card { padding: 32px 24px; }
    .confirm-card { padding: 32px 24px; }
    .hero-title { font-size: 28px; }
    .hero-stats { gap: 20px; }
    .turno-actual-info { grid-template-columns: 1fr; }
}

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.52);
    z-index: 1040;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: overlayIn .2s ease;
}

.sidebar-overlay.active { display: block; }

@keyframes overlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ============================================================
   PUBLIC NAVBAR — MOBILE
   ============================================================ */
@media (max-width: 991.98px) {
    /* Allow navbar to grow with expanded menu */
    .navbar-public {
        height: auto;
        min-height: 64px;
        overflow: visible;       /* never clip the dropdown */
    }

    /* Brand adjustments */
    .navbar-brand-pub { padding: 10px 0; }
    .navbar-brand-pub img { height: 36px; }
    .brand-pub-sub { font-size: 10px; }

    /* Expanded dropdown panel — sits below the navbar bar */
    .navbar-public .navbar-collapse {
        background: rgba(10, 22, 48, 0.98);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid rgba(255,255,255,0.12);
        padding: 8px 4px 16px;
        /* No negative margin — avoids overflow/clipping issues */
        box-shadow: 0 8px 24px rgba(0,0,0,0.35);
        border-radius: 0 0 12px 12px;
        z-index: 1000;           /* above page content */
    }

    /* Nav list */
    .navbar-public .navbar-nav {
        align-items: stretch !important;
        gap: 0 !important;
        padding: 0 8px;
    }

    .navbar-public .nav-item { width: 100%; }

    /* Nav links */
    .navbar-public .nav-link-pub {
        display: flex;
        align-items: center;
        padding: 11px 14px;
        border-radius: 8px;
        margin: 2px 0;
        font-size: 14px;
    }

    /* Buttons in mobile menu */
    .navbar-public .btn-pub-primary,
    .navbar-public .btn-pub-outline {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        text-align: center;
        padding: 11px 16px;
        margin: 3px 0;
        box-sizing: border-box;
    }

    /* Language switcher row */
    .navbar-public .nav-item.ms-2 { margin-left: 0 !important; }

    .navbar-public .theme-toggle-pub {
        width: 100%;
        height: auto;
        border-radius: 8px;
        padding: 11px 14px;
        margin: 2px 0;
        justify-content: center;
        gap: 8px;
        font-size: .74rem;
    }
    .navbar-public .theme-toggle-pub .theme-toggle-pub-label {
        display: inline !important;
        font-weight: 500;
    }

    .navbar-public .lang-switcher {
        width: 100%;
        justify-content: center;
        gap: 8px;
        padding: 12px 14px 2px;
        border-top: 1px solid rgba(255,255,255,0.09);
        margin-top: 8px;
    }

    .navbar-public .lang-btn {
        padding: 6px 14px;
        font-size: .74rem;
        background: rgba(255,255,255,.08);
        opacity: 1;
    }

    .navbar-public .lang-btn.active {
        background: rgba(255,255,255,.22);
        color: #fff;
    }

    /* Toggler button */
    .navbar-toggler { padding: 6px 8px; }
    .navbar-toggler i { font-size: 18px; }
}

/* ============================================================
   HOME PAGE — SMALL PHONES (≤ 575px)
   ============================================================ */
@media (max-width: 575.98px) {
    .hero-section { padding: 36px 0 28px; }

    .hero-badge {
        font-size: 11px;
        padding: 5px 12px;
        margin-bottom: 14px;
    }

    .hero-title {
        font-size: 26px;
        line-height: 1.2;
        margin-bottom: 12px;
    }

    .hero-subtitle {
        font-size: 14px;
        line-height: 1.55;
        margin-bottom: 20px;
    }

    /* Stack hero buttons on tiny screens */
    .hero-btns {
        flex-direction: column;
    }

    .hero-btns .btn {
        width: 100%;
        justify-content: center;
        padding: 13px 20px;
        font-size: 15px;
    }

    .hero-stats {
        gap: 16px;
        margin-top: 20px;
        flex-wrap: wrap;
    }

    .hero-stat-value { font-size: 26px; }
    .hero-stat-label { font-size: 11px; }

    /* Service cards: 1 per row on tiny screens */
    .service-card { padding: 20px 16px; }

    /* Auth / confirm cards */
    .auth-card { padding: 28px 18px; }
    .confirm-card { padding: 28px 18px; }
    .confirm-turno-code { font-size: 40px; padding: 14px 28px; }
}

/* ============================================================
   UTILITIES & HELPERS
   ============================================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i {
    color: var(--primary);
}

.section-divider {
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

.empty-state {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 52px;
    color: #d1dae3;
    margin-bottom: 16px;
}

.empty-state-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.connection-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #c5d0db;
    display: inline-block;
}

.connection-dot.connected {
    background: var(--secondary);
    box-shadow: 0 0 6px rgba(46,204,113,0.5);
    animation: pulseTurno 2s infinite;
}

.connection-dot.disconnected {
    background: var(--danger);
}

/* Scrollbar global */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5d0db; border-radius: 4px; }

/* ============================================================
   CHAT INTERNO (widget flotante) — operador/supervisor
   ============================================================ */
.chat-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    border: none;
    font-size: 22px;
    box-shadow: var(--shadow-lg);
    z-index: 1900;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.chat-fab:hover { transform: scale(1.06); }

/* Widget minimizado y llegó un mensaje nuevo -- pulso llamativo hasta que
   se abra (ver notificarMensajeConWidgetCerrado en chat.js). */
.chat-fab.chat-fab-pulso {
    animation: chatFabPulso 1s ease-out 3;
}

@keyframes chatFabPulso {
    0% { box-shadow: 0 0 0 0 rgba(46,204,113,0.6); }
    70% { box-shadow: 0 0 0 16px rgba(46,204,113,0); }
    100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}

.chat-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    border: 2px solid var(--bg-page);
}

.chat-widget-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 340px;
    height: 460px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 1900;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.chat-widget-panel.abierto { display: flex; }

.chat-widget-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.chat-header-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    margin-left: 4px;
    cursor: pointer;
}

.chat-conversacion-header .chat-header-btn {
    background: transparent;
    color: var(--text-primary);
}

.chat-panel-iniciar {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface-alt);
    flex-shrink: 0;
}

.chat-panel-iniciar-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 6px;
}

.chat-vista { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-lista-conversaciones {
    flex: 1;
    overflow-y: auto;
}

.chat-cargando, .chat-vacio {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 30px 16px;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color-soft);
    transition: var(--transition-fast);
}

.chat-item:hover, .chat-item.activa { background: var(--bg-surface-hover); }

.chat-item-icono {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-surface-alt);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-item-info { flex: 1; min-width: 0; }

.chat-item-nombre {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-ultimo {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-badge {
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    flex-shrink: 0;
}

.chat-conversacion-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    flex-shrink: 0;
}

.chat-mensajes {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-mensaje {
    max-width: 78%;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    line-height: 1.4;
}

.chat-mensaje.ajeno {
    align-self: flex-start;
    background: var(--bg-surface-alt);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chat-mensaje.propio {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.chat-mensaje-autor {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2px;
}

.chat-mensaje-texto { word-wrap: break-word; }

.chat-mensaje-hora {
    font-size: 9px;
    opacity: 0.7;
    margin-top: 3px;
    text-align: right;
}

.chat-escribiendo {
    font-size: 11px;
    font-style: italic;
    color: var(--text-muted);
    padding: 2px 14px;
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

@media (max-width: 480px) {
    .chat-widget-panel {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 84px;
        height: 60vh;
    }
    .chat-fab { right: 16px; bottom: 16px; }
}
::-webkit-scrollbar-thumb:hover { background: #a0aab4; }
