:root {
  color-scheme: dark;
  --bg-deep: #070e18;
  --bg: #091320;
  --surface: #0d1b2a;
  --surface-raised: #112235;
  --surface-soft: #152538;
  --border: rgba(142, 174, 207, 0.16);
  --border-strong: rgba(142, 174, 207, 0.27);
  --text: #f4f8fd;
  --text-soft: #bac6d4;
  --muted: #7f8da0;
  --accent: #2997ff;
  --accent-bright: #45a9ff;
  --accent-soft: rgba(41, 151, 255, 0.14);
  --danger: #ff6b7d;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.28);
}

html {
  min-height: 100%;
  font-size: 16px;
  background: var(--bg-deep);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(41, 151, 255, 0.15), transparent 34rem),
    radial-gradient(circle at 94% 18%, rgba(54, 212, 199, 0.07), transparent 30rem),
    linear-gradient(180deg, #091421 0%, #070e18 58%, #050b13 100%);
  background-attachment: fixed;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
select {
  font: inherit;
}

.app-container {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
  padding: 30px 0 44px;
}

.dashboard-shell {
  display: grid;
  gap: 20px;
}

.dashboard-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  overflow: hidden;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background:
    linear-gradient(120deg, rgba(17, 34, 53, 0.96), rgba(11, 26, 41, 0.93)),
    var(--surface);
  box-shadow: var(--shadow);
}

.dashboard-header::after {
  position: absolute;
  top: -100px;
  right: -60px;
  width: 330px;
  height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(41, 151, 255, 0.2), transparent 68%);
  content: "";
  pointer-events: none;
}

.brand-lockup {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  place-items: center;
  padding: 2px;
  border: 1px solid rgba(41, 151, 255, 0.3);
  border-radius: 14px;
  background: #0b1422;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.08), 0 14px 30px rgba(41, 151, 255, 0.12);
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 11px;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-bright);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 3px;
  color: var(--text);
  font-size: clamp(1.55rem, 2.5vw, 2.1rem);
  font-weight: 780;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

h2 {
  margin: 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 760;
  letter-spacing: -0.015em;
}

.header-description {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.82rem;
}

.status-strip {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 6px;
  width: min(330px, 100%);
  min-width: 0;
}

.status-strip div {
  min-height: 52px;
  padding: 8px 9px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(7, 17, 29, 0.62);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025);
}

.status-strip span {
  display: block;
  margin-bottom: 2px;
  color: var(--accent-bright);
  font-size: 1.08rem;
  font-weight: 800;
  line-height: 1;
}

.status-strip small {
  color: var(--muted);
  font-size: 0.6rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.preparedness-section {
  display: grid;
  gap: 9px;
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(13, 27, 42, 0.78);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.15);
}

.preparedness-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.preparedness-heading > div {
  display: grid;
  gap: 1px;
}

.preparedness-heading h2 {
  font-size: 0.98rem;
}

.preparedness-heading > span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
}

.section-kicker {
  color: var(--accent-bright);
  font-size: 0.66rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.preparedness-topics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 7px;
}

.preparedness-topic {
  display: grid;
  min-width: 0;
  min-height: 56px;
  align-content: space-between;
  gap: 5px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(21, 37, 56, 0.88), rgba(11, 26, 41, 0.9));
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.preparedness-topic span {
  color: var(--accent-bright);
  font-size: 0.59rem;
  font-weight: 850;
  letter-spacing: 0.08em;
}

.preparedness-topic strong {
  font-size: 0.72rem;
  font-weight: 760;
  line-height: 1.28;
}

.preparedness-topic:hover,
.preparedness-topic:focus-visible {
  border-color: rgba(41, 151, 255, 0.55);
  background: linear-gradient(145deg, rgba(41, 151, 255, 0.17), rgba(14, 31, 48, 0.94));
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.17);
  outline: none;
  transform: translateY(-2px);
}

.preparedness-dialog {
  width: min(640px, calc(100% - 30px));
  max-width: none;
  max-height: min(760px, calc(100vh - 40px));
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 24px;
  background: transparent;
  color: var(--text);
}

.preparedness-dialog::backdrop {
  background: rgba(2, 8, 15, 0.76);
  backdrop-filter: blur(7px);
}

.preparedness-dialog-card {
  max-height: min(760px, calc(100vh - 40px));
  padding: 26px;
  overflow: auto;
  border: 1px solid rgba(142, 174, 207, 0.27);
  border-radius: 24px;
  background:
    radial-gradient(circle at 100% 0, rgba(41, 151, 255, 0.16), transparent 17rem),
    linear-gradient(145deg, #112235, #0a1827);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.dialog-header > div {
  display: grid;
  gap: 6px;
}

.dialog-header h2 {
  font-size: clamp(1.3rem, 3vw, 1.75rem);
}

.dialog-close {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  padding: 0 0 3px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--text-soft);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.dialog-close:hover,
.dialog-close:focus-visible {
  border-color: rgba(41, 151, 255, 0.55);
  background: var(--accent-soft);
  color: var(--text);
  outline: none;
}

.dialog-description {
  margin: 20px 0 17px;
  color: var(--text-soft);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.6;
}

.dialog-items {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dialog-items li {
  position: relative;
  padding: 14px 15px 14px 44px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(7, 17, 29, 0.52);
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.55;
}

.dialog-items li::before {
  position: absolute;
  top: 16px;
  left: 16px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-bright);
  content: "✓";
  font-size: 0.68rem;
  font-weight: 900;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) minmax(100px, 0.8fr) minmax(76px, 0.52fr) auto;
  align-items: end;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 15px;
  background: rgba(7, 17, 29, 0.55);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.02);
}

