400;500;600;700&display=swap');

        :root {
            --bg-body: #f3f4f6; --bg-surface: #ffffff;
            --primary-color: #271b54; --primary-hover: #1e1540;
            --accent-color: #00913f; --accent-hover: #007834;
            --text-main: #1f2937; --text-muted: #6b7280;
            --border-color: #e5e7eb;
            --danger-color: #ef4444; --warning-color: #f59e0b; --info-color: #3b82f6;
            --radius-md: 8px; --radius-lg: 12px;
            --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
            --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            --transition: all 0.2s ease-in-out;
        }
        * { box-sizing: border-box; }
        body { font-family: 'Inter', sans-serif; background-color: var(--bg-body); color: var(--text-main); margin: 0; padding: 20px 15px; line-height: 1.5; }
        
        #app-container { max-width: 1280px; margin: 0 auto; animation: fadeIn 0.4s ease; }

        .header { text-align: center; margin-bottom: 30px; padding: 30px 20px; background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 15px;}
        .header-content { display: flex; flex-direction: column; align-items: center; flex: 1; }
        .logo-placeholder { max-width: 180px; margin: 0 auto 15px auto; display: block; }
        .header h1 { color: var(--primary-color); font-size: 1.25rem; margin: 0; text-transform: uppercase; letter-spacing: 1.5px; font-weight: 700; }
        
        .tabs { display: flex; justify-content: center; gap: 10px; margin-bottom: 25px; flex-wrap: wrap; }
        .tab-btn { background: var(--bg-surface); border: 1px solid var(--border-color); color: var(--text-muted); padding: 12px 24px; font-size: 0.9rem; font-weight: 600; border-radius: 30px; cursor: pointer; transition: var(--transition); box-shadow: var(--shadow-sm); }
        .tab-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); box-shadow: 0 4px 10px rgba(39, 27, 84, 0.2); }
        .tab-btn:hover:not(.active) { background: #f9fafb; color: var(--primary-color); border-color: var(--border-color); }
        
        .view-section { display: none; animation: fadeIn 0.3s ease; }
        .view-section.active { display: block; }
        @keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

        .form-card { background-color: var(--bg-surface); padding: 30px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); margin-bottom: 30px; border: 1px solid var(--border-color); }
        .form-title { color: var(--primary-color); margin-top: 0; margin-bottom: 25px; font-size: 1.1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
        .form-title::before { content: ''; display: inline-block; width: 4px; height: 18px; background-color: var(--accent-color); border-radius: 4px; }
        
        .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; }
        .form-group { display: flex; flex-direction: column; }
        .form-group.full-width { grid-column: 1 / -1; }
        label { margin-bottom: 6px; font-weight: 600; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
        input, select, textarea { padding: 12px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 0.9rem; transition: var(--transition); background: #f9fafb; color: var(--text-main); font-family: inherit; }
        input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary-color); background: var(--bg-surface); box-shadow: 0 0 0 3px rgba(39, 27, 84, 0.1); }
        
        /* Contenedor de Dispositivos Dinámicos */
        .dispositivo-card {
            background: #fdfdfd;
            border: 1px solid #e2e8f0;
            border-left: 4px solid var(--primary-color);
            border-radius: var(--radius-md);
            padding: 16px;
            margin-bottom: 15px;
            position: relative;
        }
        .dispositivo-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 12px;
            font-size: 0.85rem;
            font-weight: 700;
            color: var(--primary-color);
        }

        .btn { background-color: var(--primary-color); color: white; padding: 12px 24px; border: none; border-radius: var(--radius-md); cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: var(--transition); display: inline-flex; justify-content: center; align-items: center; gap: 8px; }
        .btn:hover { background-color: var(--primary-hover); transform: translateY(-1px); }
        .btn-success { background-color: var(--accent-color); }
        .btn-success:hover { background-color: var(--accent-hover); }
        .btn-outline { background-color: transparent; color: var(--text-main); border: 1px solid var(--border-color); }
        .btn-outline:hover { background-color: #f3f4f6; color: var(--primary-color); border-color: var(--primary-color); }
        
        .btn-sm { padding: 6px 12px; font-size: 0.75rem; border-radius: 6px; border: none; cursor: pointer; font-weight: 600; color: white; transition: var(--transition); }
        .btn-sm:hover { opacity: 0.9; transform: translateY(-1px); }
        .btn-sm-danger { background-color: var(--danger-color); }
        .btn-sm-warning { background-color: var(--warning-color); color: #000; }
        .btn-sm-success { background-color: var(--accent-color); }
        .btn-sm-info { background-color: var(--primary-color); }

        .btn-icon {
            width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
            border-radius: 8px; border: none; cursor: pointer; transition: var(--transition); color: white;
            padding: 0; box-shadow: var(--shadow-sm); position: relative;
        }
        .btn-icon:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); opacity: 0.95; }
        .btn-icon svg { width: 17px; height: 17px; stroke-width: 2.2; }
        .btn-icon-success { background-color: var(--accent-color); }
        .btn-icon-info { background-color: #0284c7; }
        .btn-icon-wa { background-color: #25D366; }
        .btn-icon-warning { background-color: #f59e0b; color: #1f2937; }
        .btn-icon-danger { background-color: var(--danger-color); }
        /* Alertas visuales de antigüedad */
        tr.alerta-demora-critica td {
            background-color: #fef2f2 !important;
        }
        tr.alerta-demora-critica td:first-child {
            border-left: 4px solid var(--danger-color) !important;
        }
        tr.alerta-demora-media td {
            background-color: #fffbeb !important;
        }
        tr.alerta-demora-media td:first-child {
            border-left: 4px solid var(--warning-color) !important;
        }
        .badge-alerta-dias {
            display: inline-flex; align-items: center; gap: 4px;
            font-size: 0.7rem; font-weight: 700; padding: 2px 7px;
            border-radius: 12px; margin-top: 4px;
        }
        .badge-alerta-critica {
            background: #fee2e2; color: #b91c1c; border: 1px solid #f87171;
            animation: pulseAlert 2s infinite;
        }
        .badge-alerta-media {
            background: #fef3c7; color: #b45309; border: 1px solid #fcd34d;
        }
        @keyframes pulseAlert {
            0% { opacity: 1; }
            50% { opacity: 0.7; }
            100% { opacity: 1; }
        }
        .btn-icon-wa-direct {
            background-color: #128C7E;
        }
        .btn-icon-wa-direct:hover {
            background-color: #075E54;
        }



        .table-responsive { overflow-x: auto; background: var(--bg-surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 20px; }
        table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
        th, td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border-color); vertical-align: middle; }
        th { background-color: #f9fafb; color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; white-space: nowrap; }
        tr:last-child td { border-bottom: none; }
        tr:hover td { background-color: #f9fafb; }
        
.select-estado-taller { padding: 6px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; border: none; cursor: pointer; text-align: center; outline: none; transition: var(--transition); }
        .estado-taller { background: #fef3c7; color: #d97706; }
        .estado-revisando { background: #ede9fe; color: #6d28d9; }
        .estado-progreso { background: #e0f2fe; color: #0284c7; }
        .estado-listo { background: #dcfce7; color: #15803d; }
        
        .estado-badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
        .estado-pagado { background: #dcfce7; color: #15803d; }
        .estado-abono { background: #fef3c7; color: #d97706; }
        .estado-pendiente { background: #fee2e2; color: #b91c1c; }
        .estado-garantia { background: #e0e7ff; color: #4338ca; }
        
        .badge-calidad { padding: 3px 8px; border-radius: 12px; font-size: 0.7rem; font-weight: 600; display: inline-block; background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; margin-top: 3px; }

        .acciones-td { display: flex; gap: 6px; flex-wrap: wrap; }

        /* Controles de búsqueda y filtros */
        .controls-section { display: flex; flex-direction: column; gap: 15px; margin-bottom: 25px; background: var(--bg-surface); padding: 20px; border-radius: var(--radius-lg); border: 1px solid var(--border-color); box-shadow: var(--shadow-sm); }
        .controls-row { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 15px; }
        .search-group { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
        .input-buscador {
            min-width: 260px; padding: 10px 14px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 0.9rem;
            background: #fff url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="%236b7280" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>') no-repeat 10px center; padding-left: 35px;
        }

        /* Estructura del Reporte por Bloques de Días */
        .bloque-dia {
            background: var(--bg-surface);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-lg);
            margin-bottom: 25px;
            overflow: hidden;
            box-shadow: var(--shadow-sm);
        }
        .bloque-dia-header {
            background: #f8fafc;
            padding: 12px 20px;
            border-bottom: 2px solid #e2e8f0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            font-weight: 700;
            color: var(--primary-color);
            font-size: 0.95rem;
        }
        .bloque-dia-subtotal {
            font-size: 0.85rem;
            color: var(--text-muted);
            font-weight: 500;
        }
        .bloque-dia-subtotal strong {
            color: var(--accent-color);
        }

        .totales-dia { display: flex; justify-content: flex-end; gap: 20px; margin-top: 25px; padding: 25px; background: var(--bg-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); flex-wrap: wrap; }
        .total-item { text-align: right; }
        .total-item span { display: block; font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; font-weight: 600; }
        .total-item strong { font-size: 1.35rem; color: var(--text-main); font-weight: 700; }
        .total-ganancia strong { color: var(--accent-color); }
        .total-por-cobrar strong { color: var(--danger-color); }

        #tituloImpresionDocumento { display: none; color: var(--primary-color); text-align: center; border-bottom: 2px solid var(--border-color); padding-bottom: 10px; margin-bottom: 20px; }

        #toast-container { position: fixed; bottom: 25px; right: 25px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
        .toast { background: var(--bg-surface); color: var(--text-main); padding: 16px 20px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); border-left: 4px solid var(--primary-color); display: flex; align-items: center; gap: 12px; font-size: 0.9rem; font-weight: 500; min-width: 250px; animation: slideIn 0.3s ease forwards; }
        .toast.success { border-left-color: var(--accent-color); }
        .toast.error { border-left-color: var(--danger-color); }
        .toast.fadeOut { animation: fadeOut 0.3s ease forwards; }
        @keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
        @keyframes fadeOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-10px); } }

        .modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(17, 24, 39, 0.6); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 10000; opacity: 0; visibility: hidden; transition: all 0.2s ease; }
        .modal-overlay.active { opacity: 1; visibility: visible; }
        .modal-content { background: var(--bg-surface); padding: 30px; border-radius: var(--radius-lg); width: 90%; max-width: 400px; box-shadow: var(--shadow-lg); text-align: center; transform: scale(0.95); transition: all 0.2s ease; border: 1px solid var(--border-color); }
        .modal-overlay.active .modal-content { transform: scale(1); }
        .modal-title { font-size: 1.1rem; color: var(--text-main); font-weight: 700; margin: 0 0 10px 0; }
        .modal-text { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 25px; line-height: 1.5; }
        .modal-actions { display: flex; justify-content: center; gap: 12px; }

        @media (max-width: 768px) {
            .tabs { gap: 5px; }
            .tab-btn { padding: 10px 15px; font-size: 0.8rem; flex: 1; text-align: center; }
            .controls-row { flex-direction: column; align-items: stretch; }
            .search-group { flex-direction: column; align-items: stretch; }
            .export-buttons { display: flex; flex-direction: column; gap: 10px; }
            .totales-dia { justify-content: space-between; gap: 15px; padding: 15px; }
            .total-item strong { font-size: 1.15rem; }
            #toast-container { bottom: 20px; right: 20px; left: 20px; }
            .toast { width: 100%; }
        }

        @media print {
            .no-print, #toast-container, .modal-overlay { display: none !important; }
            body { padding: 0; background: white; }
            #app-container { box-shadow: none; padding: 0; max-width: 100%; }
            .form-card, .totales-dia { box-shadow: none; border: 1px solid #ddd; }
            .bloque-dia { box-shadow: none !important; border: 1px solid #ddd !important; margin-bottom: 20px !important; }
            .table-responsive { overflow: visible !important; box-shadow: none !important; border: none !important; margin-bottom: 0 !important; background: transparent !important; }
            table { width: 100% !important; border-collapse: collapse !important; }
            th, td { border: 1px solid #e5e7eb !important; padding: 10px !important; }
            th { background-color: #f9fafb !important; color: #1f2937 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
            .estado-badge, .select-estado-taller { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
            .acciones-td, th.th-acciones { display: none !important; }
            .th-estado-trabajo, .td-estado-trabajo { display: none !important; }
            #tituloImpresionDocumento { display: block; }
        }
    
body { font-family: Inter, system-ui, sans-serif; background: #eef2f7; }
.header { text-align: left; justify-content: space-between; background: #20163f; color: #fff; }
.header-content { align-items: flex-start; }
.header h1 { color: #e5ddfa; text-transform: none; letter-spacing: 0; font-size: 1rem; font-weight: 500; }
.brand-wordmark { color: #fff; font-size: clamp(1.3rem, 4vw, 2rem); font-weight: 800; letter-spacing: .05em; }
.header .btn-outline { color: #fff; border-color: #8979a8; }
.header .btn-outline:hover { color: #20163f; }
.tabs { justify-content: flex-start; }
.btn:disabled { opacity: .6; cursor: wait; }
input, select, textarea { min-width: 0; }
.login-card { max-width: 440px; margin: 10vh auto; }
.login-card .brand-wordmark { color: var(--primary-color); }
.login-card form { display: grid; gap: 12px; }
.login-card form p { margin: 0; display: grid; }
.login-card form .errorlist { color: #a71d2a; padding-left: 18px; }
@media (max-width: 600px) {
    .form-card { padding: 16px; }
    .input-buscador { min-width: 0; width: 100%; }
    .header { padding: 16px; }
    .header .btn { padding: 8px 12px; }
}

[hidden] { display: none !important; }

@media print { [data-private] { display: none !important; } }