:root {
  color-scheme: dark;
  --bg: #070a12;
  --panel-bg: rgba(10, 14, 26, 0.8);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.82);
  --accent: #7c5cff;
  --accent-2: #18c6ff;
  --good: #2ed573;
  --danger: #ff3b7a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  --radius: 16px;
  --panel-width: 420px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: radial-gradient(1200px 800px at 70% 20%, rgba(124, 92, 255, 0.18), transparent 55%),
    radial-gradient(900px 600px at 25% 75%, rgba(24, 198, 255, 0.14), transparent 50%),
    var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  color: var(--text);
}

[hidden] {
  display: none !important;
}

#map {
  position: fixed;
  inset: 0;
}

.context-menu {
  position: fixed;
  z-index: 30;
  min-width: 240px;
  max-width: min(320px, calc(100vw - 20px));
  padding: 10px;
  border-radius: 16px;
  background: rgba(10, 14, 26, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.context-menu-title {
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.25px;
  color: rgba(255, 255, 255, 0.92);
}

.context-menu-meta {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.35;
}

.context-menu-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.context-menu-actions button {
  flex: 1 1 calc(50% - 5px);
  min-width: 130px;
}

.overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.panel {
  pointer-events: auto;
  position: fixed;
  top: 18px;
  left: 18px;
  bottom: 18px;
  width: min(var(--panel-width), calc(100vw - 36px));
  padding: 16px;
  border-radius: var(--radius);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: transform 180ms ease, opacity 180ms ease;
}

.panel.collapsed {
  transform: translateX(calc(-100% - 24px));
  opacity: 0;
  pointer-events: none;
}

.panel-toggle {
  pointer-events: auto;
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  border-radius: 0 14px 14px 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 14, 26, 0.78);
  color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.panel-toggle.hidden {
  opacity: 0;
  pointer-events: none;
}

.panel-toggle:hover {
  transform: translateY(-50%);
  background: rgba(10, 14, 26, 0.86);
  border-color: rgba(255, 255, 255, 0.22);
}

.panel-toggle:active {
  transform: translateY(-50%);
}

.panel-header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
}

.panel-header button {
  flex: 0 0 auto;
}

.panel-header-actions {
  display: flex;
  gap: 10px;
  flex: 1 1 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-width: 0;
}

.panel-header-actions form {
  margin: 0;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  flex: 1 1 240px;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124, 92, 255, 1) 0%, rgba(24, 198, 255, 1) 100%);
  box-shadow: 0 12px 35px rgba(124, 92, 255, 0.22);
  flex: 0 0 auto;
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.panel-section {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}

.module-tabs {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
}

.module-tab {
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  padding: 10px 8px;
  text-align: center;
}

.module-tab.active {
  border-color: rgba(124, 92, 255, 0.6);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.35), rgba(24, 198, 255, 0.2));
}

.module-pane {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding-right: 4px;
}

.module-pane > .panel-section:last-of-type {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0px);
}

button.primary {
  border-color: rgba(124, 92, 255, 0.55);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.7), rgba(24, 198, 255, 0.45));
}

button.primary:hover {
  border-color: rgba(124, 92, 255, 0.75);
}

button.danger {
  border-color: rgba(255, 59, 122, 0.45);
  background: rgba(255, 59, 122, 0.14);
}

button.danger:hover {
  border-color: rgba(255, 59, 122, 0.65);
  background: rgba(255, 59, 122, 0.2);
}

.ghost {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
}

.ghost:hover {
  background: rgba(255, 255, 255, 0.08);
}

.icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.field span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
}

.field-hint {
  margin: 0;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.62);
}

input,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  outline: none;
}

select {
  color-scheme: dark;
}

select option {
  background: rgba(10, 14, 26, 0.98);
  color: var(--text);
}

select[multiple] {
  min-height: 124px;
  padding: 8px;
}

input:focus,
select:focus {
  border-color: rgba(124, 92, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.18);
}

.suggestions {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
  padding-right: 6px;
}

.suggestions:empty {
  display: none;
}

.suggestion {
  text-align: left;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.suggestion:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.suggestion .title {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}

.suggestion .subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.25;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.86);
}

.module-note {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.78);
}

.distribution-grid {
  margin-top: 10px;
}

.distribution-depots-field {
  gap: 8px;
}

