:root {
  --blue: #0033A0;
  --cyan: #00AEEF;
  --cyan-active: #009FDF;
  --ink: #333333;
  --muted: #63666A;
  --panel: #F5F5F5;
  --border: #CECECE;
  --font: 'Roboto', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  overflow: hidden;
}

button {
  font-family: var(--font);
}

/* ---------- Screens ---------- */

.screen {
  display: none;
  height: 100%;
  position: relative;
  flex-direction: column;
  background: #fff;
}

.screen.is-active {
  display: flex;
}

/* ---------- Splash ---------- */

#screen-splash {
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  background: linear-gradient(160deg, var(--blue) 0%, var(--cyan) 100%);
  gap: 18px;
  padding: 32px;
}

.splash-icon {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.splash-icon img {
  width: 64px;
  height: 64px;
}

.splash-title {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.3px;
}

.splash-tagline {
  font-size: 15px;
  margin: 0;
  opacity: 0.92;
  max-width: 420px;
}

.splash-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: splash-spin 0.9s linear infinite;
  margin-top: 8px;
}

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

.splash-partners {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 28px;
  opacity: 0.9;
}

.splash-partners img {
  height: 26px;
  filter: brightness(0) invert(1);
  opacity: 0.85;
}

.splash-disclaimer {
  font-size: 11px;
  opacity: 0.75;
  max-width: 480px;
  margin-top: 6px;
  line-height: 1.4;
}

/* ---------- Top bar (shared: home + calendar) ---------- */

.top-bar {
  height: 104px;
  flex: 0 0 104px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.top-bar-icon {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

.top-bar-titles {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.2;
  flex: 0 0 auto;
}

.top-bar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--blue);
}

.top-bar-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.top-bar-search {
  position: relative;
  flex: 1 1 auto;
  max-width: 460px;
  display: flex;
  align-items: center;
}

.top-bar-search .search-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  pointer-events: none;
}

#search-input,
#search-input-calendar {
  width: 100%;
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--border);
  background: var(--panel);
  padding: 0 40px 0 40px;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}

#search-input:focus,
#search-input-calendar:focus {
  border-color: var(--cyan);
  background: #fff;
}

#search-input-calendar:disabled {
  color: var(--muted);
  cursor: default;
}

.search-clear {
  position: absolute;
  right: 10px;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
}

.search-clear:hover {
  background: var(--border);
}

.location-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-left: auto;
}

.location-btn img {
  width: 22px;
  height: 22px;
}

.location-btn.is-active {
  background: var(--cyan-active);
  border-color: var(--cyan-active);
}

.location-btn.is-active img {
  filter: brightness(0) invert(1);
}

/* ---------- Home screen ---------- */

#screen-home .map-area {
  flex: 1;
  position: relative;
  background: var(--panel);
}

#map {
  position: absolute;
  inset: 0;
  z-index: 0;
}

#map-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 24px;
}

#map-fallback[hidden] {
  display: none;
}

#fab-recenter {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30;
}

#fab-recenter img {
  width: 26px;
  height: 26px;
}

/* ---------- Suggestions overlay ---------- */

#suggestions-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 40;
}

#suggestions-overlay[hidden] {
  display: none;
}

#suggestions {
  position: fixed;
  top: 104px;
  left: 200px;
  width: 460px;
  max-height: 360px;
  overflow-y: auto;
  background: #fff;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  z-index: 41;
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

#suggestions[hidden] {
  display: none;
}

#suggestions .suggestion-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  cursor: pointer;
  font-size: 14px;
}

#suggestions .suggestion-row:hover {
  background: var(--panel);
}

#suggestions .suggestion-row img {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

#suggestions .suggestion-empty {
  padding: 14px 18px;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Loading overlay (global: outside .screen, above all screens) ---------- */

#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#loading-overlay[hidden] {
  display: none;
}

#loading-overlay .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: splash-spin 0.9s linear infinite;
}

/* ---------- Calendar screen ---------- */

#screen-calendar .calendar-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.calendar-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

#town-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
  margin: 0;
}

.calendar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#month-range {
  height: 36px;
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 0 14px;
  font-size: 13px;
  color: var(--ink);
  background: #fff;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--muted);
}

.icon-btn:hover {
  background: var(--panel);
}

.calendar-subhead {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  max-width: 720px;
  line-height: 1.5;
}

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

#risk-percent {
  font-size: 34px;
  font-weight: 700;
  color: var(--blue);
}

#risk-percent::after {
  content: '%';
  font-size: 18px;
  margin-left: 2px;
}

#risk-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--cyan-active);
  background: rgba(0, 174, 239, 0.12);
  border-radius: 14px;
  padding: 4px 12px;
}

.calendar-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.calendar-legend img {
  width: 16px;
  height: 16px;
}

#calendars {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 18px;
}

.month-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}

.month-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 8px;
  text-align: center;
}

.month-weekdays,
.month-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.month-weekdays span {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
}

.month-day {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--ink);
  border-radius: 6px;
  position: relative;
}

.month-day.is-empty {
  visibility: hidden;
}

.month-day.is-high-risk img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22px;
  height: 22px;
}

.month-day.is-high-risk .month-day-number {
  position: relative;
  z-index: 1;
  color: #fff;
  font-weight: 700;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
}

.calendar-footer {
  flex: 0 0 auto;
  padding: 10px 28px 16px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px solid var(--border);
  text-align: center;
}

/* ---------- Toast ---------- */

#toast {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--ink);
  color: #fff;
  padding: 10px 22px;
  border-radius: 22px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
}

#toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
