* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* MEL INTERIORES — iOS 26 Liquid Glass (iPhone 17) */
    --primary-color: #007AFF;       /* iOS system blue */
    --secondary-color: #5856D6;     /* indigo */
    --tertiary-color: #AF52DE;      /* purple */
    --neutral-color: #8E8E93;       /* iOS gray */
    --accent-color: #007AFF;        /* vibrant blue accent */
    --accent-hover: #0051D5;        /* deeper blue */
    --danger-color: #FF3B30;        /* iOS red */
    --warning-color: #FF9500;       /* iOS orange */
    --success-color: #34C759;       /* iOS green */
    --light-bg: #F2F2F7;            /* iOS system background */
    --card-bg: rgba(255, 255, 255, 0.72);   /* translúcido glass */
    --card-bg-solid: #FFFFFF;       /* solid fallback */
    --border-color: rgba(60, 60, 67, 0.12);  /* iOS separator */
    --border-strong: rgba(60, 60, 67, 0.29);
    --text-color: #1C1C1E;          /* iOS label */
    --text-muted: #8E8E93;          /* iOS secondary label */
    --white: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --blur-glass: blur(20px) saturate(180%);
}

/* Dark Mode ─ transición suave en todo el DOM */
*, *::before, *::after {
    transition: background-color 0.25s ease, color 0.15s ease, border-color 0.25s ease;
}

:root.dark-mode {
    --light-bg: #0F0F11;
    --card-bg: rgba(30, 30, 34, 0.92);
    --card-bg-solid: #1E1E22;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.16);
    --text-color: #E8E8ED;
    --text-muted: #8E8E93;
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.50);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.55);
    --shadow-lg: 0 12px 36px rgba(0,0,0,0.70);
}

:root.dark-mode body {
    background: #0F0F11;
    color: #E8E8ED;
}

