/* ============================================================
   ClivTrans — sim-game HUD theme
   Dark glassmorphism · cyan/teal accent · amber money/warnings
   Vanilla CSS, system fonts only (offline-safe).
   ============================================================ */

:root {
  color-scheme: dark;

  /* Surfaces */
  --bg: #0a0f18;
  --bg-deep: #070b12;
  --glass: rgba(17, 24, 38, 0.78);
  --glass-strong: rgba(13, 19, 31, 0.9);
  --glass-soft: rgba(148, 163, 184, 0.07);
  --well: rgba(7, 11, 18, 0.55);

  /* Lines */
  --border: rgba(148, 163, 184, 0.14);
  --border-strong: rgba(148, 163, 184, 0.26);

  /* Text */
  --text: #e7edf7;
  --muted: #a3b2ca;
  --faint: #6b7a94;

  /* Accents */
  --accent: #22d3ee;            /* primary cyan */
  --accent-2: #67e8f9;          /* light cyan (main.js inline styles use this) */
  --accent-deep: #0e93b4;
  --accent-soft: rgba(34, 211, 238, 0.12);
  --accent-line: rgba(34, 211, 238, 0.45);
  --warn: #fbbf24;              /* amber — money & warnings */
  --warn-soft: rgba(251, 191, 36, 0.12);
  --good: #34d399;
  --bad: #f87171;
  --bad-soft: rgba(248, 113, 113, 0.12);

  /* Effects */
  --blur: blur(16px) saturate(1.35);
  --shadow: 0 10px 30px rgba(2, 6, 14, 0.5), 0 2px 8px rgba(2, 6, 14, 0.35);
  --inner-hl: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --ring: 0 0 0 2px rgba(34, 211, 238, 0.55);
  --ease: 0.15s ease;

  /* Metrics */
  --r-lg: 14px;
  --r-md: 10px;
  --r-sm: 8px;
  --ibar-h: 52px;

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1100px 560px at 18% -12%, #131f36, transparent 62%),
    radial-gradient(900px 480px at 105% 115%, #0c1a26, transparent 60%),
    var(--bg);
  color: var(--text);
  overflow: hidden;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* —— Scrollbars (thin, subtle) —— */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.28) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.24);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.4);
  border: 2px solid transparent;
  background-clip: content-box;
}

/* —— kbd chips —— */
kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  background: rgba(148, 163, 184, 0.1);
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  vertical-align: baseline;
}

/* ============================================================
   Forms & buttons
   ============================================================ */

label {
  display: grid;
  gap: 6px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

input,
select {
  background: var(--well);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.95rem;
  min-height: 40px;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}

input::placeholder {
  color: var(--faint);
}

input:hover,
select:hover {
  border-color: var(--border-strong);
}

input:focus-visible,
select:focus-visible,
input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-line);
  box-shadow: var(--ring);
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

button {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.1), rgba(148, 163, 184, 0.04));
  color: var(--text);
  border-radius: var(--r-sm);
  min-height: 34px;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 0.83rem;
  font-weight: 500;
  line-height: 1.3;
  box-shadow: var(--inner-hl);
  transition: border-color var(--ease), background var(--ease), color var(--ease),
    box-shadow var(--ease), transform var(--ease), opacity var(--ease), filter var(--ease);
}

button:hover {
  border-color: var(--accent-line);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.14), rgba(148, 163, 184, 0.06));
}

button:active {
  transform: translateY(1px);
  filter: brightness(0.94);
}

button:focus-visible {
  outline: none;
  box-shadow: var(--ring), var(--inner-hl);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.primary {
  background: linear-gradient(180deg, #38d9f2, var(--accent-deep));
  border-color: rgba(103, 232, 249, 0.55);
  color: #05222d;
  font-weight: 700;
  width: 100%;
  padding: 10px 14px;
  text-shadow: none;
}

button.primary:hover {
  filter: brightness(1.08);
  border-color: rgba(165, 243, 252, 0.75);
}

button.ghost {
  background: transparent;
  box-shadow: none;
}

button.ghost:hover {
  background: var(--glass-soft);
}

button.full {
  width: 100%;
  margin-top: 6px;
}

button.danger,
.ibar-btn.danger {
  color: #fecaca;
}

.ibar-btn.danger:hover {
  border-color: rgba(248, 113, 113, 0.45);
  background: var(--bad-soft);
}

button.active,
.ibar-btn.active,
.station-type.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-2);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.35), var(--inner-hl);
}