.distribution-depot-summary {
  margin-top: 4px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.84);
}

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

.distribution-depot-actions .ghost {
  min-height: 30px;
  font-size: 12px;
}

.distribution-depot-source-list {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.distribution-depot-source-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px 9px;
  display: grid;
  gap: 4px;
}

.distribution-depot-source-item.is-selected {
  border-color: rgba(24, 198, 255, 0.42);
  background: rgba(24, 198, 255, 0.08);
}

.distribution-depot-source-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.distribution-depot-source-name {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.93);
}

.distribution-depot-source-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.82);
}

.distribution-depot-source-item.is-selected .distribution-depot-source-badge {
  border-color: rgba(24, 198, 255, 0.5);
  color: rgba(24, 198, 255, 0.95);
}

.distribution-depot-source-meta {
  font-size: 11px;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.76);
}

.distribution-depot-supply-block {
  margin-top: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  padding: 8px;
  display: grid;
  gap: 8px;
}

.distribution-depot-supply-title {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.distribution-depot-supply-list {
  display: grid;
  gap: 8px;
}

.distribution-depot-supply-total {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.78);
}

.distribution-depot-supply-items {
  display: grid;
  gap: 8px;
}

.distribution-depot-supply-item {
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  padding: 8px;
  display: grid;
  gap: 4px;
}

.distribution-depot-supply-item-name {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
}

.distribution-depot-supply-item-id {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.68);
}

.distribution-depot-supply-item input {
  width: 100%;
}

.distribution-result {
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.distribution-summary {
  font-size: 12px;
  line-height: 1.45;
}

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

.distribution-route-item {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.distribution-route-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.distribution-route-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.distribution-route-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--route-color, #3ba5ff);
  box-shadow: 0 0 0 4px rgba(59, 165, 255, 0.25);
}

.distribution-route-metrics {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

.distribution-load-text {
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.86);
}

.distribution-load-bar {
  margin-top: 6px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.distribution-load-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, rgba(6, 214, 160, 0.95), rgba(53, 167, 255, 0.95));
}

.distribution-load-bar.over span {
  background: linear-gradient(90deg, rgba(255, 89, 94, 0.96), rgba(251, 86, 7, 0.96));
}

.distribution-route-points {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.4;
}

.distribution-route-points code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: rgba(255, 255, 255, 0.9);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   Distribution results dock (resizable bottom panel)
   ============================================================ */

.dist-dock {
  pointer-events: auto;
  position: fixed;
  left: calc(var(--panel-width) + 36px);
  right: 18px;
  bottom: 18px;
  z-index: 22;
  height: var(--dock-h, 340px);
  min-height: 120px;
  max-height: calc(100vh - 36px);
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  overflow: hidden;
  animation: dock-rise 200ms ease;
}

@keyframes dock-rise {
  from {
    transform: translateY(16px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.dist-dock.collapsed {
  height: auto !important;
  min-height: 0;
}

.dist-dock.collapsed .dist-dock-body,
.dist-dock.collapsed .dist-dock-resize {
  display: none;
}

.dist-dock-resize {
  flex: 0 0 auto;
  height: 12px;
  cursor: ns-resize;
  display: grid;
  place-items: center;
  touch-action: none;
}

.dist-dock-resize::before {
  content: "";
  width: 46px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  transition: background 140ms ease, width 140ms ease;
}

.dist-dock-resize:hover::before,
.dist-dock-resize:focus-visible::before {
  background: var(--accent-2);
  width: 64px;
  outline: none;
}

.dist-dock-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 4px 14px 12px;
  flex-wrap: wrap;
}

.dist-dock-titlewrap {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  min-width: 0;
}

.dist-dock-title {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.dist-dock-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.dist-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  font-size: 12px;
  white-space: nowrap;
}

.dist-stat .dist-stat-label {
  color: var(--muted);
  opacity: 0.8;
}

.dist-stat .dist-stat-value {
  font-weight: 800;
  color: var(--text);
}

.dist-stat.good .dist-stat-value {
  color: var(--good);
}

.dist-stat.warn .dist-stat-value {
  color: #ffb703;
}

.dist-dock-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.dist-dock-views {
  display: inline-flex;
  padding: 3px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.dist-dock-view {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.dist-dock-view.active {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.9), rgba(24, 198, 255, 0.7));
  color: #fff;
}

.dist-dock-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 0 14px 14px;
}

/* --- Vehicle cards view --- */

.veh-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.veh-card {
  --veh-color: #35a7ff;
  position: relative;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  padding: 12px 14px 14px;
  overflow: hidden;
  transition: border-color 140ms ease, transform 140ms ease, box-shadow 140ms ease,
    background 140ms ease;
}

.veh-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--veh-color);
}