/* Sidebar — mantiene el azul pero más oscuro */
:root.dark-mode .sidebar {
    background: linear-gradient(180deg, #1a2744 0%, #0d1a36 100%) !important;
    border-right: 1px solid rgba(255,255,255,0.06) !important;
}

:root.dark-mode .sidebar-item { color: #D0D8F0 !important; }
:root.dark-mode .sidebar-item:hover { background: rgba(255,255,255,0.07) !important; }
:root.dark-mode .sidebar-item.active { background: rgba(0,122,255,0.30) !important; }

/* Cards y secciones principales */
:root.dark-mode .card,
:root.dark-mode .view-header,
:root.dark-mode .filters {
    background: rgba(30, 30, 34, 0.92) !important;
    border-color: rgba(255,255,255,0.08) !important;
    color: #E8E8ED !important;
}

:root.dark-mode .card h3,
:root.dark-mode .card h2 { color: #E8E8ED !important; }

/* Inputs */
:root.dark-mode input:not([type="checkbox"]):not([type="radio"]):not([type="color"]),
:root.dark-mode select,
:root.dark-mode textarea {
    background: #2A2A2E !important;
    color: #E8E8ED !important;
    border-color: rgba(255,255,255,0.12) !important;
}

:root.dark-mode input::placeholder,
:root.dark-mode textarea::placeholder { color: #636366 !important; }

/* Tablas */
:root.dark-mode table { color: #E8E8ED !important; }
:root.dark-mode table th {
    background: #1A1A1E !important;
    color: #8E8E93 !important;
    border-bottom: 1px solid rgba(255,255,255,0.08) !important;
}
:root.dark-mode table td { border-color: rgba(255,255,255,0.05) !important; }
:root.dark-mode table tr:hover { background: rgba(255,255,255,0.04) !important; }

/* Filas coloreadas de presupuestos — versión dark */
:root.dark-mode tr[style*="background:#e8f5e9"],
:root.dark-mode tr[style*="background: #e8f5e9"] { background: rgba(52,199,89,0.12) !important; }
:root.dark-mode tr[style*="background:#fffde7"],
:root.dark-mode tr[style*="background: #fffde7"] { background: rgba(255,149,0,0.12) !important; }
:root.dark-mode tr[style*="background:#ffebee"],
:root.dark-mode tr[style*="background: #ffebee"] { background: rgba(255,59,48,0.14) !important; }

/* Modales */
:root.dark-mode .modal-content {
    background: #1E1E22 !important;
    color: #E8E8ED !important;
    border: 1px solid rgba(255,255,255,0.10) !important;
}
:root.dark-mode .modal-header { border-bottom-color: rgba(255,255,255,0.08) !important; }
:root.dark-mode .modal-footer { border-top-color: rgba(255,255,255,0.08) !important; }

/* Badges, pills y estados */
:root.dark-mode .badge { filter: brightness(0.88) saturate(1.1); }

/* Dropdowns */
:root.dark-mode .dropdown,
:root.dark-mode [class*="dropdown"] {
    background: #2A2A2E !important;
    border-color: rgba(255,255,255,0.10) !important;
    color: #E8E8ED !important;
}

/* Login */
:root.dark-mode .login-card { background: #1E1E22 !important; }

/* Scrollbar dark */
:root.dark-mode ::-webkit-scrollbar-track { background: #1A1A1E; }
:root.dark-mode ::-webkit-scrollbar-thumb { background: #3A3A3E; border-radius: 4px; }
:root.dark-mode ::-webkit-scrollbar-thumb:hover { background: #4A4A4E; }

/* ── COBERTURA COMPLETA DARK MODE ─────────────────────────────────── */

/* Fondos blancos/claros genéricos (inline styles y clases) */
:root.dark-mode [style*="background:white"],
:root.dark-mode [style*="background: white"],
:root.dark-mode [style*="background:#fff"],
:root.dark-mode [style*="background: #fff"],
:root.dark-mode [style*="background:#ffffff"],
:root.dark-mode [style*="background: #ffffff"],
:root.dark-mode [style*="background-color:white"],
:root.dark-mode [style*="background-color: white"] {
    background: #1E1E22 !important;
    color: #E8E8ED !important;
}

/* Grises claros comunes (#f5f5f5, #f9f9f9, #f8f8f8, #f8f9fa, #fafbfc, #f9fafb) */
:root.dark-mode [style*="background:#f5f5f5"],
:root.dark-mode [style*="background:#f9f9f9"],
:root.dark-mode [style*="background:#f8f9fa"],
:root.dark-mode [style*="background:#fafbfc"],
:root.dark-mode [style*="background:#f9fafb"],
:root.dark-mode [style*="background:#f6f6f6"],
:root.dark-mode [style*="background:#f8f8f8"] {
    background: #2A2A2E !important;
    color: #E8E8ED !important;
}

/* Info-boxes azuladas (#f0f8ff, #f0f4ff, #e3f2fd, #e8f4fd, #f0f7ff, #f0f4fa) */
:root.dark-mode [style*="background:#f0f8ff"],
:root.dark-mode [style*="background:#f0f4ff"],
:root.dark-mode [style*="background:#e3f2fd"],
:root.dark-mode [style*="background:#e8f4fd"],
:root.dark-mode [style*="background:#f0f7ff"],
:root.dark-mode [style*="background:#f0f4fa"],
:root.dark-mode [style*="background:#dbeafe"] {
    background: rgba(0, 122, 255, 0.12) !important;
    border-color: rgba(0, 122, 255, 0.25) !important;
    color: #E8E8ED !important;
}

/* Info-boxes amarillas/warning (#fff3cd, #fffde7, #fff8e1, #fff8f0, #fff3e0) */
:root.dark-mode [style*="background:#fff3cd"],
:root.dark-mode [style*="background:#fffde7"],
:root.dark-mode [style*="background:#fff8e1"],
:root.dark-mode [style*="background:#fff8f0"],
:root.dark-mode [style*="background:#fff3e0"],
:root.dark-mode [style*="background:#f5f2ee"] {
    background: rgba(255, 149, 0, 0.12) !important;
    border-color: rgba(255, 149, 0, 0.25) !important;
    color: #E8E8ED !important;
}

/* Info-boxes verdes (#d4edda, #e8f5e9, #e9f7ef, #f0faf0) */
:root.dark-mode [style*="background:#d4edda"],
:root.dark-mode [style*="background:#e8f5e9"],
:root.dark-mode [style*="background:#f0faf0"],
:root.dark-mode [style*="background:#e9f7ef"] {
    background: rgba(52, 199, 89, 0.12) !important;
    border-color: rgba(52, 199, 89, 0.25) !important;
    color: #E8E8ED !important;
}

/* Info-boxes rojas (#f8d7da, #ffebee, #fee2e2, #fecaca) */
:root.dark-mode [style*="background:#f8d7da"],
:root.dark-mode [style*="background:#ffebee"],
:root.dark-mode [style*="background:#fee2e2"],
:root.dark-mode [style*="background:#fecaca"],
:root.dark-mode [style*="background:#fff0f0"] {
    background: rgba(255, 59, 48, 0.12) !important;
    border-color: rgba(255, 59, 48, 0.25) !important;
    color: #E8E8ED !important;
}

/* Info-boxes púrpuras/lilas */
:root.dark-mode [style*="background:#f5f0ff"],
:root.dark-mode [style*="background:#ede7f6"],
:root.dark-mode [style*="background:#f3e5f5"] {
    background: rgba(88, 86, 214, 0.14) !important;
    border-color: rgba(88, 86, 214, 0.25) !important;
    color: #E8E8ED !important;
}

/* Botones secundarios con fondo claro */
:root.dark-mode [style*="background:#f5f5f5"][style*="color:#333"],
:root.dark-mode [style*="background: #f5f5f5"][style*="color:#333"] {
    background: #3A3A3E !important;
    color: #E8E8ED !important;
    border-color: rgba(255,255,255,0.15) !important;
}

/* Borders grises claros (#ccc, #ddd, #e0e0e0) */
:root.dark-mode [style*="border:1px solid #ccc"],
:root.dark-mode [style*="border: 1px solid #ccc"],
:root.dark-mode [style*="border-color:#ccc"],
:root.dark-mode [style*="border-color: #ccc"] {
    border-color: rgba(255,255,255,0.15) !important;
}

/* Texto oscuro hardcodeado */
:root.dark-mode [style*="color:#333"],
:root.dark-mode [style*="color: #333"],
:root.dark-mode [style*="color:#1a1a1a"],
:root.dark-mode [style*="color:#555"],
:root.dark-mode [style*="color: #555"] {
    color: #C8C8CC !important;
}

/* Dropdowns de búsqueda (posición absolute) */
:root.dark-mode [id$="-dropdown"],
:root.dark-mode [class*="autocomplete"] {
    background: #2A2A2E !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: #E8E8ED !important;
    box-shadow: 0 8px 24px rgba(0,0,0,0.60) !important;
}
:root.dark-mode [id$="-dropdown"] div:hover,
:root.dark-mode [id$="-dropdown"] > *:hover {
    background: rgba(0,122,255,0.20) !important;
}

/* Panel Admin — secciones con fondo claro */
:root.dark-mode .adm-card,
:root.dark-mode [class*="adm-"] { color: #E8E8ED; }

/* KPI cards con colores inline */
:root.dark-mode [style*="background:#f0faf0"] { background: rgba(52,199,89,0.10) !important; }
:root.dark-mode [style*="background:#fff8f0"] { background: rgba(255,149,0,0.10) !important; }
:root.dark-mode [style*="background:#e8f5e9"] { background: rgba(52,199,89,0.10) !important; }
:root.dark-mode [style*="background:#e3f2fd"] { background: rgba(0,122,255,0.10) !important; }

/* Thead sticky con #1a3a52 — ya es oscuro, solo ajustamos en dark */
:root.dark-mode thead[style*="background:#1a3a52"],
:root.dark-mode thead tr[style*="background:#1a3a52"] {
    background: #0d1a36 !important;
}

/* WhatsApp section */
:root.dark-mode .wa-izq,
:root.dark-mode .wa-der { background: #1A1A1E !important; }
:root.dark-mode .wa-izq-header,
:root.dark-mode .wa-cabecera { background: #2A2A2E !important; color: #E8E8ED !important; }
:root.dark-mode .wa-item { background: #1E1E22 !important; color: #E8E8ED !important; border-color: rgba(255,255,255,0.06) !important; }
:root.dark-mode .wa-item:hover { background: #2A2A2E !important; }
:root.dark-mode .wa-item-on { background: rgba(0,122,255,0.18) !important; }
:root.dark-mode .wa-mensajes { background: #111114 !important; }
:root.dark-mode .wa-burbuja--inbound  { background: #2C2C30 !important; color: #E8E8ED !important; }
:root.dark-mode .wa-burbuja--outbound { background: #1B3A28 !important; color: #E8E8ED !important; }
:root.dark-mode .wa-input-area,
:root.dark-mode .wa-input-wrap { background: #1E1E22 !important; border-color: rgba(255,255,255,0.08) !important; }
:root.dark-mode .wa-input-area textarea { background: #2A2A2E !important; color: #E8E8ED !important; }
:root.dark-mode [style*="background:#ece5dd"] { background: #111114 !important; }

/* Agenda items y estados */
:root.dark-mode .proceso-badge,
:root.dark-mode [class*="badge-"] { filter: brightness(0.80) saturate(1.15); }

/* Saldo/info chips inline */
:root.dark-mode [style*="background:#d1ecf1"] { background: rgba(0,188,212,0.12) !important; }

/* Pagination buttons */
:root.dark-mode button[style*="background:white"],
:root.dark-mode button[style*="background: white"] {
    background: #2A2A2E !important;
    color: #E8E8ED !important;
    border-color: rgba(255,255,255,0.15) !important;
}

/* Presupuesto siempre en modo claro — forzar variables de light mode */
:root.dark-mode #presupuestos-view {
    --light-bg: #F2F2F7;
    --card-bg: rgba(255,255,255,0.72);
    --card-bg-solid: #FFFFFF;
    --border-color: rgba(60,60,67,0.12);
    --text-color: #1C1C1E;
    --text-muted: #8E8E93;
    background: #F2F2F7 !important;
    color: #1C1C1E !important;
}

/* Cancelar todas las reglas dark dentro de presupuestos */
:root.dark-mode #presupuestos-view input,
:root.dark-mode #presupuestos-view select,
:root.dark-mode #presupuestos-view textarea {
    background: #FFFFFF !important;
    color: #1C1C1E !important;
    border-color: rgba(60,60,67,0.20) !important;
}
:root.dark-mode #presupuestos-view .card,
:root.dark-mode #presupuestos-view [style*="background:#"] ,
:root.dark-mode #presupuestos-view [style*="background: #"],
:root.dark-mode #presupuestos-view [style*="background:white"],
:root.dark-mode #presupuestos-view [style*="background: white"] {
    /* dejar que los estilos originales actúen — solo resetear las sobreescrituras */
    filter: none !important;
}
:root.dark-mode #presupuestos-view table tbody tr {
    background: #FFFFFF !important;
    color: #1C1C1E !important;
}
:root.dark-mode #presupuestos-view table tbody tr:nth-child(even) {
    background: #F8F9FA !important;
}
:root.dark-mode #presupuestos-view td,
:root.dark-mode #presupuestos-view th {
    color: #1C1C1E !important;
    border-color: rgba(60,60,67,0.12) !important;
}
:root.dark-mode #presupuestos-view thead tr {
    background: #1a3a52 !important;
    color: white !important;
}
:root.dark-mode #presupuestos-view button:not([class*="btn-primary"]):not([class*="btn-success"]):not([class*="btn-danger"]) {
    color: inherit !important;
}
:root.dark-mode #presupuestos-view .cortina-tab {
    background: white !important;
    color: #1C1C1E !important;
}
:root.dark-mode #presupuestos-view .cortina-tab.active {
    background: var(--primary-color) !important;
    color: white !important;
}

/* ── CLIENTES / PEDIDOS — dark completo ──────────────────────────── */

/* Fondo explícito sección */
:root.dark-mode #clientes-view,
:root.dark-mode #pedidos-view {
    background: #0F0F11 !important;
}

/* Wrapper tabla */
:root.dark-mode #clientes-view > div[style*="overflow-x"],
:root.dark-mode #pedidos-view > div[style*="overflow-x"] {
    background: #1E1E22 !important;
    border-color: rgba(255,255,255,0.08) !important;
}

/* Filas — solo background, SIN forzar color (las celdas tienen sus propios colores) */
:root.dark-mode #clientes-view table tbody tr,
:root.dark-mode #pedidos-view table tbody tr {
    background: #1E1E22 !important;
}
:root.dark-mode #clientes-view table tbody tr:nth-child(even),
:root.dark-mode #pedidos-view table tbody tr:nth-child(even) {
    background: #252528 !important;
}
:root.dark-mode #clientes-view table tbody tr:hover,
:root.dark-mode #pedidos-view table tbody tr:hover {
    background: rgba(0,122,255,0.10) !important;
}

/* Celdas sin color inline — que hereden el color del body dark (#E8E8ED) */
/* NO forzar !important acá para que los colores inline (#0093FF, etc.) prevalezcan */
:root.dark-mode #clientes-view td,
:root.dark-mode #pedidos-view td {
    border-color: rgba(255,255,255,0.05) !important;
}

/* Thead */
:root.dark-mode #clientes-view thead tr,
:root.dark-mode #pedidos-view thead tr {
    background: #0d1520 !important;
    color: white !important;
}

/* Modales inline dentro de clientes (modal-nuevo-cliente, modal-cobrar) */
:root.dark-mode #modal-nuevo-cliente > div,
:root.dark-mode #modal-cobrar > div,
:root.dark-mode #modal-editar-cliente > div,
:root.dark-mode #modal-detalle-cliente > div,
:root.dark-mode #modal-presupuesto > div,
:root.dark-mode #modal-detalle-presupuesto > div,
:root.dark-mode #modal-nuevo-pedido > div,
:root.dark-mode #modal-detalle-pedido > div {
    background: #1E1E22 !important;
    color: #E8E8ED !important;
    border-color: rgba(255,255,255,0.10) !important;
}

/* Info chips dentro de modal cobrar */
:root.dark-mode #cobr-info-cliente {
    background: rgba(0,122,255,0.12) !important;
    border-color: rgba(0,122,255,0.25) !important;
}
:root.dark-mode #cobr-info-cliente > div { background: #2A2A2E !important; }

/* Resumen tarjeta (warning amarillo) */
:root.dark-mode #cobr-tarjeta-resumen,
:root.dark-mode [id*="tarjeta-resumen"] {
    background: rgba(255,149,0,0.12) !important;
    border-color: rgba(255,149,0,0.30) !important;
    color: #E8E8ED !important;
}

/* Info pedido/presupuesto vinculado */
:root.dark-mode #cobr-pedido-info {
    background: rgba(255,149,0,0.12) !important;
    border-color: rgba(255,149,0,0.25) !important;
    color: #E8E8ED !important;
}