.danger-text {
  color: #fca5a5 !important;
}

/* ============================================================
   Boot screen
   ============================================================ */

#boot {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

/* Hero backdrop — shown behind the auth, lobby and company phases,
   fading into the page background at the bottom via the ::after gradient */
#boot::before,
#boot::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: min(88vh, 920px);
  pointer-events: none;
  z-index: 0;
}

#boot::before {
  background: url('/assets/hero.png') center top / cover no-repeat;
}

#boot::after {
  background: linear-gradient(
    180deg,
    rgba(10, 15, 24, 0.3) 0%,
    rgba(10, 15, 24, 0.35) 45%,
    rgba(10, 15, 24, 0.72) 75%,
    var(--bg) 100%
  );
}

.boot-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow), var(--inner-hl);
}

.boot-card-wide {
  width: min(780px, 100%);
}

.boot-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 20px;
  margin-top: 8px;
}

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

.boot-col h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

.boot-hint {
  margin: 0 0 12px;
  font-size: 0.76rem;
}

.logo {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  background: linear-gradient(90deg, #7dd3fc, #22d3ee, #2dd4bf);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline {
  margin: 4px 0 12px;
  color: var(--accent-2);
  font-weight: 600;
  font-size: 0.9rem;
}

.blurb {
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.money-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 6px;
}

.money-prefix {
  color: var(--warn);
  font-weight: 700;
  padding-left: 4px;
}

.money-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 10px;
}

.money-presets .chip,
.boot-card .chip {
  min-height: 28px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--well);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: none;
}

.money-presets .chip:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.money-presets .chip.active {
  background: var(--warn-soft);
  color: #fde68a;
  border-color: rgba(251, 191, 36, 0.5);
}

.boot-saves {
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
}

.save-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  max-height: 240px;
  overflow: auto;
}

.save-list li {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  background: var(--glass-soft);
  transition: border-color var(--ease), background var(--ease);
}

.save-list li:hover {
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.1);
}

.save-list .save-title {
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text);
}

.save-list .save-meta {
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.save-list .save-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.save-list .save-btns button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 0.75rem;
}

.boot-save-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.boot-save-actions .ghost {
  border-color: var(--border);
}

.resume-block {
  margin: 10px 0 14px;
  padding: 12px;
  border-radius: var(--r-md);
  border: 1px solid rgba(34, 211, 238, 0.28);
  background: rgba(34, 211, 238, 0.06);
}

.resume-block h3 {
  margin-top: 0;
}

.resume-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
}

.resume-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--glass-soft);
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color var(--ease), background var(--ease);
}

.resume-list li:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.resume-list .meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.status {
  color: var(--muted);
  font-size: 0.82rem;
  min-height: 1.2em;
}

/* ============================================================
   App shell
   ============================================================ */

#app {
  height: 100%;
  display: grid;
  grid-template-rows: var(--ibar-h) 1fr auto;
}

/* —— Icon top bar —— */
#iconbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  height: var(--ibar-h);
  background: linear-gradient(180deg, rgba(17, 24, 38, 0.92), rgba(10, 15, 24, 0.88));
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  z-index: 40;
  position: relative;
}

.ibar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-shrink: 0;
}

.logo-sm {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 0.95rem;
  background: linear-gradient(90deg, #7dd3fc, #22d3ee);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--accent-2);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge:empty {
  display: none;
}

/* Segmented button groups */
.ibar-tools,
.ibar-toggles {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 3px;
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: 11px;
}

.ibar-sep {
  width: 1px;
  height: 22px;
  background: var(--border-strong);
  margin: 0 4px;
}

.ibar-btn {
  width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  position: relative;
}

.ibar-btn:hover {
  background: var(--glass-soft);
  border-color: var(--border);
}

.ibar-btn:active {
  transform: none;
  filter: brightness(0.9);
}

.ibar-btn .ibar-mini {
  position: absolute;
  bottom: 1px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--faint);
}

