:root {
  color-scheme: light;
  --bg-top: #f3efe4;
  --bg-bottom: #dfe8f5;
  --panel: rgba(255, 252, 246, 0.88);
  --panel-border: rgba(23, 37, 84, 0.12);
  --text: #172554;
  --muted: #475569;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 18px 60px rgba(15, 23, 42, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.18), transparent 28rem),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.16), transparent 24rem),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
}

code {
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
}

.shell {
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2rem 0 2.5rem;
}

.hero,
.panel {
  backdrop-filter: blur(18px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
  padding: 1.75rem;
}

h1,
h2,
p {
  margin: 0;
}

h3 {
  margin: 0;
  font-size: 1rem;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 0.95;
}

.actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 0.9rem 1.25rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    opacity 140ms ease,
    background-color 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  background: var(--accent);
  color: #f8fafc;
}

.secondary {
  background: rgba(15, 23, 42, 0.08);
  color: var(--text);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.panel {
  padding: 1.25rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  margin-top: 1rem;
}

.metrics div {
  padding: 0.85rem 0.95rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
}

dt {
  margin: 0;
  font-size: 0.84rem;
  color: var(--muted);
}

dd {
  margin: 0.35rem 0 0;
  font-size: 1rem;
  font-weight: 700;
  word-break: break-word;
}

.message {
  margin-top: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  line-height: 1.4;
}

.message.neutral {
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
}

.message.success {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
}

.message.warning {
  background: rgba(245, 158, 11, 0.14);
  color: var(--warn);
}

.message.error {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}

.map-panel {
  margin-top: 1rem;
  overflow: hidden;
}

.map-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(300px, 0.9fr);
  gap: 1rem;
  align-items: start;
}

.map-sidebar {
  display: grid;
  gap: 1rem;
}

.track-panel {
  padding: 1rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(23, 37, 84, 0.08);
}

.compact-metrics {
  margin-top: 0.85rem;
}

.compact-metrics div {
  min-height: 5.4rem;
}

.map-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: baseline;
  margin-bottom: 1rem;
}

#map-caption {
  color: var(--muted);
}

#map {
  height: min(68vh, 640px);
  min-height: 420px;
  border-radius: 22px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), rgba(59, 130, 246, 0.08)),
    #dbeafe;
}

.history-panel {
  min-height: 420px;
}

.history-header {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

#history-caption {
  color: var(--muted);
  line-height: 1.4;
}

.history-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
  max-height: min(48vh, 460px);
  overflow: auto;
}

.history-list li {
  padding: 0.9rem 1rem;
  border-radius: 18px;
  background: rgba(248, 250, 252, 0.85);
  border: 1px solid rgba(23, 37, 84, 0.08);
}

.history-item-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.history-item-time,
.history-item-fix {
  font-size: 0.88rem;
  font-weight: 700;
}

.history-item-fix {
  color: var(--accent-strong);
}

.history-item-coords {
  margin-top: 0.45rem;
  font-size: 0.96rem;
  font-weight: 700;
}

.history-item-meta {
  margin-top: 0.35rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.empty-history {
  text-align: center;
  color: var(--muted);
  border-style: dashed;
}

.leaflet-popup-content-wrapper {
  border-radius: 16px;
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
}

@media (max-width: 860px) {
  .hero,
  .map-header {
    flex-direction: column;
  }

  .map-layout {
    grid-template-columns: 1fr;
  }

  .status-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .shell {
    width: min(100% - 1rem, 1180px);
    padding-top: 1rem;
  }
}