/* Dropdown autocomplete clientes */
:root.dark-mode #cobr-dropdown,
:root.dark-mode #cli-buscar-dropdown,
:root.dark-mode [id*="-dropdown"] {
    background: #2A2A2E !important;
    border-color: rgba(255,255,255,0.12) !important;
    color: #E8E8ED !important;
}

/* Input readonly saldo/totales */
:root.dark-mode #cli-saldo,
:root.dark-mode input[readonly] {
    background: #2A2A2E !important;
    color: #E8E8ED !important;
}

/* Coef box aviso */
:root.dark-mode #cli-coef-box {
    background: rgba(255,149,0,0.12) !important;
    border-color: rgba(255,149,0,0.30) !important;
    color: #E8E8ED !important;
}

/* Proceso badges (MEDIC/PROD/INST/LISTO) ya tienen color propio — solo ajustar opacidad */
:root.dark-mode .proceso-tag,
:root.dark-mode [class*="proc-"] { filter: brightness(0.85) saturate(1.1); }

/* Botones de acción en tabla clientes (Cobrar, editar, etc.) */
:root.dark-mode #clientes-view button[style*="background:white"],
:root.dark-mode #clientes-view button[style*="background: white"] {
    background: #3A3A3E !important;
    color: #E8E8ED !important;
}