.veh-card.is-hovered {
  border-color: var(--veh-color);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-2px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px var(--veh-color) inset;
}

.veh-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.veh-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  font-weight: 800;
}

.veh-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--veh-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--veh-color) 28%, transparent);
  flex: 0 0 auto;
}

.veh-depot {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.veh-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.veh-metric {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.veh-metric b {
  color: var(--text);
}

.veh-metric .veh-metric-label {
  color: var(--muted);
  opacity: 0.78;
}

.veh-load {
  margin-top: 10px;
}

.veh-load-bar {
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.veh-load-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, rgba(6, 214, 160, 0.95), rgba(53, 167, 255, 0.95));
}

.veh-load-bar.over span {
  background: linear-gradient(90deg, rgba(255, 89, 94, 0.96), rgba(251, 86, 7, 0.96));
}

.veh-load-text {
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

/* --- Ordered stop chips (the sequence the vehicle drives) --- */

.veh-stops {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 12px;
}

.veh-trip-row {
  width: 100%;
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.veh-trip-row:last-child {
  margin-bottom: 0;
}

.veh-trip-head {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.veh-trip-stops {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.stop-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 220px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  font-size: 12px;
  line-height: 1.2;
}

.stop-chip .stop-idx {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--veh-color);
  color: #06121f;
  font-weight: 900;
  font-size: 11px;
  flex: 0 0 auto;
}

.stop-chip .stop-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.stop-chip.depot {
  border-color: rgba(255, 174, 66, 0.55);
  background: rgba(255, 156, 61, 0.12);
}

.stop-chip.depot .stop-idx {
  background: linear-gradient(135deg, #ffae42, #ff724c);
  color: #2a1400;
}

.veh-stops .stop-sep {
  color: var(--muted);
  opacity: 0.5;
  font-size: 12px;
}

/* --- Table view --- */

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

.dist-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.dist-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  font-weight: 700;
  color: var(--muted);
  background: rgba(12, 16, 28, 0.96);
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  white-space: nowrap;
}

.dist-table tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
}

.dist-table tbody tr {
  transition: background 120ms ease;
}

.dist-table tbody tr.is-hovered {
  background: rgba(255, 255, 255, 0.06);
}

.dist-table .dist-td-veh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}

.dist-table .dist-td-veh .veh-dot {
  width: 11px;
  height: 11px;
}

.dist-table .dist-td-seq {
  color: var(--muted);
  min-width: 320px;
}

.veh-stops.compact {
  margin-top: 0;
  gap: 5px;
}

.veh-stops.compact .veh-trip-row {
  gap: 4px;
  margin-bottom: 6px;
}

.veh-stops.compact .veh-trip-head {
  font-size: 10.5px;
}

.veh-stops.compact .stop-chip {
  max-width: 168px;
  padding: 2px 8px 2px 3px;
  font-size: 11px;
}

.veh-stops.compact .stop-chip .stop-idx {
  width: 16px;
  height: 16px;
  font-size: 10px;
}

.veh-stops.compact .stop-sep {
  font-size: 11px;
}

.dist-table-pct {
  font-weight: 800;
}

.dist-table-pct.over {
  color: var(--danger);
}

.distribution-progress-actions {
  margin-top: 8px;
}

#distribution-progress-modal.dist-progress-floating {
  position: fixed;
  top: 86px;
  right: 18px;
  left: auto;
  bottom: auto;
  width: min(430px, calc(100vw - 28px));
  max-height: min(74vh, 640px);
  margin: 0;
  z-index: 26;
}

#distribution-progress-modal.dist-progress-floating::backdrop {
  background: transparent;
  backdrop-filter: none;
}

#distribution-progress-modal.dist-progress-floating .dist-progress-modal-card {
  width: 100%;
  max-height: inherit;
  border-radius: 14px;
}

.dist-progress-drag-handle {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

#distribution-progress-modal.is-dragging .dist-progress-drag-handle {
  cursor: grabbing;
}

.dist-progress-modal-hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.78);
}

