@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700;800&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --w-ink: #1a3a4a;
  --w-ink-soft: #5a7a8a;
  --w-surface: #f4f8fb;
  --w-blue: #3b82f6;
  --w-red: #ef4444;
  --w-sun: #ffd23f;
  --w-card: #fff;
  --w-shadow: 0 16px 36px -16px rgba(26, 58, 74, 0.40);
  --w-radius: 24px;
  --w-font-display: 'Baloo 2', 'Trebuchet MS', ui-rounded, system-ui, sans-serif;
  --w-font-body: 'Nunito', 'Trebuchet MS', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: var(--w-font-body);
  color: var(--w-ink);
  background:
    radial-gradient(1000px 400px at 85% -5%, #e0f2fe 0%, transparent 55%),
    radial-gradient(800px 350px at 5% 0%, #fecaca 0%, transparent 50%),
    var(--w-surface);
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 95vw; height: 95vh; margin: 2.5vh auto 0;
  padding: clamp(8px, 1.5vh, 16px) clamp(14px, 3vw, 28px) clamp(12px, 2vh, 20px);
  overflow: hidden; display: flex; flex-direction: column; gap: 10px;
}

header {
  position: relative; overflow: hidden; flex-shrink: 0;
  border-radius: var(--w-radius);
  padding: clamp(10px, 1.5vh, 16px) clamp(12px, 1.8vw, 22px);
  background: linear-gradient(120deg, #8ed1f0 0%, #a7e8c8 60%, #ffe39e 120%);
  box-shadow: var(--w-shadow);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.sun {
  position: absolute; right: 6%; top: -26px; width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #fff2b0, var(--w-sun));
  box-shadow: 0 0 60px 14px rgba(255, 210, 63, 0.6);
  pointer-events: none;
}
header .logo, .hero .logo {
  position: absolute; top: 10px; right: 14px; height: 30px; z-index: 2;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}
.back {
  position: relative; z-index: 1;
  color: #1d4ed8; text-decoration: none; font-size: 12px; font-weight: 800;
  background: rgba(255, 255, 255, 0.84); border-radius: 999px; padding: 6px 12px;
  box-shadow: 0 4px 12px -4px rgba(16, 56, 79, 0.35);
}
.back:hover { background: #fff; }
.brand { position: relative; z-index: 1; min-width: 0; flex: 1; }
.brand h1 {
  font-family: var(--w-font-display); font-weight: 800;
  font-size: clamp(20px, 2.8vw, 30px); margin: 0; letter-spacing: 0.3px;
  color: #10384f; text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45);
}
.brand p {
  margin: 6px 0 0; font-size: clamp(13px, 1.3vw, 15px); font-weight: 700;
  color: #1c4a63; max-width: 56ch;
}
.header-actions {
  position: relative; z-index: 1; margin-left: auto;
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  padding-right: 90px;
}

.btn {
  background: rgba(255, 255, 255, 0.84); border: none; border-radius: 999px;
  padding: 9px 18px; font-family: var(--w-font-body); font-weight: 800;
  font-size: 13px; color: #1d4ed8; cursor: pointer;
  box-shadow: 0 4px 12px -4px rgba(16, 56, 79, 0.35);
}
.btn:hover { background: #fff; }
.btn.primary {
  background: linear-gradient(90deg, var(--w-blue), var(--w-red));
  color: #fff;
}
.btn.active { outline: 2px solid #1d4ed8; }

.stage {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 6px 1.05fr;
  align-items: stretch;
}
.stage.map-first { grid-template-columns: 1.15fr 6px 0.95fr; }
.stage.map-first #map-panel { grid-column: 1; grid-row: 1; }
.stage.map-first #splitter { grid-column: 2; grid-row: 1; }
.stage.map-first #chart-panel { grid-column: 3; grid-row: 1; }
.splitter {
  background: #cbd5e1; cursor: col-resize; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  position: relative; border-radius: 3px;
}
.splitter::after { content: '⋮'; color: #64748b; font-size: 18px; font-weight: 900; line-height: 1; pointer-events: none; }
.splitter:hover, .splitter.active { background: #3b82f6; }
.splitter:hover::after, .splitter.active::after { color: #fff; }

.panel {
  background: var(--w-card); border-radius: var(--w-radius); box-shadow: var(--w-shadow);
  padding: 18px clamp(14px, 2.2vw, 22px);
  display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
.panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-shrink: 0; }
.pill {
  font-family: var(--w-font-display); font-weight: 700; font-size: 13px;
  color: #fff; padding: 5px 14px; border-radius: 999px; letter-spacing: 0.3px; white-space: nowrap;
}
.pill.graph { background: linear-gradient(90deg, var(--w-blue), var(--w-red)); }
.pill.map { background: linear-gradient(90deg, #059669, #0284c7); }
.hint { color: var(--w-ink-soft); font-weight: 700; font-size: 13px; }
.spacer { flex: 1; }

.stats {
  display: flex; gap: 8px; margin: 0 0 10px 0; flex-wrap: nowrap;
  overflow: hidden; flex-shrink: 0; min-height: 64px;
}
.stat {
  background: linear-gradient(135deg, #eff6ff, #ecfeff);
  border: 2px solid #bae6fd; border-radius: 12px; padding: 8px 6px;
  flex: 0 0 92px; width: 92px; min-width: 92px; height: 64px; overflow: hidden;
}
.stat .val {
  font-family: var(--w-font-display); font-weight: 800; font-size: 15px;
  color: var(--w-blue); line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.stat .lbl {
  font-weight: 700; font-size: 9px; color: var(--w-ink-soft);
  text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.charts { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; }
.charts.grid-2 { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.charts.col-2 { display: grid; grid-template-columns: 1fr 1fr; }
.charts.rows-3 { display: grid; grid-template-rows: 1fr 1fr 1fr; }
#chart, .chart {
  flex: 1; min-height: 80px; border-radius: 12px; overflow: hidden;
  background: #fff; position: relative;
}

#map {
  flex: 1; min-height: 0; position: relative; border-radius: 18px; overflow: hidden;
  background: #e0f2fe; border: 3px solid #bae6fd;
}
.map-legend {
  margin: 8px 0 0; font-size: 11px; color: #666; text-align: center; font-weight: 600; flex-shrink: 0;
}

#loading {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.85); backdrop-filter: blur(4px); gap: 14px;
  transition: opacity 0.3s;
}
#loading img { height: 40px; filter: drop-shadow(0 1px 3px rgba(16, 56, 79, 0.18)); }
#loading p { margin: 0; font-weight: 700; font-size: 14px; color: #333; }
.spinner {
  width: 44px; height: 44px; border: 4px solid #bae6fd; border-top-color: #0ea5e9;
  border-radius: 50%; animation: w-spin 0.7s linear infinite;
}
@keyframes w-spin { to { transform: rotate(360deg); } }

.map-fallback {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 32px 40px; text-align: center; color: var(--w-ink-soft);
  font-size: 14px; font-weight: 700; line-height: 1.55;
}
.map-fallback > div { max-width: 42ch; }

.alarm {
  font-size: 12px; font-weight: 800; padding: 6px 12px; border-radius: 999px;
  background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca;
}
.alarm.ok { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.alarm.warn { background: #fffbeb; color: #b45309; border-color: #fde68a; }

@media (max-width: 860px) {
  .stage, .stage.map-first { grid-template-columns: 1fr; grid-template-rows: 1fr 1.2fr; }
  .splitter { display: none; }
  .stage.map-first #map-panel, .stage.map-first #splitter, .stage.map-first #chart-panel {
    grid-column: auto; grid-row: auto;
  }
  .stage.map-first #map-panel { order: -1; }
  .stats { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .stats::-webkit-scrollbar { display: none; }
  .header-actions { padding-right: 0; }
}

/* Gallery */
body.gallery { overflow: auto; height: auto; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 18px 64px; }
.hero {
  position: relative; overflow: hidden; border-radius: var(--w-radius);
  padding: 22px 24px 20px;
  background: linear-gradient(120deg, #8ed1f0 0%, #a7e8c8 60%, #ffe39e 120%);
  box-shadow: var(--w-shadow); margin-bottom: 28px;
}
.hero h1 {
  font-family: var(--w-font-display); font-weight: 800; font-size: clamp(24px, 3vw, 32px);
  margin: 8px 0 6px; color: #10384f; text-shadow: 0 2px 0 rgba(255, 255, 255, 0.45); position: relative; z-index: 1;
}
.hero p {
  color: #1c4a63; max-width: 62ch; margin: 0; font-weight: 700; line-height: 1.5; position: relative; z-index: 1;
}
.hero .count {
  position: relative; z-index: 1; margin-top: 12px;
  display: inline-block; background: rgba(255, 255, 255, 0.84);
  color: #1d4ed8; font-size: 12px; font-weight: 800; letter-spacing: 0.04em;
  border-radius: 999px; padding: 6px 12px;
}
.group { margin: 28px 0; }
.group h2 { font-family: var(--w-font-display); margin: 0 0 4px; font-size: 22px; color: var(--w-ink); }
.group .blurb { color: var(--w-ink-soft); font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
a.card {
  display: block; text-decoration: none; color: inherit;
  background: var(--w-card); border-radius: var(--w-radius); padding: 16px 16px 14px;
  box-shadow: var(--w-shadow); min-height: 132px; border: 2px solid transparent;
}
a.card:hover { border-color: #bae6fd; transform: translateY(-1px); }
a.card .emo { font-size: 22px; }
a.card h3 { font-family: var(--w-font-display); margin: 8px 0 4px; font-size: 17px; color: #10384f; }
a.card p { margin: 0; color: var(--w-ink-soft); font-size: 13px; font-weight: 700; line-height: 1.45; }
