:root {
    /* Color Palette - Premium Glassmorphism */
    --primary-aqua: #0ea5e9;
    --primary-glow: #38bdf8;
    --bg-light: #020617;
    --bg-dark: #0f172a;
    --glass-bg: rgba(15, 23, 42, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-purple: #8b5cf6;

    /* System Tokens */
    --nav-height: 80px;
    --radius-full: 9999px;
    --radius-lg: 24px;
    --shadow-soft: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 10px 20px -5px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 30px rgba(14, 165, 233, 0.3);
    --transition-smooth: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main);
    line-height: 1.5;
    overflow-x: hidden;
    height: 100vh;
}

h1,
h2,
h3 {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
}

.app-container {
    max-width: 480px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at top right, rgba(14,165,233,0.15), transparent 400px), radial-gradient(circle at bottom left, rgba(139,92,246,0.15), transparent 400px), var(--bg-light);
    overflow: hidden;
}

/* --- Navigation --- */
.main-nav {
    position: absolute;
    bottom: 24px;
    left: 20px;
    right: 20px;
    height: 72px;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.05);
    z-index: 1000;
}

.nav-item {
    background: none;
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 8px;
}

.nav-item.active {
    color: var(--primary-aqua);
    transform: translateY(-4px);
}

.nav-item i {
    width: 24px;
    height: 24px;
}

.nav-item span {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Content Transitions --- */
.content-view {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 120px 20px;
    scrollbar-width: none;
}

.content-view::-webkit-scrollbar {
    display: none;
}

.fade-in {
    animation: fadeIn 0.6s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* --- Advanced Water Components --- */
.wave-chart {
    width: 100%;
    height: 120px;
    background: rgba(43, 140, 238, 0.05);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
}

.wave {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 200%;
    height: 60%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 800 300"><path fill="%232b8cee" fill-opacity="0.3" d="M0,160 C150,220 250,50 400,160 C550,270 650,50 800,160 L800,300 L0,300 Z"></path></svg>');
    background-size: 50% 100%;
    animation: wave-slide 8s linear infinite;
}

.wave.slow {
    animation-duration: 12s;
    opacity: 0.5;
    bottom: -10px;
    filter: blur(2px);
}

@keyframes wave-slide {
    from {
        transform: translateX(0);
    }

    to {
        transform: translateX(-50%);
    }
}

/* --- Liquid Flow Connector --- */
.flow-line {
    position: absolute;
    left: 31px;
    top: 50px;
    bottom: 120px;
    width: 4px;
    background: #e2e8f0;
    z-index: 1;
}

.flow-active {
    width: 100%;
    height: 100%;
    background: var(--primary-aqua);
    box-shadow: 0 0 15px var(--primary-glow);
}

/* --- Refined 3D Bottle --- */
.bottle-container {
    perspective: 500px;
}

.bottle-3d {
    width: 50px;
    height: 90px;
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 8px 8px 4px 4px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.bottle-3d:hover {
    transform: rotateY(15deg) rotateX(10deg);
}

.bottle-liquid {
    position: absolute;
    bottom: 1px;
    left: 1px;
    right: 1px;
    background: linear-gradient(to top, var(--primary-aqua), var(--primary-glow));
    border-radius: 0 0 3px 3px;
    transition: height 1s ease-in-out;
}

/* --- Dashboard Components --- */
.card {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-soft);
}

.water-balance-widget {
    height: 280px;
    position: relative;
    overflow: hidden;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.liquid-container {
    width: 160px;
    height: 160px;
    background: #eef2f7;
    border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.05);
    animation: wave-blob 10s infinite linear;
}

.liquid-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65%;
    background: linear-gradient(180deg, var(--primary-glow) 0%, var(--primary-aqua) 100%);
    transition: height 1.5s cubic-bezier(0.19, 1, 0.22, 1);
}

.liquid-fill::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 30px;
    top: -20px;
    left: -50%;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 40%;
    animation: wave-motion 4s infinite linear;
}

@keyframes wave-blob {
    0% {
        border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%;
    }

    33% {
        border-radius: 70% 30% 46% 54% / 30% 29% 71% 70%;
    }

    66% {
        border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%;
    }

    100% {
        border-radius: 42% 58% 70% 30% / 45% 45% 55% 55%;
    }
}

@keyframes wave-motion {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.balance-info {
    text-align: center;
    margin-top: 20px;
}

.balance-percentage {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-aqua);
}

/* --- Buttons --- */
.btn-primary {
    background: var(--primary-aqua);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    padding: 16px 32px;
    font-weight: 700;
    font-size: 16px;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 8px 20px rgba(43, 140, 238, 0.3);
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-primary:hover {
    box-shadow: 0 15px 30px rgba(43, 140, 238, 0.4);
    transform: translateY(-2px);
}

/* --- Stats and Grids --- */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.stat-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    padding: 15px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    color: white;
}

.badge-3d {
    width: 100%;
    height: 80px;
    background: linear-gradient(135deg, #fff 0%, #eef2f7 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05), inset 0 -5px 10px rgba(0, 0, 0, 0.05);
    margin-bottom: 10px;
    transition: var(--transition-smooth);
}

.badge-3d:hover {
    transform: rotateY(10deg) translateY(-5px);
}

.dark-mode-card {
    background: rgba(10, 17, 40, 0.85);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dark-mode-card .text-muted {
    color: #94a3b8;
}

/* --- Notifications --- */
#notification-container {
    position: fixed;
    top: 20px;
    left: 20px;
    right: 20px;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: auto;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-aqua);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.toast-content h4 {
    font-size: 14px;
    margin-bottom: 2px;
}

.toast-content p {
    font-size: 12px;
    color: var(--text-muted);
}

/* --- Login & Splash --- */
.login-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at top right, var(--primary-glow), transparent),
        radial-gradient(circle at bottom left, var(--primary-aqua), transparent);
}