.dist-progress-modal-body {
  margin-top: 8px;
  max-height: min(52vh, 420px);
  min-height: 160px;
  overflow: auto;
  padding-right: 2px;
}

.dist-progress-modal-body .dist-progress {
  max-width: none;
  margin: 0;
  padding: 4px 2px;
}

/* --- Live solver progress --- */

.dist-progress {
  max-width: 560px;
  margin: 4px auto 0;
  padding: 14px 4px;
}

.dist-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.dist-progress-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 13px;
}

.dist-progress-time {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.dist-spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent-2);
  animation: dist-spin 0.8s linear infinite;
}

.dist-spinner.is-paused {
  animation-play-state: paused;
  opacity: 0.72;
  border-top-color: rgba(255, 255, 255, 0.42);
}

@keyframes dist-spin {
  to {
    transform: rotate(360deg);
  }
}

.dist-progress-bar {
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.dist-progress-bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(124, 92, 255, 0.95), rgba(24, 198, 255, 0.95));
  transition: width 250ms ease;
}

.dist-progress-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.dist-progress-metric {
  flex: 1 1 160px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.dist-progress-metric-label {
  font-size: 11px;
  color: var(--muted);
  opacity: 0.8;
}

.dist-progress-metric b {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.dist-spark {
  display: block;
  width: 100%;
  height: 56px;
  margin-top: 14px;
  color: var(--accent-2);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  padding: 6px;
}

/* --- Reopen toggle button (when dock closed) --- */

.dist-dock-toggle {
  pointer-events: auto;
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  z-index: 22;
  border-radius: 14px 14px 0 0;
  padding: 9px 18px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-bottom: none;
  background: rgba(10, 14, 26, 0.86);
  color: var(--text);
  font-weight: 700;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(10px);
}

@media (max-width: 720px) {
  #distribution-progress-modal.dist-progress-floating {
    top: 72px;
    right: 10px;
    width: min(360px, calc(100vw - 20px));
    max-height: min(68vh, 560px);
  }

  .dist-progress-modal-body {
    max-height: min(44vh, 320px);
  }

  .dist-dock {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }
  .veh-grid {
    grid-template-columns: 1fr;
  }
}

.toggle {
  margin: 10px 0 0;
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.84);
}

.toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.points {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  padding-right: 6px;
  flex: 1 1 auto;
  min-height: 0;
}

.point {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.035);
  padding: 10px 10px 10px 12px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.point.is-current {
  border-color: rgba(24, 198, 255, 0.45);
  background: rgba(24, 198, 255, 0.06);
  transform: translateX(2px);
}

.point.is-next {
  border-color: rgba(124, 92, 255, 0.5);
  background: rgba(124, 92, 255, 0.06);
  transform: translateX(2px);
}

.point-main {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
}

.badge {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  background: rgba(124, 92, 255, 0.22);
  border: 1px solid rgba(124, 92, 255, 0.35);
}

.badge.start {
  background: rgba(24, 198, 255, 0.18);
  border-color: rgba(24, 198, 255, 0.4);
}

.point-name {
  font-weight: 800;
  font-size: 13px;
  line-height: 1.2;
}

.point-address {
  margin-top: 3px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.25;
}

.start-radio {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.84);
}

.start-radio input {
  margin: 0;
  accent-color: var(--accent-2);
}

.point-actions {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

.point-actions button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
}

.point-actions button.active {
  border-color: rgba(255, 185, 82, 0.65);
  background: rgba(255, 166, 0, 0.2);
  color: rgba(255, 223, 158, 0.95);
}

.point-actions button.danger {
  border-color: rgba(255, 59, 122, 0.4);
  background: rgba(255, 59, 122, 0.12);
}

.panel-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.summary {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.035);
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  line-height: 1.35;
}

