/* Estilos de la aplicacion - extraidos de index.html
   Cargar despues de app.css (Tailwind). */

/* Inter variable servida localmente (antes: Google Fonts, 2 conexiones externas) */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 300 900;
    font-display: swap;
    src: url('fonts/inter-latin-var.woff2') format('woff2');
}

/* --- TOKENS DE DISENO ---------------------------------------------------
   Un solo lugar para color, radios, sombras y tiempos. El modo oscuro
   redefine las variables en vez de pelear con !important regla por regla. */
:root {
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --line: #e2e8f0;
    --line-soft: #f1f5f9;
    --text: #334155;
    --text-strong: #0f172a;
    --text-muted: #64748b;
    --text-faint: #94a3b8;
    --brand: #4f46e5;
    --brand-strong: #4338ca;
    --brand-soft: #eef2ff;
    --ok: #059669;
    --warn: #d97706;
    --danger: #dc2626;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-2: 0 12px 32px -20px rgba(15, 23, 42, 0.45);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

.dark {
    --surface: #1e293b;
    --surface-2: #0f172a;
    --surface-3: #334155;
    --line: #334155;
    --line-soft: #273449;
    --text: #cbd5e1;
    --text-strong: #f8fafc;
    --text-muted: #94a3b8;
    --text-faint: #64748b;
    --brand: #818cf8;
    --brand-strong: #a5b4fc;
    --brand-soft: rgba(99, 102, 241, 0.14);
}

        /* --- ESTILOS GENERALES --- */
        body {
            font-family: 'Inter', system-ui, -apple-system, sans-serif;
            background-color: #f8fafc;
            /* slate-50 */
            color: #334155;
            /* slate-700 */
            transition: background-color 0.3s, color 0.3s;
            -webkit-tap-highlight-color: transparent;
            min-height: 100vh;
            min-height: 100dvh;
            padding-top: env(safe-area-inset-top);
            padding-right: env(safe-area-inset-right);
            padding-bottom: env(safe-area-inset-bottom);
            padding-left: env(safe-area-inset-left);
        }

        .dark body {
            background-color: #0f172a;
            color: #cbd5e1;
        }

        .dark .bg-white {
            background-color: #1e293b !important;
        }

        .dark .bg-slate-50 {
            background-color: #0f172a !important;
        }

        .dark .bg-slate-100 {
            background-color: #1e293b !important;
        }

        .dark .bg-slate-200 {
            background-color: #334155 !important;
        }

        .dark .border-slate-100 {
            border-color: #334155 !important;
        }

        .dark .border-slate-200 {
            border-color: #334155 !important;
        }

        .dark .text-slate-500 {
            color: #94a3b8 !important;
        }

        .dark .text-slate-600 {
            color: #cbd5e1 !important;
        }

        .dark .text-slate-700 {
            color: #e2e8f0 !important;
        }

        .dark .text-slate-800 {
            color: #f1f5f9 !important;
        }

        .dark .text-slate-900 {
            color: #ffffff !important;
        }

        .dark .shadow-slate-200\/50 {
            --tw-shadow-color: rgb(15 23 42 / 0.5);
        }

        .dark .calendar-grid {
            background-color: #334155;
            border-color: #334155;
        }

        .dark .calendar-cell {
            background-color: #1e293b;
        }

        .dark .booking-card {
            background-color: #1e293b;
            border-left-width: 4px;
        }

        .dark .calendar-cell:hover {
            background-color: #334155;
        }

        /* Modal Dark Overrides */
        .dark #bookingModal .bg-white {
            background-color: #1e293b !important;
        }

        .dark #bookingModal .bg-slate-50 {
            background-color: #0f172a !important;
        }

        .dark input,
        .dark select,
        .dark textarea {
            background-color: #0f172a !important;
            border-color: #334155 !important;
            color: #f1f5f9 !important;
        }

        .dark input:focus,
        .dark select:focus,
        .dark textarea:focus {
            border-color: #6366f1 !important;
            background-color: #0f172a !important;
        }

        .hidden {
            display: none !important;
        }

        .modal-enter {
            animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
        }

        @keyframes fadeIn {
            from {
                opacity: 0;
                transform: scale(0.98) translateY(4px);
            }

            to {
                opacity: 1;
                transform: scale(1) translateY(0);
            }
        }

        /* Estilos de Grid */
        .calendar-grid {
            display: grid;
            /* minmax(0, 1fr): un nombre largo no puede ensanchar su columna */
            grid-template-columns: repeat(7, minmax(0, 1fr));
            gap: 1px;
            background-color: #e2e8f0;
            /* slate-200 */
            border: 1px solid #e2e8f0;
            border-radius: 0 0 0.75rem 0.75rem;
            overflow: hidden;
        }

        .calendar-cell {
            background-color: white;
            min-height: 100px;
            transition: background-color 0.2s;
        }

        @media (min-width: 768px) {
            .calendar-cell {
                min-height: 140px;
            }
        }

        /* Mejoras de Responsividad para Móviles */
        @media (max-width: 640px) {
            .calendar-cell {
                min-height: 65px;
                padding: 2px;
            }

            .calendar-grid {
                font-size: 0.65rem;
                gap: 1px;
            }

            /* Vista mensual móvil - 7 columnas compactas */
            #viewMonth .calendar-cell {
                min-height: 60px;
                padding: 3px;
            }

            #viewMonth .calendar-cell span.font-bold {
                width: 20px;
                height: 20px;
                font-size: 0.7rem;
            }

            #viewMonth .calendar-cell .text-xs {
                font-size: 0.55rem;
                padding: 2px 3px;
            }

            #viewMonth .calendar-cell .space-y-1 {
                margin-top: 2px;
            }

            #viewMonth .calendar-cell .flex.justify-center.gap-0\.5 {
                display: none;
            }

            /* Ajustar padding del contenedor del mes */
            #viewMonth>div {
                padding: 4px;
            }

            .toast {
                left: 12px;
                right: 12px;
                bottom: 12px;
                padding: 12px 16px;
                font-size: 0.875rem;
            }

            #bookingModal>div {
                margin: 4px;
                max-height: calc(100vh - 8px);
            }

            /* Modal compacto para móviles */
            #bookingModal .modal-header {
                padding: 12px 16px !important;
            }

            #bookingModal .modal-body {
                padding: 12px !important;
            }

            #bookingModal .modal-body .space-y-5 {
                gap: 10px !important;
            }

            #bookingModal .modal-footer {
                padding: 10px 12px !important;
            }

            #bookingModal textarea {
                height: 50px !important;
            }

            #bookingModal .info-box {
                padding: 8px !important;
            }

            #bookingModal .form-group label {
                margin-bottom: 4px !important;
                font-size: 0.65rem !important;
            }

            #bookingModal .form-group input,
            #bookingModal .form-group select {
                padding-top: 8px !important;
                padding-bottom: 8px !important;
            }

            /* Vistas - permitir scroll completo sobre la barra del navegador */
            #viewWeek>div:last-child,
            #viewDay>div {
                padding-bottom: 100px !important;
            }
        }

        @media (max-width: 375px) {
            .calendar-cell {
                min-height: 50px;
                padding: 1px;
            }

            #viewMonth .calendar-cell {
                min-height: 50px;
            }

            #viewMonth .calendar-cell span.font-bold {
                width: 18px;
                height: 18px;
                font-size: 0.6rem;
            }

            #viewMonth .calendar-cell .text-xs {
                font-size: 0.5rem;
                padding: 1px 2px;
            }
        }

        /* Vista semanal responsiva para móviles */
        @media (max-width: 768px) {
            #viewWeek .week-container {
                min-width: 100% !important;
            }

            #viewWeek .week-header-cell {
                min-width: unset !important;
            }

            #viewWeek .week-hour-cell {
                min-width: 35px !important;
            }

            #viewWeek .week-day-cell {
                min-width: unset !important;
            }

            #viewWeek .week-booking-card {
                font-size: 0.5rem !important;
            }
        }

        @media (max-width: 480px) {
            #viewWeek .week-hour-cell {
                font-size: 0.5rem !important;
                min-width: 30px !important;
            }

            #viewWeek .week-header-cell .day-number {
                font-size: 0.7rem !important;
            }

            #viewWeek .week-header-cell .day-name {
                font-size: 0.45rem !important;
            }

            #viewWeek .week-booking-card {
                font-size: 0.45rem !important;
                padding: 1px 2px !important;
            }

            #viewWeek .week-row {
                min-height: 45px !important;
            }
        }

        @media (max-width: 767px) {
            /* En móvil la semana es una agenda: la leyenda y el filtro de horas no aplican */
            body.mobile-ux .week-toolbar {
                display: none !important;
            }

            .mobile-agenda {
                display: flex;
                flex-direction: column;
                gap: 12px;
                padding: 10px;
                padding-bottom: 110px;
            }

            .mobile-day-section {
                background: rgba(255, 255, 255, 0.92);
                border: 1px solid #e2e8f0;
                border-radius: 18px;
                overflow: hidden;
                box-shadow: 0 10px 25px -18px rgba(15, 23, 42, 0.35);
            }

            .dark .mobile-day-section {
                background: rgba(30, 41, 59, 0.92);
                border-color: #334155;
            }

            .mobile-day-title {
                display: flex;
                justify-content: space-between;
                align-items: center;
                gap: 10px;
                padding: 12px 14px;
                background: #f8fafc;
                border-bottom: 1px solid #e2e8f0;
            }

            .dark .mobile-day-title {
                background: #0f172a;
                border-color: #334155;
            }

            .mobile-hour-row {
                padding: 12px;
                border-bottom: 1px solid #f1f5f9;
            }

            .dark .mobile-hour-row {
                border-color: #334155;
            }

            .mobile-hour-row:last-child {
                border-bottom: 0;
            }

            .mobile-booking-card {
                display: flex;
                gap: 10px;
                padding: 12px;
                border-radius: 16px;
                border: 1px solid #e2e8f0;
                background: white;
                box-shadow: 0 8px 20px -16px rgba(15, 23, 42, 0.5);
            }

            .dark .mobile-booking-card {
                background: #0f172a;
                border-color: #334155;
            }

            .mobile-add-btn {
                width: 100%;
                min-height: 42px;
                border-radius: 14px;
                border: 1px dashed #c7d2fe;
                color: #4f46e5;
                background: #eef2ff;
                font-size: 0.82rem;
                font-weight: 800;
            }

            .dark .mobile-add-btn {
                border-color: #4338ca;
                color: #c7d2fe;
                background: rgba(79, 70, 229, 0.18);
            }

            .bitacora-panel {
                right: 0;
                width: 100vw;
            }

            .bit-tabs {
                overflow-x: auto;
            }

            .bit-tab {
                min-width: 118px;
                flex: 0 0 auto;
                font-size: 0.68rem;
                padding: 12px 8px;
            }

            .bit-content {
                padding: 12px;
                padding-bottom: 100px;
            }
        }

        .calendar-cell:hover {
            background-color: #f8fafc;
        }

        :where(button, input, select, textarea, [tabindex]):focus-visible {
            outline: 3px solid rgba(99, 102, 241, 0.55);
            outline-offset: 2px;
        }

        .custom-scrollbar::-webkit-scrollbar {
            height: 8px;
            width: 8px;
        }

        .custom-scrollbar::-webkit-scrollbar-track {
            background: transparent;
        }

        .custom-scrollbar::-webkit-scrollbar-thumb {
            background: #cbd5e1;
            border-radius: 4px;
            border: 2px solid #f1f5f9;
        }

        .custom-scrollbar::-webkit-scrollbar-thumb:hover {
            background: #94a3b8;
        }

        /* Loader */
        .loading-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(255, 255, 255, 0.8);
            backdrop-filter: blur(4px);
            z-index: 100;
            display: flex;
            justify-content: center;
            align-items: center;
            transition: opacity 0.3s;
        }

        /* Toast Notification */
        .toast {
            position: fixed;
            bottom: 24px;
            right: 24px;
            padding: 16px 24px;
            border-radius: 12px;
            color: white;
            font-weight: 500;
            transform: translateY(120px);
            transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
            z-index: 200;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            max-width: 90%;
            word-break: break-word;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .toast.show {
            transform: translateY(0);
        }

        .toast-success {
            background-color: #059669;
        }

        /* emerald-600 */
        .toast-error {
            background-color: #dc2626;
        }

        /* red-600 */
        .toast-warning {
            background-color: #d97706;
        }

        /* amber-600 */

        /* Card styles refined: solo se animan propiedades baratas (transform/sombra) */
        .booking-card {
            box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
            transition: transform 0.15s ease, box-shadow 0.15s ease;
        }

        .booking-card:hover {
            transform: translateY(-1px);
            box-shadow: 0 6px 16px -6px rgba(15, 23, 42, 0.25);
            z-index: 10;
        }

        /* === HEADER === */
        .header-grid {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            grid-template-areas: "brand actions" "nav nav";
            align-items: center;
            gap: 8px 12px;
        }

        .header-brand { grid-area: brand; }
        .header-nav { grid-area: nav; }
        .header-actions { grid-area: actions; }

        @media (min-width: 1024px) {
            .header-grid {
                grid-template-columns: auto minmax(0, 1fr) auto;
                grid-template-areas: "brand nav actions";
                gap: 8px 24px;
            }

            .header-nav {
                justify-self: center;
                width: 100%;
                max-width: 560px;
            }
        }

        .icon-btn {
            width: 38px;
            height: 38px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 10px;
            font-size: 1.2rem;
            color: #64748b;
            transition: background-color 0.15s, color 0.15s;
        }

        .icon-btn:hover { background: #f1f5f9; }
        .dark .icon-btn { color: #94a3b8; }
        .dark .icon-btn:hover { background: #1e293b; }
        .icon-btn.hidden { display: none !important; }

        .nav-btn {
            flex: none;
            width: 32px;
            height: 32px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            font-size: 1rem;
            color: #475569;
            transition: background-color 0.15s;
        }

        .nav-btn:hover { background: #fff; }
        .dark .nav-btn { color: #cbd5e1; }
        .dark .nav-btn:hover { background: #334155; }

        .today-btn {
            flex: none;
            height: 32px;
            padding: 0 12px;
            margin-left: 2px;
            border-radius: 8px;
            font-size: 0.75rem;
            font-weight: 700;
            color: #4f46e5;
            background: #fff;
            box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
            transition: background-color 0.15s;
        }

        .today-btn:hover { background: #eef2ff; }
        .dark .today-btn { color: #a5b4fc; background: #334155; box-shadow: none; }
        .dark .today-btn:hover { background: #3f4d63; }

        /* Selector de vista segmentado */
        .seg {
            display: inline-flex;
            padding: 4px;
            gap: 2px;
            border-radius: 12px;
            background: #f1f5f9;
        }

        .dark .seg { background: #1e293b; }

        .seg-btn {
            height: 32px;
            padding: 0 12px;
            border-radius: 8px;
            font-size: 0.75rem;
            font-weight: 600;
            color: #64748b;
            transition: background-color 0.15s, color 0.15s;
        }

        .seg-btn:hover { color: #0f172a; }
        .dark .seg-btn { color: #94a3b8; }
        .dark .seg-btn:hover { color: #fff; }

        .seg-btn.is-active {
            background: #fff;
            color: #4f46e5;
            font-weight: 700;
            box-shadow: 0 1px 2px rgba(15, 23, 42, 0.1);
        }

        .dark .seg-btn.is-active { background: #334155; color: #a5b4fc; box-shadow: none; }

        @media (max-width: 639px) {
            /* Movil: sin logo ni separador para que el titulo (con la version) quepa en dos lineas */
            .brand-mark, .actions-divider, .sync-btn { display: none; }
            #app-title { white-space: normal; overflow: visible; font-size: 14px; line-height: 1.2; }
            .header-actions { gap: 0; }
            .icon-btn { width: 38px; height: 38px; }
            .seg-btn { padding: 0 8px; }
            .today-btn { padding: 0 8px; }
            #dateDisplay { font-size: 0.8rem; padding: 0 2px; }

            /* La agenda movil ya trae sus propias tarjetas: sin marco extra alrededor */
            body.mobile-ux .day-container,
            body.mobile-ux .week-container {
                background: transparent;
                border: 0;
            }
        }

        /* Recarga en segundo plano: la vista sigue visible y usable */
        .view-pane { transition: opacity 0.2s ease; }
        main.is-refreshing .view-pane { opacity: 0.6; }

        @keyframes spin360 { to { transform: rotate(360deg); } }
        .is-syncing #syncIcon { animation: spin360 0.9s linear infinite; }
        .is-syncing #statusIndicator { animation: pulseDot 1s ease-in-out infinite; }
        @keyframes pulseDot { 50% { opacity: 0.35; } }

        /* overflow: clip recorta las esquinas sin crear contenedor de scroll, asi la cabecera sticky sigue fija
           (con overflow: hidden la cabecera se desplazaba junto con la rejilla) */
        .day-container,
        .week-container {
            overflow: clip;
        }

        /* === VISTA DÍA: rejilla hora x espacio, las citas de varias horas ocupan un solo bloque === */
        .day-head,
        .day-grid {
            display: grid;
            grid-template-columns: 72px repeat(4, minmax(0, 1fr));
        }

        .day-head {
            position: sticky;
            top: 0;
            z-index: 20;
            background: #f8fafc;
            border-bottom: 1px solid #e2e8f0;
        }

        .dark .day-head { background: #0f172a; border-color: #334155; }

        .day-grid { grid-auto-rows: minmax(84px, auto); }

        .day-time {
            padding: 10px 8px;
            font-size: 0.72rem;
            font-weight: 600;
            color: #64748b;
            text-align: right;
            border-bottom: 1px solid #f1f5f9;
            border-right: 1px solid #e2e8f0;
            background: #fff;
        }

        .dark .day-time { color: #94a3b8; background: #1e293b; border-color: #334155; }

        .day-slot {
            position: relative;
            padding: 4px;
            border-bottom: 1px solid #f1f5f9;
            border-right: 1px solid #f1f5f9;
            cursor: pointer;
            transition: background-color 0.12s;
        }

        .dark .day-slot { border-color: #334155; }
        .day-slot:hover { background: #f8fafc; }
        .dark .day-slot:hover { background: #273449; }

        .day-slot .slot-add {
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            color: #6366f1;
            font-size: 1.25rem;
            transition: opacity 0.12s;
        }

        .day-slot:hover .slot-add { opacity: 1; }

        .day-booking {
            height: 100%;
            padding: 8px 10px;
            border-radius: 10px;
            border-left-width: 4px;
            overflow: hidden;
        }

        /* === VISTA MES === */
        .month-chip {
            display: flex;
            align-items: center;
            gap: 5px;
            padding: 2px 6px;
            border-radius: 6px;
            font-size: 0.7rem;
            line-height: 1.35;
            background: #f8fafc;
            color: #334155;
            white-space: nowrap;
            overflow: hidden;
        }

        .dark .month-chip { background: #0f172a; color: #cbd5e1; }
        .calendar-cell.is-today { background: #eef2ff; }
        .dark .calendar-cell.is-today { background: #1e1b4b; }
        .month-chip b { font-weight: 700; color: #64748b; flex: none; }
        .dark .month-chip b { color: #94a3b8; }
        .month-chip span:last-child { overflow: hidden; text-overflow: ellipsis; }

        /* Modern Inputs */
        input:focus,
        select:focus,
        textarea:focus {
            box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15) !important;
        }

        /* Glass Text Protection for overlays */
        .text-shadow-sm {
            text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        }

        /* === BITÁCORA PANEL === */
        .bitacora-overlay {
            position: fixed;
            inset: 0;
            background: rgba(15, 23, 42, 0.4);
            backdrop-filter: blur(4px);
            z-index: 60;
            opacity: 0;
            pointer-events: none;
            transition: opacity 0.3s;
        }

        .bitacora-overlay.active {
            opacity: 1;
            pointer-events: auto;
        }

        .bitacora-panel {
            position: fixed;
            top: 0;
            right: 0;
            width: 480px;
            max-width: 100vw;
            height: 100vh;
            height: 100dvh;
            background: white;
            z-index: 70;
            transform: translateX(100%);
            transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
            display: flex;
            flex-direction: column;
            box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
        }

        .dark .bitacora-panel {
            background: #1e293b;
        }

        .bitacora-panel.open {
            transform: translateX(0);
        }

        @media (max-width: 767px) {
            header,
            .loading-overlay,
            .bitacora-overlay,
            #bookingModal,
            #historyModal,
            #adminConsoleModal {
                backdrop-filter: none !important;
            }

            .calendar-cell { min-height: 68px; }
            #viewMonth .calendar-cell .text-xs { font-size: 0.62rem; line-height: 1.1; }
            .bit-btn, .bit-input { min-height: 42px; }
        }

        @media (prefers-reduced-motion: reduce) {
            *, *::before, *::after {
                scroll-behavior: auto !important;
                animation-duration: 0.01ms !important;
                animation-iteration-count: 1 !important;
                transition-duration: 0.01ms !important;
            }
        }

        .bit-tabs {
            display: flex;
            border-bottom: 2px solid #e2e8f0;
            flex-shrink: 0;
        }

        .dark .bit-tabs {
            border-color: #334155;
        }

        .bit-tab {
            flex: 1;
            padding: 10px 6px;
            text-align: center;
            font-size: 0.7rem;
            font-weight: 700;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            transition: all 0.2s;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }

        .bit-tab:hover {
            color: #4f46e5;
            background: #f8fafc;
        }

        .dark .bit-tab:hover {
            background: #334155;
        }

        .bit-tab.active {
            color: #4f46e5;
            border-bottom-color: #4f46e5;
            background: #eef2ff;
        }

        .dark .bit-tab.active {
            color: #818cf8;
            border-bottom-color: #818cf8;
            background: rgba(99, 102, 241, 0.1);
        }

        .bit-content {
            flex: 1;
            overflow-y: auto;
            padding: 16px;
        }

        .bit-card {
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            border-radius: 12px;
            padding: 12px 14px;
            margin-bottom: 10px;
            cursor: pointer;
            transition: all 0.2s;
            position: relative;
        }

        .dark .bit-card {
            background: #0f172a;
            border-color: #334155;
        }

        .bit-card:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
        }

        .bit-badge {
            display: inline-flex;
            align-items: center;
            padding: 2px 8px;
            border-radius: 999px;
            font-size: 0.65rem;
            font-weight: 700;
        }

        .badge-dictada {
            background: #d1fae5;
            color: #065f46;
        }

        .badge-reprogramada {
            background: #fef3c7;
            color: #92400e;
        }

        .badge-falta {
            background: #fee2e2;
            color: #991b1b;
        }

        .badge-pendiente {
            background: #f1f5f9;
            color: #475569;
        }

        .dark .badge-dictada {
            background: rgba(16, 185, 129, 0.2);
            color: #6ee7b7;
        }

        .dark .badge-reprogramada {
            background: rgba(245, 158, 11, 0.2);
            color: #fcd34d;
        }

        .dark .badge-falta {
            background: rgba(239, 68, 68, 0.2);
            color: #fca5a5;
        }

        .dark .badge-pendiente {
            background: rgba(100, 116, 139, 0.2);
            color: #94a3b8;
        }

        .progress-ring {
            width: 100%;
            height: 8px;
            background: #e2e8f0;
            border-radius: 999px;
            overflow: hidden;
        }

        .dark .progress-ring {
            background: #334155;
        }

        .progress-ring-fill {
            height: 100%;
            border-radius: 999px;
            transition: width 0.5s ease;
        }

        .bit-input {
            width: 100%;
            padding: 8px 12px;
            border: 1px solid #e2e8f0;
            border-radius: 10px;
            font-size: 0.85rem;
            outline: none;
            transition: all 0.2s;
            background: white;
        }

        .dark .bit-input {
            background: #0f172a;
            border-color: #334155;
            color: #f1f5f9;
        }

        .bit-input:focus {
            border-color: #6366f1;
            box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
        }

        .bit-btn {
            padding: 8px 16px;
            border-radius: 10px;
            font-weight: 700;
            font-size: 0.8rem;
            cursor: pointer;
            transition: all 0.2s;
            border: none;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .bit-btn-primary {
            background: #4f46e5;
            color: white;
        }

        .bit-btn-primary:hover {
            background: #4338ca;
        }

        .bit-btn-danger {
            background: #fee2e2;
            color: #dc2626;
        }

        .bit-btn-danger:hover {
            background: #fecaca;
        }

        .bit-btn-ghost {
            background: transparent;
            color: #64748b;
        }

        .bit-btn-ghost:hover {
            background: #f1f5f9;
        }

        .dark .bit-btn-ghost {
            color: #cbd5e1;
        }

        .dark .bit-btn-ghost:hover {
            background: #334155;
        }

        .dark .bit-btn-danger {
            background: rgba(239, 68, 68, 0.15);
            color: #f87171;
        }

        .dark .bit-btn-danger:hover {
            background: rgba(239, 68, 68, 0.25);
        }

        .bit-empty {
            text-align: center;
            padding: 40px 20px;
            color: #94a3b8;
        }

        .bit-empty i {
            font-size: 2.5rem;
            margin-bottom: 8px;
            display: block;
            opacity: 0.5;
        }

        .vencimiento-ok {
            color: #059669;
        }

        .vencimiento-warn {
            color: #d97706;
        }

        .vencimiento-danger {
            color: #dc2626;
            font-weight: 700;
        }

        /* --- Bitácora Dark Mode Improvements --- */
        .bit-label {
            font-size: 0.75rem;
            font-weight: 700;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            display: block;
            margin-bottom: 6px;
        }

        .dark .bit-label {
            color: #94a3b8;
        }

        .bit-text-secondary {
            font-size: 0.7rem;
            color: #64748b;
        }

        .dark .bit-text-secondary {
            color: #94a3b8;
        }

        .bit-text-muted {
            font-size: 0.65rem;
            color: #94a3b8;
        }

        .dark .bit-text-muted {
            color: #64748b;
        }

        .bit-sesion-item {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 10px;
            border-radius: 8px;
            margin-bottom: 4px;
            background: #f8fafc;
            border: 1px solid #e2e8f0;
            font-size: 0.8rem;
        }

        .dark .bit-sesion-item {
            background: #1e293b;
            border-color: #334155;
            color: #e2e8f0;
        }

        .bit-sesion-date {
            font-weight: 600;
            color: #1e293b;
        }

        .dark .bit-sesion-date {
            color: #f1f5f9;
        }

        .bit-estado-select {
            font-size: 0.7rem;
            padding: 4px 6px;
            border-radius: 6px;
            border: 1px solid #e2e8f0;
            font-weight: 700;
            cursor: pointer;
            background: white;
            color: #334155;
        }

        .dark .bit-estado-select {
            background: #0f172a;
            border-color: #475569;
            color: #e2e8f0;
        }

        .bit-paq-header {
            font-weight: 700;
            font-size: 0.85rem;
            color: #1e293b;
        }

        .dark .bit-paq-header {
            color: #f1f5f9;
        }

        .bit-paq-dates {
            font-size: 0.7rem;
            color: #64748b;
            margin-top: 2px;
        }

        .dark .bit-paq-dates {
            color: #94a3b8;
        }

        .bit-progress-text {
            display: flex;
            justify-content: space-between;
            font-size: 0.7rem;
            font-weight: 600;
            margin-bottom: 4px;
            color: #334155;
        }

        .dark .bit-progress-text {
            color: #cbd5e1;
        }

        .bit-dashed-border {
            margin-top: 12px;
            padding-top: 12px;
            border-top: 1px dashed #e2e8f0;
        }

        .dark .bit-dashed-border {
            border-color: #475569;
        }

        .bit-form-green {
            background: #f0fdf4;
            border: 1px solid #bbf7d0;
            border-radius: 10px;
            padding: 10px;
            margin-bottom: 8px;
        }

        .dark .bit-form-green {
            background: rgba(16, 185, 129, 0.08);
            border-color: #065f46;
        }

        .bit-form-blue {
            background: #eff6ff;
            border: 1px solid #bfdbfe;
            border-radius: 10px;
            padding: 12px 14px;
            margin-bottom: 10px;
        }

        .dark .bit-form-blue {
            background: rgba(99, 102, 241, 0.08);
            border-color: #312e81;
        }

        .bit-form-label {
            font-weight: 700;
            font-size: 0.8rem;
            margin-bottom: 10px;
            color: #1e40af;
        }

        .dark .bit-form-label {
            color: #93c5fd;
        }

        .bit-form-sublabel {
            font-size: 0.65rem;
            font-weight: 600;
            color: #64748b;
        }

        .dark .bit-form-sublabel {
            color: #94a3b8;
        }

        .bit-client-header {
            font-size: 1.1rem;
            font-weight: 800;
            display: flex;
            align-items: center;
            gap: 6px;
            color: #1e293b;
        }

        .dark .bit-client-header {
            color: #f1f5f9;
        }

        .bit-client-phone {
            font-size: 0.75rem;
            color: #64748b;
        }

        .dark .bit-client-phone {
            color: #94a3b8;
        }

        .bit-form-green-label {
            font-weight: 700;
            font-size: 0.8rem;
            margin-bottom: 10px;
            color: #065f46;
        }

        .dark .bit-form-green-label {
            color: #6ee7b7;
        }

/* =====================================================================
   REFINAMIENTO VISUAL
   ===================================================================== */

/* Chip de version junto al titulo */
.version-chip {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 7px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.02em;
    color: var(--brand);
    background: var(--brand-soft);
    border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
    flex: none;
}

/* Contencion de pintado: cada celda del calendario se aisla del resto */
.week-day-cell,
.calendar-cell,
.mobile-hour-row {
    contain: layout style;
}

/* Tarjetas de cita: mismo criterio en semana y dia */
.week-booking-card {
    border-radius: 8px;
    border-width: 1px;
    box-shadow: var(--shadow-1);
}

.week-booking-card:hover {
    box-shadow: var(--shadow-2);
}

.day-booking {
    border-radius: 10px;
    box-shadow: var(--shadow-1);
}

@media (hover: none) {
    .booking-card:hover,
    .bit-card:hover,
    .week-booking-card:hover {
        transform: none;
    }
}

/* Mes: hoy con anillo, mas sobrio que el circulo relleno */
.calendar-cell.is-today {
    background: var(--brand-soft);
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 35%, transparent);
}

.today-number {
    box-shadow: inset 0 0 0 2px var(--brand);
    border-radius: 999px;
}

.month-chip {
    max-width: 100%;
    border-radius: 7px;
    background: var(--surface-3);
}

.dark .month-chip {
    background: var(--surface-2);
}

/* Scrollbar coherente en modo oscuro */
.dark .custom-scrollbar::-webkit-scrollbar-thumb {
    background: #475569;
    border-color: #1e293b;
}

/* Cabecera: marca un poco mas compacta y sin ruido */
.brand-mark {
    border-radius: 12px;
    box-shadow: 0 6px 16px -8px rgba(79, 70, 229, 0.55);
}

/* En movil la agenda mantiene el titulo del dia a la vista */
@media (max-width: 767px) {
    .mobile-day-title {
        position: sticky;
        top: 0;
        z-index: 5;
        backdrop-filter: none;
    }

    .mobile-booking-card {
        min-height: 56px;
    }

    .mobile-add-btn {
        min-height: 46px;
    }
}

/* --- Cargador con esqueleto (en vez de spinner a pantalla completa) --- */
.dark .loading-overlay {
    background: rgba(15, 23, 42, 0.82);
}

.skeleton-panel {
    width: min(920px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border-radius: var(--radius-lg);
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-2);
}

.skeleton-bar {
    height: 14px;
    width: 42%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
    background-size: 400% 100%;
    animation: skeletonShimmer 1.4s ease infinite;
}

.skeleton-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

.skeleton-cell {
    height: 76px;
    border-radius: var(--radius-md);
    background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
    background-size: 400% 100%;
    animation: skeletonShimmer 1.4s ease infinite;
}

.skeleton-cell:nth-child(2n) { animation-delay: 0.12s; }
.skeleton-cell:nth-child(3n) { animation-delay: 0.24s; }

@keyframes skeletonShimmer {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* --- Dialogo propio (confirm / alert / prompt) --- */
.dialog-overlay {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
}

.dialog-overlay.hidden { display: none; }

.dialog-card {
    width: 100%;
    max-width: 400px;
    padding: 22px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: 0 24px 60px -24px rgba(15, 23, 42, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    transform: translateY(8px) scale(0.98);
    opacity: 0;
    transition: transform 0.18s var(--ease-out), opacity 0.18s var(--ease-out);
}

.dialog-card.dialog-in {
    transform: none;
    opacity: 1;
}

.dialog-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    margin-bottom: 4px;
}

.dialog-icon-danger { background: #fee2e2; color: var(--danger); }
.dialog-icon-primary { background: var(--brand-soft); color: var(--brand); }
.dialog-icon-info { background: #e0f2fe; color: #0284c7; }

.dark .dialog-icon-danger { background: rgba(239, 68, 68, 0.18); color: #fca5a5; }
.dark .dialog-icon-primary { background: rgba(99, 102, 241, 0.18); color: #a5b4fc; }
.dark .dialog-icon-info { background: rgba(14, 165, 233, 0.18); color: #7dd3fc; }

.dialog-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--text-strong);
    letter-spacing: -0.01em;
}

.dialog-message {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-muted);
    white-space: pre-line;
}

.dialog-input {
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--text-strong);
    font-size: 0.9rem;
    outline: none;
}

.dialog-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.16);
}

.dialog-input.hidden { display: none; }

.dialog-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-top: 16px;
}

.dialog-btn {
    flex: 1;
    min-height: 42px;
    border-radius: 11px;
    font-size: 0.83rem;
    font-weight: 700;
    transition: background-color 0.15s, color 0.15s;
}

.dialog-btn-danger {
    background: var(--danger);
    color: #fff;
}

.dialog-btn-danger:hover { background: #b91c1c; }

.dialog-btn-primary {
    background: var(--brand);
    color: #fff;
}

.dialog-btn-primary:hover { background: var(--brand-strong); }

.dialog-btn-ghost {
    background: var(--surface-3);
    color: var(--text);
}

.dialog-btn-ghost:hover { background: var(--line); }

.dark .dialog-btn-ghost { background: var(--surface-3); }

/* Toast: mismo lenguaje visual en escritorio */
@media (min-width: 768px) {
    .toast {
        border-radius: 14px;
        box-shadow: 0 18px 40px -20px rgba(15, 23, 42, 0.55);
    }
}