/* Pedidos — cards de órdenes y grupos proveedor */
:root.dark-mode #pedidos-view [style*="background:white"],
:root.dark-mode #pedidos-view [style*="background:#fff;"],
:root.dark-mode #pedidos-view [style*="background: white"] {
    background: #1E1E22 !important;
    color: #E8E8ED !important;
}
:root.dark-mode #pedidos-view [style*="background:#f0f4f8"],
:root.dark-mode #pedidos-view [style*="background:#f0f4fa"] {
    background: rgba(0,122,255,0.08) !important;
    color: #C8C8CC !important;
}

/* Efecto Liquid Glass para cards y modales */
.card,
.view-header,
.filters,
section.view > div[style*="background:var(--card-bg)"] {
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
}

/* Sidebar con efecto vidrio */
.sidebar {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border-right: 1px solid var(--border-color);
}

/* Botones con accent vibrante iOS */
.btn-primary,
button[style*="background:var(--primary-color)"] {
    background: var(--primary-color) !important;
    border-radius: var(--radius-md) !important;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.btn-primary:hover,
button[style*="background:var(--primary-color)"]:hover {
    background: var(--accent-hover) !important;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Inputs estilo iOS */
.input-text,
.input-select,
input[type="text"],
input[type="number"],
input[type="date"],
select {
    border-radius: var(--radius-sm) !important;
    border: 1px solid var(--border-color) !important;
    background: rgba(255, 255, 255, 0.6) !important;
    transition: all 0.15s ease;
}
.input-text:focus,
.input-select:focus,
input:focus,
select:focus {
    outline: none !important;
    border-color: var(--primary-color) !important;
    background: rgba(255, 255, 255, 1) !important;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15) !important;
}

/* Tablas más limpias iOS-style */
.data-table {
    border-radius: var(--radius-md);
    overflow: hidden;
}
.data-table th {
    background: rgba(242, 242, 247, 0.7) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-muted) !important;
    font-weight: 600 !important;
    text-transform: uppercase;
    font-size: 0.7rem !important;
    letter-spacing: 0.5px;
}
.data-table tbody tr {
    transition: background 0.15s ease;
}
.data-table tbody tr:hover {
    background: rgba(0, 122, 255, 0.04) !important;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--light-bg);
    color: var(--text-color);
    line-height: 1.6;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Topbar (oculto) */
.topbar {
    display: none;
}

.topbar-left h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
}

