:root {
  --bg: #091821;
  --bg-soft: #102a34;
  --panel: rgba(10, 26, 34, 0.78);
  --panel-strong: rgba(15, 38, 49, 0.92);
  --panel-soft: rgba(17, 42, 55, 0.86);
  --stroke: rgba(173, 217, 214, 0.16);
  --stroke-strong: rgba(173, 217, 214, 0.28);
  --text: #ecf8f4;
  --muted: #9fc0ba;
  --sea: #59d4c8;
  --sea-deep: #2ca59a;
  --sand: #f4bc74;
  --sand-deep: #d99237;
  --coral: #f07f73;
  --ink: #061117;
  --shadow: 0 28px 80px rgba(2, 12, 16, 0.35);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 15%, rgba(89, 212, 200, 0.18), transparent 34%),
    radial-gradient(circle at 85% 10%, rgba(244, 188, 116, 0.18), transparent 28%),
    linear-gradient(180deg, #08151d 0%, #0c1f28 100%);
}

.aurora,
.grid-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.aurora-a {
  background: radial-gradient(circle at 20% 20%, rgba(89, 212, 200, 0.16), transparent 36%);
}

.aurora-b {
  background: radial-gradient(circle at 80% 18%, rgba(240, 127, 115, 0.14), transparent 28%);
}

.grid-glow {
  opacity: 0.16;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.8), transparent);
}

.page-shell {
  position: relative;
  z-index: 1;
  width: min(100%, 1600px);
  margin: 0 auto;
  padding: clamp(14px, 2vw, 28px);
}

.topbar,
.hero,
.card {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: clamp(18px, 2vw, 24px);
  border: 1px solid var(--stroke);
  border-radius: calc(var(--radius) + 6px);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  box-shadow: var(--shadow);
}

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

.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  font-family: "Space Grotesk", sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(135deg, var(--sand), var(--sea));
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.22);
}

.eyebrow,
.section-tag {
  margin: 0 0 8px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

h2 {
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  max-width: 14ch;
}

h3 {
  font-size: 1.15rem;
}

.status-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.status-chip,
.overlay-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  min-height: 46px;
}

#modePill[data-mode="running"],
#wsStatus[data-state="online"] {
  color: #b7fff5;
}

#wsStatus[data-state="connecting"] {
  color: #ffe0af;
}

#wsStatus[data-state="offline"] {
  color: #ffc7bf;
}

#modePill[data-mode="paused"] {
  color: #ffe0af;
}

#modePill[data-mode="stopped"] {
  color: #ffc7bf;
}

.chip-label,
.metric-label,
.mini-label {
  color: var(--muted);
  font-size: 0.78rem;
}

.layout {
  display: grid;
  gap: clamp(18px, 2vw, 26px);
  margin-top: clamp(18px, 2vw, 24px);
}

.hero,
.card {
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: clamp(18px, 2vw, 28px);
  padding: clamp(20px, 2vw, 28px);
  align-items: start;
}

.hero-copy {
  margin-top: 12px;
  max-width: 64ch;
  color: #cfe3dd;
  line-height: 1.65;
}

.flash-note {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 0.9rem;
}

.flash-note[data-tone="ok"] {
  border-color: rgba(89, 212, 200, 0.34);
}

.flash-note[data-tone="warn"] {
  border-color: rgba(244, 188, 116, 0.34);
}

