@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

/* ── Variables ── */
:root {
  --bg:        #060d1a;
  --bg2:       #0a1628;
  --card:      #0d1e35;
  --card2:     #102240;
  --border:    #1a3050;
  --border2:   #243d5e;
  --text:      #ddeeff;
  --muted:     #6a8aaa;
  --muted2:    #4a6a8a;
  --accent:    #38bdf8;
  --accent2:   #7dd3fc;
  --glow:      #38bdf833;
  --danger:    #f87171;
  --success:   #34d399;
  --warning:   #fbbf24;
  --stripe:    #0b1a2e;
  --radius:    14px;
  --radius-sm: 8px;
}

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

/* ── Base ── */
html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(ellipse 65% 45% at 75% 8%, #fbbf2433, transparent 70%),
    linear-gradient(180deg, #050c18 0%, #0a1930 45%, #0d2138 75%, #081222 100%);
  animation: sunPulse 8s ease-in-out infinite;
}

@keyframes sunPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.75; }
}

/* Drifting cloud layer, more visible + faster */
body::after {
  content: '';
  position: fixed;
  inset: -10% -30%;
  z-index: -2;
  background-image:
    radial-gradient(ellipse 260px 85px at 10% 15%, #8fb3d444, transparent 70%),
    radial-gradient(ellipse 220px 75px at 30% 12%, #8fb3d43a, transparent 70%),
    radial-gradient(ellipse 300px 95px at 65% 25%, #a3c2e044, transparent 70%),
    radial-gradient(ellipse 240px 80px at 85% 18%, #8fb3d438, transparent 70%),
    radial-gradient(ellipse 280px 90px at 20% 60%, #6a8aaa3a, transparent 70%),
    radial-gradient(ellipse 230px 75px at 55% 70%, #6a8aaa32, transparent 70%),
    radial-gradient(ellipse 250px 82px at 90% 65%, #8fb3d436, transparent 70%);
  animation: driftClouds 35s linear infinite;
  pointer-events: none;
}

@keyframes driftClouds {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-20%); }
}

/* Faint rain-streak texture, very subtle */
main::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: repeating-linear-gradient(
    100deg,
    transparent 0px,
    transparent 140px,
    #38bdf80c 140px,
    transparent 142px
  );
  animation: rainDrift 6s linear infinite;
  pointer-events: none;
}

@keyframes rainDrift {
  0%   { background-position: 0 0; }
  100% { background-position: -200px 400px; }
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin-bottom: 0.5rem; }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); margin-bottom: 0.4rem; }
h3 { font-size: 1.2rem; margin-bottom: 0.3rem; }

p { color: var(--muted); margin-bottom: 1rem; }
a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent2); }

/* ── Header / Nav ── */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(6, 13, 26, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffe66d, #ff922b 45%, #e85d04 75%);
  box-shadow: 0 0 20px rgba(255, 146, 43, 0.55), 0 0 6px rgba(255, 230, 109, 0.3);
  flex-shrink: 0;
  transition: transform .3s, box-shadow .3s;
}

.logo:hover {
  transform: scale(1.1);
  box-shadow: 0 0 30px rgba(255, 146, 43, 0.8);
}

.brand {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.5px;
  color: var(--text);
  white-space: nowrap;
}

.nav-links {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color .2s, background .2s;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--card);
}

.nav-links .nav-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}

.nav-links span {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--glow);
  border-radius: var(--radius-sm);
  border: 1px solid #38bdf822;
}

/* ── Main ── */
main {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 32px auto;
  padding: 0 24px;
}

/* ── Cards ── */
.card {
  background: rgba(13, 30, 53, 0.55);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.card:hover { border-color: var(--border2); }
.card.pad { padding: 24px; }
.card.pad-lg { padding: 32px; }

/* ── Auth Cards ── */
.auth-wrap {
  max-width: 440px;
  margin: 40px auto;
}

.auth-wrap .card {
  padding: 36px;
  background: linear-gradient(160deg, #0f2040, #0a1628);
  border-color: var(--border2);
  box-shadow: 0 20px 60px rgba(0,0,0,.5), 0 0 0 1px var(--border);
}

.auth-wrap h1 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}

.auth-wrap .subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 28px;
}

/* ── Forms ── */
form { display: flex; flex-direction: column; gap: 0; }

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

label {
  display: block;
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 8px;
}

input, select, textarea {
  width: 100%;
  padding: 11px 14px;
  background: rgba(6, 13, 26, 0.8);
  color: var(--text);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  transition: border-color .2s, box-shadow .2s, background .2s;
  outline: none;
  margin-bottom: 16px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
  background: rgba(6, 13, 26, 1);
}

input::placeholder { color: var(--muted2); }

select option { background: var(--bg2); color: var(--text); }

textarea { resize: vertical; min-height: 120px; line-height: 1.5; }