.topbar-right {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.user-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-logout {
    color: var(--white);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

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

/* App Wrapper */
.app-wrapper {
    display: flex;
    flex: 1;
}

/* Sidebar Vertical Colapsable */
.sidebar-vertical {
    width: 80px;
    background-color: var(--primary-color);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    z-index: 100;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    padding-top: 0.4rem;
    padding-bottom: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 0.8rem;
    color: var(--white);
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
    justify-content: center;
}

.sidebar-user i {
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-user span {
    opacity: 0;
    transition: opacity 0.3s;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-vertical:hover .sidebar-user span {
    opacity: 1;
}

.sidebar-logout {
    color: rgba(255, 255, 255, 0.85) !important;
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.25) !important;
    border-left-color: #ef4444 !important;
}

.sidebar-vertical:hover {
    width: 220px;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-top: 1rem;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
    white-space: nowrap;
    border-left: 4px solid transparent;
}

.sidebar-item i {
    font-size: 1.3rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-item span {
    font-size: 0.95rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-vertical:hover .sidebar-item span {
    opacity: 1;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
    border-left-color: var(--accent-color);
}

.sidebar-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: var(--white);
    border-left-color: var(--accent-color);
}

.btn-logout {
    background-color: var(--danger-color);
    color: var(--white);
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.btn-logout:hover {
    background-color: #c0392b;
}

/* Content Wrapper */
.content-wrapper {
    display: flex;
    flex: 1;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--primary-color);
    padding: 2rem 0;
    box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.nav-item {
    color: var(--white);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    cursor: pointer;
    border-left: 4px solid transparent;
    transition: all 0.3s;
    text-decoration: none;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary-color);
}

.nav-item.active {
    background-color: var(--secondary-color);
    border-left-color: var(--secondary-color);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

#whatsapp-view.active {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Anular padding del main-content cuando WhatsApp está activo */
.main-content.wa-active {
    padding: 0 !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    /* 100vh funciona directo — no dependemos de herencia de height desde flex:1 */
    height: 100vh !important;
}

/* Headers */
h2 {
    margin-bottom: 1.5rem;
    font-size: 2rem;
    color: var(--text-color);
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* KPI Cards */
.kpi-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.kpi-card h3 {
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--secondary-color);
}

/* Cards Container */
.cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
    gap: 1.5rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.card h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.dashboard-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.dashboard-item {
    padding: 0.8rem;
    background: #f5f5f5;
    border-left: 4px solid var(--primary-color);
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-item-badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.badge-medicion {
    background-color: #3498db;
}

.badge-instalacion {
    background-color: #27ae60;
}

.badge-flete {
    background-color: #f39c12;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.5rem;
}

.dashboard-table thead {
    background-color: #f5f5f5;
}

.dashboard-table th {
    padding: 0.8rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

.dashboard-table td {
    padding: 0.8rem;
    border-bottom: 1px solid #eee;
}

.dashboard-table tbody tr:hover {
    background-color: #f9f9f9;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 2rem;
}

/* Buttons */
.btn {
    padding: 0.7rem 1.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-primary:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-success {
    background-color: var(--success-color);
    color: var(--white);
}

.btn-danger {
    background-color: var(--danger-color);
    color: var(--white);
}

.btn-warning {
    background-color: var(--warning-color);
    color: var(--white);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Filters */
.filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.input-search,
.input-select {
    padding: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
}

.input-search {
    flex: 1;
    min-width: 250px;
}

.input-select {
    min-width: 200px;
}

/* Tables */
.data-table,
#tabla-presupuestos-dashboard,
#tabla-clientes-dashboard {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.data-table thead,
#tabla-presupuestos-dashboard thead,
#tabla-clientes-dashboard thead {
    background-color: var(--primary-color);
    color: var(--white);
}

.data-table th,
#tabla-presupuestos-dashboard th,
#tabla-clientes-dashboard th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.data-table td,
#tabla-presupuestos-dashboard td,
#tabla-clientes-dashboard td {
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--light-bg);
}

.data-table tbody tr:hover,
#tabla-presupuestos-dashboard tbody tr:hover,
#tabla-clientes-dashboard tbody tr:hover {
    background-color: #f8f9fa;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-action {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    color: var(--white);
    transition: all 0.3s;
}

.btn-view {
    background-color: var(--secondary-color);
}

.btn-view:hover {
    background-color: #2980b9;
}

.btn-edit {
    background-color: var(--warning-color);
}

.btn-edit:hover {
    background-color: #e67e22;
}

.btn-delete {
    background-color: var(--danger-color);
}

.btn-delete:hover {
    background-color: #c0392b;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-color);
}

.modal-close:hover {
    color: var(--danger-color);
}

/* Form */
.form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.7rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.95rem;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* WhatsApp Button */
.btn-whatsapp {
    background-color: #25d366;
    color: var(--white);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.btn-whatsapp:hover {
    background-color: #1ebd57;
}

/* Status Badges */
.badge {
    display: inline-block;
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-warning {
    background-color: #fff3cd;
    color: #856404;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.badge-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

/* Responsive */
@media (max-width: 768px) {
    .content-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        padding: 1rem 0;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .nav-item {
        padding: 1rem;
        white-space: nowrap;
        flex: 1;
    }

    .main-content {
        padding: 1rem;
    }

    .kpi-container {
        grid-template-columns: 1fr;
    }

    .cards-container {
        grid-template-columns: 1fr;
    }

    .filters {
        flex-direction: column;
    }

    .input-search {
        min-width: unset;
    }

    .data-table,
    #tabla-presupuestos-dashboard,
    #tabla-clientes-dashboard {
        font-size: 0.85rem;
    }

    .data-table th,
    .data-table td,
    #tabla-presupuestos-dashboard th,
    #tabla-presupuestos-dashboard td,
    #tabla-clientes-dashboard th,
    #tabla-clientes-dashboard td {
        padding: 0.5rem;
    }

    .table-actions {
        flex-direction: column;
        gap: 0.2rem;
    }

    .view-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .modal-content {
        width: 95%;
        padding: 1.5rem;
    }
}

/* Loading */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-color);
}

.spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid var(--light-bg);
    border-top-color: var(--secondary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Login Screen */
.login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1a252f 100%);
}

.login-box {
    background: var(--white);
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-box h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: #7f8c8d;
    margin-bottom: 2rem;
    font-size: 1.1rem;
}

.login-box .form-group {
    text-align: left;
}

/* User info in navbar */
.user-info {
    color: var(--white);
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Admin-only elements hidden by default */
.admin-only {
    display: none !important;
}

body.is-admin .admin-only {
    display: flex !important;
}

body.is-admin section.admin-only {
    display: none !important;
}

body.is-admin section.admin-only.active {
    display: block !important;
}

/* Formulario Presupuestos Cortinas */
#modal-presupuesto-cortinas .modal-content {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

#modal-presupuesto-cortinas h3 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

#modal-presupuesto-cortinas h4 {
    margin: 15px 0 10px 0;
    color: var(--primary-color);
    font-size: 1rem;
}

.paso {
    padding: 15px 0;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color);
}

.input-text, .input-select {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.95rem;
    font-family: inherit;
}

.input-text:focus, .input-select:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.3);
}

.tipo-cortina-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 15px 0;
}

