:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --text: #13212e;
  --muted: #5d6b78;
  --border: #dde3e8;
  --navy: #0b2a45;
  --available: #1e9e5a;
  --soon: #e0a100;
  --assignment: #2f6fd6;
  --maintenance: #8a95a1;
  --farm: #b08968;
  --underway: #0b2a45;
  --stationary: #5d6b78;
  --offline: #c3cad1;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--navy);
  color: #fff;
}
.brand strong { font-size: 18px; letter-spacing: .3px; }
.brand .sub { margin-left: 10px; opacity: .75; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.mode-toggle {
  display: inline-flex;
  background: rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 3px;
}
.mode-toggle button {
  border: 0;
  background: transparent;
  color: #fff;
  opacity: .8;
  font: 600 13px system-ui, sans-serif;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.mode-toggle button.active { background: #fff; color: var(--navy); opacity: 1; }
.clock { font-variant-numeric: tabular-nums; opacity: .85; font-size: 14px; }

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: calc(100% - 56px);
}

.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.stat { text-align: center; }
.stat .num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat.available .num { color: var(--available); }
.stat.soon .num { color: var(--soon); }
.stat.busy .num { color: var(--assignment); }
.stat.underway .num { color: var(--underway); }
.stat.stationary .num { color: var(--stationary); }
.stat.offline .num { color: var(--offline); }

.demo-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 0 5px;
  border: 1px dashed var(--soon);
  border-radius: 4px;
  color: #9a6b00;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .3px;
  vertical-align: 1px;
}
.real-only { display: none !important; }
body.real-mode .real-only { display: inline-flex !important; }
body.real-mode .demo-only { display: none !important; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }

.boat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}
.boat {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.boat:hover, .boat.selected { background: #eef3f8; }
.boat .name { font-weight: 600; }
.boat .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.boat .meta.dest { color: var(--navy); font-weight: 500; }
.boat .ready { text-align: right; font-size: 13px; font-weight: 600; white-space: nowrap; }
.boat .ready small { display: block; font-weight: 400; color: var(--muted); font-size: 11px; }

.dot {
  display: inline-block;
  width: 12px; height: 12px;
  border-radius: 50%;
}
.dot.available { background: var(--available); }
.dot.soon { background: var(--soon); }
.dot.assignment { background: var(--assignment); }
.dot.maintenance { background: var(--maintenance); }
.dot.underway { background: var(--underway); }
.dot.stationary { background: var(--stationary); }
.dot.offline { background: var(--offline); }
.dot.farm { background: var(--farm); width: 9px; height: 9px; }

.note { font-size: 11px; color: var(--muted); padding: 10px 16px; margin: 0; border-top: 1px solid var(--border); }

.note.live::before, .note.offline::before {
  content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px;
}
.note.live::before { background: var(--available); }
.note.offline::before { background: var(--soon); }

.map-wrap { position: relative; }
.map-btn {
  background: var(--surface);
  border: 2px solid rgba(0,0,0,.2);
  border-radius: 4px;
  padding: 6px 10px;
  font: 600 12px system-ui, sans-serif;
  color: var(--navy);
  cursor: pointer;
}
.map-btn:hover { background: #eef3f8; }
#map { position: absolute; inset: 0; }

.legend {
  position: absolute;
  bottom: 20px;
  left: 12px;
  z-index: 500;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  gap: 14px;
  font-size: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Boat marker */
.boat-marker {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 1px 5px rgba(0,0,0,.35);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.boat-marker svg { width: 16px; height: 16px; }
.boat-marker.available { background: var(--available); }
.boat-marker.soon { background: var(--soon); }
.boat-marker.assignment { background: var(--assignment); }
.boat-marker.maintenance { background: var(--maintenance); }
.boat-marker.underway { background: var(--underway); }
.boat-marker.stationary { background: var(--stationary); }
.boat-marker.offline { background: var(--offline); }
.boat-marker.selected { outline: 3px solid var(--navy); }

.popup h3 { margin: 0 0 6px; font-size: 15px; }
.popup table { border-collapse: collapse; font-size: 13px; }
.popup td { padding: 2px 10px 2px 0; vertical-align: top; }
.popup td:first-child { color: var(--muted); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 6px;
}
.badge.available { background: var(--available); }
.badge.soon { background: var(--soon); }
.badge.assignment { background: var(--assignment); }
.badge.maintenance { background: var(--maintenance); }
.badge.underway { background: var(--underway); }
.badge.stationary { background: var(--stationary); }
.badge.offline { background: var(--offline); color: var(--text); }
.badge.farm { background: var(--farm); }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; grid-template-rows: 45% 55%; }
  .panel { border-right: none; border-bottom: 1px solid var(--border); order: 2; }
  .map-wrap { order: 1; }
  .legend { flex-wrap: wrap; right: 12px; }
  .brand .sub, .clock { display: none; }
  .mode-toggle button { padding: 5px 10px; font-size: 12px; }
}
