:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --bg-deep: #e3e6ed;
  --ink: #10131c;
  --muted: #6a7280;
  --accent: #ff6b4a;
  --accent-soft: rgba(255, 107, 74, 0.2);
  --cool: #0b6dff;
  --cool-soft: rgba(11, 109, 255, 0.18);
  --panel: #ffffff;
  --panel-border: #d6dbe5;
  --shadow: 0 22px 60px rgba(14, 25, 45, 0.12);
  --radius: 18px;
  --font-display: "Space Grotesk", "Pretendard", "Noto Sans KR", "Apple SD Gothic Neo", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-display);
  background: radial-gradient(circle at top left, #fef1ec 0%, var(--bg) 42%, #e6f0ff 100%);
  color: var(--ink);
  min-height: 100vh;
}

.app {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 28px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 18px 26px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ffb585);
  box-shadow: 0 0 14px var(--accent);
}

.brand__title {
  font-size: 22px;
  font-weight: 700;
}

.brand__subtitle {
  color: var(--muted);
  font-size: 14px;
}

.topbar__status {
  display: flex;
  align-items: center;
  gap: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  position: relative;
}

.pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  opacity: 0.6;
  animation: pulse 1.6s ease-out infinite;
}

.timestamp {
  font-weight: 600;
  color: var(--muted);
}

.layout {
  margin-top: 26px;
  display: grid;
  grid-template-columns: 240px minmax(320px, 1fr) minmax(360px, 1.2fr);
  gap: 20px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-height: 0;
}

.panel h2,
.panel h3 {
  font-size: 17px;
  font-weight: 700;
}

.panel--teams {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel--info {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel--map {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-card {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  transition: transform 0.25s ease, border 0.25s ease, box-shadow 0.25s ease;
  cursor: pointer;
  background: #f9fafc;
}

.team-card.active {
  border-color: var(--accent);
  box-shadow: 0 12px 30px rgba(255, 107, 74, 0.18);
  transform: translateY(-2px);
}

.team-card h3 {
  font-size: 15px;
}

.team-card p {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.panel__footer {
  border-top: 1px dashed var(--panel-border);
  padding-top: 12px;
}

.panel-block {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px;
  background: #fdfdfd;
}

.panel-block__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.panel-block--logs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.log-column {
  background: #f7f9fc;
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--panel-border);
}

.place-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.place-card {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  background: #f8f7f4;
  cursor: pointer;
  transition: border 0.25s ease, transform 0.25s ease;
}

.place-card.active {
  border-color: var(--cool);
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(11, 109, 255, 0.15);
}

.place-card h4 {
  font-size: 14px;
  margin-bottom: 6px;
}

.place-card .meta {
  font-size: 12px;
  color: var(--muted);
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.device-item {
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 12px;
  background: #f5f7fb;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.device-item.active {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.device-item h4 {
  font-size: 14px;
}

.device-meta {
  font-size: 12px;
  color: var(--muted);
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge--ok {
  background: rgba(54, 210, 150, 0.2);
  color: #1d8f64;
}

.badge--warn {
  background: rgba(255, 180, 67, 0.25);
  color: #b36b0d;
}

.badge--alert {
  background: rgba(255, 106, 74, 0.25);
  color: #c83a1b;
}

.log-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.log-list li {
  padding: 10px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--panel-border);
}

.log-time {
  font-weight: 700;
  color: var(--ink);
  font-size: 12px;
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.map-legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot--route {
  background: linear-gradient(135deg, #89f7fe, #66a6ff);
}

.legend-dot--last {
  background: #ff6b4a;
}

.map-frame {
  position: relative;
  height: 380px;
  border-radius: 22px;
  overflow: hidden;
  background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.6), transparent 55%),
    linear-gradient(135deg, rgba(0, 38, 77, 0.06), rgba(255, 255, 255, 0.8));
  border: 1px solid var(--panel-border);
}

.map-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(11, 109, 255, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(11, 109, 255, 0.07) 1px, transparent 1px);
  background-size: 40px 40px;
  mix-blend-mode: multiply;
}

.map-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#routeLine {
  opacity: 0;
  transition: opacity 0.3s ease;
}

#lastPoint {
  fill: var(--accent);
  stroke: #fff;
  stroke-width: 0.8;
}

.map-frame.show-route #routeLine {
  opacity: 1;
}

.map-info {
  position: absolute;
  bottom: 16px;
  right: 16px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 14px;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 22px rgba(16, 19, 28, 0.1);
}

.detail-card {
  background: linear-gradient(140deg, #fff7f2, #ffffff);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 20px;
}

.meta-label {
  font-size: 12px;
  color: var(--muted);
}

.meta-value {
  font-weight: 600;
  margin-top: 4px;
}

.meta-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--cool-soft);
  color: var(--cool);
  font-weight: 600;
}

.ghost {
  border: 1px solid var(--panel-border);
  background: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  transition: border 0.2s ease, color 0.2s ease;
}

.ghost:hover {
  border-color: var(--cool);
  color: var(--cool);
}

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

  .panel--teams,
  .panel--info,
  .panel--map {
    order: initial;
  }

  .panel-block--logs {
    grid-template-columns: 1fr;
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}