.tipo-cortina-btn {
    padding: 15px;
    border: 2px solid var(--border-color);
    background: var(--white);
    color: var(--text-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 600;
}

.tipo-cortina-btn:hover {
    border-color: var(--secondary-color);
    background: #f0f7ff;
}

.tipo-cortina-btn.active {
    border-color: var(--secondary-color);
    background: var(--secondary-color);
    color: var(--white);
}

.dropdown-search {
    position: relative;
    z-index: 10;
    max-height: 165px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.dropdown-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

.dropdown-item:hover {
    background: #f5f5f5;
}

.dropdown-item-main {
    font-weight: 600;
    color: var(--primary-color);
}

.dropdown-item-sub {
    font-size: 0.85rem;
    color: #7f8c8d;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    font-size: 0.95rem;
}

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

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

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--light-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--light-bg);
    border-color: var(--primary-color);
}

.btn-success {
    background: var(--success-color);
    color: var(--white);
}

.btn-success:hover {
    background: #229954;
    transform: translateY(-2px);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--white);
}

.btn-danger:hover {
    background: #c0392b;
}

/* KPI CARDS */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 147, 255, 0.1);
    border-left: 4px solid var(--primary-color);
    transition: transform 0.3s, box-shadow 0.3s;
}

.kpi-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 147, 255, 0.15);
}

.kpi-card-label {
    font-size: 0.85rem;
    color: var(--neutral-color);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.kpi-card-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.kpi-card-subtext {
    font-size: 0.75rem;
    color: #7f8c8d;
    margin-top: 0.5rem;
}

/* PRESUPUESTO TABLE */
.presupuesto-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.presupuesto-table thead {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
}

.presupuesto-table th {
    padding: 1.2rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
}

.presupuesto-table td {
    padding: 1rem 1.2rem;
    border-bottom: 1px solid var(--light-bg);
    font-size: 0.95rem;
}

.presupuesto-table tbody tr:hover {
    background-color: #f9fafb;
}

.presupuesto-table-cliente {
    font-weight: 500;
    color: var(--primary-color);
}

.presupuesto-table-actions {
    display: flex;
    gap: 0.5rem;
}

/* PRESUPUESTO MODAL V2 - REDESIGN */
.presupuesto-modal-v2 {
    padding: 2rem 2.5rem;
    max-width: 1280px;
    max-height: 95vh;
    overflow-y: auto;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    font-family: 'Inter', sans-serif;
}

.pres-header-v2 {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.pres-titulo-v2 {
    font-size: 2rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
}

.pres-header-meta {
    text-align: right;
}

.pres-draft {
    font-size: 0.85rem;
    color: var(--neutral-color);
    font-weight: 600;
    letter-spacing: 0.5px;
}

.pres-fecha-v2 {
    font-size: 1rem;
    color: var(--text-color);
    font-weight: 500;
    margin-top: 0.25rem;
}

/* CLIENTE ROW - 3 inputs horizontales */
.pres-cliente-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    padding: 0.8rem 1rem;
    background: #fafbfc;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-bottom: 0.8rem;
}

.pres-cliente-row--with-title {
    grid-template-columns: auto 1fr 1fr 1fr;
    align-items: end;
}

.pres-titulo-inline {
    display: flex;
    align-items: center;
    padding-right: 0.5rem;
    border-right: 1px solid var(--border-color);
    height: 100%;
    margin-right: 0.3rem;
}

.pres-titulo-inline .pres-titulo-v2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a202c;
    margin: 0;
    white-space: nowrap;
}

.pres-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.pres-field label {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--neutral-color);
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.pres-field .input-text,
.pres-field .input-select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    background: var(--white);
    transition: all 0.2s;
}

.pres-field .input-text:focus,
.pres-field .input-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 147, 255, 0.1);
}

/* Campos compactos para fila de paño */
.pres-field--xs .input-text,
.pres-field--xs .input-select {
    padding: 0.3rem 0.25rem;
    font-size: 0.78rem;
    text-align: center;
}
.pres-field--sm .input-text,
.pres-field--sm .input-select {
    padding: 0.3rem 0.4rem;
    font-size: 0.82rem;
}

.input-readonly {
    background: #f0f4fa !important;
    color: var(--primary-color);
    font-weight: 600;
}

/* TOOLBAR con cortina-tabs y subtabs */
.tabs-toolbar {
    display: flex;
    gap: 1rem;
    margin: 0.5rem 0;
    flex-wrap: wrap;
    align-items: flex-start;
}

.tabs-toolbar .cortina-tabs {
    flex: 1;
    min-width: 300px;
}

/* SUB-TABS — mismo estilo que cortina-tab */
.subtabs-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.subtab {
    padding: 0.5rem 0.9rem;
    border: 2px solid var(--border-color);
    background: var(--white);
    color: var(--text-color);
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.75rem;
    transition: all 0.3s;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.subtab-small {
    padding: 0.35rem 0.65rem;
    font-size: 0.65rem;
    font-weight: 500;
}

.subtab:hover {
    border-color: var(--secondary-color);
    background: #f0f7ff;
}

.subtab.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 147, 255, 0.25);
}

/* FORM ROWS */
.form-row-2,
.form-row-3,
.form-row-4 {
    display: grid;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.cortina-form-title {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 1.2rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border-color);
}

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

.btn-buscador-rapido {
    margin-left: auto;
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef6ff;
    border: 1px solid #cfe4fb;
    border-radius: 6px;
    color: var(--primary-color, #0093FF);
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-buscador-rapido:hover {
    background: var(--primary-color, #0093FF);
    color: #fff;
}

/* INPUT CON ICONO LUPA */
.input-with-icon {
    position: relative;
}

.input-with-icon .input-text {
    padding-right: 2.5rem;
    width: 100%;
}

.input-with-icon .input-icon {
    position: absolute;
    right: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--neutral-color);
    pointer-events: none;
}

/* OPCIONES ADICIONALES - iconos con colores */
.option-icon.icon-motor {
    background: rgba(39, 174, 96, 0.1);
    color: #27ae60;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-icon.icon-cenefa {
    background: rgba(0, 147, 255, 0.1);
    color: var(--primary-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.option-icon.icon-suplementos {
    background: rgba(157, 92, 189, 0.1);
    color: var(--tertiary-color);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.75rem 0;
}

.btn-guardar-full {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-guardar-full:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 147, 255, 0.25);
}

/* PRESUPUESTO MODAL 2-COLUMN LAYOUT */
.presupuesto-modal {
    padding: 2rem;
}

.presupuesto-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--light-bg);
}

.presupuesto-header h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin: 0;
}

