html,
body {
  height: 100%;
  margin: 0;
  font-family: Inter, system-ui, Arial, sans-serif;
  background: #f4f8fb;
  color: #1e293b;
}

.material-icons {
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
  vertical-align: middle;
}

.error-screen {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef7fb;
}

.error-box {
  width: min(420px, 100%);
  text-align: center;
  background: #fff;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  box-shadow: 0 16px 38px rgba(15, 23, 42, .12);
  padding: 32px 28px;
}

.error-box img {
  max-width: 94px;
  margin-bottom: 18px;
}

.error-box h1 {
  margin: 0 0 10px;
  color: #0f172a;
  font-size: 22px;
}

.error-box p {
  margin: 0;
  color: #475569;
  font-size: 14px;
  line-height: 1.5;
}

.app {
  height: 100%;
  display: grid;
  grid-template-rows: 64px 1fr;
}

.topbar {
  background: #fff;
  border-bottom: 1px solid #dbeafe;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  z-index: 1000;
  box-shadow: 0 2px 12px rgba(15, 23, 42, .06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 900;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #38bdf8, #22c55e);
  color: white;
  display: grid;
  place-items: center;
}

.brand-title {
  font-size: 21px;
}

.brand-title img {
  display: block;
  max-width: 70px;
}

.brand-title span {
  color: #0ea5e9;
}

.subtitle {
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
  border-left: 1px solid #cbd5e1;
  padding-left: 14px;
}

.topbar-city {
  min-width: 190px;
  border-left: 1px solid #cbd5e1;
  padding-left: 14px;
}

.scenario-scale {
  width: 430px;
  display: grid;
  gap: 8px;
  user-select: none;
}

.scenario-scale-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 10px;
  font-weight: 900;
}

.scenario-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: #cad4e0;
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, .18);
}

.scenario-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #084e88;
  border: 3px solid #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, .25);
  transform: translate(-50%, -50%);
  transition: left .2s ease;
}

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

.scenario-option {
  border: 0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  text-align: center;
  font-size: 12px;
  font-weight: 850;
}

.scenario-option.active {
  color: #084e88;
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  min-height: 0;
}

.sidebar {
  background: rgba(239, 248, 255, .96);
  border-right: 1px solid #bae6fd;
  padding: 20px 16px;
  overflow: auto;
}

.sidebar-kicker,
.zone-mode-title,
.card-kicker {
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 10px;
  font-weight: 900;
}

.sidebar-kicker {
  letter-spacing: .16em;
  font-size: 11px;
  margin-bottom: 8px;
}

.sidebar-title {
  font-size: 19px;
  font-weight: 900;
  margin-bottom: 18px;
}

.zone-mode-card,
.risk-card {
  background: white;
  border: 1px solid #e0f2fe;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .08);
}

.zone-mode-card {
  padding: 14px;
  margin-bottom: 14px;
}

.zone-mode-title {
  margin-bottom: 10px;
}

.zone-mode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.zone-mode-label {
  flex: 1 1 auto;
  font-size: 13px;
  font-weight: 900;
  color: #1e293b;
}

.zone-pattern-help-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0369a1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 3px 8px rgba(15, 23, 42, .12);
}

.zone-pattern-help-btn.active {
  background: #0284c7;
  color: white;
}

.zone-pattern-help {
  display: none;
  left: 24px;
  top: 24px;
  width: min(820px, calc(100vw - 48px));
  min-height: 0;
  overflow: hidden;
  z-index: 1170;
  padding: 8px 10px;
  border-radius: 999px;
}

.zone-pattern-help.show {
  display: flex;
  gap: 8px;
  align-items: center;
}

.zone-pattern-help::before {
  content: none;
}

.zone-pattern-help-title {
  flex: 0 0 auto;
  color: #172033;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.zone-pattern-help-items {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.zone-pattern-row {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  flex: 0 0 auto;
  color: #334155;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.zone-pattern-swatch {
  width: 46px;
  height: 34px;
  border: 0;
  border-radius: 0;
  background-color: #fff;
  overflow: hidden;
}

.zone-pattern-title {
  color: #0f172a;
  font-weight: 950;
}

