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

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2d3148;
  --text: #e8eaf0;
  --text-muted: #7b82a0;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 12px;
  --font: system-ui, -apple-system, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
}

h1 { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }

nav { display: flex; gap: 0.25rem; flex: 1; }

.nav-link {
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--surface2); color: var(--text); }
.nav-link.active { background: var(--surface2); color: var(--text); font-weight: 600; }

.location-select {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
  cursor: pointer;
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

.hidden { display: none !important; }

/* ── Dashboard ─────────────────────────────────────────────── */

.recommendation-banner {
  border-radius: var(--radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--border);
}
.recommendation-banner.green { background: #14532d44; border-color: var(--green); color: var(--green); }
.recommendation-banner.yellow { background: #71350044; border-color: var(--yellow); color: var(--yellow); }
.recommendation-banner.red { background: #7f1d1d44; border-color: var(--red); color: var(--red); }

.windows-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) { .windows-grid { grid-template-columns: 1fr; } }

.window-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.window-card.green { border-color: var(--green); }
.window-card.yellow { border-color: var(--yellow); }
.window-card.red { border-color: var(--red); }

.window-header { display: flex; align-items: center; gap: 0.75rem; }
.window-label { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.window-title { font-size: 1rem; font-weight: 600; }

.traffic-light {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}
.traffic-light.green { background: #14532d; color: var(--green); box-shadow: 0 0 16px #22c55e44; }
.traffic-light.yellow { background: #713500; color: var(--yellow); box-shadow: 0 0 16px #eab30844; }
.traffic-light.red { background: #7f1d1d; color: var(--red); box-shadow: 0 0 16px #ef444444; }

.window-reason { font-size: 0.9rem; color: var(--text-muted); }

.window-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.stat-box {
  background: var(--surface2);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  text-align: center;
}
.stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; }
.stat-value { font-size: 1.1rem; font-weight: 700; margin-top: 0.1rem; }

.mini-bar-container { display: flex; align-items: flex-end; gap: 3px; height: 36px; }
.mini-bar {
  flex: 1;
  min-height: 2px;
  border-radius: 2px 2px 0 0;
  transition: background 0.2s;
}

.last-updated {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 1rem;
}

/* ── Charts ────────────────────────────────────────────────── */

.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  position: relative;
  height: 360px;
}

/* ── Tables ────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.data-table th {
  background: var(--surface2);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 0.6rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.data-table th:first-child { text-align: left; }
.data-table td {
  padding: 0.5rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--border);
}
.data-table td:first-child { text-align: left; color: var(--text-muted); }
.data-table tr:hover td { background: var(--surface2); }

/* ── Model weights ─────────────────────────────────────────── */

.model-weights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.model-chip {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.model-chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

.window-loading { color: var(--text-muted); font-size: 0.9rem; text-align: center; padding: 2rem 0; }
.window-reason { font-size: 0.85rem; color: var(--text-muted); margin-top: -0.25rem; }

/* ── Mini hourly bars ──────────────────────────────────────── */

.mini-bar-container {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 44px;
  padding-top: 4px;
}
.mini-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  gap: 2px;
  cursor: default;
}
.mini-bar {
  width: 100%;
  border-radius: 2px 2px 0 0;
  transition: height 0.2s;
  min-height: 3px;
}
.mini-bar-label {
  font-size: 0.6rem;
  color: var(--text-muted);
}

/* ── 7-day week overview ───────────────────────────────────── */

.week-overview { margin-top: 1rem; }

.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
}
@media (max-width: 640px) {
  .week-grid { grid-template-columns: repeat(4, 1fr); }
}

.week-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.25rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.week-day-green  { border-color: #22c55e44; }
.week-day-yellow { border-color: #eab30844; }
.week-day-red    { border-color: #ef444444; }

.week-day-name   { font-size: 0.75rem; font-weight: 700; color: var(--text); }
.week-day-date   { font-size: 0.65rem; color: var(--text-muted); }
.week-status     { font-size: 1rem; font-weight: 700; }
.week-temp       { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.week-prob       { font-size: 0.7rem; font-weight: 600; }

/* ── Locations view ────────────────────────────────────────── */

.locations-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1rem;
  height: calc(100vh - 120px);
}
@media (max-width: 768px) {
  .locations-layout { grid-template-columns: 1fr; grid-template-rows: auto 300px; }
}

.locations-sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
}

.location-map {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  min-height: 300px;
}

.locations-search { position: relative; }
.locations-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-size: 0.9rem;
}
.locations-search input:focus { outline: none; border-color: var(--blue); }

.geocode-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  z-index: 1000;
  max-height: 220px;
  overflow-y: auto;
  box-shadow: 0 8px 24px #0006;
}
.geocode-item {
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  line-height: 1.3;
}
.geocode-item:last-child { border-bottom: none; }
.geocode-item:hover { background: var(--surface2); }

.locations-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  overflow-y: auto;
}

.location-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.location-item-default { border-color: var(--blue); }

.location-item-info {
  flex: 1;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.location-item-name   { font-size: 0.9rem; font-weight: 600; }
.location-item-coords { font-size: 0.7rem; color: var(--text-muted); }
.location-item-badge  {
  font-size: 0.65rem;
  background: var(--blue);
  color: #fff;
  border-radius: 4px;
  padding: 0 4px;
  width: fit-content;
}

.location-item-actions { display: flex; gap: 4px; }

.btn-icon {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 4px;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}
.btn-icon:hover { color: var(--text); border-color: var(--text-muted); }
.btn-icon-danger { border-color: #ef444455; }
.btn-icon-danger:hover { color: var(--red); border-color: var(--red); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.location-hint {
  font-size: 0.8rem;
  color: var(--blue);
  text-align: center;
  padding: 0.25rem 0;
}

.location-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.location-form input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  color: var(--text);
  font-size: 0.9rem;
  width: 100%;
}
.location-form input:focus { outline: none; border-color: var(--blue); }
.loc-coords { font-size: 0.75rem; color: var(--text-muted); min-height: 1em; }
.form-buttons { display: flex; gap: 0.5rem; }

/* ── Scoring section ───────────────────────────────────────── */

.scoring-section {
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.scoring-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.scoring-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.scoring-info {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-sm {
  padding: 0.25rem 0.6rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.scoring-tables {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.scoring-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.scoring-var-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.6rem;
}

.scoring-unit {
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Radar view ────────────────────────────────────────────── */

.radar-wrapper {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 100px);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.radar-map-container {
  flex: 1;
  min-height: 0;
}

.radar-controls-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.radar-playback {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.radar-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1.4;
  transition: background 0.1s;
}
.radar-btn:hover { background: #353960; }
.radar-btn-play  { min-width: 32px; text-align: center; }

.radar-time {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 600;
  margin-left: 0.4rem;
  min-width: 160px;
}

.radar-frame-type {
  font-size: 0.72rem;
  color: var(--blue);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.radar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.radar-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  opacity: 0.85;
}

.radar-opacity-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: default;
}

.radar-opacity-wrap input[type="range"] {
  width: 72px;
  accent-color: var(--blue);
}

/* Location markers on radar map */
.radar-marker {
  width: 10px;
  height: 10px;
  background: var(--blue);
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 6px #0006;
}
.radar-marker-active {
  background: var(--green);
  width: 13px;
  height: 13px;
  box-shadow: 0 0 10px #22c55e88;
}