.presupuesto-fecha {
    font-size: 0.85rem;
    color: var(--neutral-color);
    margin: 0.25rem 0 0 0;
}

.presupuesto-cliente-card {
    background: linear-gradient(135deg, rgba(0, 147, 255, 0.05) 0%, rgba(63, 117, 212, 0.05) 100%);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
}

.presupuesto-2col {
    display: grid;
    grid-template-columns: 88% 12%;
    gap: 2rem;
    padding: 1.5rem 0;
}

.presupuesto-left {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.presupuesto-right {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0 1rem 1rem 0.5rem;
}

.presupuesto-cliente-info {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--secondary-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.presupuesto-cliente-info h4 {
    font-size: 1.1rem;
    color: var(--primary-color);
    margin: 0 0 0.5rem 0;
}

.presupuesto-cliente-info p {
    margin: 0.25rem 0;
    color: var(--text-color);
    font-size: 0.95rem;
}

/* TABS STYLING */
.ambiente-tabs, .cortina-tabs {
    display: flex;
    gap: 0.6rem;
    margin: 0;
    flex-wrap: wrap;
}

.ambiente-btn, .cortina-tab {
    padding: 0.5rem 0.9rem;
    border: 2px solid var(--border-color);
    background: var(--white);
    color: var(--text-color);
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: all 0.3s;
    white-space: nowrap;
}

.ambiente-btn:hover, .cortina-tab:hover {
    border-color: var(--secondary-color);
    background: #f0f7ff;
}

.ambiente-btn.active, .cortina-tab.active {
    background: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 147, 255, 0.25);
}

.ambiente-btn i, .cortina-tab i {
    margin-right: 0.5rem;
}

.cortina-form {
    background: var(--white);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.cortina-form h4 {
    font-size: 0.9rem;
    color: var(--primary-color);
    margin-bottom: 0.8rem;
}

.cortina-form-wrapper {
    display: grid;
    gap: 1rem;
}

#cortina-form-container {
    border: 1px solid var(--border-color);
    padding: 1rem;
}

.cortinas-list {
    display: grid;
    gap: 0.8rem;
    max-height: 400px;
    overflow-y: auto;
}

.cortina-item {
    background: #f9fafb;
    border: 1px solid var(--border-color);
    padding: 0.8rem;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cortina-item-info {
    flex: 1;
    font-size: 0.85rem;
}

.cortina-item-label {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.2rem;
}

.cortina-item-details {
    color: #666;
    font-size: 0.75rem;
}

.cortina-item-price {
    font-weight: 700;
    color: var(--primary-color);
    text-align: right;
    min-width: 80px;
}

.cortina-item-remove {
    background: #fee2e2;
    color: #dc2626;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.cortina-item-remove:hover {
    background: #fecaca;
}

.presupuesto-summary-section {
    border-top: 1px solid var(--border-color);
    padding-top: 0.8rem;
}

.presupuesto-buttons {
    border-top: 1px solid var(--border-color);
    padding-top: 1rem;
}

/* ARTICLE TAG */
.article-tag {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: var(--white);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.article-tag .tag-close {
    cursor: pointer;
    margin-left: 0.5rem;
    font-weight: bold;
}

/* PRESUPUESTO OPTIONS (TOGGLE SWITCHES) */
.presupuesto-options {
    background: var(--white);
    padding: 0.8rem;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.presupuesto-options h4 {
    font-size: 0.85rem;
    color: var(--primary-color);
    margin-bottom: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.option-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--light-bg);
    transition: background 0.2s;
}

.option-row:hover {
    background: #f9fafb;
}

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

.option-icon {
    font-size: 1rem;
    color: var(--secondary-color);
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.option-row span {
    flex: 1;
    font-weight: 500;
    color: var(--text-color);
    font-size: 0.85rem;
}

/* TOGGLE SWITCH */
.toggle-switch {
    position: relative;
    display: inline-flex;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    display: inline-block;
    position: relative;
    width: 50px;
    height: 26px;
    background-color: #ccc;
    border-radius: 20px;
    transition: background-color 0.3s;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-slider::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    left: 2px;
    top: 2px;
    background-color: white;
    border-radius: 50%;
    transition: left 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider::after {
    left: 26px;
}

/* PRESUPUESTO SUMMARY */
.presupuesto-summary {
    background: linear-gradient(135deg, #f8fafb 0%, var(--light-bg) 100%);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-size: 0.95rem;
    color: var(--text-color);
}

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

.summary-row strong {
    color: var(--primary-color);
    font-weight: 600;
}

.summary-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 0;
    margin-top: 0.8rem;
    padding-top: 1.2rem;
    border-top: 2px solid var(--primary-color);
    font-size: 1.1rem;
    font-weight: 700;
}

.summary-total strong {
    color: var(--primary-color);
    font-size: 1.4rem;
}

/* RESPONSIVE 2-COLUMN MODAL */
@media (max-width: 1024px) {
    .presupuesto-2col {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .presupuesto-right {
        position: sticky;
        top: 0;
        z-index: 10;
    }
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 6px;


/* ===== MODAL PAÑO — Nuevo diseño profesional ===== */
#modal-pano input[type="text"]:focus,
#modal-pano input[type="number"]:focus,
#modal-pano select:focus {
    outline: none;
    border-color: #c9a84c !important;
    box-shadow: 0 0 0 3px rgba(201,168,76,0.15);
}

#modal-pano .modal-tipo-tab.active,
#modal-pano .modal-tipo-tab[style*="linear-gradient"] {
    background: linear-gradient(135deg,#c9a84c,#a07830) !important;
    color: white !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(160,120,48,0.4) !important;
}

#ped-ambiente-tabs-modal button {
    padding: 5px 13px;
    font-size: 0.74rem;
    background: #f5f2ee;
    border: 1.5px solid #cfc0ae;
    border-bottom: none;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    color: #5a4535;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: background 0.15s;
}

#ped-ambiente-tabs-modal button.active {
    background: white;
    color: #1a3346;
    border-color: #c9a84c;
    font-weight: 700;
}


/* ══════════════════════════════════════════════════════
   MÓDULO WHATSAPP — Sistema MEL  (rewrite v2)
══════════════════════════════════════════════════════ */

/* Badge en el sidebar */
.wa-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #25D366;
    color: #fff;
    border-radius: 10px;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    margin-left: auto;
}

/* ── Main-content overrides cuando WA está activo ── */
.main-content.wa-active {
    padding: 0 !important;
    overflow: hidden !important;
}

/* ── Vista WhatsApp ── */
#whatsapp-view.active {
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    /* height se setea via JS con inline style */
}

/* ── Root del módulo ── */
.wa-root {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #ece5dd;
}

/* ══ Panel izquierdo ══ */
.wa-izq {
    width: 340px;
    min-width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 1px solid rgba(60,60,67,0.15);
    overflow: hidden;
}

.wa-izq-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.2rem 0.9rem;
    border-bottom: 1px solid rgba(60,60,67,0.1);
    font-size: 1.05rem;
    font-weight: 700;
    color: #1C1C1E;
    flex-shrink: 0;
    background: #fff;
}

.wa-izq-header .fa-whatsapp { color: #25D366; font-size: 1.2rem; }

.wa-buscador {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: #f6f6f6;
    border-bottom: 1px solid rgba(60,60,67,0.1);
    flex-shrink: 0;
}

.wa-buscador .fa-search { color: #8E8E93; font-size: 0.85rem; flex-shrink: 0; }

.wa-buscador input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    font-size: 0.88rem;
    color: #1C1C1E;
}

.wa-lista {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* Item de conversación */
.wa-item {
    display: flex !important;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid rgba(60,60,67,0.07);
    transition: background 0.12s;
    background: #fff;
}

.wa-item:hover { background: #f5f5f5; }
.wa-item-on { background: #e8f4fd !important; border-left: 3px solid #007AFF; }

.wa-av {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: #fff;
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.15rem;
    flex-shrink: 0;
    user-select: none;
}

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

.wa-fila1, .wa-fila2 {
    display: flex !important;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
}

.wa-fila1 { margin-bottom: 0.2rem; }

.wa-nombre {
    flex: 1;
    font-weight: 600;
    font-size: 0.9rem;
    color: #1C1C1E;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-ts {
    font-size: 0.71rem;
    color: #8E8E93;
    flex-shrink: 0;
}

.wa-preview {
    flex: 1;
    font-size: 0.82rem;
    color: #8E8E93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wa-unread {
    background: #25D366;
    color: #fff;
    border-radius: 12px;
    padding: 0.1rem 0.45rem;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.wa-estado-vacio {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 1rem;
    color: #8E8E93;
    gap: 0.5rem;
    font-size: 0.88rem;
    text-align: center;
}

/* ══ Panel derecho (chat) ══ */
.wa-der {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ece5dd;
}

.wa-der-vacio {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: #8E8E93;
    background: #f0f0f0;
}

.wa-der-vacio i { font-size: 4rem; color: #25D366; opacity: 0.4; }

/* Cabecera del chat */
.wa-cabecera {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.85rem 1.2rem;
    background: #fff;
    border-bottom: 1px solid rgba(60,60,67,0.12);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.wa-cab-av {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
}

.wa-cab-meta { flex: 1; min-width: 0; }
.wa-cab-nombre { font-weight: 700; font-size: 0.95rem; color: #1C1C1E; }
.wa-cab-tel { font-size: 0.78rem; color: #8E8E93; }

.wa-btn-ficha {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.35rem 0.85rem;
    background: #007AFF;
    color: #fff;
    border: none;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}
.wa-btn-ficha:hover { background: #0051D5; }

/* Área de mensajes */
.wa-msgs {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: #ece5dd;
}

.wa-msgs-vacio { text-align: center; color: #8E8E93; font-size: 0.88rem; margin: auto; }

/* Burbujas */
.wa-burbuja-wrap { display: flex; margin-bottom: 0.15rem; }
.wa-burbuja-wrap--inbound { justify-content: flex-start; }
.wa-burbuja-wrap--outbound { justify-content: flex-end; }

.wa-burbuja {
    max-width: 68%;
    padding: 0.5rem 0.85rem 0.45rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.45;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.wa-burbuja--inbound  { background: #fff;     color: #1C1C1E; border-top-left-radius: 3px; }
.wa-burbuja--outbound { background: #dcf8c6;  color: #1a1a1a; border-top-right-radius: 3px; }

.wa-hora { display: block; font-size: 0.67rem; color: #8E8E93; text-align: right; margin-top: 0.2rem; }

.wa-img-attachment { max-width: 220px; border-radius: 8px; cursor: pointer; display: block; }

.wa-doc-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #007AFF;
    font-size: 0.85rem;
    text-decoration: none;
}
.wa-doc-link:hover { text-decoration: underline; }

/* Barra de escritura */
.wa-bar-input {
    display: flex;
    align-items: flex-end;
    gap: 0.55rem;
    padding: 0.7rem 1rem;
    background: #f0f0f0;
    border-top: 1px solid rgba(60,60,67,0.1);
    flex-shrink: 0;
}

.wa-textarea {
    flex: 1;
    border: none;
    border-radius: 20px;
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
    background: #fff;
    resize: none;
    min-height: 38px;
    max-height: 120px;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.wa-btn-pdf, .wa-btn-enviar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
}
.wa-btn-pdf    { background: #e0e0e0; color: #8E8E93; }
.wa-btn-pdf:hover { background: #d0d0d0; }
.wa-btn-enviar { background: #25D366; color: #fff; }
.wa-btn-enviar:hover { background: #128C7E; transform: scale(1.05); }

/* Mobile */
@media (max-width: 700px) {
    .wa-izq { width: 100%; min-width: unset; }
    .wa-der { display: none; }
    .wa-root.wa-chat-on .wa-izq { display: none; }
    .wa-root.wa-chat-on .wa-der { display: flex; }
}