.login-brand {
    text-align: center;
    margin-bottom: 40px;
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.login-form {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.1);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.form-group input {
    width: 100%;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.4);
    font-family: inherit;
    font-size: 16px;
    color: var(--text-main);
    transition: var(--transition-smooth);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-aqua);
    background: white;
    box-shadow: 0 0 15px rgba(43, 140, 238, 0.2);
}

.login-footer {
    text-align: center;
    margin-top: 30px;
    font-size: 14px;
    color: var(--text-muted);
}

/* --- Real-time Tracking Animations --- */
.map-overlay-tracking {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.radar-pulse {
    position: absolute;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, var(--primary-aqua) 0%, transparent 70%);
    border-radius: 50%;
    opacity: 0.2;
    animation: radar-expand 3s infinite ease-out;
}

@keyframes radar-expand {
    0% {
        transform: scale(0.1);
        opacity: 0.8;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

.truck-marker {
    position: absolute;
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 100;
    transition: all 1s linear;
    animation: truck-bounce 2s infinite ease-in-out;
}

@keyframes truck-bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

.delivery-path {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 150px;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    transform: translate(-50%, -50%) rotate(-45deg);
    border-radius: 2px;
}

.path-fill {
    height: 100%;
    background: var(--primary-aqua);
    box-shadow: 0 0 10px var(--primary-glow);
    animation: path-progress 20s forwards linear;
}

@keyframes path-progress {
    from {
        width: 0%;
    }

    to {
        width: 100%;
    }
}

/* --- Gallon Icon (Garrafón) --- */
.empty-gallon-icon {
    width: 30px;
    height: 40px;
    position: relative;
    border: 2px solid white;
    border-radius: 6px 6px 4px 4px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(2px);
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.gallon-neck {
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 8px;
    border: 2px solid white;
    background: var(--bg-dark);
    border-radius: 2px;
}

.gallon-handle {
    position: absolute;
    top: 5px;
    right: 2px;
    width: 8px;
    height: 12px;
    border: 2px solid white;
    border-left: none;
    border-radius: 0 4px 4px 0;
}

.gallon-body::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 10%;
    /* Representa que está casi vacío */
    background: var(--primary-aqua);
    opacity: 0.5;
}

.hidden {
    display: none;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.justify-between {
    justify-content: space-between;
}

.items-center {
    align-items: center;
}

.gap-10 {
    gap: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.text-center {
    text-align: center;
}

/* --- Download Modal --- */
.download-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 17, 40, 0.85);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.download-modal {
    width: 100%;
    max-width: 480px;
    background: white;
    border-top-left-radius: 32px;
    border-top-right-radius: 32px;
    padding: 30px 24px 40px;
    position: relative;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-main);
}

.download-tabs {
    display: flex;
    background: #f1f5f9;
    padding: 6px;
    border-radius: 16px;
    margin-bottom: 24px;
}

.download-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: none;
    border-radius: 12px;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.download-tab.active {
    background: white;
    color: var(--primary-aqua);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.download-step {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
    align-items: center;
}

.step-number {
    width: 28px;
    height: 28px;
    background: var(--primary-aqua);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    flex-shrink: 0;
}

.step-text {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
}

.step-icon-bg {
    background: #f1f5f9;
    padding: 6px;
    border-radius: 8px;
    display: inline-flex;
    vertical-align: middle;
}
/* --- Premium Glassmorphism Enhancements --- */
.glass-card {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.glass-btn {
    background: rgba(14, 165, 233, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(14, 165, 233, 0.3);
    color: white;
    padding: 10px 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.glass-btn:hover {
    background: rgba(14, 165, 233, 0.4);
    transform: translateY(-2px);
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-bottom: 10px;
}

.lab-param {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.lab-input {
    width: 80px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 5px 10px;
    border-radius: 8px;
    text-align: center;
}
.glass-input {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: 12px 16px;
    border-radius: 12px;
    width: 100%;
}

.glass-input:focus {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-aqua);
    outline: none;
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 800;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-dark);
}

/* Pulse animation for recording indicator */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}
/* =============================================
   LEAFLET MAP OVERRIDES
   ============================================= */
.leaflet-plant-marker,
.leaflet-driver-marker {
    background: transparent !important;
    border: none !important;
}

@keyframes driverPulse {
    0% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

.leaflet-driver-pulse {
    position: relative;
}

.leaflet-control-zoom a {
    background: rgba(15, 23, 42, 0.9) !important;
    color: white !important;
    border: 1px solid rgba(255,255,255,0.15) !important;
}

.leaflet-control-zoom {
    border: none !important;
    border-radius: 12px !important;
    overflow: hidden;
}

.animated-dash {
    animation: dashMove 1.5s linear infinite;
}

@keyframes dashMove {
    to { stroke-dashoffset: -18; }
}

#kpi-weekly-chart,
#kpi-product-chart {
    max-width: 100%;
}
