:root {
  --bg: #e8ece6;
  --ink: #172026;
  --muted: #4c5f6c;
  --panel: #f7faf8;
  --panel-border: #c8d2cc;
  --online: #2f8f4f;
  --degraded: #c78d2b;
  --offline: #bd3b35;
  --gdop-good: #3d9b6d;
  --gdop-poor: #b43f39;
  --status-confirmed: #1f8f5e;
  --status-tentative: #cc8e2e;
  --status-coasting: #6c7787;
  --iff-friendly: #b8e0b4;
  --iff-unknown: #d9dce3;
  --iff-hostile: #f4b0a9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 0% 0%, #ffffff 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, #d8e5df 0%, transparent 30%),
    linear-gradient(160deg, #eef3ef 0%, #e2e9e4 100%);
}

.app-header {
  padding: 0.9rem 1.2rem 0.7rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
  border-bottom: 1px solid var(--panel-border);
}

.app-header h1 {
  margin: 0;
  font-family: "Bitter", Georgia, serif;
  font-size: 1.45rem;
}

.app-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.status-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
}

.status-pill,
.origin-pill {
  font-size: 0.78rem;
  padding: 0.18rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #b8c3bc;
  background: #e9efeb;
}

.system-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  padding: 0.65rem 1.2rem;
}

.system-strip > div {
  border: 1px solid #becbc3;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.system-strip strong {
  font-size: 1.1rem;
}

.system-strip span {
  color: var(--muted);
  font-size: 0.76rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 0.75rem;
  padding: 0 1.2rem 1.2rem;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(25, 34, 40, 0.06);
}

.map-panel {
  padding: 0.75rem;
}

.map-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.map-toolbar label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.74rem;
  color: var(--muted);
}

.map-toolbar select,
.map-toolbar input {
  width: 100%;
  font-size: 0.82rem;
  border: 1px solid #b6c3bc;
  border-radius: 7px;
  padding: 0.3rem 0.35rem;
  background: #ffffff;
}

#filterConfidenceValue {
  justify-self: end;
  font-variant-numeric: tabular-nums;
}

#map {
  width: 100%;
  height: min(68vh, 720px);
  border: 1px solid #bbc8c1;
  border-radius: 10px;
  overflow: hidden;
}

.legend {
  margin-top: 0.48rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.9rem;
  font-size: 0.78rem;
  color: #3d4f5a;
}

.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 0.3rem;
  vertical-align: baseline;
}

.health-online {
  background: var(--online);
}

.health-degraded {
  background: var(--degraded);
}

.health-offline {
  background: var(--offline);
}

.gdop-good {
  background: var(--gdop-good);
}

.gdop-poor {
  background: var(--gdop-poor);
}

.zone-alert {
  background: #c67d7d;
}

.zone-exclusion {
  background: #c9a16f;
}

.zone-coverage {
  background: #7ca7c0;
}

.side-panel {
  display: grid;
  grid-template-rows: minmax(260px, 1fr) minmax(200px, 1fr) minmax(160px, auto);
  gap: 0.6rem;
  padding: 0.7rem;
}

.subpanel {
  border: 1px solid #cad6ce;
  border-radius: 11px;
  background: #ffffff;
  overflow: hidden;
}

.subpanel h2 {
  margin: 0;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid #d7e2db;
  font-family: "Bitter", Georgia, serif;
  font-size: 0.95rem;
}

.track-panel {
  overflow: auto;
}

.track-panel table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.track-panel th,
.track-panel td {
  text-align: left;
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid #e2ebe5;
  white-space: nowrap;
}

.track-panel th {
  position: sticky;
  top: 0;
  background: #f4f8f5;
  font-size: 0.72rem;
  color: #4a6170;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
}

.track-panel tr.is-selected {
  background: #eff7f1;
}

.feed-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

#detectionFeed {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

#detectionFeed li {
  border-bottom: 1px solid #e2ebe5;
  padding: 0.48rem 0.65rem;
  display: grid;
  gap: 0.2rem;
  font-size: 0.8rem;
}

.feed-meta {
  color: #4e6371;
  font-size: 0.73rem;
}

.feed-actions {
  display: flex;
  gap: 0.4rem;
}

.feed-actions button {
  font-size: 0.73rem;
  border: 1px solid #b8c6be;
  border-radius: 7px;
  background: #f8fbf9;
  padding: 0.18rem 0.45rem;
  cursor: pointer;
}

.track-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-width: 2px;
  border-style: solid;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
}

.track-status-confirmed {
  border-color: var(--status-confirmed);
}

.track-status-tentative {
  border-color: var(--status-tentative);
}

.track-status-coasting {
  border-color: var(--status-coasting);
}

.track-iff-friendly {
  background: var(--iff-friendly);
}

.track-iff-unknown {
  background: var(--iff-unknown);
}

.track-iff-hostile {
  background: var(--iff-hostile);
}

.track-symbol-security {
  border-radius: 0;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

.track-symbol-vehicle {
  transform: rotate(45deg);
}

.track-symbol-vehicle > span {
  transform: rotate(-45deg);
}

.track-symbol-wildlife {
  border-radius: 50%;
}

.track-symbol-human {
  border-radius: 2px;
}

.track-symbol-unknown {
  clip-path: polygon(25% 0%, 75% 0%, 100% 50%, 75% 100%, 25% 100%, 0% 50%);
}

.alert-panel {
  display: grid;
  grid-template-rows: auto 1fr;
}

#alertFeed {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

#alertFeed li {
  border-bottom: 1px solid #e2ebe5;
  padding: 0.42rem 0.65rem;
  font-size: 0.8rem;
}

.alert-item--high {
  color: var(--offline);
  font-weight: 600;
}

.alert-item--normal {
  color: var(--ink);
}

/* Toast container — bottom-right corner, above everything */
#alertToastContainer {
  position: fixed;
  bottom: 1.2rem;
  right: 1.2rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.alert-toast {
  max-width: 320px;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
  animation: toast-in 0.2s ease-out;
}

.alert-toast--high {
  background: #fde8e7;
  border: 1px solid var(--offline);
  color: #7a1612;
}

.alert-toast--normal {
  background: #fff9e6;
  border: 1px solid var(--degraded);
  color: #5a3d08;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

  .side-panel {
    grid-template-rows: auto auto;
  }
}

@media (max-width: 760px) {
  .system-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .map-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-header {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .layout {
    padding: 0 0.8rem 0.8rem;
  }
}
