:root {
  color-scheme: dark;
  --bg: #111318;
  --bg-soft: #141822;
  --panel: #181c24;
  --panel-2: #202631;
  --text: #edf2f7;
  --muted: #98a4b3;
  --line: #303846;
  --accent: #6db6ff;
  --accent-2: #f6d36d;
  --danger: #ff6b6b;
  --ok: #80d27e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    radial-gradient(circle at top left, rgba(109, 182, 255, 0.16), transparent 32rem),
    linear-gradient(135deg, var(--bg), var(--bg-soft) 45%, #10151a);
  background-size: 48px 48px, 48px 48px, auto, auto;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(109, 182, 255, 0.08), rgba(246, 211, 109, 0.06), transparent 55%),
    rgba(13, 15, 20, 0.88);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 19px;
  font-weight: 700;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(109, 182, 255, 0.46);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(109, 182, 255, 0.18), rgba(246, 211, 109, 0.1));
  color: var(--accent-2);
  font-size: 14px;
  letter-spacing: 0;
  box-shadow: inset 0 0 18px rgba(109, 182, 255, 0.13), 0 0 22px rgba(109, 182, 255, 0.08);
}

.brand-title,
.brand-subtitle {
  display: block;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

nav {
  display: flex;
  gap: 10px;
}

nav a {
  position: relative;
  padding: 8px 12px;
  border-radius: 6px;
  color: var(--muted);
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

nav a.active,
nav a:hover {
  color: var(--text);
  background: var(--panel-2);
  transform: translateY(-2px);
}

nav a::after {
  position: absolute;
  right: 12px;
  bottom: 5px;
  left: 12px;
  height: 2px;
  content: "";
  background: var(--accent);
  border-radius: 999px;
  opacity: 0;
  transform: scaleX(0.3);
  transition: opacity 160ms ease, transform 160ms ease;
}

nav a.active::after,
nav a:hover::after {
  opacity: 1;
  transform: scaleX(1);
}

.page {
  width: min(1240px, calc(100% - 40px));
  margin: 28px auto 56px;
}

.hero,
.panel,
.chart-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 28, 36, 0.92);
  box-shadow: var(--shadow);
}

.hero {
  padding: 28px;
}

.hero-command {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(109, 182, 255, 0.18), rgba(246, 211, 109, 0.08) 46%, rgba(24, 28, 36, 0.96)),
    var(--panel);
}

.hero-command::after {
  position: absolute;
  inset: auto 28px 0;
  height: 3px;
  content: "";
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), transparent);
  opacity: 0.72;
}

.panel {
  padding: 18px;
  margin: 18px 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 32px;
}

h2 {
  margin-bottom: 14px;
  font-size: 21px;
}

.muted {
  color: var(--muted);
}

.eyebrow,
.ship-tag {
  margin-bottom: 8px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.stat {
  position: relative;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.035), transparent 42%),
    var(--panel-2);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, background 180ms ease;
}

.stat:hover,
.stat:focus-visible {
  border-color: rgba(109, 182, 255, 0.74);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(109, 182, 255, 0.15);
  transform: translateY(-5px) scale(1.01);
}

.starship-card::before {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 2px;
  content: "";
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 18px rgba(109, 182, 255, 0.56);
  transition: width 180ms ease, opacity 180ms ease;
}

.starship-card:hover::before,
.starship-card:focus-visible::before {
  width: 56px;
  opacity: 0.95;
}

.ship-tag {
  display: block;
}

.stat strong {
  display: block;
  margin-bottom: 4px;
  font-size: 24px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 16px 0;
}

button,
input,
select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1218;
  color: var(--text);
  font: inherit;
}

input,
select {
  padding: 8px 10px;
}

.control-field {
  display: inline-grid;
  gap: 4px;
  min-width: min(100%, 280px);
}

.control-field span {
  color: var(--muted);
  font-size: 12px;
}

.toggle-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1218;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.toggle-option input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--accent);
}

button {
  cursor: pointer;
  padding: 8px 12px;
  background: var(--panel-2);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

button:hover {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(109, 182, 255, 0.14), rgba(246, 211, 109, 0.07));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  transform: translateY(-2px);
}

button:disabled {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(109, 182, 255, 0.55);
  outline-offset: 2px;
}

button.danger {
  color: var(--danger);
}

.maintenance-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 2fr;
  gap: 18px;
  align-items: center;
  background:
    linear-gradient(120deg, rgba(246, 211, 109, 0.08), transparent 32%),
    rgba(24, 28, 36, 0.92);
}

.message {
  min-height: 24px;
  color: var(--muted);
}

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

.message.ok {
  color: var(--ok);
}

.graph-range {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid rgba(48, 56, 70, 0.88);
  border-radius: 8px;
  background: rgba(15, 18, 24, 0.74);
}

.graph-range-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.graph-range-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.graph-range-slider {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.graph-range-slider input[type="range"] {
  width: 100%;
  min-height: 34px;
  padding: 0;
  accent-color: var(--accent);
}

.graph-range-actions {
  display: flex;
  justify-content: flex-end;
}

#charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
  gap: 18px;
  margin-top: 18px;
}

.telemetry-summary {
  display: grid;
  flex: 1 1 100%;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.summary-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid rgba(48, 56, 70, 0.88);
  border-radius: 8px;
  background: rgba(15, 18, 24, 0.74);
}

.summary-item a {
  color: var(--accent);
  overflow-wrap: anywhere;
}