.toolbar-heading {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.toolbar-heading div {
  display: grid;
  gap: 2px;
}

.toolbar-heading strong {
  color: var(--text);
  font-size: 0.82rem;
}

.toolbar-heading div span {
  color: var(--muted);
  font-size: 0.7rem;
}

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid rgba(54, 212, 199, 0.2);
  border-radius: 999px;
  background: rgba(54, 212, 199, 0.08);
  color: #67e2d7;
  font-size: 0.65rem;
  font-weight: 800;
}

.live-badge i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #36d4c7;
  box-shadow: 0 0 0 5px rgba(54, 212, 199, 0.08);
}

.toolbar label {
  display: grid;
  gap: 4px;
  color: var(--text-soft);
  font-size: 0.68rem;
  font-weight: 760;
}

.toolbar .form-select {
  min-height: 38px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background-color: var(--surface-soft);
  color: var(--text);
  box-shadow: none;
  cursor: pointer;
}

.toolbar .form-select:hover,
.toolbar .form-select:focus {
  border-color: rgba(41, 151, 255, 0.68);
  box-shadow: 0 0 0 3px rgba(41, 151, 255, 0.12);
}

.toolbar .btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: linear-gradient(135deg, #2997ff, #147ee5);
  color: #fff;
  font-weight: 800;
  box-shadow: 0 10px 26px rgba(41, 151, 255, 0.23);
}

.toolbar .btn-primary:hover {
  border-color: var(--accent-bright);
  background: linear-gradient(135deg, #45a9ff, #208cf2);
  transform: translateY(-1px);
}

.toolbar .btn-primary:disabled {
  opacity: 0.58;
  transform: none;
}

.alert {
  border-radius: 14px;
}

.alert-danger {
  border-color: rgba(255, 107, 125, 0.24);
  background: rgba(255, 107, 125, 0.1);
  color: #ffadb8;
}

.alert-secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--text-soft);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(380px, 0.92fr) minmax(500px, 1.35fr);
  gap: 20px;
  min-height: 680px;
}

.quake-list-panel,
.map-panel {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: rgba(10, 23, 37, 0.68);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.17);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  margin-bottom: 14px;
}

.panel-heading span {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-size: 0.75rem;
  font-weight: 800;
}

.quake-list {
  display: grid;
  gap: 10px;
  max-height: 640px;
  padding-right: 5px;
  overflow: auto;
  scrollbar-color: #29435c transparent;
  scrollbar-width: thin;
}

.quake-list::-webkit-scrollbar {
  width: 6px;
}

.quake-list::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background: #29435c;
}

.quake-item {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 105px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(17, 34, 53, 0.98), rgba(13, 28, 44, 0.98));
  color: inherit;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025), 0 12px 26px rgba(0, 0, 0, 0.12);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.quake-item:hover {
  border-color: color-mix(in srgb, var(--source-color, var(--accent)) 58%, transparent);
  box-shadow: inset 3px 0 var(--source-color, var(--accent)), 0 16px 34px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px);
}

.quake-item:focus-visible {
  outline: 3px solid rgba(41, 151, 255, 0.36);
  outline-offset: 3px;
}

.quake-magnitude {
  display: grid;
  min-height: 74px;
  place-content: center;
  border: 1px solid var(--magnitude-border, var(--border-strong));
  border-radius: 15px;
  background: var(--magnitude-soft, rgba(255, 255, 255, 0.035));
  box-shadow: inset 0 0 22px rgba(255, 255, 255, 0.025), 0 0 18px color-mix(in srgb, var(--magnitude-border, transparent) 18%, transparent);
  text-align: center;
  transition: border-color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.magnitude-value {
  color: var(--magnitude-color, var(--text));
  font-size: 1.7rem;
  font-weight: 850;
  letter-spacing: -0.04em;
  line-height: 1;
  text-shadow: 0 2px 12px color-mix(in srgb, var(--magnitude-color, transparent) 28%, transparent);
}

.magnitude-type {
  margin-top: 5px;
  color: var(--magnitude-color, var(--muted));
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  opacity: 0.82;
  text-transform: uppercase;
}

.quake-main {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.quake-location {
  overflow: hidden;
  color: var(--text);
  font-size: 0.98rem;
  font-weight: 730;
  line-height: 1.3;
  text-overflow: ellipsis;
}

.quake-secondary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 650;
}

.depth-pill::before {
  margin-right: 5px;
  color: var(--text-soft);
  content: "↓";
}

.source-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid color-mix(in srgb, var(--source-color, var(--accent)) 24%, transparent);
  border-radius: 9px;
  background: var(--source-soft, var(--accent-soft));
  color: var(--source-color, var(--accent-bright));
  font-size: 0.72rem;
  font-weight: 850;
}

