:root {
  --ink: #11202f;
  --ink-soft: #3f5565;
  --sand: #efe7d4;
  --panel: #faf7ef;
  --panel-2: #f2eddd;
  --line: #d2c7ac;
  --accent: #2f6a52;
  --shadow: 0 18px 40px rgba(17, 32, 47, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; height: 100%; }
body {
  font-family: "Bahnschrift", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
  background: radial-gradient(circle at top left, rgba(159,77,47,0.12), transparent 28%), linear-gradient(135deg, #f8f3e8, #e7dcc4);
  color: var(--ink);
  overflow: hidden;
}
.shell { display: grid; grid-template-columns: 308px 1fr; min-height: 100vh; height: 100vh; column-gap: 20px; overflow: hidden; }
.sidebar { background: linear-gradient(180deg, #152636, #1c3246); color: #f5f0e0; padding: 18px 18px 24px; display: grid; gap: 18px; align-content: start; grid-template-rows: auto 1fr auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 4px 2px; }
.brand-mark { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 20px; background: linear-gradient(135deg, #2f6a52, #9f4d2f); flex: 0 0 auto; }
.brand > div:last-child { min-width: 0; }
.eyebrow { margin: 0 0 3px; text-transform: uppercase; letter-spacing: .16em; font-size: 10px; opacity: .72; }
.brand h1, .hero h2, .section-head h2, .section-head h3 { margin: 0; font-family: "Georgia", "Times New Roman", serif; }
.brand h1 { white-space: nowrap; font-size: 18px; line-height: 1.05; }
.sidebar-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 6px 0;
  font-size: 11px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: rgba(245,240,224,.56);
  align-self: end;
}
.mission-card, .panel, .artifact-card, .command-card { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 20px; padding: 18px; box-shadow: var(--shadow); }
.compact { align-self: start; }
.section-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 14px; }
.section-head span { font-size: 12px; opacity: .72; }
.scenario-list, .job-list { display: grid; gap: 10px; }
.scenario-item, .job-item { border-radius: 16px; padding: 12px 14px; cursor: pointer; border: 1px solid rgba(255,255,255,.12); background: rgba(255,255,255,.04); color: inherit; text-align: left; transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease, background .14s ease; }
.scenario-item.active, .job-item.active { background: linear-gradient(135deg, rgba(255,255,255,.22), rgba(255,255,255,.12)); border-color: rgba(255,255,255,.5); box-shadow: inset 4px 0 0 #d9c489, 0 12px 28px rgba(0,0,0,.18); transform: translateX(2px); }
.scenario-item strong, .job-item strong { display: block; margin-bottom: 4px; }
.scenario-item small, .job-item small { opacity: .75; line-height: 1.4; }
.job-item {
  position: relative;
  padding-right: 52px;
}
.job-delete {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(17,32,47,.18);
  color: #f5f0e0;
}
.job-delete:hover {
  background: rgba(140,31,36,.74);
  border-color: rgba(255,255,255,.28);
}
.workspace { padding: 28px; display: grid; gap: 20px; align-content: start; grid-auto-rows: max-content; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.hero { background: linear-gradient(135deg, rgba(255,255,255,.74), rgba(255,249,238,.94)); border: 1px solid rgba(17,32,47,.08); border-radius: 24px; padding: 20px 24px; display: grid; gap: 12px; align-content: start; position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px); }
.hero-copy { max-width: 900px; color: var(--ink-soft); margin: 8px 0 0; }
.status-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-pill { padding: 8px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); display: inline-flex; gap: 8px; align-items: center; font-size: 12px; line-height: 1.2; min-height: 36px; }
.status-pill-job { background: linear-gradient(135deg, rgba(17,32,47,.9), rgba(47,106,82,.88)); color: #f5f0e0; border-color: rgba(17,32,47,.2); }
.status-pill-job.running { background: linear-gradient(135deg, #345f82, #2b506f); }
.status-pill-job.done { background: linear-gradient(135deg, #2f6a52, #24513f); }
.status-pill-job.failed { background: linear-gradient(135deg, #8c1f24, #6f191d); }
.status-pill-job.queued { background: linear-gradient(135deg, #8a6a21, #705417); }
.ghost-button.is-busy { opacity: .72; pointer-events: none; }
.install-pwa-button {
  min-height: 36px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #d98a42, #b9652e) !important;
  border: 1px solid rgba(126, 69, 34, .34) !important;
  color: #fff7ef !important;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(185,101,46,.22);
}
.install-pwa-button:hover {
  filter: brightness(1.04);
}
.panel-grid { display: grid; grid-template-columns: 430px 1fr; gap: 20px; }
.panel { background: rgba(250,247,239,.82); border: 1px solid rgba(17,32,47,.08); border-radius: 24px; padding: 20px; }
.panel-form { display: grid; gap: 18px; align-content: start; }
.queue-panel { display: grid; gap: 14px; }
.queue-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
}
.queue-log {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.queue-command-card {
  min-width: 0;
  min-height: 100%;
  background: linear-gradient(180deg, rgba(255,255,255,.58), rgba(250,247,239,.88));
  border: 1px solid rgba(17,32,47,.08);
}
.queue-command-card .section-head {
  margin-bottom: 10px;
}
.queue-command-card #commandPreview {
  min-height: 156px;
  max-height: 260px;
  overflow: auto;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(17,32,47,.05);
  border: 1px solid rgba(17,32,47,.08);
}
.queue-actions { display: flex; gap: 10px; }
.job-pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; }
.job-pager-status { font-size: 12px; color: var(--ink-soft); }
.job-pager .ghost-button[disabled] { opacity: .45; cursor: default; }
#scenarioForm { display: grid; gap: 14px; }
.form-section { display: grid; gap: 12px; padding: 16px; background: rgba(255,255,255,.4); border: 1px solid rgba(17,32,47,.08); border-radius: 18px; }
.accordion-section[open] { padding-bottom: 16px; }
.section-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 24px;
  font-weight: 700;
}
.section-summary::-webkit-details-marker { display: none; }
.section-summary::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(17,32,47,.08);
  font-family: "Bahnschrift", "Segoe UI Variable Display", "Trebuchet MS", sans-serif;
  font-size: 16px;
  margin-right: 8px;
}
.accordion-section[open] > .section-summary::before { content: '-'; }
.section-summary-actions { margin-left: auto; display: inline-flex; gap: 10px; align-items: center; font-family: "Bahnschrift", "Segoe UI Variable Display", "Trebuchet MS", sans-serif; font-size: 12px; }
.section-stack { display: grid; gap: 12px; }
.section-head-inline { display: flex; gap: 10px; align-items: center; }
.field { display: grid; gap: 8px; padding: 14px; background: rgba(255,255,255,.55); border-radius: 16px; border: 1px solid rgba(17,32,47,.08); }
.field label { font-weight: 700; display: flex; justify-content: space-between; gap: 10px; }
.field label span { font-weight: 500; color: var(--ink-soft); font-size: 12px; }
.field input, .field textarea, .field select { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: #fffdfa; color: var(--ink); font: inherit; }
.field textarea { min-height: 96px; resize: vertical; }
.color-table { display: grid; gap: 8px; }
.color-row { display: grid; grid-template-columns: 72px 72px repeat(3, 1fr); gap: 8px; align-items: center; padding: 10px 12px; background: rgba(255,255,255,.55); border-radius: 14px; border: 1px solid rgba(17,32,47,.08); }
.color-level { font-weight: 700; text-align: center; }
.color-picker { width: 100%; height: 40px; padding: 0; border: 1px solid var(--line); border-radius: 10px; background: #fffdfa; }
.color-number { width: 100%; }
.checkbox { display: flex; align-items: center; gap: 10px; }
.checkbox input { width: auto; }
.submit-row { display: flex; gap: 12px; margin-top: 6px; }
button { border: 0; cursor: pointer; font: inherit; border-radius: 14px; padding: 12px 16px; transition: transform .06s ease, filter .12s ease, box-shadow .12s ease, background .12s ease; }
.primary-button { background: linear-gradient(135deg, var(--accent), #1e4d3a); color: white; font-weight: 700; }
.ghost-button { background: transparent; border: 1px solid var(--line); color: inherit; }
button[disabled],
input[disabled],
select[disabled],
textarea[disabled] {
  opacity: .58;
  cursor: not-allowed;
}
button:active,
.scenario-item:active,
.job-item:active,
.artifact-link:active,
.visual-card:active,
.maplibregl-ctrl.projection-toggle button:active {
  transform: translateY(1px) scale(.985);
  filter: brightness(.96);
}
#commandPreview { margin: 0; white-space: pre-wrap; font-family: Consolas, "Liberation Mono", monospace; font-size: 12px; line-height: 1.6; word-break: break-word; }
.result-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.result-map-shell { position: relative; min-height: 620px; border-radius: 22px; overflow: hidden; border: 1px solid rgba(17,32,47,.08); background: linear-gradient(180deg, #1b2833, #334a5f); }
.map { position: absolute; inset: 0; }
.image-preview {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #101820;
}
.map-loader {
  position: absolute; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 5; background: rgba(247, 244, 236, 0.96); color: var(--ink);
  border: 1px solid rgba(17,32,47,.14); border-radius: 999px; padding: 10px 14px;
  font-size: 12px; font-weight: 700; box-shadow: var(--shadow);
}
.map-hud {
  position: absolute; left: 16px; right: 16px; bottom: 16px; z-index: 4;
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-end;
}
.map-hud-left, .map-hud-right {
  background: rgba(10, 20, 31, 0.74); color: #f4f1e7; border-radius: 16px;
  padding: 10px 12px; backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.14); box-shadow: 0 14px 26px rgba(0,0,0,.25);
}
.map-hud-right { display: flex; gap: 12px; align-items: center; margin-left: auto; }
.map-metrics { font-size: 12px; line-height: 1.55; white-space: nowrap; }
.map-metrics b { font-weight: 700; }
.opacity-wrap { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.opacity-wrap input { width: 180px; }
.map-empty { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; color: rgba(255,255,255,.85); gap: 10px; padding: 28px; }
.map-empty i { font-size: 34px; }
.legend-box { position: absolute; left: 16px; bottom: 16px; z-index: 3; background: rgba(248,243,232,.94); border-radius: 16px; padding: 8px; border: 1px solid rgba(17,32,47,.14); max-width: 118px; }
.legend-box span { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; margin-bottom: 8px; color: var(--ink-soft); }
.legend-box img { display: block; max-width: 100%; max-height: 430px; border-radius: 8px; background: white; object-fit: contain; }
.result-map-shell .legend-box { bottom: 104px; }
.hidden { display: none !important; }
.artifact-list { display: grid; gap: 8px; }
.artifact-link { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; background: var(--panel); border-radius: 14px; border: 1px solid rgba(17,32,47,.08); color: inherit; text-decoration: none; }
.artifact-link:hover { border-color: var(--accent); }
.visual-results-card { display: grid; gap: 12px; }
.visual-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.visual-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--panel);
  border-radius: 16px;
  border: 1px solid rgba(17,32,47,.08);
  color: inherit;
  text-decoration: none;
}
.visual-card:hover { border-color: var(--accent); }
.visual-card img {
  width: 100%;
  min-height: 220px;
  max-height: 500px;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(17,32,47,.05);
}
.visual-card span {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  word-break: break-word;
}
.result-side { display: grid; gap: 16px; }
.job-notes { color: var(--ink-soft); line-height: 1.7; }
.report-box { margin-top: 12px; padding: 12px 14px; background: rgba(17,32,47,.06); border: 1px solid rgba(17,32,47,.08); border-radius: 14px; color: var(--ink); font-size: 13px; line-height: 1.6; }
.badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; border: 1px solid transparent; box-shadow: inset 0 0 0 1px rgba(255,255,255,.08); }
.badge.queued { background: #eadfbe; color: #705417; }
.badge.running { background: #d7e5ee; color: #224863; }
.badge.done { background: #d6eadf; color: #28523b; }
.badge.failed { background: #f0d6d6; color: #8c1f24; }
.badge.admin { background: #f0d6d6; border-color: rgba(140,31,36,.22); color: var(--ink); }
.badge.user { background: #d6eadf; border-color: rgba(40,82,59,.22); color: var(--ink); }
.maplibregl-ctrl.projection-toggle button {
  width: 29px;
  height: 29px;
  font-size: 14px;
  font-weight: 700;
  color: #152636;
}
.map-marker {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 8px 18px rgba(0,0,0,.28);
  border: 2px solid rgba(255,255,255,.9);
}
.map-marker i {
  line-height: 1;
}
.map-marker-tx, .map-marker-tx2, .map-marker-tx3, .map-marker-tx4 { background: rgba(48, 84, 107, 0.88); }
.map-marker-rx { background: rgba(94, 123, 62, 0.9); }
.map-marker-obstacle {
  width: 24px;
  height: 24px;
  background: rgba(117, 61, 41, 0.92);
  font-size: 11px;
}
.map-marker-obstacle i {
  font-size: 11px;
}
@media (max-width: 1320px) { .shell, .panel-grid, .result-layout, .queue-layout { grid-template-columns: 1fr; } }
@media (max-width: 820px) {
  .map-hud { flex-direction: column; align-items: stretch; }
  .map-hud-right { flex-direction: column; align-items: stretch; margin-left: 0; }
  .opacity-wrap { flex-wrap: wrap; }
  .opacity-wrap input { width: 100%; }
  .result-map-shell .legend-box { bottom: 176px; max-width: 108px; }
}
.auth-body {
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(201, 162, 86, 0.18), transparent 40%), #152636;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.login-card {
  width: min(460px, 100%);
  padding: 32px;
  border-radius: 28px;
  background: linear-gradient(180deg, rgba(248, 243, 235, 0.98), rgba(244, 237, 224, 0.96));
  border: 1px solid rgba(20, 36, 52, 0.1);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.24), inset 0 1px 0 rgba(255,255,255,.5);
}

.login-card h1 {
  margin: 0 0 10px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(20, 36, 52, 0.08);
}

.login-brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  font-size: 24px;
  color: #f6efe1;
  background: linear-gradient(135deg, #2f6a52, #9f4d2f);
  box-shadow: 0 12px 28px rgba(47, 106, 82, 0.18);
}

.login-brand-copy {
  display: grid;
  gap: 4px;
}

.login-brand-copy strong {
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 22px;
  line-height: 1.1;
  color: #122434;
}

.lead {
  margin: 0 0 22px;
  color: #425467;
  line-height: 1.5;
}

.stack {
  display: grid;
  gap: 16px;
}

.auth-field {
  display: grid;
  gap: 8px;
  color: #142434;
  font-weight: 600;
}

.auth-field input,
.auth-field select {
  width: 100%;
  min-height: 52px;
  padding: 13px 15px;
  border-radius: 16px;
  border: 1px solid rgba(20, 36, 52, 0.14);
  background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(248, 244, 235, .96));
  box-shadow: inset 0 1px 2px rgba(17,32,47,.05);
  color: #122434;
  font-size: 15px;
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

.auth-field input::placeholder {
  color: #6b7a88;
}

.auth-field input:focus,
.auth-field select:focus {
  outline: none;
  border-color: rgba(47, 106, 82, 0.58);
  box-shadow: 0 0 0 4px rgba(47, 106, 82, 0.12), inset 0 1px 2px rgba(17,32,47,.05);
  background: #fffdfa;
}

.auth-submit {
  justify-content: center;
  min-height: 52px;
  font-size: 15px;
}

.auth-message {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(193, 68, 67, 0.12);
  color: #8a1f1f;
  font-weight: 600;
}

.auth-message.error {
  border: 1px solid rgba(193, 68, 67, 0.22);
}

.auth-footer {
  margin-top: 22px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #5a6876;
  font-size: 12px;
}

.top-nav-button {
  text-decoration: none;
}

.user-pill {
  max-width: 360px;
}

.status-pill-button {
  border: 1px solid rgba(198, 173, 128, 0.56);
  background: rgba(243, 236, 224, 0.96);
  color: #162738;
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.status-pill-button:hover {
  background: #f8f2e7;
  border-color: rgba(198, 173, 128, 0.82);
  box-shadow: 0 10px 22px rgba(36, 45, 62, 0.08);
}

.status-pill-button:active {
  transform: translateY(1px) scale(0.99);
}

.status-pill-button.hidden {
  display: none;
}

.sidebar-utility-nav {
  margin-top: auto;
  display: grid;
  gap: 12px;
}

.sidebar-nav-item {
  text-decoration: none;
  width: 100%;
  text-align: left;
}

.sidebar-nav-item strong {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-nav-item small {
  display: block;
}

.sidebar-nav-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  cursor: pointer;
}

.users-shell .sidebar {
  justify-content: space-between;
}

.users-workspace {
  gap: 22px;
}

.users-panel {
  display: grid;
  gap: 18px;
}

.users-side-card {
  display: grid;
  gap: 18px;
}

.users-side-copy {
  margin: 0;
  color: rgba(236, 240, 244, 0.86);
  line-height: 1.55;
}

.users-side-actions {
  display: grid;
  gap: 10px;
}

.users-warning {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(193, 68, 67, 0.12);
  color: #8a1f1f;
  font-weight: 600;
}

.users-table-wrap {
  overflow: auto;
  border-radius: 20px;
  border: 1px solid rgba(20, 36, 52, 0.08);
}

.users-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.92);
}

.users-table th,
.users-table td {
  padding: 16px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(20, 36, 52, 0.08);
  vertical-align: top;
}

.users-table th {
  color: #5d6b79;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.users-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.users-action-button {
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 21, 31, 0.58);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: 24px;
  border-radius: 24px;
  background: rgba(248, 243, 235, 0.98);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.28);
}

.modal-form {
  display: grid;
  gap: 16px;
}

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

@media (max-width: 1040px) {
  body {
    overflow: auto;
  }

  .shell {
    height: auto;
    overflow: visible;
  }

  .sidebar,
  .workspace {
    min-height: auto;
    overflow: visible;
  }

  .hero {
    position: static;
  }

  .user-pill {
    max-width: none;
  }

  .users-actions {
    min-width: 220px;
  }
}