.ibar-btn.active .ibar-mini,
.ibar-btn[aria-pressed="true"] .ibar-mini {
  color: var(--accent-2);
}

.ibar-btn[aria-pressed="true"],
.ibar-btn.panel-open {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.ibar-ico {
  font-size: 1.1rem;
  line-height: 1;
}

/* CSS tooltips from data-tip */
.ibar-btn[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%) translateY(-2px);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--ease), transform var(--ease);
  z-index: 60;
  box-shadow: var(--shadow);
}

.ibar-btn[data-tip]:hover::after,
.ibar-btn[data-tip]:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.ibar-toggles .ibar-btn[data-tip]::after {
  left: auto;
  right: 0;
  transform: translateY(-2px);
}

.ibar-toggles .ibar-btn[data-tip]:hover::after,
.ibar-toggles .ibar-btn[data-tip]:focus-visible::after {
  transform: translateY(0);
}

/* —— Stats strip —— */
.ibar-stats {
  display: flex;
  gap: 6px;
  flex: 1;
  justify-content: center;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.ibar-stats::-webkit-scrollbar {
  display: none;
}

.ibar-stats .stat {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  color: var(--muted);
  transition: border-color var(--ease), background var(--ease);
}

.ibar-stats .stat:hover {
  border-color: var(--border);
  background: var(--glass-soft);
}

.ibar-stats .stat span {
  opacity: 0.8;
  font-size: 12px;
}

.ibar-stats .stat strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

#moneyStat {
  color: var(--warn);
}

#transferRevStat {
  color: #fde68a;
}

.ibar-stats .stat.muted {
  opacity: 0.6;
}

/* ============================================================
   Main viewport — canvas fills its parent, do not pad
   ============================================================ */

#main {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
}

#viewport-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
  background: var(--bg-deep);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

#hoverInfo {
  position: absolute;
  left: 12px;
  top: 12px;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  pointer-events: none;
  max-width: 280px;
  z-index: 3;
  box-shadow: var(--shadow);
}

#hoverInfo:empty {
  display: none;
}

#toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(4px);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--accent-line);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 999px;
  opacity: 0;
  transition: opacity var(--ease), transform var(--ease);
  pointer-events: none;
  font-size: 0.85rem;
  font-weight: 500;
  z-index: 6;
  box-shadow: var(--shadow), 0 0 18px rgba(34, 211, 238, 0.12);
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— Minimap —— */
#minimapWrap {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 168px;
  height: 168px;
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-strong);
  background: var(--bg-deep);
  cursor: crosshair;
  z-index: 5;
  transition: opacity 0.2s ease, transform 0.2s ease, border-color var(--ease);
}

#minimapWrap:hover {
  border-color: var(--accent-line);
}

#minimapWrap.hidden-map {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(0.96);
}

#minimap {
  display: block;
  width: 168px;
  height: 168px;
}

.minimap-label {
  position: absolute;
  left: 8px;
  top: 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(203, 213, 225, 0.85);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  font-weight: 700;
}

/* ============================================================
   Flyout panels
   ============================================================ */

#flyouts {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100% - 24px);
  pointer-events: none;
}

.flyout {
  pointer-events: auto;
  width: min(320px, calc(100vw - 24px));
  max-height: min(70vh, 520px);
  overflow: auto;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), var(--inner-hl);
  padding: 14px;
  animation: flyIn 0.15s ease;
}

.flyout-wide {
  width: min(420px, calc(100vw - 24px));
}

@keyframes flyIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.flyout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -14px -14px 10px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.35);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  position: sticky;
  top: -14px;
  z-index: 2;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.flyout-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent-2);
}

.flyout-close {
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 7px;
  border-color: transparent;
  font-size: 1.05rem;
  line-height: 1;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  display: grid;
  place-items: center;
}