.zone-pattern-help-close {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 50%;
  background: #e2e8f0;
  color: #334155;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.zone-pattern-help-close .material-icons {
  font-size: 17px;
}

.city-select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #bae6fd;
  border-radius: 9px;
  background: #f8fcff;
  color: #0f172a;
  font: inherit;
  font-size: 13px;
  font-weight: 850;
  padding: 8px 10px;
  outline: none;
}

.city-select:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, .22);
}

.city-select-topbar {
  min-height: 34px;
  background: #fff;
  border-color: #dbeafe;
  padding: 5px 34px 5px 10px;
}

.modern-switch,
.risk-toggle {
  position: relative;
  flex: 0 0 auto;
}

.modern-switch {
  width: 52px;
  height: 28px;
}

.risk-toggle {
  width: 38px;
  height: 22px;
}

.modern-switch input,
.risk-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.modern-slider,
.risk-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 999px;
  transition: .2s;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, .18);
}

.modern-slider:before,
.risk-toggle-slider:before {
  content: "";
  position: absolute;
  background: white;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 4px 10px rgba(15, 23, 42, .22);
}

.modern-slider:before {
  width: 22px;
  height: 22px;
  left: 3px;
  top: 1px;
}

.risk-toggle-slider:before {
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .22);
}

.modern-switch input:checked + .modern-slider {
  background: #07508D;
}

.modern-switch input:checked + .modern-slider:before {
  transform: translateX(24px);
}

.risk-toggle input:checked + .risk-toggle-slider {
  background: #07508D;
}

.risk-toggle input:checked + .risk-toggle-slider:before {
  transform: translateX(16px);
}

.risk-card {
  margin-bottom: 10px;
  overflow: hidden;
}

.risk-row {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 13px 14px;
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 9px;
  align-items: center;
  cursor: pointer;
  text-align: left;
}

.risk-row.active {
  background: linear-gradient(90deg, rgba(7, 80, 141, .1), rgba(14, 165, 233, .04));
  outline: 2px solid #07508D;
  box-shadow: inset 4px 0 0 #07508D, 0 8px 18px rgba(7, 80, 141, .12);
}

.risk-code {
  width: 48px;
  height: 30px;
  border-radius: 9px;
  background: #e0f2fe;
  color: #0369a1;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 950;
}

.risk-name {
  font-size: 13px;
  font-weight: 900;
  color: #1e293b;
  line-height: 1.2;
}

.risk-levers {
  display: none;
  border-top: 1px solid #e5eef7;
  background: #f8fcff;
  padding: 8px 0 10px 30px;
}

.risk-levers.show {
  display: grid;
}

.lever-row {
  min-height: 32px;
  border-radius: 0;
  color: #334155;
  transition: color .2s ease;
}

.lever-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 12px 3px 10px;
}

.lever-name {
  min-width: 0;
}

.lever-row.checked {
  color: #020617;
  font-weight: 650;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .85), 0 0 10px rgba(7, 80, 141, .18);
  box-shadow: none;
}

.lever-toggle {
  position: relative;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
}

.lever-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.lever-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #fff;
  border: 2px solid #cad4e0;
  border-radius: 50%;
  transition: .2s;
  box-shadow: 0 2px 6px rgba(15, 23, 42, .12);
}

.lever-toggle-slider:before {
  content: "";
  position: absolute;
  width: 5px;
  height: 9px;
  left: 6px;
  top: 3px;
  background: transparent;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  border-radius: 0;
  transform: rotate(45deg) scale(0);
  transform-origin: center;
  transition: .2s;
  box-shadow: none;
}

.lever-toggle input:checked + .lever-toggle-slider {
  background: #07508D;
  border-color: #07508D;
  box-shadow: 0 0 0 3px rgba(7, 80, 141, .12), 0 4px 10px rgba(7, 80, 141, .18);
}

.lever-toggle input:checked + .lever-toggle-slider:before {
  transform: rotate(45deg) scale(1);
}

.map-wrap {
  position: relative;
  min-width: 0;
}

#map {
  width: 100%;
  height: 100%;
  background: #e7f6fd;
}

.leaflet-control-attribution {
  display: none !important;
}

.leaflet-container {
  background: #e7f6fd;
}

