:root {
    --bg-dark: #090d16;
    --bg-card: rgba(18, 25, 41, 0.65);
    --border-card: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(0, 242, 254, 0.3);
    
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-sub: #64748b;

    --cyan-glow: #00f2fe;
    --cyan-dark: #4facfe;
    --blue-glow: #38bdf8;
    --purple-glow: #a855f7;
    --emerald-glow: #10b981;
    --amber-glow: #f59e0b;
    --rose-glow: #ef4444;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Ambient Lighting Effect */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
}
.glow-blue {
    top: -10%;
    left: 10%;
    width: 600px;
    height: 600px;
    background: #00f2fe;
}
.glow-cyan {
    bottom: -10%;
    right: 15%;
    width: 700px;
    height: 700px;
    background: #3b82f6;
}
.glow-purple {
    top: 40%;
    left: 45%;
    width: 500px;
    height: 500px;
    background: #8b5cf6;
}

.app-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

/* Header Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.brand-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: linear-gradient(135deg, #00f2fe, #4facfe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.4);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-text h1 span {
    color: var(--cyan-glow);
}

.sub-brand {
    font-size: 12px;
    color: var(--text-muted);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.sync-info-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-card);
    border-radius: 30px;
    font-size: 13px;
    color: var(--text-muted);
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--emerald-glow);
    box-shadow: 0 0 10px var(--emerald-glow);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.countdown {
    font-weight: 600;
    color: var(--cyan-glow);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 12px;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #00f2fe, #0072ff);
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 242, 254, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-main);
    border: 1px solid var(--border-card);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: var(--cyan-glow);
}

/* Alert Banner */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.25), rgba(245, 158, 11, 0.25));
    border: 1px solid rgba(239, 68, 68, 0.5);
    border-radius: 16px;
    margin-bottom: 24px;
    backdrop-filter: blur(12px);
    box-shadow: 0 8px 32px rgba(239, 68, 68, 0.2);
    animation: alertPulse 2s infinite alternate;
}

@keyframes alertPulse {
    from { border-color: rgba(239, 68, 68, 0.4); box-shadow: 0 0 15px rgba(239, 68, 68, 0.2); }
    to { border-color: rgba(239, 68, 68, 0.8); box-shadow: 0 0 30px rgba(239, 68, 68, 0.5); }
}

.alert-banner.hidden {
    display: none;
}

.alert-icon {
    font-size: 28px;
    color: var(--rose-glow);
}

.alert-content h4 {
    font-family: var(--font-heading);
    color: var(--rose-glow);
    font-size: 16px;
    font-weight: 700;
}

.alert-content p {
    font-size: 13px;
    color: var(--text-main);
}

.alert-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

/* Glass Card Base */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-card);
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title i {
    font-size: 18px;
}

.card-title h3 {
    font-family: var(--font-heading);
    font-size: 17px;
    font-weight: 600;
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--emerald-glow); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--rose-glow); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-info { background: rgba(56, 189, 248, 0.15); color: var(--blue-glow); border: 1px solid rgba(56, 189, 248, 0.3); }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: var(--purple-glow); border: 1px solid rgba(168, 85, 247, 0.3); }

.card-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 12px;
    color: var(--text-sub);
}

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

@media (max-width: 1200px) {
    .cards-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .cards-grid { grid-template-columns: 1fr; }
}

/* Tank Visualizer Container */
.tank-visual-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.glass-tank {
    position: relative;
    width: 80px;
    height: 140px;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.6), 0 0 15px rgba(0, 242, 254, 0.1);
}

.water-reflection {
    position: absolute;
    top: 0;
    left: 10%;
    width: 20%;
    height: 100%;
    background: linear-gradient(90deg, rgba(255,255,255,0.15), rgba(255,255,255,0));
    pointer-events: none;
    z-index: 5;
}

.liquid {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    background: linear-gradient(180deg, #00f2fe 0%, #0072ff 100%);
    transition: height 1s ease-in-out;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.6);
}