.flyout-close:hover {
  color: var(--text);
  background: var(--glass-soft);
  border-color: var(--border);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 8px;
}

.hint strong {
  color: var(--text);
  font-weight: 600;
}

/* —— Track piece grid —— */
.piece-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.piece-btn {
  aspect-ratio: 1;
  min-height: 36px;
  padding: 4px;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: var(--r-sm);
  background: var(--well);
  box-shadow: none;
}

.piece-btn small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 600;
}

.piece-btn:hover {
  background: var(--glass-soft);
}

.piece-btn.active {
  border-color: var(--accent-line);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.35);
  background: var(--accent-soft);
}

.piece-btn.active small {
  color: var(--accent-2);
}

/* —— Stations & depots —— */
.station-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 10px;
}

.station-type {
  text-align: center;
  padding: 9px 6px;
  font-size: 0.82rem;
  line-height: 1.35;
  background: var(--well);
  box-shadow: none;
}

.station-type small {
  color: var(--warn);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.depot-select-label {
  margin: 0 0 10px;
  font-size: 12px;
}

.depot-select-label select {
  width: 100%;
  margin-top: 4px;
  padding: 8px 10px;
  min-height: 36px;
  font-size: 0.85rem;
}

/* —— Buy vehicles —— */
.buy-grid {
  display: grid;
  gap: 6px;
}

.buy {
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  font-weight: 600;
  font-size: 0.86rem;
}

.buy small {
  color: var(--warn);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  background: var(--warn-soft);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 11px;
}

/* —— Quick fleet —— */
.fleet-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  max-height: 220px;
  overflow: auto;
}

.fleet-list li {
  padding: 8px 10px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.84rem;
  transition: background var(--ease), border-color var(--ease);
}

.fleet-list li:hover {
  background: var(--glass-soft);
}

.fleet-list li.selected {
  background: var(--accent-soft);
  border-color: var(--accent-line);
}

.fleet-list .meta {
  color: var(--muted);
  font-size: 0.72rem;
}

/* —— World panel —— */
.world-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 10px;
}

.flyout h4 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--faint);
}

#leaderboard,
#townList,
#eventList {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 140px;
  overflow: auto;
  font-size: 12.5px;
}

#leaderboard li,
#townList li,
#eventList li {
  padding: 6px 4px;
  border-bottom: 1px solid var(--border);
  transition: background var(--ease);
}

#townList li:hover {
  background: var(--glass-soft);
}

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

.transfer-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.transfer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.transfer-stats > div {
  background: var(--well);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 8px;
  text-align: center;
}