.status {
  pointer-events: auto;
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: min(560px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(10, 14, 26, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(10px);
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.35);
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  line-height: 1.35;
}

.status.error {
  border-color: rgba(255, 59, 122, 0.45);
  background: rgba(40, 10, 22, 0.62);
}

.modal {
  pointer-events: auto;
  border: none;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(560px, calc(100vw - 40px));
  border-radius: 18px;
  background: rgba(10, 14, 26, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  padding: 14px;
}

.ui-dialog-body {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.ui-dialog-message {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.86);
  white-space: pre-wrap;
}

.ui-dialog-error {
  font-size: 12px;
  color: rgba(255, 59, 122, 0.9);
}

.compare-meta {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.35;
}

.compare-grid {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.compare-item {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.035);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.compare-item-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.compare-item-title {
  font-size: 13px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.92);
}

.compare-item-sub {
  margin-top: 2px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  line-height: 1.25;
}

.compare-chips {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.86);
  white-space: nowrap;
}

.chip.good {
  border-color: rgba(24, 198, 255, 0.35);
  background: rgba(24, 198, 255, 0.08);
}

.chip.bad {
  border-color: rgba(255, 59, 122, 0.35);
  background: rgba(255, 59, 122, 0.09);
}

.chip.neutral {
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
}

.compare-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.metric {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
}

.metric-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

.metric-value {
  margin-top: 2px;
  font-size: 14px;
  font-weight: 850;
  color: rgba(255, 255, 255, 0.92);
}

.compare-route {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
}

.compare-route code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
}

.compare-item-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-card.wide {
  width: min(920px, calc(100vw - 40px));
}

.modal-card.wide.import-card {
  width: min(1300px, calc(100vw - 40px));
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.modal-header h3 {
  margin: 0;
  font-size: 15px;
}

.grid {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.import-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.import-controls {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.import-inline {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
}

.import-toggle {
  margin: 0;
}

.import-hint {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.import-hint-title {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
}

.import-hint-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
}

.import-hint-text {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
}

.import-mapping {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  padding: 12px;
}

.import-mapping-title {
  font-size: 12px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
}

.import-mapping-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.import-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.import-actions button {
  flex: 0 0 auto;
}

.import-stats {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.35;
}

.import-progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.import-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

.import-preview {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.02);
  padding: 12px;
  min-height: 360px;
  overflow: auto;
  min-width: 0;
}

.import-empty {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.35;
}

.import-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.import-table th,
.import-table td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  text-align: left;
  vertical-align: top;
}

.import-table th:nth-child(1),
.import-table td:nth-child(1) {
  width: 44px;
  text-align: center;
}

.import-table th:nth-child(2),
.import-table td:nth-child(2) {
  min-width: 140px;
}

.import-table th:nth-child(3),
.import-table td:nth-child(3) {
  min-width: 240px;
  max-width: 560px;
  white-space: normal;
  overflow-wrap: break-word;
  word-break: break-word;
}

.import-table th:nth-child(4),
.import-table td:nth-child(4),
.import-table th:nth-child(5),
.import-table td:nth-child(5) {
  min-width: 80px;
  white-space: nowrap;
  text-align: right;
}

.import-table th:nth-child(6),
.import-table td:nth-child(6) {
  min-width: 120px;
}

.import-table th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

.import-status {
  font-weight: 800;
  white-space: nowrap;
}

.import-status.ok {
  color: rgba(24, 198, 255, 0.95);
}

.import-status.pending {
  color: var(--accent);
}

.import-status.err {
  color: rgba(255, 59, 122, 0.95);
}

.import-status.skip {
  color: rgba(255, 255, 255, 0.7);
}

.import-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

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

.matrix table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

.matrix th,
.matrix td {
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 10px;
  text-align: right;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
}

.matrix th:first-child,
.matrix td:first-child {
  text-align: left;
  white-space: normal;
  position: sticky;
  left: 0;
  background: rgba(10, 14, 26, 0.92);
  box-shadow: 10px 0 18px rgba(0, 0, 0, 0.22);
}

.matrix td:first-child {
  z-index: 1;
}

.matrix th:first-child {
  z-index: 2;
}

.matrix th {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 800;
}

.matrix .meta {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.35;
}

.point-marker {
  width: 34px;
  height: 34px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.95);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.95), rgba(24, 198, 255, 0.65));
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.22);
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.point-marker.start {
  background: linear-gradient(135deg, rgba(24, 198, 255, 0.95), rgba(124, 92, 255, 0.65));
  box-shadow: 0 14px 35px rgba(24, 198, 255, 0.18);
}

.point-marker.depot {
  background: linear-gradient(135deg, rgba(255, 174, 66, 0.95), rgba(255, 114, 76, 0.75));
  border-color: rgba(255, 194, 102, 0.72);
  box-shadow: 0 0 0 8px rgba(255, 156, 61, 0.16), 0 14px 35px rgba(0, 0, 0, 0.35);
}

