:root {
  --bg: #0b1220;
  --panel: rgba(15, 23, 42, 0.92);
  --border: rgba(148, 163, 184, 0.22);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0284c7;
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.topbar {
  height: 54px;
  padding: 0 16px;
  background: #0f172a;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 20;
}

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

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22d3ee;
  box-shadow: 0 0 12px #22d3ee;
}

.brand h1 {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.subtitle {
  font-size: 11px;
  color: var(--muted);
}

.topbar-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid var(--border);
}

.badge-s1 { color: #22d3ee; }
.badge-s2 { color: #34d399; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

select, input[type="date"], button {
  font: inherit;
  color: var(--text);
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
}

button {
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.btn-primary {
  width: 100%;
  background: var(--accent-strong);
  border-color: var(--accent);
  font-weight: 600;
  padding: 8px 12px;
}

.btn-secondary {
  background: #1e293b;
}

.workspace {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

.panel {
  position: absolute;
  top: 12px;
  bottom: 12px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 10px;
  z-index: 10;
  overflow-y: auto;
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.45);
}

.left-panel {
  left: 12px;
  width: 288px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.left-panel.collapsed {
  display: none;
}

.right-panel {
  right: 12px;
  width: 320px;
  padding: 14px;
}

.hidden {
  display: none !important;
}

.panel-section h2, .panel-section h3 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #f8fafc;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.segmented button.active {
  background: var(--accent-strong);
  border-color: var(--accent);
  font-weight: 600;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.btn-chip {
  padding: 5px 8px;
  font-size: 11px;
  background: rgba(30, 41, 59, 0.7);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  margin: 8px 0 12px;
  cursor: pointer;
}

.legend-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 10px;
  font-size: 12px;
}

.legend-grid span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.legend-ship {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.detail-header h2 {
  font-size: 15px;
  margin-top: 6px;
}

.icon-btn {
  padding: 4px 8px;
  line-height: 1;
}

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.crop-box {
  width: 100%;
  min-height: 170px;
  max-height: 240px;
  background: #020617;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.crop-box img {
  max-width: 100%;
  max-height: 236px;
  object-fit: contain;
}

.crop-empty {
  color: var(--muted);
  font-size: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 7px 10px;
  font-size: 12px;
}

.detail-grid dt {
  color: var(--muted);
}

.detail-grid dd {
  color: var(--text);
  word-break: break-all;
}

.toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--accent);
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 12px;
  z-index: 30;
}

.timeline-bar {
  height: 86px;
  background: #0f172a;
  border-top: 1px solid var(--border);
  padding: 6px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  user-select: none;
}

.timeline-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
}

#timeline-hover {
  color: #facc15;
  font-variant-numeric: tabular-nums;
}

.timeline-bars {
  position: relative;
  flex: 1;
  min-height: 0;
}

#timeline-canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

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

.panel-header h2 {
  margin-bottom: 0;
}

.mobile-only {
  display: none;
}

.mobile-stats {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 9;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  font-size: 11px;
  color: var(--text);
  pointer-events: none;
  max-width: calc(100% - 20px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex;
    align-items: center;
  }
  .topbar {
    height: 50px;
    padding: 0 10px;
    gap: 8px;
  }
  .subtitle {
    display: none;
  }
  .brand {
    gap: 7px;
    min-width: 0;
  }
  .brand h1 {
    font-size: 14px;
    white-space: nowrap;
  }
  .topbar-stats {
    display: none;
  }
  .topbar-actions {
    gap: 6px;
  }
  .topbar-actions select,
  .topbar-actions button {
    padding: 6px 8px;
    min-height: 34px;
    font-size: 12px;
  }
  .left-panel {
    left: 8px;
    right: 8px;
    top: 8px;
    bottom: 8px;
    width: auto;
    max-height: calc(100% - 16px);
    z-index: 25;
  }
  .left-panel select,
  .left-panel input[type="date"],
  .left-panel button {
    min-height: 36px;
    font-size: 14px;
  }
  .right-panel {
    left: 8px;
    right: 8px;
    top: auto;
    bottom: 8px;
    width: auto;
    max-height: 58%;
    z-index: 24;
    border-radius: 14px;
  }
  .crop-box {
    min-height: 110px;
    max-height: 150px;
  }
  .crop-box img {
    max-height: 146px;
  }
  .detail-grid {
    grid-template-columns: 96px 1fr;
    gap: 5px 8px;
  }
  .timeline-bar {
    height: 74px;
    padding: 5px 10px calc(6px + env(safe-area-inset-bottom));
  }
  .timeline-meta {
    gap: 8px;
  }
  .timeline-meta span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