.transfer-stats span {
  display: block;
  font-size: 10px;
  color: var(--faint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.transfer-stats strong {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   Selection inspector
   ============================================================ */

.inspector {
  position: absolute;
  right: 12px;
  top: 12px;
  width: min(300px, calc(100vw - 24px));
  max-height: calc(100% - 24px);
  overflow: auto;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), var(--inner-hl);
  z-index: 18;
  padding: 14px;
  animation: flyIn 0.15s ease;
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.inspector-kind {
  margin: 0;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent-2);
}

.inspector-head h3 {
  margin: 3px 0 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.inspector-body {
  font-size: 0.84rem;
  color: var(--muted);
  line-height: 1.45;
}

.inspector-body .insp-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}

.inspector-body .insp-row strong {
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.inspector-body .insp-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 140px;
  overflow: auto;
}

.inspector-body .insp-list li {
  padding: 6px 9px;
  border-radius: var(--r-sm);
  cursor: pointer;
  margin-bottom: 4px;
  background: var(--well);
  border: 1px solid transparent;
  font-size: 12.5px;
  color: var(--text);
  transition: border-color var(--ease), background var(--ease);
}

.inspector-body .insp-list li:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.inspector-body .insp-list .meta {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.inspector-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.inspector-actions button {
  width: 100%;
  text-align: left;
}

.inspector-actions .insp-rename-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.inspector-actions .insp-rename-row input {
  padding: 7px 10px;
  min-height: 34px;
  font-size: 0.84rem;
}

/* ============================================================
   Status bar
   ============================================================ */

#statusBar {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: center;
  padding: 5px 14px;
  border-top: 1px solid var(--border);
  background: rgba(13, 19, 31, 0.92);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

#connStatus {
  color: var(--good);
  font-weight: 600;
}

/* ============================================================
   Modals
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  display: grid;
  place-items: center;
  z-index: 50;
  padding: 20px;
}

.modal-card {
  width: min(520px, 100%);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow), var(--inner-hl);
}

.modal-card h2 {
  margin-top: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.modal-card ol {
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.9rem;
  padding-left: 20px;
}

.modal-card ol li {
  margin-bottom: 4px;
}

.modal-card strong {
  color: var(--text);
}

.keys-row {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 2;
}

.save-modal-card {
  width: min(420px, 100%);
}

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

.save-modal-actions .primary {
  width: auto;
  min-width: 120px;
}

.save-modal-list-title {
  margin: 18px 0 8px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ============================================================
   Operations drawer (route manager)
   ============================================================ */

#routeModal.modal {
  place-items: stretch end;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  pointer-events: none;
  padding: 12px;
}

#routeModal .route-card {
  pointer-events: auto;
  width: min(440px, 100%);
  height: calc(100vh - 24px);
  max-height: none;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  box-shadow: var(--shadow), 0 0 0 1px rgba(34, 211, 238, 0.15);
}

#routeModal .ops-card {
  width: min(480px, 100%);
}

.route-card {
  width: min(860px, 100%);
  max-height: min(90vh, 720px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.route-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.35);
}

.route-header h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.route-sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

#closeRoutes {
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--muted);
}

#closeRoutes:hover {
  color: var(--text);
}

/* —— Ops tabs —— */
.ops-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 0;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 18, 0.35);
}

.ops-tab {
  flex: 1;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  padding: 10px;
  font-weight: 600;
  font-size: 0.84rem;
  transition: color var(--ease), border-color var(--ease), background var(--ease);
}

.ops-tab:hover {
  color: var(--text);
  background: var(--glass-soft);
  transform: none;
  border-color: transparent;
  border-bottom-color: var(--border-strong);
}

.ops-tab.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: none;
}

.route-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: minmax(120px, 28%) 1fr;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

/* —— Fleet list section —— */
.route-fleet {
  border-bottom: 1px solid var(--border);
  padding: 12px;
  overflow: auto;
  background: rgba(7, 11, 18, 0.3);
}

.route-fleet h3,
.route-detail h3 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

#routeFleetList {
  list-style: none;
  margin: 0;
  padding: 0;
}

#routeFleetList li {
  padding: 9px 11px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  cursor: pointer;
  margin-bottom: 6px;
  background: var(--glass-soft);
  font-size: 0.86rem;
  transition: border-color var(--ease), background var(--ease), box-shadow var(--ease);
}

#routeFleetList li:hover {
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.1);
}

#routeFleetList li.active {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.15);
}

#routeFleetList .meta {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 3px;
}

.route-detail {
  padding: 14px 16px 18px;
  overflow: auto;
}

.route-empty {
  color: var(--muted);
  padding: 40px 12px;
  text-align: center;
  line-height: 1.5;
  font-size: 0.9rem;
}

.route-empty p {
  margin: 0 0 8px;
}

.route-empty strong {
  color: var(--text);
}

/* —— Vehicle meta / legacy —— */
.route-vehicle-meta,
.ops-vehicle-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  align-items: end;
  margin-bottom: 12px;
}

.route-name-label {
  margin: 0;
  grid-column: 1;
}

.route-stats {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.route-stats strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* —— Ops status pills —— */
.ops-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.ops-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--well);
  border: 1px solid var(--border);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.ops-pill strong {
  color: var(--text);
  font-weight: 600;
}

.ops-pill.warn {
  border-color: rgba(251, 191, 36, 0.45);
  background: var(--warn-soft);
  color: #fde68a;
}

