:root {
    /* Paleta Médica Moderna */
    --primary: #4a90e2;      /* Azul Clínico */
    --accent: #50e3c2;       /* Verde Agua */
    --danger: #ff5f57;       /* Rojo Alerta */
    --warning: #f7b731;      /* Amarillo Precaución */
    --success: #2ecc71;      /* Verde Normal */
    
    /* Fondos y Efectos */
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    
    /* Textos */
    --text-main: #333;
    --text-sec: #666;
    
    /* Tipografía Nativa */
    --font-stack: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --radius: 16px;
}

/* Modo Oscuro Automático */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-gradient: linear-gradient(135deg, #1e1e24 0%, #2d3436 100%);
        --glass-bg: rgba(40, 40, 40, 0.6);
        --glass-border: rgba(255, 255, 255, 0.1);
        --text-main: #f5f5f5;
        --text-sec: #aaa;
    }
}

/* --- RESET & BASICS --- */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

body {
    font-family: var(--font-stack);
    background: var(--bg-gradient);
    color: var(--text-main);
    min-height: 100vh;
    /* Evita el efecto de rebote elástico en iOS */
    overscroll-behavior-y: none; 
    -webkit-font-smoothing: antialiased;
}

#app {
    max-width: 600px; /* Límite para tablet/desktop */
    margin: 0 auto;
    padding: 20px;
    padding-bottom: 80px; /* Espacio para scroll y FAB */
}

/* --- GLASSMORPHISM UTILITIES --- */
/* Paneles semitransparentes */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* --- HEADER --- */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    position: sticky;
    top: 10px;
    z-index: 100;
}

/* --- BOTONES --- */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    width: 100%;
    padding: 15px;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 10px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-primary:active {
    opacity: 0.8;
}

.btn-small {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

/* Botón Flotante (FAB) */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 30px;
    border: none;
    box-shadow: 0 4px 15px rgba(74, 144, 226, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 90;
    transition: transform 0.2s;
}

.fab:active {
    transform: scale(0.9);
}

.icon-btn { 
    background: none; 
    border: none; 
    font-size: 1.5rem; 
    cursor: pointer; 
    color: var(--text-main); 
    padding: 5px;
}

/* --- INPUTS & FORMULARIOS --- */
/* Inputs Móviles Optimizados */
input, select {
    width: 100%;
    padding: 12px; /* Altura táctil correcta */
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    background: rgba(255,255,255,0.5);
    font-size: 16px; /* Evita zoom automático en iOS */
    margin-top: 5px;
    color: var(--text-main);
    outline: none;
}

input:focus, select:focus {
    border-color: var(--primary);
    background: rgba(255,255,255,0.8);
}

.input-group { margin-bottom: 15px; }

/* Grid para inputs de Tensión (Sys/Dia) */
.bp-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* --- CARDS & DASHBOARD --- */
.actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.action-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s, background 0.2s;
}

.action-card:active { transform: scale(0.98); background: var(--glass-border); }
.action-card .icon { font-size: 2rem; margin-bottom: 10px; }

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    text-align: center;
    padding: 15px;
    margin-bottom: 0;
}

.stat-card strong {
    display: block;
    font-size: 1.5rem;
    color: var(--primary);
}

.stat-card .label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-sec);
    margin-bottom: 5px;
}

/* --- MODAL (IMPORTAR/EXPORTAR) --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4); /* Fondo oscurecido */
    backdrop-filter: blur(5px); /* Desenfoque del fondo */
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.modal-content {
    background: rgba(255, 255, 255, 0.9); /* Más opaco para legibilidad */
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    animation: slideUp 0.3s ease-out;
}

@media (prefers-color-scheme: dark) {
    .modal-content {
        background: rgba(40, 40, 40, 0.95);
    }
}

@keyframes slideUp {
    from { transform: translateY(50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* --- UTILIDADES --- */
.hidden { display: none !important; }

/* Barra de herramientas en historiales */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

/* Lista scrollable */
.list-container {
    padding-bottom: 20px;
}
