/* ============================================================
   AquaMonitor — Premium Dark Theme
   ============================================================ */

/* ── Google Font ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Tokens ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:            #070c1d;
    --surface:       rgba(10, 18, 42, 0.85);
    --border:        rgba(0, 229, 180, 0.12);
    --accent:        #00e5b4;
    --accent-dim:    rgba(0, 229, 180, 0.12);
    --flow:          #00e5b4;
    --pressure:      #7c83ff;
    --pressure-dim:  rgba(124,131,255,0.12);
    --warning:       #ffb800;
    --warning-dim:   rgba(255,184,0,0.12);
    --danger:        #ff3b5c;
    --danger-dim:    rgba(255,59,92,0.12);
    --text:          #c8d6e8;
    --text-bright:   #e8f0fb;
    --text-muted:    #4a5770;
    --radius:        12px;
    --radius-lg:     18px;
    --shadow:        0 8px 32px rgba(0,0,0,0.45);
}

/* ── Base ── */
html { font-size: 16px; scroll-behavior: smooth; }
body {
    min-height: 100vh;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 15% 0%,  rgba(0,229,180,0.07) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 100%, rgba(124,131,255,0.06) 0%, transparent 55%);
    color: var(--text);
    font-family: 'Inter', system-ui, sans-serif;
    overflow-x: hidden;
}

/* ── Navbar ── */
nav {
    display: flex;
    align-items: center;
    padding: 0 2rem;
    height: 64px;
    background: rgba(7,12,29,0.96);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(20px);
    position: sticky; top: 0; z-index: 100;
    gap: 1.5rem;
}
.nav-logo {
    display: flex; align-items: center; gap: 0.55rem;
    font-size: 1.1rem; font-weight: 800; color: var(--text-bright);
    letter-spacing: -0.03em; flex-shrink: 0; text-decoration: none;
}
.nav-logo .accent { color: var(--accent); }
.nav-links { display: flex; gap: 0.2rem; flex: 1; }
.nav-links a {
    padding: 0.4rem 1rem; border-radius: 8px; text-decoration: none;
    font-size: 0.875rem; font-weight: 500; color: var(--text-muted);
    transition: all 0.2s;
}
.nav-links a:hover  { color: var(--text); background: rgba(255,255,255,0.04); }
.nav-links a.active { color: var(--accent); background: var(--accent-dim); }

.status-badge {
    display: flex; align-items: center; gap: 0.4rem;
    font-size: 0.75rem; font-weight: 600; padding: 0.35rem 0.85rem;
    border-radius: 20px; letter-spacing: 0.02em; flex-shrink: 0;
}
.status-badge.ok   { color: var(--accent);   background: var(--accent-dim);   border: 1px solid rgba(0,229,180,0.3); }
.status-badge.warn { color: var(--warning);  background: var(--warning-dim);  border: 1px solid rgba(255,184,0,0.3); }
.status-badge.demo { color: var(--pressure); background: var(--pressure-dim); border: 1px solid rgba(124,131,255,0.3); }

.status-dot {
    width: 7px; height: 7px; border-radius: 50%; background: currentColor;
    animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.4} }

/* ── Main ── */
main { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem; display: flex; flex-direction: column; gap: 1.75rem; }

.section-label {
    font-size: 0.68rem; font-weight: 700; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-muted); margin-bottom: 1rem;
}

/* ── Card ── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); backdrop-filter: blur(20px);
    box-shadow: var(--shadow); transition: border-color 0.3s;
}
.card:hover { border-color: rgba(0,229,180,0.22); }

/* ── Gauge Row ── */
.gauges-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.gauge-card { padding: 1.5rem; display: flex; flex-direction: column; align-items: center; gap: 0.25rem; }
.gauge-card-label {
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-muted); align-self: flex-start;
}
.gauge-svg { width: 100%; max-width: 280px; will-change: transform; transform: translateZ(0); backface-visibility: hidden; }
.gauge-val        { fill: var(--text-bright); font-size: 30px; font-weight: 800; font-family: 'Inter', sans-serif; }
.gauge-unit       { fill: var(--text-muted);  font-size: 12px; font-weight: 500; font-family: 'Inter', sans-serif; }
.gauge-name       { fill: var(--text);        font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif; }
.gauge-minmax     { fill: var(--text-muted);  font-size: 11px; font-family: 'Inter', sans-serif; }

/* ── Charts Row ── */
.charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.chart-card { padding: 0 0 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem 0; }
.card-title  { font-size: 0.875rem; font-weight: 600; color: var(--text-bright); display: flex; align-items: center; gap: 0.5rem; }