.map-panel {
  display: grid;
  grid-template-rows: auto auto minmax(470px, 1fr);
  gap: 12px;
}

.map-panel > .panel-heading {
  margin-bottom: 2px;
}

.quake-map {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  background: #e8eef3;
  box-shadow: inset 0 0 24px rgba(15, 44, 70, 0.08);
}

.leaflet-tile-pane {
  filter: none;
}

.leaflet-control-zoom a,
.leaflet-control-attribution {
  border-color: #d7e0e8 !important;
  background: rgba(255, 255, 255, 0.94) !important;
  color: #334155 !important;
}

.leaflet-control-zoom a:hover {
  background: #eef6ff !important;
  color: #0969c7 !important;
}

.map-marker {
  display: block;
  width: var(--marker-size, 16px) !important;
  height: var(--marker-size, 16px) !important;
  margin-top: calc(var(--marker-size, 16px) / -2) !important;
  margin-left: calc(var(--marker-size, 16px) / -2) !important;
  border: 2px solid #dceeff;
  border-radius: 50%;
  background: var(--source-color, var(--accent));
  box-shadow: 0 0 0 5px var(--source-soft, var(--accent-soft)), 0 8px 22px rgba(0, 0, 0, 0.5);
}

.leaflet-container {
  font-family: inherit;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  border: 1px solid #d7e0e8;
  background: #ffffff;
  color: #142334;
  box-shadow: 0 18px 45px rgba(15, 44, 70, 0.18);
}

.leaflet-popup-content {
  min-width: 190px;
  margin: 13px;
  color: #142334;
}

.leaflet-container a.leaflet-popup-close-button {
  color: #64748b;
}

.popup-title {
  display: block;
  margin-bottom: 6px;
  color: #142334;
  font-weight: 800;
}

.popup-meta {
  color: #526477;
  font-size: 0.82rem;
  font-weight: 650;
  line-height: 1.5;
}

.loading-state {
  position: fixed;
  z-index: 1100;
  right: 22px;
  bottom: 22px;
  display: none;
  align-items: center;
  gap: 9px;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: rgba(17, 34, 53, 0.96);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 750;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.loading-state.is-visible {
  display: inline-flex;
}

@media (max-width: 1040px) {
  .dashboard-header {
    align-items: stretch;
    flex-direction: column;
  }

  .status-strip {
    min-width: 0;
  }

  .preparedness-topics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .toolbar {
    grid-template-columns: minmax(120px, 1fr) minmax(110px, 1fr) minmax(90px, 0.65fr) auto;
  }

  .toolbar .btn {
    grid-column: auto;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .quake-list {
    max-height: 600px;
  }

  .map-panel {
    grid-template-rows: auto auto minmax(430px, 1fr);
  }

  .quake-map {
    min-height: 480px;
  }
}

@media (max-width: 640px) {
  .app-container {
    width: min(100% - 20px, 1480px);
    padding: 12px 0 26px;
  }

  .dashboard-shell {
    gap: 12px;
  }

  .dashboard-header {
    gap: 14px;
    padding: 14px;
    border-radius: 20px;
  }

  .brand-mark {
    width: 43px;
    height: 43px;
    border-radius: 13px;
  }

  .header-description {
    font-size: 0.76rem;
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-strip div {
    min-height: 49px;
    padding: 7px 8px;
    border-radius: 11px;
  }

  .status-strip span {
    font-size: 1rem;
  }

  .status-strip small {
    font-size: 0.56rem;
  }

  .preparedness-section {
    gap: 9px;
    padding: 12px;
    overflow: hidden;
    border-radius: 19px;
  }

  .preparedness-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .preparedness-topics {
    display: flex;
    margin: 0 -12px;
    padding: 0 12px 3px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .preparedness-topics::-webkit-scrollbar {
    display: none;
  }

  .preparedness-topic {
    flex: 0 0 146px;
    min-height: 56px;
    scroll-snap-align: start;
  }

  .preparedness-dialog-card {
    padding: 20px;
    border-radius: 20px;
  }

  .dialog-items li {
    padding: 13px 13px 13px 40px;
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 11px;
    border-radius: 14px;
  }

  .toolbar-heading {
    align-items: flex-start;
  }

  .toolbar-heading div span {
    max-width: 240px;
  }

  .toolbar .btn {
    grid-column: 2;
  }

  .quake-list-panel,
  .map-panel {
    padding: 13px;
    border-radius: 19px;
  }

  .quake-list {
    max-height: none;
    padding-right: 0;
  }

  .quake-item {
    grid-template-columns: 66px minmax(0, 1fr);
    min-height: 94px;
    padding: 12px;
    border-radius: 16px;
  }

  .quake-magnitude {
    min-height: 66px;
  }

  .magnitude-value {
    font-size: 1.45rem;
  }

  .source-pill {
    grid-column: 2;
    justify-self: start;
    margin-top: -5px;
  }

  .quake-map {
    min-height: 420px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
