/* AeroSLAM web service. Design tokens, top bar, panels, buttons, badges and telemetry cards are
   taken from sim.aeromosaix.cloud (css/style.css) so the two sites read as one product family.
   Dark is the default; the top-bar toggle sets data-theme="light" on <html>. */
:root {
  color-scheme: dark;
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232734;
  --border: #2e3345;
  --text: #e0e4f0;
  --text-dim: #8890a8;
  --accent: #4a9eff;
  --accent-glow: rgba(74, 158, 255, 0.15);
  --green: #34d399;
  --red: #f87171;
  --orange: #fbbf24;
  --well: #0a0c10;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface2: #edf0f5;
  --border: #d3d9e4;
  --text: #1a1f2e;
  --text-dim: #5d6579;
  --accent: #1f6fe0;
  --accent-glow: rgba(31, 111, 224, 0.12);
  --green: #059669;
  --red: #dc2626;
  --orange: #b45309;
  --well: #f7f8fb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.45;
}
a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ top bar */
header#top-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.logo { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.logo .sub { font-weight: 400; color: var(--text-dim); margin-left: 8px; }
.logo .tag {
  margin-left: 10px; font-size: 11px; font-weight: 500; color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; vertical-align: 2px; white-space: nowrap;
}
.bar-right { display: flex; align-items: center; gap: 10px; }
.uptime { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ buttons + badges (simulator) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface2); color: var(--text);
  cursor: pointer; font: 500 13px inherit; font-family: inherit; text-decoration: none;
  transition: all 0.15s;
}
.btn:hover { background: var(--border); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-start { background: rgba(52, 211, 153, 0.15); border-color: var(--green); color: var(--green); }
.btn-start:hover:not(:disabled) { background: rgba(52, 211, 153, 0.25); }
.btn-primary { background: rgba(74, 158, 255, 0.15); border-color: var(--accent); color: var(--accent); }
.btn-primary:hover { background: rgba(74, 158, 255, 0.25); }
.btn-icon { padding-left: 7px; padding-right: 7px; }
.btn-theme { padding: 5px 8px; color: var(--text-dim); }
.btn-theme:hover { color: var(--text); }
.btn-theme .icon-sun { display: none; }
:root[data-theme="light"] .btn-theme .icon-sun { display: inline; }
:root[data-theme="light"] .btn-theme .icon-moon { display: none; }
.btn:focus-visible, input:focus-visible, #drop:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.status-badge {
  padding: 4px 12px; border-radius: 20px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; white-space: nowrap;
}
.status-badge.offline { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.status-badge.running { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.status-badge.starting { background: rgba(251, 191, 36, 0.15); color: var(--orange); }
.status-badge.idle { background: var(--accent-glow); color: var(--accent); }
.badge { font-size: 12px; color: var(--text-dim); margin-left: auto; }

/* ------------------------------------------------------------------ layout: flat panels on 1px gaps */
main#app {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1px;
  background: var(--border);
  min-height: calc(100vh - 53px);
}
.col-left, .col-main { display: flex; flex-direction: column; gap: 1px; background: var(--border); min-width: 0; }
.col-left > .panel:last-child, .col-main > .panel.grow { flex: 1 1 auto; }
.panel { background: var(--surface); padding: 16px; }
.panel h2 {
  font-size: 14px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 14px;
}
.panel-header-row { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.panel-header-row h2 { margin: 0; }
@media (max-width: 900px) {
  main#app { grid-template-columns: 1fr; }
  .logo .sub { display: block; margin: 2px 0 0; font-size: 14px; }
}

/* ------------------------------------------------------------------ telemetry cards (simulator) */
.telem-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.telem-grid.three { grid-template-columns: repeat(3, 1fr); }
.telem-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; min-width: 0; }
.telem-card.wide, .telem-grid .wide { grid-column: 1 / -1; }
.telem-card label {
  display: block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-dim); margin-bottom: 4px;
}
.telem-card .val { font-size: 18px; font-weight: 600; display: block; }
.telem-card .val.num { font-variant-numeric: tabular-nums; }
.telem-card .val.small { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.telem-card .fn { font-family: var(--mono); }
.note { font-size: 12px; color: var(--text-dim); margin-top: 10px; }
.warn-text { color: var(--orange); margin-top: 0; }

/* ------------------------------------------------------------------ new flight */
#drop {
  display: grid; justify-items: center; gap: 4px; text-align: center;
  padding: 20px 14px; margin-bottom: 10px;
  border: 1.5px dashed var(--border); border-radius: var(--radius);
  background: var(--well); color: var(--text-dim); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
#drop b { color: var(--text); font-size: 14px; font-weight: 600; }
#drop span { font-size: 12px; }
#drop:hover, #drop.over { border-color: var(--accent); background: var(--accent-glow); color: var(--accent); }
.picked { margin-bottom: 10px; }
label.field {
  display: grid; gap: 4px; margin-bottom: 12px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim);
}
input[type=text] {
  font: 13px inherit; font-family: inherit; text-transform: none; letter-spacing: normal;
  color: var(--text); background: var(--well);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px;
}
.msg { font-size: 12px; margin-top: 10px; color: var(--text-dim); }
.msg:empty { display: none; }
.msg.err { color: var(--red); }
pre.well {
  background: var(--well); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; margin: 10px 0 8px; white-space: pre; overflow-x: auto; color: var(--text);
}

/* ------------------------------------------------------------------ processing jobs */
.jobs { display: grid; gap: 10px; }
.job {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; display: grid; gap: 10px;
}
.job.failed { border-color: rgba(248, 113, 113, 0.5); }
.job-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 6px 16px; }
.job-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.job-title b { font-size: 15px; font-weight: 600; }
.timer { font-size: 13px; font-variant-numeric: tabular-nums; }
.timer b { color: var(--accent); font-weight: 600; }
.bar { width: 100%; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width 0.4s; }
.job.uploading .bar > i, .job.queued .bar > i { background: var(--orange); }
.job.failed .bar > i { background: var(--red); }
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.steps li {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; padding: 3px 9px 3px 7px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
}
.steps li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--border); flex: none; }
.steps li.done { color: var(--text); }
.steps li.done::before { background: var(--green); }
.steps li.running { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); font-weight: 600; }
.steps li.running::before { background: var(--accent); animation: pulse 1.2s infinite; }
.steps li.skipped { text-decoration: line-through; opacity: 0.55; }
.steps li.failed { color: var(--red); border-color: var(--red); }
.steps li.failed::before { background: var(--red); }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .steps li.running::before { animation: none; } .bar > i, .btn, #drop { transition: none; } }
.checks { list-style: none; display: grid; gap: 3px; font-size: 12px; }
.checks .warn { color: var(--orange); }
.checks .fail { color: var(--red); }
.error { color: var(--red); font-size: 13px; }

/* ------------------------------------------------------------------ library */
.lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.thumb { display: block; aspect-ratio: 16 / 10; background: var(--well); border-bottom: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover img { opacity: 0.9; }
.card-body { padding: 12px; display: grid; gap: 10px; align-content: start; flex: 1; }
.card-title { font-size: 15px; font-weight: 600; }
.card .telem-card { background: var(--surface); }
.card .telem-card .val { font-size: 15px; }
.card-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
details { font-size: 12px; }
details summary { cursor: pointer; color: var(--text-dim); }
details ul { margin: 6px 0 0 16px; display: grid; gap: 2px; }
.empty { color: var(--text-dim); font-size: 13px; }
footer { color: var(--text-dim); font-size: 12px; padding: 12px 24px 20px; border-top: 1px solid var(--border); background: var(--surface); }
