:root {
  --bg: #edf5fd;
  --surface: #ffffff;
  --surface-soft: rgba(255, 255, 255, 0.92);
  --line: #d8e5f2;
  --line-strong: #c2d6eb;
  --text: #102033;
  --muted: #64748b;
  --blue: #1f6ed4;
  --blue-2: #0b4ea2;
  --red: #ef344d;
  --orange: #ff8b2a;
  --yellow: #ffc83d;
  --green: #28b463;
  --purple: #8b5cf6;
  --shadow-sm: 0 8px 24px rgba(15, 45, 86, 0.08);
  --shadow: 0 18px 45px rgba(15, 45, 86, 0.13);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --sidebar: 292px;
  --topbar: 92px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { min-height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at 9% 8%, rgba(51, 130, 224, .17), transparent 26%),
    linear-gradient(135deg, #f8fbff 0%, #e7f1fb 100%);
  overflow-x: hidden;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .68; }

.toast-stack {
  position: fixed;
  top: 18px;
  right: 18px;
  width: min(430px, calc(100vw - 36px));
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  border-radius: 20px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(15, 45, 86, .22);
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 12px;
  animation: slideIn .25s ease-out;
}
.toast .mag-badge { width: 54px; height: 54px; border-radius: 16px; font-size: 17px; }
.toast strong { display: block; font-size: 16px; }
.toast small { display: block; color: var(--muted); line-height: 1.45; margin-top: 4px; }
.toast.critical { border-color: #ffc2cc; background: linear-gradient(135deg, #fff, #fff5f6); }
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 30px 18px;
  border-right: 1px solid var(--line);
  background: rgba(246, 251, 255, .94);
  display: flex;
  flex-direction: column;
  gap: 34px;
  z-index: 40;
}
.brand { display: flex; align-items: center; gap: 14px; padding: 6px 4px; }
.brand-logo {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(135deg, #2d7df0, #07468d);
  color: white;
  display: grid;
  place-items: center;
  box-shadow: 0 16px 35px rgba(31, 110, 212, .28);
  flex: 0 0 auto;
}
.brand-logo svg { width: 34px; height: 34px; }
.brand h1 { margin: 0; font-size: 25px; line-height: 1; letter-spacing: -0.03em; }
.brand p { margin: 7px 0 0; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); font-weight: 850; font-size: 12px; }
.nav-list { display: flex; flex-direction: column; gap: 8px; }
.nav-link {
  color: #21364f;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 850;
  min-height: 52px;
}
.nav-link span { width: 20px; text-align: center; color: #263f5d; }
.nav-link:hover, .nav-link.active { background: #dfedff; color: #0752a7; }
.nav-link b {
  margin-left: auto;
  background: var(--red);
  color: white;
  border-radius: 99px;
  min-width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  font-size: 13px;
}
.data-note {
  margin-top: auto;
  padding: 18px;
  border-radius: 18px;
  background: #e4f0ff;
  color: #55708c;
  line-height: 1.55;
  font-size: 14px;
}
.live-dot { color: #0a4ea1; font-weight: 950; margin-bottom: 12px; }
.live-dot span { width: 12px; height: 12px; border-radius: 50%; background: #35c371; display: inline-block; box-shadow: 0 0 0 7px rgba(53, 195, 113, .18); margin-right: 8px; }

.main { min-width: 0; }
.topbar {
  min-height: var(--topbar);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  background: rgba(251,253,255,.96);
  position: sticky;
  top: 0;
  z-index: 30;
}
.search-box {
  flex: 1 1 360px;
  min-width: 240px;
  max-width: 760px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: white;
  box-shadow: var(--shadow-sm);
}
.search-box svg { width: 22px; height: 22px; fill: #55708c; flex: 0 0 auto; }
.search-box input { width: 100%; min-width: 0; border: 0; outline: 0; font-size: 16px; background: transparent; color: var(--text); }
.top-actions { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 12px; min-width: 0; }
.updated { text-align: right; white-space: nowrap; }
.updated span { display: block; text-transform: uppercase; letter-spacing: .12em; font-size: 12px; font-weight: 950; color: var(--muted); }
.updated strong { font-size: 15px; }
.live-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #bfe3cf;
  background: #f1fff7;
  color: #096b36;
  border-radius: 999px;
  padding: 9px 12px;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(21, 152, 75, .09);
}
.live-pill span { width: 10px; height: 10px; background: #28b463; border-radius: 50%; box-shadow: 0 0 0 8px rgba(40,180,99,.16); }
.live-pill small { color: #4f7662; font-weight: 850; }
.profile { display: flex; align-items: center; gap: 12px; background: white; padding: 10px 16px 10px 10px; border-radius: 26px; box-shadow: var(--shadow-sm); white-space: nowrap; }
.profile span { width: 46px; height: 46px; border-radius: 50%; background: #254665; color: white; display: grid; place-items: center; font-weight: 950; }
.profile small { display: block; color: var(--muted); text-transform: uppercase; font-weight: 950; letter-spacing: .06em; }

.content-grid {
  display: grid;
  grid-template-columns: minmax(310px, 380px) minmax(0, 1fr) minmax(300px, 355px);
  grid-template-areas: "overview map right";
  gap: 22px;
  padding: 24px;
  align-items: start;
  max-width: 1920px;
  margin: 0 auto;
}
.overview-panel { grid-area: overview; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.map-column { grid-area: map; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.right-panel { grid-area: right; min-width: 0; display: flex; flex-direction: column; gap: 18px; }

.section-kicker { color: #064ea0; text-transform: uppercase; letter-spacing: .13em; font-weight: 950; font-size: 12px; margin-bottom: 6px; }
.hero-row { display: flex; align-items: start; justify-content: space-between; gap: 14px; }
h2 { margin: 0; font-size: clamp(30px, 3vw, 46px); line-height: 1.03; letter-spacing: -.055em; }
h3 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.card { background: var(--surface-soft); border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head.wrap { flex-wrap: wrap; }

.status-banner {
  display: grid;
  grid-template-columns: 42px minmax(0,1fr);
  gap: 12px;
  align-items: center;
  background: linear-gradient(135deg, #ffffff, #eff9ff);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 14px;
  box-shadow: var(--shadow-sm);
}
.status-banner span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 14px; background: #e8fff1; }
.status-banner strong { display: block; }
.status-banner p { margin: 4px 0 0; color: var(--muted); font-weight: 720; line-height: 1.38; }
.status-banner.warning { background: linear-gradient(135deg, #fff8e7, #fff); border-color: #ffde91; }
.status-banner.critical { background: #fff1f3; border-color: #ffc4ce; color: #8d0618; }
.status-banner.critical p { color: #9b3341; }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 22px;
  min-height: 118px;
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.stat-icon { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; color: white; font-size: 25px; flex: 0 0 auto; }
.stat-card.blue .stat-icon { background: linear-gradient(135deg, #3b82f6, #0752c6); }
.stat-card.red .stat-icon { background: linear-gradient(135deg, #ff5870, #d90d29); }
.stat-card.green .stat-icon { background: linear-gradient(135deg, #39c979, #15984b); }
.stat-card.orange .stat-icon { background: linear-gradient(135deg, #ffac3d, #f26d11); }
.stat-card strong { display: block; font-size: clamp(26px, 3vw, 34px); line-height: 1.08; letter-spacing: -.05em; overflow-wrap: anywhere; }
.stat-card p { margin: 4px 0 0; color: var(--muted); font-weight: 850; font-size: 13px; }

.controls-card, .list-card, .alert-card, .legend-card, .forecast-card, .detail-card { padding: 18px; }
select {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
  font-weight: 850;
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
.filters-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.filters-row.compact { grid-template-columns: 1fr; }
.filters-row label { color: var(--muted); font-weight: 850; font-size: 13px; display: flex; flex-direction: column; gap: 7px; }
.inline-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.events-list, .alerts-list, .forecast-list { display: flex; flex-direction: column; gap: 10px; max-height: 440px; overflow: auto; padding-right: 4px; scrollbar-width: thin; }
.events-list { margin-top: 14px; max-height: 560px; }
.alerts-list { margin-top: 14px; max-height: 420px; }
.forecast-list { max-height: 420px; }
.event-row, .alert-row, .forecast-row {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 12px;
  align-items: center;
  background: #fff;
  text-align: left;
  width: 100%;
  transition: transform .15s ease, box-shadow .15s ease;
}
.event-row, .alert-row { grid-template-columns: 60px minmax(0,1fr); }
button.event-row, button.alert-row, button.forecast-row { border-color: var(--line); }
.event-row:hover, .alert-row:hover, .forecast-row:hover { transform: translateY(-1px); box-shadow: 0 10px 26px rgba(16,52,88,.09); }
.mag-badge { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; font-weight: 950; color: white; font-size: 18px; }
.mag-badge.low { background: linear-gradient(135deg, #2b82ee, #0f5cbf); }
.mag-badge.green { background: linear-gradient(135deg, #40c980, #18a453); }
.mag-badge.yellow { background: linear-gradient(135deg, #ffd95b, #f4af0b); color: #1c2533; }
.mag-badge.orange { background: linear-gradient(135deg, #ffab42, #ff7020); }
.mag-badge.red { background: linear-gradient(135deg, #ff506a, #de132d); }
.event-main, .alert-main { min-width: 0; }
.event-main strong, .alert-main strong { display: block; font-size: 16px; overflow-wrap: anywhere; }
.event-main small, .alert-main small { display: block; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.live-tag { display: inline-flex; align-items: center; gap: 6px; background: #fff0f2; color: #cf132b; border-radius: 999px; font-size: 11px; font-weight: 950; text-transform: uppercase; padding: 4px 8px; margin-left: 6px; }

.map-card { min-height: auto; }
.map-head {
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(280px, 520px);
  gap: 16px;
  align-items: start;
  background: #fff;
}
.map-subtitle { margin: 8px 0 0; color: var(--muted); font-weight: 720; line-height: 1.35; max-width: 520px; }
.map-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.mag-btn, .ghost-btn, .primary-btn, .alarm-btn, .stop-alarm-btn, .danger-btn {
  border: 0;
  border-radius: 17px;
  padding: 12px 16px;
  font-weight: 950;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
  line-height: 1;
}
.primary-btn { background: linear-gradient(135deg, #287be9, #0758c4); color: #fff; box-shadow: 0 12px 24px rgba(31,110,212,.24); }
.primary-btn.small { padding: 12px 18px; min-width: 96px; }
.ghost-btn { background: white; color: #0d4d9d; border: 1px solid var(--line); }
.alarm-btn { background: #fff5e9; color: #b9500d; border: 1px solid #ffd0a4; white-space: nowrap; }
.alarm-btn.enabled { background: linear-gradient(135deg, #ff506a, #de132d); color: white; border-color: transparent; box-shadow: 0 12px 26px rgba(222, 19, 45, .22); }
.stop-alarm-btn { background: #eef3f9; color: #7a8798; border: 1px solid var(--line); white-space: nowrap; }
.stop-alarm-btn.active { background: linear-gradient(135deg, #ef344d, #b20a20); color: white; border-color: transparent; box-shadow: 0 16px 32px rgba(239, 52, 77, .28); animation: alarmPulseBtn .72s infinite alternate; }
.danger-btn { background: linear-gradient(135deg, #ef344d, #b20a20); color: #fff; box-shadow: 0 16px 34px rgba(239, 52, 77, .28); }
.ghost-btn.dark { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); }
.mag-btn { background: #fff; border: 1px solid var(--line); color: #22364d; min-width: 66px; }
.mag-btn[data-mag="2"].active, .mag-btn[data-mag="2"]:hover { background: #e8f2ff; color: #0a5bc4; border-color: #a8cbff; }
.mag-btn[data-mag="3"].active, .mag-btn[data-mag="3"]:hover { background: #e9f9ef; color: #15984b; border-color: #a8e6bf; }
.mag-btn[data-mag="4"].active, .mag-btn[data-mag="4"]:hover { background: #fff6d4; color: #9b7400; border-color: #ffe38b; }
.mag-btn[data-mag="5"].active, .mag-btn[data-mag="5"]:hover { background: #fff0df; color: #ca520d; border-color: #ffd0a4; }
.mag-btn[data-mag="6"].active, .mag-btn[data-mag="6"]:hover { background: #ffe8ee; color: #c3122a; border-color: #ffc3cf; }
.primary-btn:hover, .ghost-btn:hover, .mag-btn:hover, .alarm-btn:hover, .stop-alarm-btn:hover, .danger-btn:hover { transform: translateY(-1px); }
.map-wrap {
  position: relative;
  height: clamp(520px, calc(100vh - 250px), 760px);
  min-height: 520px;
  background: #b9dcf5;
}
#quakeMap { position: absolute; inset: 0; width: 100%; height: 100%; }
.maplibregl-canvas { outline: none; }
.map-status {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 4;
  background: rgba(255,255,255,.95);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  font-weight: 900;
  color: #28435f;
  box-shadow: var(--shadow-sm);
  max-width: calc(100% - 32px);
}
.map-error {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  max-width: 420px;
  background: #fff3f5;
  border: 1px solid #ffc5ce;
  color: #b20f24;
  border-radius: 16px;
  padding: 12px 14px;
  font-weight: 850;
  box-shadow: var(--shadow-sm);
}

.detail-badge { border-radius: 16px; padding: 12px 14px; min-width: 72px; text-align: center; font-weight: 950; background: #e8f2ff; color: #0c58b4; }
.detail-body { color: var(--muted); line-height: 1.6; margin-top: 14px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-item { background: #f5f9fe; border: 1px solid var(--line); padding: 12px; border-radius: 14px; }
.detail-item span { display: block; color: var(--muted); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.detail-item strong { display: block; margin-top: 4px; color: var(--text); overflow-wrap: anywhere; }
.detail-link { display: inline-flex; margin-top: 14px; color: #0758c4; font-weight: 900; text-decoration: none; }
.guidance { margin-top: 12px; padding: 12px; background: #f7fbff; border: 1px solid var(--line); border-radius: 14px; color: #294158; }
.guidance strong { display: block; color: var(--text); margin-bottom: 4px; }

.forecast-card { background: linear-gradient(135deg, rgba(255,255,255,.97), rgba(246,242,255,.97)); border-color: #dfd4ff; }
.forecast-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.ai-chip { background: linear-gradient(135deg, #8b5cf6, #4f46e5); color: #fff; padding: 8px 12px; border-radius: 999px; font-size: 11px; font-weight: 950; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.forecast-note { color: #5d5377; background: rgba(139,92,246,.08); border: 1px solid rgba(139,92,246,.18); padding: 12px; border-radius: 16px; font-weight: 720; line-height: 1.45; }
.forecast-row { grid-template-columns: minmax(0,1fr); }
.forecast-title { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.forecast-title strong { font-size: 16px; }
.risk-score { min-width: 76px; height: 36px; border-radius: 999px; display: grid; place-items: center; background: #eee7ff; color: #4f2cbd; font-weight: 950; }
.risk-bar { height: 9px; background: #edf1f7; border-radius: 999px; overflow: hidden; margin: 10px 0 8px; }
.risk-bar span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #35c371, #ffc83d, #ff8b2a, #ef344d); }
.forecast-row small { color: var(--muted); line-height: 1.4; font-weight: 730; }
.forecast-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.forecast-meta span { background: #f5f1ff; border: 1px solid #e7dcff; border-radius: 999px; padding: 5px 9px; color: #5d44a1; font-size: 12px; font-weight: 900; }

.legend-card h3 { margin-bottom: 14px; }
.legend-row { display: grid; grid-template-columns: 18px 1fr auto; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.legend-row:last-of-type { border-bottom: 0; }
.dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.dot.red { background: var(--red); }
.dot.orange { background: var(--orange); }
.dot.yellow { background: var(--yellow); }
.dot.green { background: var(--green); }
.dot.blue { background: var(--blue); }
.dot.purple { background: var(--purple); box-shadow: 0 0 0 8px rgba(139,92,246,.14); }
.legend-row small { color: var(--muted); font-weight: 750; text-align: right; }
.legend-note { color: var(--muted); line-height: 1.55; margin: 16px 0 0; font-size: 14px; }
.empty-state { color: var(--muted); background: #f7fbff; border: 1px dashed var(--line); border-radius: 18px; padding: 16px; font-weight: 800; line-height: 1.5; }

.alarm-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(82, 10, 20, .52);
  backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  padding: 22px;
}
.alarm-overlay[hidden] { display: none !important; }
.alarm-modal {
  width: min(780px, 96vw);
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 24px;
  align-items: center;
  color: #fff;
  border-radius: 34px;
  padding: 30px;
  border: 1px solid rgba(255,255,255,.20);
  background:
    radial-gradient(circle at 12% 16%, rgba(255,255,255,.2), transparent 28%),
    linear-gradient(135deg, #d91132 0%, #7f0618 58%, #32040a 100%);
  box-shadow: 0 38px 120px rgba(88, 7, 20, .55);
  position: relative;
  overflow: hidden;
}
.alarm-modal::after {
  content: "";
  position: absolute;
  inset: -40%;
  background: repeating-linear-gradient(45deg, transparent 0 18px, rgba(255,255,255,.05) 18px 34px);
  animation: alarmStripes 1.8s linear infinite;
  pointer-events: none;
}
.alarm-modal > * { position: relative; z-index: 1; }
.alarm-overlay-mag {
  width: 118px;
  height: 118px;
  border-radius: 30px;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 1000;
  background: #fff;
  color: #d91132;
  box-shadow: inset 0 0 0 8px rgba(239, 52, 77, .15), 0 16px 42px rgba(0,0,0,.25);
}
.alarm-beacon { position: absolute; width: 240px; height: 240px; border-radius: 999px; background: rgba(255,255,255,.12); left: -60px; top: -80px; animation: beaconScale 1.1s ease-in-out infinite; }
.alarm-modal h2 { margin: 0 0 10px; font-size: clamp(28px, 4vw, 52px); line-height: .98; letter-spacing: -.04em; }
.alarm-modal p { color: rgba(255,255,255,.88); font-size: 17px; line-height: 1.55; margin: 0; }
.alarm-modal .section-kicker { color: #ffe3e8; margin-bottom: 8px; }
.alarm-actions { display: flex; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
body.alarm-active::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 2500; background: rgba(239,52,77,.13); animation: screenFlash .7s infinite alternate; }
@keyframes alarmPulseBtn { from { transform: translateY(0) scale(1); } to { transform: translateY(-1px) scale(1.035); } }
@keyframes alarmStripes { to { transform: translateX(54px); } }
@keyframes beaconScale { 0%,100% { transform: scale(.7); opacity: .45; } 50% { transform: scale(1.15); opacity: .9; } }
@keyframes screenFlash { from { opacity: .28; } to { opacity: .75; } }

.map-expanded .app-shell { display: block; }
.map-expanded .sidebar, .map-expanded .topbar, .map-expanded .overview-panel, .map-expanded .right-panel, .map-expanded .detail-card { display: none !important; }
.map-expanded .content-grid { display: block; padding: 0; max-width: none; }
.map-expanded .map-card { position: fixed; inset: 0; z-index: 999; border-radius: 0; min-height: 100vh; border: 0; }
.map-expanded .map-head { min-height: 94px; padding: 14px 18px; grid-template-columns: minmax(180px,1fr) auto; }
.map-expanded .map-wrap { height: calc(100vh - 94px); min-height: 0; }
.map-expanded .map-head h3 { font-size: 18px; }
.map-expanded .section-kicker { margin-bottom: 2px; }
.map-expanded .map-subtitle { display: none; }

@media (max-width: 1780px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 410px);
    grid-template-areas:
      "map map"
      "overview right";
  }
  .map-column {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
    gap: 18px;
    align-items: start;
  }
  .map-card { min-width: 0; }
  .detail-card { margin-top: 0; }
  .map-wrap { height: clamp(520px, 58vh, 720px); }
}
@media (max-width: 1360px) {
  .topbar { align-items: stretch; flex-wrap: wrap; }
  .top-actions { flex: 1 1 100%; justify-content: flex-start; flex-wrap: wrap; }
  .search-box { max-width: none; }
  .content-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "overview"
      "right";
  }
  .map-column { display: flex; }
  .right-panel { display: grid; grid-template-columns: 1fr 1fr; }
  .legend-card { grid-column: 1 / -1; }
  .map-head { grid-template-columns: 1fr; }
  .map-controls { justify-content: flex-start; }
}
@media (max-width: 1080px) {
  :root { --sidebar: 1fr; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    overflow-x: auto;
    padding: 14px 18px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { min-width: max-content; }
  .brand-logo { width: 46px; height: 46px; border-radius: 14px; }
  .brand h1 { font-size: 21px; }
  .brand p { font-size: 10px; }
  .nav-list { flex-direction: row; min-width: max-content; }
  .nav-link { padding: 12px 14px; min-height: 44px; }
  .data-note { display: none; }
  .topbar { position: static; }
}
@media (max-width: 760px) {
  .content-grid, .topbar { padding-left: 14px; padding-right: 14px; }
  .content-grid { gap: 16px; padding-top: 16px; padding-bottom: 24px; }
  .topbar { padding-top: 14px; padding-bottom: 14px; gap: 12px; }
  .top-actions { gap: 8px; }
  .search-box { height: 52px; flex-basis: 100%; }
  .updated, .profile { display: none; }
  .live-pill { flex: 1 1 100%; justify-content: center; }
  .top-actions > button { flex: 1 1 calc(50% - 8px); min-height: 46px; }
  .hero-row { flex-direction: column; }
  .stat-grid, .filters-row, .detail-grid, .right-panel { grid-template-columns: 1fr; }
  .map-head { padding: 16px; }
  .map-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .mag-btn, .ghost-btn, .primary-btn { width: 100%; }
  .map-wrap { height: 62vh; min-height: 440px; }
  .events-list, .alerts-list, .forecast-list { max-height: none; overflow: visible; }
  .card { border-radius: 22px; }
  .alarm-modal { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .alarm-actions { justify-content: center; }
}
@media (max-width: 480px) {
  .sidebar { padding: 12px; }
  .brand p { display: none; }
  .nav-link { font-size: 14px; gap: 8px; }
  h2 { font-size: 32px; }
  .stat-card { min-height: 104px; padding: 14px; }
  .stat-icon { width: 44px; height: 44px; }
  .stat-card strong { font-size: 26px; }
  .event-row, .alert-row { grid-template-columns: 52px minmax(0,1fr); padding: 12px; }
  .mag-badge { width: 50px; height: 50px; border-radius: 16px; font-size: 16px; }
  .map-status { left: 10px; bottom: 10px; font-size: 12px; }
}

/* =======================================================================
   v9 PRODUCTION LAYOUT PATCH
   Purpose: prevent overlapping cards/header/map, improve desktop/tablet/mobile,
   and keep all public-facing sections clean and production-ready.
   ======================================================================= */
html { scroll-padding-top: 110px; }
body { overflow-x: hidden; }
.app-shell {
  grid-template-columns: minmax(260px, 300px) minmax(0, 1fr);
  width: 100%;
}
.main {
  min-width: 0;
  width: 100%;
}
.sidebar {
  width: 100%;
  min-width: 0;
}
.topbar {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 88px;
  padding: 14px 24px;
  background: rgba(251, 253, 255, 0.98);
  backdrop-filter: none;
  box-shadow: 0 8px 26px rgba(15, 45, 86, .06);
}
.search-box {
  width: 100%;
  max-width: 620px;
  min-width: 0;
  flex: initial;
  height: 54px;
}
.top-actions {
  min-width: 0;
  flex-wrap: wrap;
  row-gap: 8px;
}
.top-actions > * { flex: 0 0 auto; }
.live-pill small { max-width: 170px; overflow: hidden; text-overflow: ellipsis; }
.updated strong { font-size: 14px; }
.profile { padding: 8px 14px 8px 8px; }
.profile span { width: 42px; height: 42px; }

.content-grid {
  max-width: none;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  grid-template-areas:
    "overview map"
    "overview right";
  gap: 22px;
  padding: 26px 28px 34px;
  align-items: start;
}
.overview-panel,
.map-column,
.right-panel {
  min-width: 0;
  width: 100%;
}
.overview-panel {
  grid-area: overview;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.map-column {
  grid-area: map;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.right-panel {
  grid-area: right;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.right-panel > .card { min-width: 0; height: 100%; }

.hero-row { align-items: flex-start; }
h2 { font-size: clamp(32px, 2.45vw, 42px); line-height: 1.04; }
.status-banner { padding: 14px 16px; }
.stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-card {
  min-height: 112px;
  padding: 16px;
  gap: 13px;
}
.stat-card strong {
  font-size: clamp(24px, 2.1vw, 32px);
  max-width: 100%;
}
.stat-card p { line-height: 1.25; }
.stat-icon { width: 48px; height: 48px; }

.card { overflow: hidden; }
.card-head,
.forecast-head,
.map-head,
.hero-row { min-width: 0; }
.controls-card { order: 20; }
.list-card { order: 30; }

.map-card {
  border-radius: 28px;
  overflow: hidden;
}
.map-head {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 20px 22px;
  background: #ffffff;
}
.map-head > div:first-child { min-width: 0; }
.map-subtitle {
  max-width: 720px;
  font-size: 14px;
}
.map-controls {
  justify-content: flex-start;
  align-items: center;
  gap: 9px;
  width: 100%;
}
.map-controls .ghost-btn,
.map-controls .primary-btn,
.map-controls .mag-btn {
  min-height: 44px;
  padding: 11px 15px;
}
.map-wrap {
  height: min(68vh, 700px);
  min-height: 520px;
  width: 100%;
}
#quakeMap { width: 100%; height: 100%; }

.detail-card { display: block; }
.events-list { max-height: 520px; }
.alerts-list,
.forecast-list { max-height: 460px; }
.forecast-note,
.legend-note { font-size: 13px; }
.legend-row { grid-template-columns: 18px minmax(0, 1fr) auto; }
.legend-row strong { min-width: 0; overflow-wrap: anywhere; }

.nav-link[href="#forecast"]::after { content: none !important; }

@media (max-width: 1640px) {
  .topbar {
    grid-template-columns: 1fr;
  }
  .search-box { max-width: none; }
  .top-actions { justify-content: flex-start; }
  .content-grid {
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
    padding: 24px;
  }
  .right-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .legend-card { grid-column: 1 / -1; }
  .map-wrap { height: min(66vh, 660px); }
}

@media (max-width: 1280px) {
  .content-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "overview"
      "right";
  }
  .overview-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
  .overview-panel > .hero-row,
  .overview-panel > .status-banner,
  .overview-panel > .stat-grid,
  .overview-panel > .controls-card,
  .overview-panel > .list-card {
    grid-column: 1 / -1;
  }
  .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stat-card { flex-direction: column; align-items: flex-start; min-height: 126px; }
  .map-wrap { height: 62vh; min-height: 500px; }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 14px;
    overflow-x: auto;
    padding: 14px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { min-width: max-content; }
  .nav-list { flex-direction: row; min-width: max-content; }
  .nav-link { min-height: 44px; padding: 11px 14px; }
  .data-note { display: none; }
  .topbar { position: static; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .right-panel { grid-template-columns: 1fr; }
  .legend-card { grid-column: auto; }
}

@media (max-width: 820px) {
  .topbar { padding: 14px; gap: 12px; }
  .content-grid { padding: 16px 14px 28px; gap: 16px; }
  .search-box { height: 50px; }
  .top-actions { gap: 8px; }
  .updated, .profile { display: none; }
  .live-pill { flex: 1 1 100%; justify-content: center; }
  .top-actions > button { flex: 1 1 calc(50% - 8px); min-height: 46px; }
  .hero-row { flex-direction: column; }
  h2 { font-size: 34px; }
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card { flex-direction: row; min-height: 106px; }
  .filters-row,
  .detail-grid { grid-template-columns: 1fr; }
  .map-head { padding: 16px; }
  .map-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .map-controls .mag-btn,
  .map-controls .ghost-btn,
  .map-controls .primary-btn { width: 100%; }
  .map-wrap { height: 64vh; min-height: 430px; }
  .events-list, .alerts-list, .forecast-list { max-height: none; overflow: visible; }
  .card { border-radius: 22px; }
}

@media (max-width: 520px) {
  .brand-logo { width: 44px; height: 44px; border-radius: 14px; }
  .brand h1 { font-size: 20px; }
  .brand p { display: none; }
  .nav-link { font-size: 14px; gap: 8px; }
  .top-actions > button { flex-basis: 100%; }
  .map-controls { grid-template-columns: 1fr; }
  .map-wrap { min-height: 400px; height: 62vh; }
  .status-banner { grid-template-columns: 1fr; }
  .event-row, .alert-row { grid-template-columns: 52px minmax(0, 1fr); padding: 12px; }
  .mag-badge { width: 50px; height: 50px; border-radius: 16px; font-size: 16px; }
  .legend-row { grid-template-columns: 18px 1fr; }
  .legend-row small { grid-column: 2; text-align: left; }
  .map-status { left: 10px; bottom: 10px; font-size: 12px; }
}