.point-marker-root {
  /* MapLibre owns this element: it adds .maplibregl-marker (position:absolute,
     top:0, left:0) and drives the position with `transform`. Never override
     `position` here — `position: relative` detaches the marker from its
     coordinate and lays markers out in normal flow ("markers in the wrong
     place"). The absolute positioning also serves as the containing block for
     the depot badge below. */
  width: 34px;
  height: 34px;
  transition: none !important;
}

.point-marker-depot-badge {
  position: absolute;
  right: -8px;
  top: -8px;
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 14, 26, 0.9);
  color: rgba(255, 255, 255, 0.92);
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  padding: 0 5px;
  letter-spacing: 0.2px;
}

.point-marker.current {
  transform: scale(1.12);
  border-color: rgba(24, 198, 255, 0.65);
  box-shadow: 0 0 0 8px rgba(24, 198, 255, 0.16), 0 14px 35px rgba(0, 0, 0, 0.35);
}

.point-marker.next {
  transform: scale(1.12);
  border-color: rgba(124, 92, 255, 0.7);
  box-shadow: 0 0 0 8px rgba(124, 92, 255, 0.16), 0 14px 35px rgba(0, 0, 0, 0.35);
}

/* Light "dot" markers — used in the distribution module so points stay subtle
   and do not cover the computed routes. */
.point-marker-root.light {
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  pointer-events: none; /* clients let route hover pass through */
}

.point-marker-root.light.depot {
  width: 22px;
  height: 22px;
  pointer-events: auto; /* depots stay right-clickable */
}

.point-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1.5px solid rgba(10, 14, 26, 0.7);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
}

.point-dot.start {
  background: var(--accent-2);
  border-color: rgba(255, 255, 255, 0.85);
}

.point-dot.depot {
  width: 16px;
  height: 16px;
  background: radial-gradient(circle at 50% 40%, #ffd08a, #ff9c3d 70%);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 0 4px rgba(255, 156, 61, 0.22), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.point-dot.current,
.point-dot.next {
  box-shadow: 0 0 0 5px rgba(24, 198, 255, 0.28), 0 2px 8px rgba(0, 0, 0, 0.5);
}

.maplibregl-map {
  filter: saturate(1.05) contrast(1.03);
}

/* MapLibre positions markers via transform on the element it owns
   (.point-marker-root / .route-arrow). Never animate that transform,
   otherwise markers visibly lag ("float") while panning/zooming. */
.maplibregl-marker {
  will-change: transform;
  transition: none !important;
}

.compute {
  pointer-events: auto;
  position: fixed;
  top: 18px;
  right: 18px;
  bottom: 18px;
  width: min(740px, calc(100vw - 36px));
  border-radius: var(--radius);
  background: rgba(10, 14, 26, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 24px));
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.compute-toggle {
  pointer-events: auto;
  position: fixed;
  top: 50%;
  right: 0;
  transform: translateY(-50%);
  border-radius: 14px 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 14, 26, 0.78);
  color: rgba(255, 255, 255, 0.92);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.compute-toggle.hidden {
  opacity: 0;
  pointer-events: none;
}

.compute-toggle:hover {
  transform: translateY(-50%);
  background: rgba(10, 14, 26, 0.86);
  border-color: rgba(255, 255, 255, 0.22);
}

.compute-toggle:active {
  transform: translateY(-50%);
}

.compute.open {
  transform: translateX(0);
  opacity: 1;
}

.compute-header {
  padding: 14px 14px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}

.compute-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.compute-header-actions select {
  width: auto;
  min-width: 72px;
}

.compute-header-actions .primary {
  padding: 10px 12px;
}

.compute-header h3 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.2px;
  flex: 1 1 auto;
  min-width: 140px;
}

.compute-body {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.compute-tabs {
  padding: 12px 14px 0;
  display: flex;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.compute-tab {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
}

.compute-tab.active {
  border-color: rgba(124, 92, 255, 0.6);
  background: rgba(124, 92, 255, 0.18);
}

.compute-views {
  padding: 14px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: auto;
  min-width: 0;
}

.compute-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

.compute-view[hidden] {
  display: none !important;
}

.compute-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.compute-future h4 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.86);
}

.matrix {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  min-width: 0;
  position: relative;
}

.compute-tasks h4 {
  margin: 0 0 8px;
  font-size: 13px;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.86);
}