.liquid-blue {
    background: linear-gradient(180deg, #38bdf8 0%, #1e40af 100%);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.6);
}

.liquid-danger {
    background: linear-gradient(180deg, #ef4444 0%, #991b1b 100%) !important;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.8) !important;
}

/* Wave Animations */
.wave {
    position: absolute;
    top: -10px;
    left: 0;
    width: 200%;
    height: 14px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 120' preserveAspectRatio='none'%3E%3Cpath d='M321.39,56.44c58-10.79,114.16-30.13,172-41.86,82.39-16.72,168.19-17.73,250.45-.39C823.78,31,906.67,72,985.66,92.83c70.05,18.48,146.53,26.09,214.34,3V0H0V27.35A600.21,600.21,0,0,0,321.39,56.44Z' fill='%23ffffff' opacity='0.3'%3E%3C/path%3E%3C/svg%3E") repeat-x;
    background-size: 50% 14px;
    animation: wave 4s linear infinite;
}

.wave2 {
    top: -12px;
    opacity: 0.5;
    animation: wave 2.5s linear infinite reverse;
}

@keyframes wave {
    0% { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

.tank-stats {
    flex: 1;
}

.metric-value-container {
    display: flex;
    align-items: baseline;
}

.metric-val {
    font-family: var(--font-heading);
    font-size: 38px;
    font-weight: 800;
    line-height: 1;
}

.metric-unit {
    font-size: 20px;
    color: var(--text-muted);
    margin-left: 4px;
}

.metric-label {
    font-size: 13px;
    color: var(--text-muted);
    display: block;
    margin-top: 4px;
}

.min-threshold-tag {
    margin-top: 10px;
    font-size: 11px;
    color: var(--text-sub);
    background: rgba(255, 255, 255, 0.04);
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-block;
}

/* Pressure Card Gauge */
.gauge-wrapper {
    display: flex;
    justify-content: center;
    margin: 10px 0;
}

.gauge-arc {
    position: relative;
    width: 140px;
    height: 70px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 140px 140px 0 0;
    overflow: hidden;
}

.gauge-fill {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #a855f7, #00f2fe);
    transform-origin: center bottom;
    transform: rotate(0deg);
    transition: transform 1s ease;
}

.gauge-cover {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 116px;
    height: 58px;
    background: var(--bg-dark);
    border-radius: 116px 116px 0 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
}

.gauge-number {
    text-align: center;
}

.gauge-number span:first-child {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
}

.gauge-number .unit {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
}

.pressure-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 10px;
}

.pressure-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #a855f7, #00f2fe);
    transition: width 0.8s ease;
}

/* Motor Card */
.motor-status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.motor-on {
    background: rgba(16, 185, 129, 0.2);
    color: var(--emerald-glow);
    border: 1px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.motor-off {
    background: rgba(100, 116, 139, 0.2);
    color: var(--text-muted);
    border: 1px solid rgba(100, 116, 139, 0.3);
}

.motor-display-box {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 15px 0;
}

.motor-icon-ring {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border-card);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    color: var(--text-sub);
    transition: all 0.3s ease;
}

.motor-ring-active {
    border-color: var(--emerald-glow);
    color: var(--emerald-glow);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.4);
}

.status-large {
    font-family: var(--font-heading);
    font-size: 26px;
    font-weight: 800;

}

.motor-subtext {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Analytics Grid */
.analytics-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

@media (max-width: 992px) {
    .analytics-grid { grid-template-columns: 1fr; }
}

.chart-card {
    min-height: 380px;
    display: flex;
    flex-direction: column;
}

.chart-legend-custom {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.dot-cyan { background: var(--cyan-glow); }
.dot-blue { background: var(--blue-glow); }
.dot-purple { background: var(--purple-glow); }

.chart-container {
    flex: 1;
    position: relative;
    width: 100%;
    min-height: 280px;
}

/* Logs List Card */
.logs-card {
    display: flex;
    flex-direction: column;
}

.logs-list-container {
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
    padding-right: 6px;
}

.log-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.log-icon-warning {
    color: var(--rose-glow);
    font-size: 16px;
}

.log-time {
    font-size: 11px;
    color: var(--text-sub);
}

.empty-log {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-sub);
}

.empty-log i {
    font-size: 32px;
    margin-bottom: 8px;
    color: var(--emerald-glow);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
}

.modal-box {
    width: 100%;
    max-width: 650px;
    background: var(--bg-dark);
    border: 1px solid var(--border-card);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border-card);
}

.modal-header h2 {
    font-family: var(--font-heading);
    font-size: 20px;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
}

.form-section-title {
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 600;
    color: var(--cyan-glow);
    margin: 18px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    border-radius: 10px;
    color: var(--text-main);
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.form-control:focus {
    border-color: var(--cyan-glow);
}

.form-group small {
    display: block;
    font-size: 11px;
    color: var(--text-sub);
    margin-top: 4px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-card);
}

.text-cyan { color: var(--cyan-glow); }
.text-blue { color: var(--blue-glow); }
.text-purple { color: var(--purple-glow); }
.text-amber { color: var(--amber-glow); }
.text-emerald { color: var(--emerald-glow); }
