/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #070d1a;
  --bg2: #0d1525;
  --bg3: #111d30;
  --card: #0f1b2e;
  --card-border: rgba(99,179,237,0.12);
  --accent: #38bdf8;
  --accent2: #818cf8;
  --accent3: #34d399;
  --accent4: #f472b6;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 32px rgba(0,0,0,0.5);
  --font: 'Inter', sans-serif;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: #1e3a5f; border-radius: 4px; }

/* ===== CONTAINER ===== */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ===== HEADER ===== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7,13,26,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(56,189,248,0.1);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-icon {
  font-size: 2rem;
  filter: drop-shadow(0 0 12px rgba(56,189,248,0.6));
}

.logo h1 {
  font-size: 1.2rem;
  font-weight: 700;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.last-update {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: rgba(56,189,248,0.07);
  padding: 6px 12px;
  border-radius: 100px;
  border: 1px solid rgba(56,189,248,0.15);
}

/* ===== HERO ===== */
.hero {
  padding: 40px 0 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 40px rgba(56,189,248,0.1);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card:nth-child(1)::before { background: linear-gradient(90deg, #38bdf8, #0ea5e9); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, #818cf8, #6366f1); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, #34d399, #10b981); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, #f472b6, #ec4899); }

.stat-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 500;
}

.stat-value {
  font-size: 2.4rem;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 6px;
}
.stat-card:nth-child(1) .stat-value { color: #38bdf8; }
.stat-card:nth-child(2) .stat-value { color: #818cf8; }
.stat-card:nth-child(3) .stat-value { color: #34d399; }
.stat-card:nth-child(4) .stat-value { color: #f472b6; }

.stat-sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* ===== SKELETON ===== */
.skeleton {
  min-height: 120px;
  background: linear-gradient(90deg, var(--bg3) 25%, #172038 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border: 1px solid rgba(255,255,255,0.04) !important;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== SECTIONS ===== */
.section {
  padding: 32px 0;
}

.section-header {
  margin-bottom: 20px;
}

.section-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.section-header p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ===== CARD ===== */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

/* ===== CHARTS ===== */
.chart-wrap {
  position: relative;
  height: 300px;
}

.chart-wrap--tall {
  height: 420px;
}

/* ===== CONTROLS ===== */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  margin-bottom: 28px;
  align-items: flex-end;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.control-group label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}

select {
  background: var(--bg2);
  border: 1px solid rgba(56,189,248,0.2);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  min-width: 280px;
  transition: border-color 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

select:focus { border-color: var(--accent); }
select option { background: #0d1525; }

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-period, .btn-metric {
  background: var(--bg2);
  border: 1px solid rgba(56,189,248,0.15);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-period:hover, .btn-metric:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-period.active {
  background: rgba(56,189,248,0.12);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-metric.active {
  background: rgba(129,140,248,0.12);
  border-color: var(--accent2);
  color: var(--accent2);
}

/* ===== RESERVOIR CARDS ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.reservoir-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 22px;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  cursor: default;
}

.reservoir-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  border-color: rgba(56,189,248,0.25);
}

.res-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}

.res-location {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.res-bar-wrap {
  background: rgba(255,255,255,0.06);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}

.res-bar {
  height: 100%;
  border-radius: 100px;
  transition: width 1.2s cubic-bezier(.16,1,.3,1);
}

.res-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.res-stat {
  text-align: center;
}

.res-stat-val {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 2px;
}

.res-stat-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Percent color levels */
.level-critical { color: #f87171; }
.level-low      { color: #fb923c; }
.level-mid      { color: #facc15; }
.level-good     { color: #4ade80; }
.level-full     { color: #38bdf8; }

.bar-critical { background: linear-gradient(90deg, #f87171, #ef4444); }
.bar-low      { background: linear-gradient(90deg, #fb923c, #f97316); }
.bar-mid      { background: linear-gradient(90deg, #facc15, #eab308); }
.bar-good     { background: linear-gradient(90deg, #4ade80, #22c55e); }
.bar-full     { background: linear-gradient(90deg, #38bdf8, #0ea5e9); }

/* ===== FOOTER ===== */
.footer {
  margin-top: 48px;
  padding: 32px 0;
  border-top: 1px solid rgba(255,255,255,0.05);
  text-align: center;
}

.footer p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.footer-sub {
  font-size: 0.75rem !important;
  color: #334155 !important;
}

/* ===== LOADING SPINNER ===== */
.spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 300px;
  color: var(--text-muted);
  font-size: 0.9rem;
  gap: 10px;
}

.spinner::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid rgba(56,189,248,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-inner { flex-direction: column; align-items: flex-start; gap: 8px; }
  .controls { flex-direction: column; gap: 16px; }
  select { min-width: 100%; }
  .chart-wrap { height: 240px; }
  .chart-wrap--tall { height: 320px; }
  .stat-value { font-size: 1.8rem; }
  .card { padding: 18px; }
}