.task-save {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: end;
}

.task-save .primary {
  width: auto;
  padding: 10px 14px;
  height: 42px;
}

.task-save .ghost {
  width: auto;
  height: 42px;
}

.tasks {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.task-item {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
  display: grid;
  gap: 10px;
}

.task-item.is-current {
  border-color: rgba(124, 92, 255, 0.5);
  background: rgba(124, 92, 255, 0.06);
}

.task-item-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}

.task-item-name {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 650;
}

.task-item-meta {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

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

.task-actions button {
  padding: 8px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.task-actions .danger {
  border-color: rgba(255, 65, 92, 0.35);
  background: rgba(255, 65, 92, 0.08);
  color: rgba(255, 255, 255, 0.92);
}

.task-actions .danger:hover {
  border-color: rgba(255, 65, 92, 0.55);
  background: rgba(255, 65, 92, 0.12);
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  counter-reset: step;
}

.steps > li {
  display: grid;
  grid-template-columns: 6ch 1fr;
  gap: 10px;
  align-items: start;
}

.steps > li:not(.meta)::before {
  counter-increment: step;
  content: counter(step) ".";
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: rgba(255, 255, 255, 0.72);
  padding-top: 1px;
}

.steps > li > .step-content {
  min-width: 0;
}

.steps > li.meta {
  grid-template-columns: 1fr;
}

.steps > li.meta::before {
  display: none;
}

.steps .meta {
  color: rgba(255, 255, 255, 0.85);
}

.steps code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
}

.little-tree-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.little-tree-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.little-tree-nav button {
  padding: 8px 10px;
  min-width: 44px;
}

.little-tree-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.little-tree-wrap:fullscreen {
  background: radial-gradient(1200px 800px at 70% 20%, rgba(124, 92, 255, 0.18), transparent 55%),
    radial-gradient(900px 600px at 25% 75%, rgba(24, 198, 255, 0.14), transparent 50%),
    var(--bg);
  padding: 16px;
  overflow: hidden;
}

.little-tree-wrap:fullscreen .little-tree-canvas {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.little-tree-wrap:fullscreen .little-tree-details {
  max-height: min(30vh, 260px);
  overflow: auto;
}

.little-tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.little-tree-head h4 {
  margin: 0;
}

.little-tree-controls button {
  width: auto;
  padding: 8px 12px;
}

.little-tree-canvas {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
  min-height: 420px;
  height: 520px;
}

.little-tree-svg {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

.little-tree-svg.is-dragging {
  cursor: grabbing;
}

.lt-edge {
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1;
}

.lt-edge.best {
  stroke: var(--good);
  stroke-opacity: 0.9;
  stroke-width: 2.4;
}

.lt-edge.dead {
  stroke: rgba(255, 59, 122, 0.45);
  stroke-opacity: 0.65;
  stroke-width: 1.4;
  stroke-dasharray: 4 4;
}

.lt-node circle {
  fill: rgba(255, 255, 255, 0.16);
  stroke: rgba(255, 255, 255, 0.28);
  stroke-width: 1.2;
}

.lt-node.root circle {
  fill: rgba(255, 255, 255, 0.2);
  stroke: rgba(255, 255, 255, 0.55);
}

.lt-node.open circle,
.lt-node.expanded circle {
  fill: rgba(124, 92, 255, 0.16);
  stroke: rgba(124, 92, 255, 0.46);
}

.lt-node.leaf circle {
  fill: rgba(24, 198, 255, 0.14);
  stroke: rgba(24, 198, 255, 0.45);
}

.lt-node.best circle {
  fill: rgba(46, 213, 115, 0.26);
  stroke: rgba(46, 213, 115, 0.95);
  stroke-width: 2;
}

.lt-node.best-path circle {
  stroke: rgba(46, 213, 115, 0.7);
}

.lt-node.pruned circle {
  fill: rgba(255, 255, 255, 0.08);
  stroke: rgba(255, 255, 255, 0.18);
}

.lt-node.infeasible circle,
.lt-node.aborted circle {
  fill: rgba(255, 59, 122, 0.18);
  stroke: rgba(255, 59, 122, 0.65);
}

.lt-node.selected circle {
  stroke: rgba(255, 255, 255, 0.92);
  stroke-width: 3;
}

.little-tree-details {
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.45;
}

.little-tree-details:empty {
  display: none;
}

.little-tree-details code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.92);
}

.little-tree-details .lt-section {
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

.little-tree-details .lt-title {
  font-size: 12px;
  font-weight: 750;
  color: rgba(255, 255, 255, 0.92);
  letter-spacing: 0.2px;
}

.little-tree-details .lt-edge-line {
  display: block;
}

.little-tree-details .lt-edge-line.include code {
  color: rgba(46, 213, 115, 0.95);
}

.little-tree-details .lt-edge-line.exclude code {
  color: rgba(255, 59, 122, 0.95);
}

.route-arrow {
  width: 38px;
  height: 38px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(10, 14, 26, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(10px);
}

.route-arrow-inner {
  display: block;
  font-size: 18px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.92);
  transform: rotate(var(--angle, 0deg));
}

@media (max-width: 720px) {
  .panel {
    top: auto;
    left: 14px;
    right: 14px;
    bottom: 14px;
    width: auto;
    max-height: 62vh;
  }

  .panel.collapsed {
    transform: translateY(calc(100% + 18px));
  }

  .panel-toggle {
    top: auto;
    bottom: 14px;
    left: 14px;
    transform: none;
    border-radius: 14px;
  }

  .panel-toggle:hover,
  .panel-toggle:active {
    transform: none;
  }

  .status {
    right: 14px;
    bottom: calc(62vh + 28px);
    left: 14px;
    width: auto;
  }

  .compute {
    top: auto;
    left: 14px;
    right: 14px;
    bottom: 14px;
    width: auto;
    max-height: 75vh;
    transform: translateY(calc(100% + 18px));
  }

  .compute.open {
    transform: translateY(0);
  }

  .compute-toggle {
    top: auto;
    bottom: calc(62vh + 26px);
    right: 14px;
    transform: none;
    border-radius: 14px;
  }

  .compute-toggle:hover,
  .compute-toggle:active {
    transform: none;
  }
}

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

  .admin-cell-form {
    flex-direction: column;
    align-items: stretch;
  }

  .admin-cell-form input,
  .admin-cell-form select {
    min-width: 0;
  }

  .panel-header {
    align-items: stretch;
  }

  .panel-header-actions {
    justify-content: flex-start;
  }

  .panel-header-actions button,
  .panel-header-actions form {
    flex: 1 1 auto;
  }

  .compute-header h3 {
    flex-basis: 100%;
  }

  .compute-header-actions {
    justify-content: flex-start;
  }

  .compute-header-actions button,
  .compute-header-actions select {
    flex: 1 1 auto;
  }

  .task-save {
    grid-template-columns: 1fr;
  }

  .task-save button {
    width: 100%;
  }

  .task-item-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .task-item-meta {
    white-space: normal;
  }

  .compare-metrics {
    grid-template-columns: 1fr;
  }

  .matrix th,
  .matrix td {
    padding: 6px 6px;
    font-size: 11px;
  }

  .matrix .meta {
    font-size: 12px;
  }
}

.auth {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, calc(100vw - 36px));
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.auth-card h1 {
  margin: 0;
  font-size: 20px;
}

.auth-sub {
  margin: 4px 0 14px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.auth-info {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(24, 198, 255, 0.08);
  border: 1px solid rgba(24, 198, 255, 0.25);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  margin-bottom: 12px;
}

.auth-error {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 59, 122, 0.12);
  border: 1px solid rgba(255, 59, 122, 0.35);
  font-size: 13px;
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 12px;
}

.auth-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.admin-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-card {
  width: min(1220px, calc(100vw - 36px));
  padding: 18px;
  border-radius: var(--radius);
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.admin-top {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
}

.admin-top h1 {
  margin: 0;
  font-size: 22px;
}

.admin-top-actions {
  display: flex;
  gap: 10px;
}

.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.admin-link:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.admin-section {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 14px;
  padding-top: 14px;
}

.admin-section h2 {
  margin: 0 0 12px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1.5fr 180px;
  gap: 10px;
}

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

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

.admin-table-wrap {
  overflow: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

.admin-table th {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
}

.admin-cell-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.admin-cell-form input,
.admin-cell-form select {
  min-width: 180px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid rgba(24, 198, 255, 0.4);
  background: rgba(24, 198, 255, 0.12);
}
