:root {
  --ink: #18212f;
  --muted: #667085;
  --line: #d6dbe3;
  --panel: #ffffff;
  --action: #2563eb;
  --danger: #ef4444;
  --shadow: 0 18px 48px rgba(20, 32, 50, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell,
.map {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #edf1f5;
}

.app-shell {
  position: relative;
  overflow: hidden;
}

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

.status-panel {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 400;
  display: grid;
  gap: 16px;
  width: min(380px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(214, 219, 227, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--action);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.2;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
}

.metrics div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
}

dt {
  color: var(--muted);
  font-size: 0.72rem;
}

dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-size: 1rem;
  font-weight: 800;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

button,
.actions a {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--action);
  border-radius: 6px;
  color: #ffffff;
  background: var(--action);
  font: inherit;
  font-weight: 700;
  line-height: 38px;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.actions a {
  border-color: var(--line);
  color: var(--ink);
  background: #ffffff;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.map-legend {
  display: grid;
  grid-template-columns: repeat(5, auto auto);
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.legend-chip {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid currentColor;
}

.legend-default {
  color: #020617;
  background: #111827;
}

.legend-fixation {
  color: #854d0e;
  background: #facc15;
}

.legend-work {
  color: #7f1d1d;
  background: #ef233c;
}

.legend-missile {
  color: #701a75;
  background: #d946ef;
}

.legend-clear {
  color: #020617;
  background: #111827;
  opacity: 0.68;
}

.message-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.message-list li {
  display: grid;
  gap: 4px;
  padding-top: 10px;
  padding-left: 8px;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
  transition: background 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.message-list li.message-has-dot {
  border-left-color: var(--message-accent);
}

.message-list li.message-highlighted {
  background: #ffedd5;
  border-left-color: #111827;
  box-shadow:
    inset 0 0 0 1px rgba(17, 24, 39, 0.18),
    0 4px 14px rgba(17, 24, 39, 0.12);
}

.message-list a {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.message-list time {
  color: var(--muted);
  font-size: 0.78rem;
}

.message-list p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #344054;
  font-size: 0.84rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.messages-block,
.logs-block {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.panel-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-section-header h2 {
  margin: 0;
  font-size: 0.95rem;
}

.panel-section-header span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.log-list {
  display: grid;
  gap: 6px;
  max-height: 210px;
  margin: 0;
  padding: 8px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #101828;
  color: #e4e7ec;
  list-style: none;
}

.log-list li {
  display: grid;
  grid-template-columns: 44px 64px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  min-width: 0;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
}

.log-list strong {
  color: #93c5fd;
  text-transform: uppercase;
}

.log-list time {
  color: #98a2b3;
}

.log-list span {
  overflow-wrap: anywhere;
}

.log-list .log-warn strong {
  color: #fbbf24;
}

.log-list .log-error strong {
  color: #f87171;
}

.point-marker-icon {
  background: transparent;
}

.point-marker {
  position: relative;
  display: block;
  width: 62px;
  height: 62px;
  background: transparent;
}

.point-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 30px;
  height: 30px;
  border: 3px solid var(--dot-stroke);
  border-radius: 999px;
  background: var(--dot-background);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.34);
  opacity: var(--dot-opacity);
  outline: 0 solid transparent;
  transform: translate(-50%, -50%);
  transition: outline 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.point-direction {
  position: absolute;
  left: 50%;
  top: 50%;
  display: block;
  width: 32px;
  height: 32px;
  opacity: var(--arrow-opacity);
  transform: translate(-50%, -50%) rotate(var(--arrow-rotation));
  transform-origin: 50% 50%;
  pointer-events: none;
}

.point-direction::before {
  position: absolute;
  top: -20px;
  left: 50%;
  width: 0;
  height: 0;
  border-right: 6px solid transparent;
  border-left: 6px solid transparent;
  border-bottom: 18px solid var(--arrow-color);
  content: "";
  filter:
    drop-shadow(0 1px 1px rgba(255, 255, 255, 0.75))
    drop-shadow(0 1px 2px rgba(16, 24, 40, 0.4));
  transform: translateX(-50%);
}

.point-marker-highlighted .point-dot {
  box-shadow:
    0 0 0 7px rgba(17, 24, 39, 0.18),
    0 4px 14px rgba(17, 24, 40, 0.36);
  outline: 3px solid #111827;
}

.popup {
  display: grid;
  gap: 6px;
  width: min(420px, calc(100vw - 48px));
  max-width: 420px;
}

.popup strong {
  font-size: 0.98rem;
}

.popup time {
  color: var(--muted);
  font-size: 0.78rem;
}

.popup p {
  max-height: 150px;
  margin: 0;
  overflow: auto;
  line-height: 1.35;
  white-space: pre-wrap;
}

.popup a {
  color: var(--action);
  font-weight: 700;
}

.group-popup ol {
  display: grid;
  gap: 8px;
  max-height: 360px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.group-popup li {
  display: grid;
  gap: 3px;
  padding-top: 6px;
  padding-left: 8px;
  border-top: 1px solid var(--line);
  border-left: 3px solid var(--message-accent);
}

.group-popup li:first-child {
  padding-top: 0;
  border-top: 0;
}

.group-popup li p {
  max-height: none;
  font-size: 0.82rem;
  -webkit-line-clamp: unset;
}

.status-chip {
  width: fit-content;
  padding: 2px 6px;
  border: 1px solid var(--message-accent);
  border-radius: 999px;
  color: #101828;
  background: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-tooltip {
  border: 0;
  border-radius: 6px;
  background: rgba(16, 24, 40, 0.95);
  box-shadow: 0 10px 24px rgba(16, 24, 40, 0.28);
  color: #ffffff;
}

.status-tooltip::before {
  border-top-color: rgba(16, 24, 40, 0.95);
}

.status-tooltip-content {
  display: grid;
  gap: 7px;
  min-width: 150px;
}

.status-tooltip-content > strong {
  font-size: 0.82rem;
}

.status-tooltip-content ol {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.status-tooltip-content li {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 7px;
  align-items: center;
  font-size: 0.76rem;
}

.tooltip-swatch {
  width: 10px;
  height: 10px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: var(--message-accent);
}

.leaflet-container {
  font: inherit;
}

@media (max-width: 700px) {
  .status-panel {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: 42vh;
    padding: 14px;
  }

  .metrics {
    grid-template-columns: repeat(4, minmax(58px, 1fr));
  }

  .map-legend {
    grid-template-columns: repeat(2, auto auto);
  }

  h1 {
    font-size: 1.1rem;
  }
}
