:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #172033;
  --muted: #5f6b80;
  --line: #d8dfeb;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --danger: #c2410c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 10%, #dff4f1 0%, transparent 45%),
    radial-gradient(circle at 90% 90%, #f8ecd8 0%, transparent 42%), var(--bg);
}

.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: 100dvh;
}

.panel {
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  gap: 0.35rem;
}

h1 {
  margin-top: 0;
  margin-bottom: 0.3rem;
}

p {
  margin-top: 0;
  color: var(--muted);
}

.track-form {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.ship-controls {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  background: #fbfdff;
}

.ship-controls summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  user-select: none;
}

.ship-controls[open] {
  padding-bottom: 0.6rem;
}

.track-row {
  display: flex;
  gap: 0.4rem;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  font-size: 0.95rem;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.8rem;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

.message {
  min-height: 1.1rem;
  font-size: 0.92rem;
  margin-bottom: 0.75rem;
}

.message.error {
  color: var(--danger);
}

.tracked-list {
  padding-left: 1rem;
  margin-top: 0.2rem;
  margin-bottom: 0.4rem;
  max-height: 120px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.tracked-list li {
  margin-bottom: 0.15rem;
}

.meta {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.map-wrap {
  display: grid;
  gap: 0.8rem;
  padding: 0.8rem;
  min-height: 0;
}

#map {
  width: 100%;
  height: calc(100vh - 1.6rem);
  border: 1px solid var(--line);
  border-radius: 12px;
}

#map .ship-label {
  display: none;
  pointer-events: none;
  padding: 1px 6px;
  font-size: 11px;
  border: 1px solid rgba(23, 32, 51, 0.18);
}

#map.show-ship-labels .ship-label {
  display: block;
}

.ships-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ships-panel h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

.visible-ships {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  max-height: calc(100vh - 3.2rem);
}

.visible-ships.left {
  flex: 1;
  min-height: 220px;
  max-height: none;
  margin-top: 0.15rem;
}

.visible-ships li {
  margin-bottom: 0.2rem;
}

.ship-select {
  width: 100%;
  text-align: left;
  background: #f7fafc;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-size: 0.88rem;
  line-height: 1.2;
}

.ship-select:hover {
  background: #eef4ff;
}

.ship-select.selected {
  border-color: var(--brand);
  background: #e5f5f3;
}

.ship-select small {
  display: block;
  color: var(--muted);
  margin-top: 0.1rem;
  font-size: 0.78rem;
}

@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
  }

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

  .panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    min-height: 0;
  }

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

  #map {
    height: 65vh;
  }

  .visible-ships {
    max-height: 35vh;
  }

  .visible-ships.left {
    min-height: 140px;
  }
}
