:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #071017;
  --panel: #0d1820;
  --panel-2: #111f29;
  --line: #263741;
  --text: #edf4f6;
  --muted: #91a5af;
  --accent: #29d4bd;
  --accent-dark: #0c887b;
  --warning: #f4b942;
  --danger: #fa6f78;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button, input { font: inherit; letter-spacing: 0; }
button { color: inherit; }

body.privacy-page {
  min-height: 100%;
  height: auto;
  overflow: auto;
  background: var(--bg);
  color: var(--text);
}

.privacy-document {
  max-width: 780px;
  margin: 0 auto;
  padding: 42px 22px 64px;
  line-height: 1.58;
}
.privacy-document h1 {
  margin: 18px 0 4px;
  font-size: 32px;
}
.privacy-document h2 {
  margin: 28px 0 8px;
  font-size: 16px;
  color: #f3fafb;
}
.privacy-document p {
  margin: 10px 0;
  color: #c8d8dd;
}
.privacy-updated {
  color: var(--muted) !important;
  font-size: 13px;
}
.privacy-back {
  display: inline-flex;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #cfe9eb;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.privacy-back:hover {
  border-color: #47616d;
  color: #ffffff;
}

.app-shell {
  display: grid;
  grid-template-columns: 350px 1fr;
  grid-template-rows: 58px 34px 1fr;
  width: 100%;
  height: 100%;
  background: var(--bg);
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: #09141b;
  z-index: 1000;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid #39766f;
  border-radius: 6px;
  color: var(--accent);
  font-weight: 800;
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 14px; }
.brand span { color: var(--muted); font-size: 11px; margin-top: 1px; }
.topbar-link {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #cfe9eb;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
}
.topbar-link:hover {
  border-color: #47616d;
  color: #ffffff;
}

.beta-strip {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0 14px;
  border-bottom: 1px solid #2e2b1d;
  background: #15140d;
  color: #d7d0af;
  font-size: 11px;
  z-index: 999;
}
.beta-strip strong {
  flex: 0 0 auto;
  color: var(--warning);
  text-transform: uppercase;
}
.beta-strip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.position-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status-dot.live { background: var(--accent); box-shadow: 0 0 0 3px rgb(41 212 189 / 14%); }
.status-dot.stale { background: var(--warning); }
.status-dot.error { background: var(--danger); }

.control-panel {
  grid-row: 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.control-section {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 12px;
  font-weight: 700;
  color: #c9d7dc;
  text-transform: uppercase;
}

.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  min-width: 138px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #081219;
}
.segment {
  min-height: 28px;
  padding: 4px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}