.flash-note[data-tone="error"] {
  border-color: rgba(240, 127, 115, 0.34);
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.metric-card {
  min-width: 0;
  min-height: 172px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  align-content: start;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(173, 217, 214, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 50%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 16px 30px rgba(2, 12, 16, 0.16);
  position: relative;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 26%);
}

.metric-card-sea {
  border-color: rgba(89, 212, 200, 0.22);
}

.metric-card-sand {
  border-color: rgba(244, 188, 116, 0.22);
}

.metric-card-coral {
  border-color: rgba(240, 127, 115, 0.22);
}

.metric-card-slate {
  border-color: rgba(191, 211, 216, 0.18);
}

.metric-head {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.metric-heading {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.metric-badge {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 14px 26px rgba(2, 12, 16, 0.16);
  flex: 0 0 auto;
}

.metric-badge.sea {
  color: #d9fff8;
  background: linear-gradient(135deg, rgba(89, 212, 200, 0.32), rgba(44, 165, 154, 0.78));
}

.metric-badge.sand {
  color: #fff8ef;
  background: linear-gradient(135deg, rgba(244, 188, 116, 0.28), rgba(217, 146, 55, 0.84));
}

.metric-badge.coral {
  color: #fff4f2;
  background: linear-gradient(135deg, rgba(240, 127, 115, 0.32), rgba(189, 66, 52, 0.8));
}

.metric-badge.slate {
  color: #ebfbf7;
  background: linear-gradient(135deg, rgba(173, 217, 214, 0.2), rgba(70, 102, 109, 0.8));
}

.metric-badge-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.metric-value {
  display: block;
  min-width: 0;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  letter-spacing: -0.02em;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.metric-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(219, 238, 232, 0.58);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-note,
.metric-copy {
  display: block;
  min-width: 0;
  margin-top: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.55;
  overflow: hidden;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.metric-copy {
  padding: 12px 14px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0));
  border-radius: 14px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(320px, 0.9fr);
  gap: 24px;
  align-items: start;
}

.side-stack,
.lower-grid {
  display: grid;
  gap: 24px;
}

.card {
  padding: clamp(18px, 1.7vw, 24px);
  overflow: hidden;
}

.card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.button-row,
.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  width: 100%;
}

.button-grid {
  margin-bottom: 18px;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--stroke-strong);
  border-radius: 18px;
  min-height: 54px;
  padding: 12px 18px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 14px 26px rgba(2, 12, 16, 0.18);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.38);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 18px 30px rgba(2, 12, 16, 0.22);
}

.btn:focus-visible {
  outline: none;
  border-color: rgba(159, 231, 222, 0.88);
  box-shadow: 0 0 0 4px rgba(89, 212, 200, 0.18), 0 18px 30px rgba(2, 12, 16, 0.22);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  color: var(--ink);
  background: linear-gradient(135deg, #63e0d1, #aaf3ea);
  border-color: rgba(255, 255, 255, 0.32);
}

.btn.warn {
  color: var(--ink);
  background: linear-gradient(135deg, #f4bc74, #ffd59d);
}

.btn.danger {
  color: #fff4f2;
  background: linear-gradient(135deg, rgba(240, 127, 115, 0.92), rgba(189, 66, 52, 0.92));
}

.btn.ghost {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 1.1rem;
  height: 1.1rem;
  flex: 0 0 auto;
}

.btn-svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-label {
  min-width: 0;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.map-frame {
  position: relative;
  min-height: clamp(340px, 54vh, 620px);
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #d9ebe5;
}

#map {
  width: 100%;
  height: 100%;
  min-height: clamp(340px, 54vh, 620px);
}

.map-overlay {
  position: absolute;
  left: 18px;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: calc(100% - 36px);
}

.map-footer,
.status-panel {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.03);
}

.map-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  align-items: center;
  gap: 18px;
  color: var(--muted);
}

.progress-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
}

.progress-meter-card {
  min-width: 0;
  width: 100%;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
}

.progress-meter-card.compact {
  min-width: 0;
}

.interval-card {
  margin-top: 16px;
}

.progress-meter {
  position: relative;
  height: 12px;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.18);
}

.progress-meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  transition: width 0.9s linear;
  background: linear-gradient(90deg, rgba(89, 212, 200, 0.42), rgba(89, 212, 200, 0.96));
  box-shadow: 0 0 18px rgba(89, 212, 200, 0.28);
}

.progress-meter-fill.sea {
  background: linear-gradient(90deg, rgba(89, 212, 200, 0.42), rgba(89, 212, 200, 0.96));
  box-shadow: 0 0 18px rgba(89, 212, 200, 0.28);
}