/* ── Buttons ── */
.actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 22px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: linear-gradient(180deg, #1a3d5c, #122d47);
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  transition: transform .15s, box-shadow .15s, border-color .15s, background .15s;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,.3);
  border-color: var(--accent);
  color: var(--accent2);
}

.btn:active { transform: translateY(0); }

.btn.primary {
  background: linear-gradient(135deg, #0369a1, #0284c7);
  border-color: #38bdf8aa;
  color: #fff;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.25);
}

.btn.primary:hover {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  box-shadow: 0 8px 24px rgba(56, 189, 248, 0.4);
  color: #fff;
}

.btn.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn.secondary:hover {
  border-color: var(--border2);
  color: var(--text);
}

.btn.danger {
  background: linear-gradient(135deg, #7f1d1d, #991b1b);
  border-color: #f8717188;
  color: #fca5a5;
}

.btn.danger:hover {
  background: linear-gradient(135deg, #991b1b, #dc2626);
  box-shadow: 0 8px 20px rgba(248, 113, 113, 0.3);
}

/* ── Flash Messages ── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(90deg, #0c2a4a, #0a1e38);
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
  animation: slideIn .3s ease;
}

.flash.error {
  border-left-color: var(--danger);
  background: linear-gradient(90deg, #2a0c0c, #1e0a0a);
}

.flash.success {
  border-left-color: var(--success);
  background: linear-gradient(90deg, #0c2a1e, #0a1e16);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Error text ── */
.error { color: var(--danger); font-size: 0.85rem; margin-top: -10px; margin-bottom: 10px; }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 0.9rem;
}

thead th {
  background: #102447;
  color: #a0c4e8;
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border2);
  text-align: left;
}

tbody tr { transition: background .15s; }
tbody tr:nth-child(odd) { background: var(--stripe); }
tbody tr:hover { background: var(--card2); }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); }

/* ── Stat Cards ── */
.cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin: 16px 0;
}

.stat {
  background: rgba(13, 30, 53, 0.45);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .2s, transform .2s, background .2s;
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: 0;
  transition: opacity .2s;
}

.stat:hover { border-color: var(--border2); transform: translateY(-2px); }
.stat:hover::before { opacity: 1; }

.stat h4 {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 8px;
}

.stat .val {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--text);
  line-height: 1;
}

.stat .unit {
  font-size: 0.85rem;
  color: var(--muted);
  margin-left: 3px;
}

/* ── Pills / Badges ── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid var(--border2);
  background: var(--card);
}

.pill.ok   { color: #6ee7b7; border-color: #065f46; background: #052e1e; }
.pill.bad  { color: #fca5a5; border-color: #7f1d1d; background: #2a0c0c; }
.pill.warn { color: #fde68a; border-color: #78350f; background: #2a1a06; }
.pill.info { color: var(--accent2); border-color: #075985; background: #0c2a40; }

/* ── Grid Layouts ── */
.grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 860px) { .grid { grid-template-columns: 1fr 2fr; } }

/* ── Plot / Chart containers ── */
.plot { width: 100%; min-height: 360px; }
@media (max-width: 600px) { .plot { min-height: 260px; } }

/* ── Muted text ── */
.muted { color: var(--muted); font-size: 0.875rem; }
.muted-sm { color: var(--muted2); font-size: 0.8rem; }

/* ── Divider ── */
hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

/* ── Footer ── */
footer {
  padding: 20px 24px;
  text-align: center;
  color: var(--muted2);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
  letter-spacing: 0.3px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted2); }

/* ── Responsive ── */
@media (max-width: 860px) {
  .cards { grid-template-columns: repeat(2, 1fr); }
  .nav { padding: 0 16px; }
  main { padding: 0 16px; margin: 20px auto; }
  .auth-wrap .card { padding: 24px; }
}

@media (max-width: 540px) {
  .cards { grid-template-columns: 1fr 1fr; }
  .nav-links { gap: 2px; }
  .nav-links a { padding: 5px 8px; font-size: 0.8rem; }
  .brand { font-size: 0.95rem; }
  .row { grid-template-columns: 1fr; }
}

/* ── Leaflet overlay controls & legend ── */
.leaflet-control-layers {
  background: rgba(13, 30, 53, 0.92) !important;
  backdrop-filter: blur(10px);
  border: 1px solid var(--border2) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text) !important;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  padding: 10px 14px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
}

.leaflet-control-layers label {
  color: var(--text) !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-weight: 500 !important;
  font-size: 0.9rem !important;
  margin-bottom: 6px !important;
  display: flex !important;
  align-items: center;
  gap: 8px;
}

.leaflet-control-layers-selector {
  width: 16px;
  height: 16px;
}

.weather-legend {
  background: rgba(13, 30, 53, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text);
  font-size: 0.8rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  max-width: 220px;
}

.weather-legend h5 {
  font-family: 'Syne', sans-serif;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  margin-bottom: 6px;
}

.weather-legend .gradient-bar {
  height: 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.weather-legend .legend-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
}