.segment.active { background: #1c313a; color: var(--text); }

.field {
  display: grid;
  grid-template-columns: 1fr 112px;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  color: var(--muted);
  font-size: 12px;
}
.sailing-fields { border-top: 1px solid #1c2c34; margin-top: 8px; padding-top: 8px; }
.preference-field {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}
.preference-control { width: 100%; min-width: 0; }
.field-stacked {
  grid-template-columns: 1fr;
  align-items: stretch;
  gap: 7px;
  padding: 5px 0;
}
.tiered-control {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 6px;
  color: #78939d;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}
.tiered-control small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.segment.live-tier {
  border-color: #24514d;
  color: #8eeadf;
}
.segment.live-tier.active {
  border-color: #42ddc8;
  background: #102b2a;
  color: #d8fffb;
}
.segment.simulated-tier.active {
  color: #dbeafe;
}
.input-suffix {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #081219;
}
.input-suffix input {
  min-width: 0;
  width: 100%;
  padding: 0 6px 0 10px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
  text-align: right;
}
.input-suffix span { padding-right: 9px; color: #6f858f; font-size: 11px; }
.datetime-input {
  grid-template-columns: minmax(0, 1fr) auto;
}
.datetime-input input {
  font-size: 11px;
}

.coordinate-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  border-bottom: 1px solid #1c2c34;
}
.demo-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 7px;
  margin-bottom: 7px;
}
.demo-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 34px;
  margin: 0;
  border: 1px solid #31505b;
  border-radius: 5px;
  background: #10232c;
  color: #c8dade;
  font-size: 11px;
  cursor: pointer;
}
.demo-button:hover { border-color: #47707c; }
.demo-button svg { width: 14px; height: 14px; color: var(--accent); }
.rpm-demo-button { grid-column: 1 / -1; }
.coordinate-row:last-child { border-bottom: 0; }
.clearance-field {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #1c2c34;
}
.coordinate-label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 11px; }
.coordinate-row strong { display: block; font-size: 12px; font-weight: 600; }

.route-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}
.metric { min-width: 0; padding: 14px 10px; background: var(--panel-2); }
.metric span, .metric strong { display: block; }
.metric span { margin-bottom: 5px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.metric strong { font-size: 15px; white-space: nowrap; }
.route-state {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #0b191f;
  color: var(--accent);
  font-size: 11px;
}
.route-state svg { width: 14px; height: 14px; }
.export-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #1c2c34;
  background: #0a151c;
}
.secondary-button.compact {
  min-height: 32px;
  padding: 7px 10px;
  font-size: 10px;
}
.route-explanation {
  grid-column: 1 / -1;
  display: grid;
  gap: 5px;
  padding: 11px 12px 12px;
  background: #08161d;
  border-top: 1px solid #1c2c34;
}
.route-explanation strong {
  color: #e1f0f2;
  font-size: 11px;
}
.route-explanation span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}
.navigation-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}
.navigation-summary div { padding: 10px 12px; background: #102027; }
.navigation-summary span, .navigation-summary strong { display: block; }
.navigation-summary span { color: var(--muted); font-size: 9px; text-transform: uppercase; }
.navigation-summary strong { margin-top: 4px; font-size: 13px; }

.motor-comparison {
  border-bottom: 1px solid var(--line);
  background: #0a151c;
}
.comparison-heading {
  display: flex;
  justify-content: space-between;
  padding: 11px 12px 8px;
  color: #c9d7dc;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.comparison-heading small {
  color: var(--warning);
  font-size: 9px;
  font-weight: 600;
}
.comparison-row {
  display: grid;
  grid-template-columns: 1.15fr repeat(4, minmax(0, 1fr));
  gap: 5px;
  align-items: center;
  min-height: 31px;
  padding: 0 12px;
  border-top: 1px solid #1c2c34;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}
.comparison-row strong {
  overflow: hidden;
  color: #b9c9ce;
  text-align: left;
  text-overflow: ellipsis;
  text-transform: capitalize;
}
.profile-summary {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #31505b;
  border-radius: 5px;
  background: #10232c;
}
.profile-summary strong, .profile-summary span { display: block; }
.profile-summary strong { color: #dce9ec; font-size: 11px; }
.profile-summary span { margin-top: 3px; color: var(--muted); font-size: 9px; }
.route-instructions {
  border-bottom: 1px solid var(--line);
  background: #0a151c;
}
.instruction-row {
  display: grid;
  grid-template-columns: 24px repeat(4, minmax(0, 1fr));
  gap: 5px;
  align-items: center;
  width: 100%;
  min-height: 42px;
  padding: 7px 12px;
  border: 0;
  border-top: 1px solid #1c2c34;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 9px;
  text-align: left;
}
.instruction-row:hover,
.instruction-row.active {
  background: #10232c;
}
.instruction-row.active {
  box-shadow: inset 3px 0 0 var(--warning);
}
.instruction-row strong {
  color: #e1f0f2;
  font-size: 10px;
}
.instruction-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.instruction-row small {
  grid-column: 2 / -1;
  color: #8fb4bd;
  font-size: 9px;
}
.instruction-row.maneuver {
  background: #18202a;
}
.instruction-row.partial-forecast {
  box-shadow: inset 3px 0 0 #f4b942;
}
.instruction-row.assumption {
  background: #171b22;
}
.instruction-row.assumption small {
  color: #c7aab0;
}
.instruction-row.assumption strong {
  color: #ffd0d5;
}
.instruction-more {
  padding: 8px 12px 10px;
  border-top: 1px solid #1c2c34;
  color: var(--muted);
  font-size: 9px;
}
.schedule-summary {
  padding: 9px 12px;
  border-top: 1px solid #1c2c34;
}
.schedule-summary span, .schedule-summary strong { display: block; }
.schedule-summary span { color: #b9c9ce; font-size: 10px; }
.schedule-summary strong { margin-top: 3px; color: var(--accent); font-size: 10px; }
.schedule-summary small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.35;
}
.schedule-row {
  display: grid;
  grid-template-columns: 0.85fr 1.35fr 0.75fr 0.65fr;
  gap: 6px;
  align-items: center;
  min-height: 29px;
  padding: 0 12px;
  border-top: 1px solid #1c2c34;
  color: var(--muted);
  font-size: 9px;
  text-align: right;
}
.schedule-row strong { color: #c9d7dc; text-align: left; }
.telemetry-plots {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #1c2c34;
  background: #07161e;
}
.telemetry-plot {
  display: grid;
  grid-template-columns: 54px 1fr 42px;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.telemetry-plot span {
  color: var(--muted);
  font-size: 9px;
  text-transform: uppercase;
}
.telemetry-plot strong {
  color: #dce9ec;
  font-size: 10px;
  text-align: right;
}
.telemetry-plot svg {
  display: block;
  width: 100%;
  height: 34px;
  overflow: visible;
}
.telemetry-grid-line {
  stroke: #29414b;
  stroke-width: 1;
}
.telemetry-area {
  fill: rgb(41 212 189 / 12%);
}
.telemetry-line {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2.2;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.telemetry-line.rpm { stroke: #fa6f78; }
.telemetry-line.speed { stroke: #38bdf8; }
.telemetry-line.fuel { stroke: #f4b942; }
.comparison-row.selected {
  border-left: 3px solid var(--accent);
  background: #10252a;
  color: var(--text);
}

.panel-actions { display: grid; gap: 8px; padding: 16px; }
.primary-button, .secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 6px;
  cursor: pointer;
}
.primary-button {
  border: 1px solid #42ddc8;
  background: var(--accent);
  color: #04201d;
  font-weight: 750;
}
.primary-button:disabled { opacity: 0.5; cursor: wait; }
.secondary-button { border: 1px solid var(--line); background: var(--panel-2); }
.primary-button svg, .secondary-button svg { width: 17px; height: 17px; }

.safety-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: auto 16px 16px;
  padding: 11px;
  border-left: 3px solid var(--warning);
  background: #191910;
  color: #c9c3a7;
  font-size: 10px;
  line-height: 1.45;
}
.safety-note svg { flex: 0 0 auto; width: 15px; height: 15px; color: var(--warning); }

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  cursor: pointer;
}
.icon-button:hover { border-color: #47616d; }
.icon-button svg { width: 17px; height: 17px; }
.icon-button.small { width: 28px; height: 28px; background: transparent; }
.icon-button.small svg { width: 14px; height: 14px; }

.map-region { grid-row: 3; position: relative; min-width: 0; min-height: 0; }
#map { width: 100%; height: 100%; background: #0b1c25; }
#map.drawing-no-go { cursor: crosshair; }
.leaflet-container { font-family: inherit; }
.leaflet-control-zoom a { background: #0d1820 !important; color: #e4eff2 !important; border-color: var(--line) !important; }
.leaflet-control-attribution { background: rgb(7 16 23 / 85%) !important; color: #77909b !important; }
.leaflet-control-attribution a { color: #8cb6c2 !important; }

.map-toolbar {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  gap: 7px;
  z-index: 800;
}
.map-button { background: rgb(9 20 27 / 92%); }
.map-button.active-layer {
  border-color: #318b83;
  color: var(--accent);
}
.route-inspector {
  display: grid;
  gap: 7px;
  min-width: 210px;
  color: #dce9ec;
}
.route-inspector strong:first-child {
  color: #f3fafb;
  font-size: 13px;
}
.route-inspector div {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 10px;
  align-items: baseline;
}
.route-inspector span {
  color: #8fa6ae;
  font-size: 11px;
  text-transform: uppercase;
}
.route-inspector div strong {
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
}
.route-inspector-popup .leaflet-popup-content-wrapper,
.route-inspector-popup .leaflet-popup-tip {
  background: #0d1820;
  color: #dce9ec;
  border: 1px solid #29404a;
  box-shadow: 0 12px 28px rgb(0 0 0 / 45%);
}
.route-inspector-popup .leaflet-popup-content {
  margin: 12px 14px;
}
.wind-arrow-container { background: transparent; border: 0; }
.wind-arrow {
  position: relative;
  display: block;
  width: 2px;
  height: 20px;
  margin: 1px auto;
  transform-origin: 50% 50%;
  background: #56d9ff;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 65%));
}
.wind-arrow::before {
  position: absolute;
  top: -1px;
  left: -4px;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-bottom: 7px solid #56d9ff;
  border-left: 5px solid transparent;
  content: "";
}
.current-arrow {
  position: relative;
  display: block;
  width: 3px;
  height: 16px;
  margin: 3px auto;
  transform-origin: 50% 50%;
  border-radius: 2px;
  background: #65e59a;
  filter: drop-shadow(0 1px 1px rgb(0 0 0 / 65%));
}
.current-arrow::before {
  position: absolute;
  top: -2px;
  left: -4px;
  width: 0;
  height: 0;
  border-right: 5px solid transparent;
  border-bottom: 7px solid #65e59a;
  border-left: 5px solid transparent;
  content: "";
}
.wind-system-label {
  border: 0;
  background: transparent;
  color: #dcecf0;
  font-size: 10px;
  font-weight: 650;
  text-align: center;
  text-shadow: 0 1px 3px #001018, 0 0 5px #001018;
  white-space: nowrap;
}
.map-message {
  position: absolute;
  left: 50%;
  bottom: 24px;
  z-index: 800;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 14px;
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgb(9 20 27 / 96%);
  color: #d9e5e8;
  font-size: 12px;
  box-shadow: 0 8px 26px rgb(0 0 0 / 30%);
}
.map-message.error { border-color: #7d3b40; color: #ffb5bb; }
.accuracy-badge {
  position: absolute;
  left: 14px;
  bottom: 24px;
  z-index: 800;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgb(9 20 27 / 92%);
  color: var(--muted);
  font-size: 10px;
}
.map-legend {
  position: absolute;
  right: 14px;
  bottom: 24px;
  z-index: 800;
  display: flex;
  gap: 12px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgb(9 20 27 / 92%);
  color: #b8c8cd;
  font-size: 9px;
}
.map-legend span { display: flex; align-items: center; gap: 5px; }
.legend-line { display: block; width: 18px; height: 0; border-top: 2px solid; }
.legend-line.optimized { border-color: var(--accent); }
.legend-line.direct { border-color: var(--warning); border-top-style: dashed; }
.rpm-map-legend { gap: 4px !important; }
.rpm-swatch {
  display: inline-block;
  width: 11px;
  height: 4px;
  border-radius: 1px;
}
.rpm-low { background: #38bdf8; }
.rpm-mid { background: #f4b942; }
.rpm-high { background: #fa6f78; }
.legend-dot {
  display: block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
}
.legend-current {
  display: block;
  width: 12px;
  height: 3px;
  border-radius: 2px;
  background: #65e59a;
}

.hidden { display: none !important; }

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 54px 34px minmax(270px, 50vh) minmax(0, 1fr);
  }
  .topbar { grid-row: 1; padding: 0 10px; }
  .brand { min-width: 0; }
  .brand span { display: none; }
  .topbar-link { padding: 6px 8px; }
  .beta-strip { grid-row: 2; padding: 0 10px; }
  .position-status { max-width: 160px; }
  .position-status span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .map-region { grid-row: 3; }
  .control-panel {
    grid-row: 4;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .control-section { padding: 13px 14px; }
  .safety-note { margin-top: 4px; }
  .map-legend { right: 8px; bottom: 8px; }
}