.progress-meter-fill.sand {
  background: linear-gradient(90deg, rgba(244, 188, 116, 0.42), rgba(244, 188, 116, 0.95));
  box-shadow: 0 0 18px rgba(244, 188, 116, 0.28);
}

.progress-caption {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.status-panel.dual {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.status-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.status-block {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.status-copy {
  min-width: 0;
  margin: 0;
  padding: 14px 16px;
  min-height: 108px;
  max-height: 180px;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  color: #dbeee8;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  scrollbar-width: thin;
}

.status-copy-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: #e3f8f2;
}

.status-copy-delivery {
  font-size: 0.84rem;
}

.map-footer p {
  margin: 6px 0 0;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.vessel-library-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 18px;
}

.form-grid.two-col {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.form-grid.four-col {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.form-grid.compact {
  margin-top: 10px;
}

.field {
  display: grid;
  gap: 8px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field span {
  font-size: 0.84rem;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  min-height: 52px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  font: inherit;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: rgba(89, 212, 200, 0.7);
  box-shadow: 0 0 0 3px rgba(89, 212, 200, 0.16);
}

.toggle-field {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  align-content: center;
  min-height: 84px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
}

.toggle-field input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 58px;
  height: 34px;
  margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.toggle-field input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #f8fffd, #d3ebe4);
  box-shadow: 0 8px 16px rgba(6, 17, 23, 0.26);
  transition: transform 0.22s ease;
}

.toggle-field input[type="checkbox"]:checked {
  border-color: rgba(89, 212, 200, 0.54);
  background: linear-gradient(90deg, rgba(89, 212, 200, 0.34), rgba(89, 212, 200, 0.8));
  box-shadow: 0 0 0 4px rgba(89, 212, 200, 0.12);
}

.toggle-field input[type="checkbox"]:checked::after {
  transform: translateX(24px);
}

.toggle-field input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px rgba(89, 212, 200, 0.18);
}

.readiness-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.readiness-list li {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.readiness-list li.ok {
  border-color: rgba(89, 212, 200, 0.28);
}

.readiness-list li.bad {
  border-color: rgba(240, 127, 115, 0.3);
}

.table-wrap {
  overflow: auto;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.data-table th,
.data-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.data-table th {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
}

.data-table input,
.data-table select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  font: inherit;
}

.data-table button {
  width: 100%;
}

.wide-card {
  grid-column: 1 / -1;
}

.lower-grid {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.log-panel {
  min-height: 240px;
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(4, 12, 16, 0.56);
  color: #dbf3ee;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.82rem;
  line-height: 1.6;
}

.ship-wrap {
  width: 34px;
  height: 34px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(6, 17, 23, 0.18);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 28px rgba(0, 0, 0, 0.22);
}

.ship-glyph {
  color: var(--sea-deep);
  font-size: 18px;
  transform-origin: 50% 50%;
  transition: transform 0.2s linear;
}

.leaflet-control-attribution {
  font-size: 10px;
}

.leaflet-draw-toolbar a {
  background-color: rgba(9, 24, 33, 0.9);
  border-color: rgba(255, 255, 255, 0.18);
}

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

@media (max-width: 1080px) {
  .hero,
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .status-cluster {
    justify-content: flex-start;
  }

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

@media (max-width: 820px) {
  .topbar,
  .hero,
  .card {
    padding: 18px;
  }

  .brand,
  .card-head {
    flex-direction: column;
    align-items: stretch;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero-metrics,
  .button-row,
  .button-grid,
  .status-panel,
  .status-panel.dual,
  .lower-grid,
  .form-grid.two-col,
  .form-grid.four-col,
  .vessel-library-grid {
    grid-template-columns: 1fr;
  }

  .map-overlay {
    position: static;
    padding: 12px 0 0;
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 12px;
  }

  .status-chip,
  .overlay-pill {
    width: 100%;
    justify-content: space-between;
  }

  .btn {
    width: 100%;
  }

  .field input,
  .field select {
    min-height: 50px;
  }

  .toggle-field {
    min-height: 76px;
  }

  .map-frame,
  #map {
    min-height: 300px;
  }

  .data-table {
    min-width: 560px;
  }
}