.summary-label {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-item strong {
  display: block;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
}

.chart-block {
  position: relative;
  height: 380px;
  min-width: 0;
  margin: 0;
  padding: 16px 16px 18px;
}

.chart-block h2 {
  max-width: calc(100% - 190px);
  margin-bottom: 4px;
  font-size: 18px;
  line-height: 1.2;
}

.chart-meta {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 7px;
  width: min(178px, 42%);
  max-height: 124px;
  overflow: auto;
}

.chart-unit {
  justify-self: end;
  max-width: 100%;
  padding: 3px 8px;
  border: 1px solid rgba(109, 182, 255, 0.28);
  border-radius: 6px;
  background: rgba(15, 18, 24, 0.84);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-block canvas {
  width: 100%;
  height: 310px;
  margin-top: 12px;
}

.gps-map-block {
  height: 360px;
  margin-top: 18px;
}

.gps-map-block canvas {
  display: block;
  width: 100%;
  height: 292px;
  border: 1px solid rgba(109, 182, 255, 0.18);
  border-radius: 6px;
  background: #07090e;
}

.chart-stats {
  display: grid;
  gap: 4px;
}

.chart-stat-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  align-items: baseline;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid rgba(48, 56, 70, 0.82);
  border-left: 3px solid var(--series-color);
  border-radius: 6px;
  background: rgba(15, 18, 24, 0.86);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.chart-stat-name {
  overflow: hidden;
  color: var(--series-color);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-stat-values {
  display: block;
  overflow-wrap: anywhere;
}

.replay-controls {
  position: relative;
  z-index: 2;
}

.replay-timeline {
  display: grid;
  gap: 8px;
}

.replay-timeline input[type="range"] {
  width: 100%;
  min-height: 34px;
  padding: 0;
  accent-color: var(--accent);
}

.replay-timeline-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.replay-stage {
  position: relative;
  width: 100vw;
  max-width: 100vw;
  min-height: 620px;
  margin: 22px 0 0 calc(50% - 50vw);
  overflow: hidden;
  background:
    linear-gradient(rgba(109, 182, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(109, 182, 255, 0.035) 1px, transparent 1px),
    #07090e;
  background-size: 56px 56px;
}

.replay-viewport {
  width: 100%;
  height: min(74vh, 760px);
  min-height: 620px;
}

.replay-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.replay-hud {
  position: absolute;
  top: 18px;
  left: max(18px, calc((100vw - 1240px) / 2 + 18px));
  width: min(370px, calc(100vw - 36px));
  max-height: calc(100% - 36px);
  padding: 18px;
  overflow: auto;
  border: 1px solid rgba(109, 182, 255, 0.38);
  border-radius: 8px;
  background: rgba(11, 14, 20, 0.86);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.36), inset 0 0 22px rgba(109, 182, 255, 0.08);
  backdrop-filter: blur(12px);
}

.replay-hud-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.replay-hud-header strong {
  color: var(--text);
  font-size: 22px;
  line-height: 1.1;
}

.replay-hud-grid {
  display: grid;
  grid-template-columns: minmax(92px, 0.7fr) minmax(0, 1.3fr);
  gap: 7px 12px;
  align-items: baseline;
}

.replay-hud-grid span {
  color: var(--muted);
  font-size: 12px;
}

.replay-hud-grid strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  text-align: right;
}

.replay-raw-line {
  max-height: 120px;
  margin: 16px 0 0;
  padding: 10px;
  overflow: auto;
  border: 1px solid rgba(48, 56, 70, 0.82);
  border-radius: 6px;
  background: rgba(15, 18, 24, 0.74);
  color: #dbe6f3;
  font-size: 11px;
  white-space: pre-wrap;
}

.log-output {
  width: 100%;
  min-height: 560px;
  max-height: 70vh;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(109, 182, 255, 0.045) 1px, transparent 1px),
    #0d0f14;
  background-size: 100% 28px;
  color: #dbe6f3;
  text-align: left;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.table th {
  color: var(--muted);
  font-weight: 600;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  nav a {
    min-width: 0;
    text-align: center;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .maintenance-panel {
    grid-template-columns: 1fr;
  }

  #charts {
    grid-template-columns: 1fr;
  }

  .chart-block {
    height: 430px;
  }

  .chart-block h2 {
    max-width: 100%;
    padding-right: 0;
  }

  .chart-meta {
    position: static;
    width: 100%;
    max-height: none;
    margin-top: 10px;
  }

  .chart-stats {
    grid-template-columns: repeat(auto-fit, minmax(126px, 1fr));
  }

  .chart-block canvas {
    height: 270px;
  }

  .control-field {
    width: 100%;
  }

  .replay-controls .toolbar {
    align-items: stretch;
  }

  .replay-controls .toolbar button,
  .replay-controls .toolbar .toggle-option {
    flex: 1 1 auto;
    justify-content: center;
  }

  #replayStatus {
    flex: 1 1 100%;
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .replay-timeline-meta {
    display: grid;
    gap: 4px;
  }

  .replay-stage {
    display: flex;
    flex-direction: column-reverse;
    min-height: 0;
    padding: 14px;
  }

  .replay-viewport {
    height: 420px;
    min-height: 420px;
  }

  .replay-hud {
    position: static;
    width: 100%;
    max-height: none;
    margin-bottom: 14px;
  }

  .replay-hud-grid {
    grid-template-columns: 1fr;
  }

  .replay-hud-grid strong {
    text-align: left;
  }
}