.leaflet-interactive:focus,
.leaflet-container path:focus {
  outline: none;
}

.floating-card {
  position: absolute;
  z-index: 800;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(16px);
  border: 1px solid #bae6fd;
  border-radius: 16px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .14);
  padding: 14px 16px;
}

.info-card {
  left: 24px;
  top: 20px;
  width: 300px;
}

.card-kicker {
  margin-bottom: 6px;
}

.card-title {
  font-size: 16px;
  font-weight: 900;
}

.card-meta {
  margin-top: 4px;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.score-card,
.risk-scale-panel {
  display: none;
}

.legend-panel {
  right: 24px;
  top: 24px;
  width: 315px;
  max-height: calc(100vh - 130px);
  overflow: auto;
}

.legend-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.legend-panel h3 {
  margin: 0;
  color: #0284c7;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 11px;
}

.legend-help-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0369a1;
  font-weight: 950;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(15, 23, 42, .12);
  display: grid;
  place-items: center;
  padding: 0;
}

.legend-help-btn.active {
  background: #0284c7;
  color: white;
}

.legend-help {
  display: none;
  border: 1px solid #bae6fd;
  background: #f0f9ff;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 10px;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.legend-help.show,
.legend-list.show {
  display: block;
}

.legend-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 10px;
  padding: 4px;
  border-radius: 12px;
  background: #eef5fe;
}

.legend-tab {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #475569;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 900;
  padding: 8px 8px;
}

.legend-tab.active {
  background: #fff;
  color: #172033;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .12);
}

.legend-list {
  display: none;
}

.pattern-legend-list {
  display: none;
}

.pattern-legend-list.show {
  display: grid;
  gap: 8px;
}

.legend-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  margin: 9px 0;
  font-size: 12px;
  font-weight: 500;
}

.pattern-legend-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #172033;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  padding: 4px 6px;
  text-align: left;
  transition: background .2s ease, opacity .2s ease;
}

.pattern-legend-row:hover {
  background: rgba(7, 80, 141, .06);
}

.pattern-legend-row.is-hidden {
  opacity: .45;
}

.pattern-legend-row.is-hidden .zone-pattern-title {
  text-decoration: line-through;
}

.pattern-legend-row .zone-pattern-title {
  font-weight: 650;
}

.tooltip-risk-level {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.tooltip-risk-swatch {
  width: 18px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, .65);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, .18);
}

.swatch {
  width: 22px;
  height: 14px;
  border-radius: 4px;
  border: 1px solid rgba(15, 23, 42, .25);
}

.status {
  font-size: 10px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #dcfce7;
  color: #16a34a;
  font-weight: 900;
}

.zone-visibility-row {
  display: none;
}

.leaflet-tooltip.zone-label {
  border: 0;
  background: rgba(15, 23, 42, .9);
  color: white;
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .25);
  font-weight: 800;
}

.app-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 2200;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, .94);
  box-shadow: 0 16px 36px rgba(15, 23, 42, .24);
  color: #fff;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.35;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 14px);
  transition: opacity .18s ease, transform .18s ease;
}

.app-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .scenario-scale {
    width: 300px;
  }
}

@media (max-width: 700px) {
  .app {
    grid-template-rows: 118px 1fr;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    align-content: center;
    gap: 10px;
    padding: 10px 16px;
    overflow: hidden;
  }

  .brand {
    min-width: 0;
  }

  .topbar-city {
    min-width: 138px;
    padding-left: 10px;
  }

  .city-select-topbar {
    min-height: 31px;
    font-size: 12px;
  }

  .brand-title img {
    max-width: 58px;
  }

  .subtitle {
    font-size: 13px;
    line-height: 1.2;
  }

  .scenario-scale {
    width: min(calc(100% - 12px), 430px);
    margin-left: 6px;
    margin-right: 6px;
  }

  .scenario-option {
    font-size: 11px;
  }

  .scenario-options {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 0 16px;
  }

  .legend-panel {
    left: 16px;
    right: 16px;
    top: 24px;
    width: auto;
    max-height: calc(100vh - 170px);
  }

  .zone-pattern-help {
    left: 16px;
    right: 16px;
    top: 146px;
    width: auto;
    max-height: calc(100vh - 190px);
  }
}