.badge { font-size: 0.62rem; font-weight: 700; padding: 0.2rem 0.55rem; border-radius: 20px; letter-spacing: 0.06em; }
.badge-noise    { color: var(--warning); background: var(--warning-dim); border: 1px solid rgba(255,184,0,0.3); }
.badge-filtered { color: var(--accent);  background: var(--accent-dim);  border: 1px solid rgba(0,229,180,0.3); }

.chart-legend { display: flex; gap: 1.2rem; padding: 0.5rem 1.4rem; flex-wrap: wrap; }
.legend-item  { display: flex; align-items: center; gap: 0.4rem; font-size: 0.72rem; color: var(--text-muted); font-weight: 500; }
.legend-dot   { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.chart-wrap   { padding: 0 1rem 0; height: 220px; position: relative; }

/* ── Prediction Panel ── */
.prediction-card { padding: 1.5rem; }
.pred-header { display: flex; align-items: flex-start; gap: 0.85rem; margin-bottom: 1.25rem; }
.pred-icon   { font-size: 1.6rem; line-height: 1; padding-top: 2px; }
.pred-title  { font-size: 1rem; font-weight: 700; color: var(--text-bright); }
.pred-sub    { font-size: 0.73rem; color: var(--text-muted); margin-top: 0.15rem; }
.pred-grid   { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }

.pred-stat {
    padding: 1.1rem 1.2rem; border-radius: var(--radius);
    border: 1px solid var(--border); background: rgba(0,0,0,0.2);
    display: flex; flex-direction: column; gap: 0.3rem; transition: all 0.35s;
}
.pred-stat.st-stable  { border-color: rgba(0,229,180,0.35); background: rgba(0,229,180,0.05); }
.pred-stat.st-warning { border-color: rgba(255,184,0,0.4);  background: rgba(255,184,0,0.07);  }
.pred-stat.st-danger  { border-color: rgba(255,59,92,0.4);  background: rgba(255,59,92,0.07);  }

.pred-stat-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); }
.pred-stat-val   { font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; color: var(--text-muted); }
.pred-stat-val.c-ok   { color: var(--accent);  }
.pred-stat-val.c-warn { color: var(--warning); }
.pred-stat-val.c-red  { color: var(--danger);  }
.pred-stat-desc  { font-size: 0.73rem; color: var(--text-muted); }

/* ── Status Bar ── */
.status-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.7rem 2rem; background: rgba(7,12,29,0.7);
    border-top: 1px solid var(--border);
    font-size: 0.73rem; color: var(--text-muted); flex-wrap: wrap; gap: 0.5rem;
}
.sb-item { display: flex; align-items: center; gap: 0.4rem; }
.sb-item span { color: var(--text); }

/* ── History Page ── */
.history-main { max-width: 1400px; margin: 2rem auto; padding: 0 1.5rem; }
.history-controls {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem;
}
.filter-group { display: flex; align-items: center; gap: 0.5rem; }
.filter-group label { font-size: 0.75rem; color: var(--text-muted); font-weight: 600; }
.filter-group input {
    padding: 0.4rem 0.75rem; border-radius: 8px; border: 1px solid var(--border);
    background: rgba(255,255,255,0.04); color: var(--text); font-size: 0.8rem;
    font-family: 'Inter', sans-serif; outline: none;
}
.filter-group input:focus { border-color: var(--accent); }
.btn {
    padding: 0.45rem 1.1rem; border-radius: 8px; font-size: 0.8rem; font-weight: 600;
    cursor: pointer; border: 1px solid; transition: all 0.2s; font-family: 'Inter', sans-serif;
}
.btn-primary { background: var(--accent-dim); color: var(--accent); border-color: rgba(0,229,180,0.4); }
.btn-primary:hover { background: rgba(0,229,180,0.2); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }

.history-table-wrap { overflow-x: auto; border-radius: var(--radius-lg); }
table { width: 100%; border-collapse: collapse; font-size: 0.825rem; }
thead th {
    padding: 0.85rem 1rem; text-align: left; font-size: 0.68rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted);
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody tr { border-bottom: 1px solid rgba(255,255,255,0.04); transition: background 0.15s; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
tbody td { padding: 0.75rem 1rem; color: var(--text); white-space: nowrap; }
td.flow-col { color: var(--flow); font-weight: 600; }
td.pres-col { color: var(--pressure); font-weight: 600; }
td.muted    { color: var(--text-muted); }
.empty-state { text-align: center; padding: 4rem; color: var(--text-muted); font-size: 0.9rem; }

/* ── Responsive ── */
@media (max-width: 900px) {
    .gauges-row, .charts-row { grid-template-columns: 1fr; }
    .pred-grid { grid-template-columns: 1fr 1fr; }
    nav { padding: 0 1rem; gap: 0.75rem; }
    main { padding: 1rem; }
}
@media (max-width: 560px) {
    .pred-grid { grid-template-columns: 1fr; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2a3550; border-radius: 3px; }