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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    min-height: 100vh;
    padding: 10px;
}

.container {
    max-width: 1500px;
    margin: 0 auto;
    background: white;
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, #001f3f 0%, #003d66 100%);
    padding: 20px 30px;
    border-bottom: 4px solid #f39c12;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 20px;
}

.header-text {
    color: white;
}

.header-text h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 2px;
}

.header-text p {
    font-size: 12px;
    opacity: 0.9;
}

.tabs {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 15px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid rgba(243, 156, 18, 0.3);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tab-btn:hover {
    background: rgba(243, 156, 18, 0.3);
    border-color: #f39c12;
}

.tab-btn.active {
    background: #f39c12;
    color: #001f3f;
    border-color: #f39c12;
}

.content {
    padding: 20px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

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

label {
    font-size: 12px;
    font-weight: 700;
    color: #001f3f;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.required::after {
    content: " *";
    color: #e74c3c;
    font-weight: 700;
}

input, select, textarea {
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    transition: all 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #f39c12;
    box-shadow: 0 0 0 3px rgba(243, 156, 18, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.section-title {
    font-size: 14px;
    font-weight: 700;
    color: #001f3f;
    margin-top: 20px;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 3px solid #f39c12;
}

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

.button-group {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-top: 20px;
}

button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-primary {
    background: linear-gradient(135deg, #001f3f 0%, #003d66 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 31, 63, 0.3);
}

.btn-success {
    background: #27ae60;
    color: white;
}

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

.btn-warning {
    background: #f39c12;
    color: white;
}

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

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

/* COTIZADOR */
.cotizador-grid {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 20px;
    margin-top: 20px;
}

.products-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 15px;
}

.product-category {
    background: #f8f9fa;
    border-left: 5px solid #f39c12;
    padding: 15px;
    border-radius: 8px;
}

.product-category-title {
    font-size: 13px;
    font-weight: 700;
    color: #001f3f;
    margin-bottom: 10px;
}

.product-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 5px 0;
    background: white;
    border-radius: 6px;
    border: 2px solid #e0e0e0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.product-item:hover {
    border-color: #f39c12;
    box-shadow: 0 2px 8px rgba(243, 156, 18, 0.2);
}

.product-item input[type="checkbox"] {
    margin-right: 10px;
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #f39c12;
}

.product-name {
    flex: 1;
    font-size: 12px;
}

.product-price {
    font-size: 11px;
    color: #f39c12;
    font-weight: 700;
}

.cotizador-sidebar {
    position: sticky;
    top: 20px;
}

.summary-box {
    background: linear-gradient(135deg, #001f3f 0%, #003d66 100%);
    color: white;
    padding: 20px;
    border-radius: 8px;
    border-top: 4px solid #f39c12;
    max-height: 80vh;
    overflow-y: auto;
}

.summary-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    margin-bottom: 15px;
}

.summary-items {
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.summary-item {
    font-size: 11px;
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    color: #e9ecef;
}

.summary-item-price {
    color: #f39c12;
    font-weight: 700;
}

.option-label {
    font-size: 11px;
    font-weight: 700;
    color: #f39c12;
    text-transform: uppercase;
    margin-top: 12px;
    margin-bottom: 8px;
}

.payment-methods {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

.payment-btn {
    padding: 8px !important;
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid rgba(243, 156, 18, 0.3) !important;
    font-size: 10px;
}

.payment-btn:hover {
    border-color: #f39c12 !important;
    background: rgba(243, 156, 18, 0.2);
}

.payment-btn.active {
    background: #f39c12;
    color: #001f3f;
    border-color: #f39c12 !important;
    font-weight: 700;
}

.montura-section {
    background: rgba(0,0,0,0.3);
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 12px;
}

.montura-input-group {
    margin-bottom: 10px;
}

.montura-input-group label {
    font-size: 10px;
    color: #f39c12;
}

.montura-input-group input {
    width: 100%;
    padding: 8px;
    border: 2px solid rgba(243, 156, 18, 0.5) !important;
    margin-top: 4px;
    border-radius: 4px;
    color: white;
    background: rgba(255,255,255,0.1);
    font-size: 11px;
}

.montura-input-group input::placeholder {
    color: rgba(255,255,255,0.6);
}

.price-breakdown {
    background: rgba(0,0,0,0.2);
    padding: 12px;
    border-radius: 6px;
    font-size: 10px;
    margin-bottom: 12px;
}

.breakdown-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    color: #e9ecef;
}

.breakdown-line:last-child {
    margin-bottom: 0;
    padding-top: 5px;
    border-top: 1px solid rgba(255,255,255,0.2);
    color: #90EE90;
    font-weight: 700;
}

.total-amount {
    font-size: 28px;
    font-weight: 700;
    color: #f39c12;
    text-align: center;
    margin: 15px 0;
}

/* TABLA BASE DE DATOS */
.table-container {
    overflow-x: auto;
    margin-top: 20px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
}

thead {
    background: linear-gradient(135deg, #001f3f 0%, #003d66 100%);
    color: white;
}

th {
    padding: 12px;
    text-align: left;
    font-weight: 700;
}

td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background: #f8f9fa;
}

.delete-btn {
    background: #e74c3c;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 10px;
}

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

/* FÓRMULA ÓPTICA */
.formula-container {
    background: white;
    padding: 40px;
    margin: 20px 0;
    border: 2px solid #001f3f;
    border-radius: 8px;
    max-width: 600px;
}

.formula-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 3px solid #f39c12;
    padding-bottom: 15px;
}

.formula-header h1 {
    color: #001f3f;
    font-size: 24px;
    margin-bottom: 5px;
}

.formula-patient-info {
    margin-bottom: 20px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
}

.formula-patient-info p {
    margin: 8px 0;
    font-size: 12px;
}

.formula-patient-info strong {
    color: #001f3f;
}

.formula-prescription {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.formula-eye {
    border-left: 4px solid #f39c12;
    padding-left: 15px;
}

.formula-eye h3 {
    color: #001f3f;
    font-size: 14px;
    margin-bottom: 15px;
}

.formula-field {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
    font-size: 12px;
}

.formula-field label {
    color: #666;
    font-weight: 600;
}

.formula-field value {
    color: #001f3f;
    font-weight: 700;
}

.formula-signature {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 40px;
    font-size: 11px;
    text-align: center;
}

.formula-signature-line {
    border-top: 2px solid #333;
    padding-top: 10px;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #28a745;
}

.info-message {
    background: #d1ecf1;
    color: #0c5460;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #17a2b8;
}

.warning-message {
    background: #fff3cd;
    color: #856404;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border-left: 4px solid #ffc107;
}

.empty-state {
    text-align: center;
    color: #999;
    padding: 30px 20px;
    font-size: 12px;
}

@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        overflow: visible !important;
        max-width: 100%;
        max-height: none !important;
    }

    .tab-content.active {
        overflow: visible !important;
        max-height: none !important;
    }
    
    .header, .tabs, .button-group, .tab-content:not(.active),
    .cloud-search-bar, .sync-badge, #pwaBanner, #pwaUpdateBanner {
        display: none !important;
    }
    
    .formula-container, .orden-container {
        border: 1px solid #999;
        max-width: 100%;
        margin: 0;
        padding: 20px;
        overflow: visible !important;
        page-break-inside: avoid;
    }
}

@media (max-width: 1200px) {
    .form-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
    
    .refraction-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .cotizador-grid {
        grid-template-columns: 1fr;
    }
}

/* ═══ ESTILOS MÓDULO CLOUD ═══ */
/* Badge de estado de sincronización (esquina superior derecha del header) */
.sync-badge {
    display: none;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 12px;
    border-radius: 20px;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.sync-success { background: #d4edda; color: #155724; }
.sync-warning { background: #fff3cd; color: #856404; }
.sync-info    { background: #d1ecf1; color: #0c5460; }

/* Barra de búsqueda por cédula en tab Base de Datos */
.cloud-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, #e8f4fd, #d1ecf1);
    border: 2px solid #17a2b8;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
}
.cloud-search-bar label {
    font-size: 12px;
    font-weight: 700;
    color: #0c5460;
    white-space: nowrap;
    margin-bottom: 0;
}
.cloud-search-bar input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #17a2b8;
    border-radius: 6px;
    font-size: 13px;
}
.cloud-search-bar input:focus {
    border-color: #0c5460;
    box-shadow: 0 0 0 3px rgba(23, 162, 184, 0.2);
}
.btn-cloud {
    background: linear-gradient(135deg, #17a2b8, #0c5460);
    color: white;
    padding: 9px 18px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
}
.btn-cloud:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(23,162,184,0.4); }
.btn-sync {
    background: linear-gradient(135deg, #6f42c1, #4a2c8a);
    color: white;
}