.ops-pill.good {
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(52, 211, 153, 0.1);
  color: #a7f3d0;
}

.ops-pill.accent {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-2);
}

/* —— Ops sections —— */
.ops-section {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: rgba(7, 11, 18, 0.28);
}

.ops-section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 8px;
}

.ops-section-head h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-2);
}

.ops-section-head .hint {
  margin: 0;
  font-size: 11px;
  text-align: right;
}

.ops-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.ops-chip {
  min-height: 26px;
  padding: 3px 11px;
  font-size: 11.5px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--well);
  color: var(--muted);
  box-shadow: none;
}

.ops-chip:hover {
  color: var(--text);
}

.ops-chip.active {
  background: var(--accent-soft);
  color: var(--accent-2);
  border-color: var(--accent-line);
  box-shadow: none;
}

/* —— Route stops —— */
.route-stops {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  counter-reset: stop;
}

.route-stops li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 6px;
  background: var(--glass-soft);
  counter-increment: stop;
  transition: border-color var(--ease), background var(--ease);
}

.route-stops li:hover {
  border-color: var(--border-strong);
}

.route-stops li::before {
  content: counter(stop);
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: var(--accent-2);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.route-stops li.active-stop {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.25);
}

.route-stops .stop-name {
  font-size: 0.86rem;
  font-weight: 500;
}

.route-stops .stop-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
}

.route-stops .stop-btns {
  display: flex;
  gap: 4px;
}

.route-stops .stop-btns button {
  min-height: 28px;
  padding: 4px 8px;
  min-width: 30px;
  font-size: 0.78rem;
}

.route-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 10px;
}

.route-add-row select {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.ops-stop-tools {
  display: flex;
  gap: 6px;
}

.ops-stop-tools .ghost {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.78rem;
}

.ops-quick-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-bottom: 6px;
}

.ops-quick-row select {
  padding: 7px 10px;
  min-height: 36px;
  font-size: 0.84rem;
}

.ops-save-tpl {
  margin-top: 4px;
}

.ops-save-tpl:disabled,
#opsApplySavedBtn:disabled,
#opsCopyFromBtn:disabled,
#routeApplyBtn:disabled,
#routeDispatchBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* —— Route actions —— */
.route-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.route-actions .primary {
  width: auto;
  min-width: 140px;
}

.ops-actions {
  flex-wrap: wrap;
}

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

.ops-actions-sticky {
  position: sticky;
  bottom: 0;
  margin-top: 8px;
  padding: 12px 0 4px;
  background: linear-gradient(180deg, transparent, rgba(13, 19, 31, 0.94) 30%);
  z-index: 2;
}

/* —— Route library —— */
.ops-saved-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  max-height: 50vh;
  overflow: auto;
}

.ops-saved-list li {
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: 8px;
  background: var(--glass-soft);
  transition: border-color var(--ease), background var(--ease);
}

.ops-saved-list li:hover {
  border-color: var(--border-strong);
  background: rgba(148, 163, 184, 0.1);
}

.ops-saved-list .ops-saved-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--text);
  margin-bottom: 4px;
}

.ops-saved-list .ops-saved-meta {
  font-size: 0.72rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.ops-saved-list .ops-saved-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}

.ops-saved-list .tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  border: 1px solid rgba(34, 211, 238, 0.25);
  color: var(--accent-2);
}

.ops-saved-list .ops-saved-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ops-saved-list .ops-saved-btns button {
  min-height: 28px;
  padding: 4px 10px;
  font-size: 0.75rem;
}

.ops-lib-empty {
  padding: 20px 8px;
  text-align: center;
}

#opsLibraryTab.hidden,
#opsVehicleTab.hidden {
  display: none !important;
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 900px) {
  .ibar-stats .stat.muted {
    display: none;
  }
  .logo-sm {
    display: none;
  }
}

@media (max-width: 640px) {
  .ibar-stats {
    display: none;
  }
  .flyout-wide {
    width: min(100vw - 24px, 360px);
  }
  .world-cols {
    grid-template-columns: 1fr;
  }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
