/* =====================================================
   Hit Rail RTMDE — Design Tokens
   ===================================================== */
:root {
  --ht-olive-900: #1f221a;
  --ht-olive-800: #2a2d24;
  --ht-olive-700: #353930;
  --ht-olive-600: #46493d;
  --ht-olive-500: #5a5e4b;
  --ht-olive-400: #767a66;
  --ht-olive-300: #9ea28e;
  --ht-olive-200: #c7cab9;
  --ht-olive-100: #e6e8dd;
  --ht-olive-50:  #f3f4ed;

  --ht-gold-600: #c88800;
  --ht-gold-500: #f5a800;
  --ht-gold-400: #f7b933;
  --ht-gold-300: #fbd27a;
  --ht-gold-100: #fdecc0;
  --ht-gold-50:  #fff7e1;

  --surface-0: #ffffff;
  --surface-1: #fafaf6;
  --surface-2: #f3f3ec;
  --surface-3: #e9e9df;
  --border-soft: #e4e4d8;
  --border: #d6d6c7;
  --border-strong: #b5b6a4;

  --dark-0: #16180f;
  --dark-1: #1c1f15;
  --dark-2: #242719;
  --dark-3: #2e3122;
  --dark-4: #3a3d2e;
  --dark-text: #d4d6c4;
  --dark-muted: #8e9180;
  --dark-dim: #61634f;

  --ok: #2d9d6e;
  --ok-bg: #e3f4ec;
  --ok-dark: #1b6e4c;
  --warn: #e89c2a;
  --warn-bg: #fcefd6;
  --warn-dark: #8a5a0a;
  --err: #d84545;
  --err-bg: #fbe4e4;
  --err-dark: #8f2020;
  --info: #3a7bd5;
  --info-bg: #e3edfa;

  --text: #1f221a;
  --text-muted: #5a5e4b;
  --text-dim: #8a8d7a;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 14px;

  --shadow-sm: 0 1px 2px rgba(31,34,26,0.06);
  --shadow-md: 0 2px 8px rgba(31,34,26,0.08), 0 1px 2px rgba(31,34,26,0.05);
  --shadow-lg: 0 12px 32px rgba(31,34,26,0.12), 0 2px 6px rgba(31,34,26,0.06);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Menlo', monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%; overflow: hidden;
}
body {
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface-1);
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
.thin-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.thin-scroll::-webkit-scrollbar-track { background: transparent; }
.thin-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.thin-scroll::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

.dark-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.dark-scroll::-webkit-scrollbar-track { background: transparent; }
.dark-scroll::-webkit-scrollbar-thumb { background: var(--dark-3); border-radius: 4px; }
.dark-scroll::-webkit-scrollbar-thumb:hover { background: var(--dark-4); }

:focus-visible { outline: 2px solid var(--ht-gold-500); outline-offset: 2px; }
button { font-family: inherit; }

/* Utility */
.hidden { display: none !important; }


/* =====================================================
   CONFIG OVERLAY
   ===================================================== */
.config-overlay {
  position: fixed;
  inset: 0;
  background: var(--ht-olive-900);
  background-image: repeating-linear-gradient(45deg, transparent 0 24px, rgba(245,168,0,0.04) 24px 25px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.config-overlay.hidden { display: none !important; }

.config-overlay__card {
  background: var(--surface-0);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 48px;
  width: 480px;
  max-width: 94vw;
  text-align: center;
}
.config-overlay__logo {
  height: 36px;
  width: auto;
  margin-bottom: 20px;
}
.config-overlay__title {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  margin: 0 0 8px;
}
.config-overlay__sub {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 24px;
}
.config-or-settings {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 14px;
}
.config-or-settings a { color: var(--ht-gold-600); }

.config-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
  padding: 28px 20px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  cursor: pointer;
}
.config-upload-area:hover, .config-upload-area.drag-over {
  border-color: var(--ht-gold-500);
  background: var(--ht-gold-50);
}
.config-upload-icon { font-size: 28px; margin-bottom: 10px; }
.config-upload-area p { margin: 4px 0; color: var(--text-muted); font-size: 13px; }
.config-upload-or { color: var(--text-dim); font-size: 11px; margin: 8px 0 !important; }
.config-upload-btn { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; cursor: pointer; }

.config-status-msg {
  margin-top: 14px;
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: pre-wrap;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--r-md);
  display: none;
}
.config-status-msg.success { background: var(--ok-bg); color: var(--ok-dark); display: block; }
.config-status-msg.error   { background: var(--err-bg); color: var(--err-dark); display: block; }
.config-status-msg.loading { background: var(--surface-2); color: var(--text-muted); display: block; }
.config-status-msg.warning { background: var(--warn-bg); color: var(--warn-dark); display: block; }


/* =====================================================
   APP LAYOUT
   ===================================================== */
.rtmde-app {
  display: none; /* shown via JS */
  grid-template-columns: 220px 1fr;
  height: 100vh;
  background: var(--surface-1);
  overflow: hidden;
}
.rtmde-app.visible { display: grid; }

/* =====================================================
   SIDEBAR
   ===================================================== */
.sidebar {
  background: var(--surface-0);
  color: var(--text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-soft);
  min-width: 0;
  overflow: hidden;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 20px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.sidebar__brand img { height: 22px; width: auto; display: block; }
.sidebar__brand-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--ht-gold-600);
  text-transform: uppercase;
  margin-left: auto;
  padding: 3px 7px;
  border: 1px solid rgba(200,136,0,0.35);
  border-radius: 3px;
}

/* ── Environment picker (workspace-switcher style) ── */
.env-picker {
  position: relative;
  padding: 8px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.env-picker__trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  text-align: left;
}
.env-picker__trigger:hover {
  background: var(--surface-3);
  border-color: var(--border-strong, #c1c8d4);
}
.env-picker__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s;
}
.env-picker__texts {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  overflow: hidden;
}
.env-picker__name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
  line-height: 1.2;
}
.env-picker__label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.env-picker__chevron {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.15s;
}
.env-picker__trigger[aria-expanded="true"] .env-picker__chevron {
  transform: rotate(180deg);
}

/* Dropdown */
.env-picker__dropdown {
  display: none;
  position: absolute;
  left: 10px;
  right: 10px;
  top: calc(100% - 6px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  z-index: 200;
  overflow: hidden;
}
.env-picker__dropdown.is-open { display: block; }

.env-picker__option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  transition: background 0.1s;
}
.env-picker__option:hover { background: var(--surface-2); }
.env-picker__option.is-active { background: var(--surface-2); }
.env-picker__option-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.env-picker__option-name {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
}
.env-picker__option-label {
  flex: 1;
  font-size: 11px;
  color: var(--text-muted);
}
.env-picker__option svg { color: var(--text-muted); flex-shrink: 0; }

/* Hide text in collapsed sidebar — show only the dot */
.sidebar-collapsed .env-picker { padding: 6px; }
.sidebar-collapsed .env-picker__trigger {
  padding: 8px;
  justify-content: center;
}
.sidebar-collapsed .env-picker__texts,
.sidebar-collapsed .env-picker__chevron { display: none; }

.sidebar__nav { padding: 14px 10px 10px; flex: 1; overflow-y: auto; }
.sidebar__section-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 14px 8px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--text-muted);
  font-size: 13px;
  border-radius: var(--r-md);
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 1px;
  position: relative;
  user-select: none;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--ht-olive-100); color: var(--text); }
.nav-item.is-active::before {
  content: '';
  position: absolute;
  left: -10px; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--ht-gold-500);
  border-radius: 0 2px 2px 0;
}
.nav-item__icon { color: var(--text-dim); display: flex; }
.nav-item.is-active .nav-item__icon { color: var(--ht-gold-600); }

.sidebar__delay-legend {
  padding: 10px 14px 8px;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.sidebar__delay-legend__title {
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-dim);
  margin-bottom: 5px;
  font-weight: 600;
}
.sidebar__delay-legend__row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.8;
}
.sdl-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sdl-dot--outline {
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
}
.sidebar-collapsed .sidebar__delay-legend { display: none; }

.sidebar__foot {
  border-top: 1px solid var(--border-soft);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  flex-shrink: 0;
}
.sidebar__foot-name { color: var(--text); font-weight: 500; }
.sidebar__foot-role { color: var(--text-dim); font-size: 10.5px; }


/* =====================================================
   MAIN + TOPBAR
   ===================================================== */
.main { display: grid; grid-template-rows: auto 1fr; min-width: 0; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--surface-0);
  border-bottom: 1px solid var(--border-soft);
  min-height: 52px;
  flex-shrink: 0;
}
.topbar__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.topbar__crumb { color: var(--text-dim); font-weight: 400; }
.topbar__slash { color: var(--border-strong); font-weight: 300; }
.topbar__spacer { flex: 1; }

.iconbtn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  border-radius: var(--r-md);
  cursor: pointer;
  flex-shrink: 0;
}
.iconbtn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-0);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn--primary {
  background: var(--ht-gold-500);
  border-color: var(--ht-gold-600);
  color: var(--ht-olive-900);
  font-weight: 600;
}
.btn--primary:hover { background: var(--ht-gold-400); }
.btn--dark {
  background: var(--ht-olive-800);
  border-color: var(--ht-olive-900);
  color: #fff;
}
.btn--dark:hover { background: var(--ht-olive-700); }


/* =====================================================
   CONTENT GRID (3 columns)
   ===================================================== */
.content {
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* =====================================================
   LOGS PANEL COLLAPSIBLE
   ===================================================== */
.logs-panel {
  width: 360px;
  min-width: 220px;
  flex-shrink: 1;
  transition: width 0.25s ease, min-width 0.25s ease, flex-shrink 0s;
  position: relative;
}
.logs-panel.collapsed {
  width: 28px;
  min-width: 28px;
  flex-shrink: 0;
  overflow: hidden;
}
.logs-panel.collapsed .logs-head,
.logs-panel.collapsed .logs-stream,
.logs-panel.collapsed .logs-status-msg,
.logs-panel.collapsed .logs-foot {
  opacity: 0;
  pointer-events: none;
}

.logs-toggle-tab {
  position: absolute;
  left: -1px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 56px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 6px 0 0 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 9px;
  font-family: var(--font-mono);
  letter-spacing: 0.08em;
  z-index: 10;
  transition: background 0.15s, color 0.15s, left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease, transform 0.25s ease, border-radius 0.25s ease;
}
.logs-toggle-tab:hover { background: var(--surface-3); color: var(--text); }
.logs-panel.collapsed .logs-toggle-tab {
  left: 0;
  top: 0;
  transform: none;
  border-radius: 0;
  width: 28px;
  height: 100%;
  writing-mode: vertical-lr;
  text-orientation: mixed;
  background: var(--surface-1);
  border: none;
  border-right: 1px solid var(--border-soft);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}


/* =====================================================
   SEARCH PANEL
   ===================================================== */
.search-panel {
  background: var(--surface-0);
  border-right: 1px solid var(--border-soft);
  padding: 16px 16px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-head { display: flex; align-items: center; justify-content: space-between; }
.panel-head__title {
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.tabs__tab {
  flex: 1;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}
.tabs__tab.is-active {
  background: var(--surface-0);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.field { display: flex; flex-direction: column; gap: 5px; }
.field__label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.field__input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--text);
  width: 100%;
}
.field__input:focus {
  outline: none;
  border-color: var(--ht-gold-500);
  box-shadow: 0 0 0 3px rgba(245,168,0,0.15);
}
.field__hint { font-size: 10.5px; color: var(--text-dim); font-family: var(--font-mono); }

.chipset { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 10px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  font-size: 11.5px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}
.chip:hover { background: var(--surface-2); }
.chip.is-active { background: var(--ht-olive-700); border-color: var(--ht-olive-700); color: #fff; }

.date-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.divider { height: 1px; background: var(--border-soft); margin: 4px -16px; }

.search-status-msg {
  font-size: 12px;
  font-family: var(--font-mono);
  padding: 8px 10px;
  border-radius: var(--r-md);
  display: none;
  white-space: pre-wrap;
}
.search-status-msg.success { background: var(--ok-bg); color: var(--ok-dark); display: block; }
.search-status-msg.error   { background: var(--err-bg); color: var(--err-dark); display: block; }
.search-status-msg.loading { background: var(--surface-2); color: var(--text-muted); display: block; }
.search-status-msg.warning { background: var(--warn-bg); color: var(--warn-dark); display: block; }


/* =====================================================
   RESULTS
   ===================================================== */
.results {
  background: var(--surface-1);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  min-width: 180px;
}
.results__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0;
  z-index: 2;
  flex-shrink: 0;
}
.results__count { font-size: 13px; font-weight: 600; }
.results__count b { font-family: var(--font-mono); }
.results__meta { font-size: 11px; color: var(--text-dim); font-family: var(--font-mono); }
.results__toolbar { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.results__list { padding: 12px 18px 24px; display: flex; flex-direction: column; gap: 8px; }

.results-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-dim);
}
.results-empty__icon { font-size: 32px; margin-bottom: 12px; opacity: 0.5; }
.results-empty p { font-size: 13px; }


/* =====================================================
   TRACE CARD (results)
   ===================================================== */
.trace-card {
  background: var(--surface-0);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.trace-card:hover { border-color: var(--border); box-shadow: var(--shadow-sm); }
.trace-card.is-selected {
  border-color: var(--ht-gold-500);
  box-shadow: 0 0 0 1px var(--ht-gold-500), var(--shadow-md);
}

.trace-card__main {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  column-gap: 14px;
  row-gap: 8px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}
.trace-card__route-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.trace-card__bottom {
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.train-sigil {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 58px;
  padding: 7px 8px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
}
.train-sigil__class {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
}
.train-sigil__num {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
  margin-top: 1px;
}
.train-sigil__op { font-size: 9px; color: var(--text-dim); margin-top: 2px; }

.route { display: flex; align-items: center; gap: 10px; min-width: 0; }
.route__node { min-width: 0; }
.route__code {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text);
  display: flex; align-items: center; gap: 4px;
}
.route__name {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}
.route__line {
  flex: 1;
  height: 2px;
  background: var(--border);
  position: relative;
  min-width: 24px;
  border-radius: 1px;
}
.route__line::before, .route__line::after {
  content: ''; position: absolute; top: 50%; transform: translateY(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--border-strong);
}
.route__line::before { left: -2px; }
.route__line::after { right: -2px; }

.trace-card__route-wrap .route__node { min-width: 0; }

.times { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; white-space: nowrap; }
.times__primary { font-family: var(--font-mono); font-size: 12px; font-weight: 600; }
.times__secondary { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); }

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-badge--ok   { background: var(--ok-bg);   color: var(--ok-dark); }
.status-badge--warn { background: var(--warn-bg); color: var(--warn-dark); }
.status-badge--err  { background: var(--err-bg);  color: var(--err-dark); }
/* Journey-phase variants */
.status-badge--pending { background: var(--surface-2); color: var(--text-dim); }
.status-badge--enroute { background: rgba(50,130,220,0.12); color: #3a8ae0; border: 1px solid rgba(50,130,220,0.25); }
.status-badge--arrived { background: rgba(60,180,100,0.10); color: var(--ok-dark); }

.status-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; color: var(--text-dim); font-family: var(--font-mono); }

.trace-card__meta {
  padding: 0 16px 10px;
  display: flex;
  gap: 12px;
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  border-bottom: 1px dashed var(--border-soft);
  flex-wrap: wrap;
}
.trace-card__meta span b { color: var(--text-muted); font-weight: 600; }

.cc-tag {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 1px 4px;
  border-radius: 2px;
  border: 1px solid var(--border-soft);
}

.merits-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.05em;
  color: var(--info); background: var(--info-bg);
  padding: 2px 7px; border-radius: 3px;
}
.merits-badge-sm, .provider-badge-sm {
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 1px 5px;
  border-radius: 3px;
}
.merits-badge-sm { color: var(--info); background: var(--info-bg); }
.provider-badge-sm { color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border-soft); }


/* =====================================================
   TRAIN DETAIL (expanded inside card)
   ===================================================== */
.train-detail {
  border-top: 1px solid var(--border-soft);
  background: var(--surface-1);
  overflow: hidden;
}

.detail-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.detail-section:last-child { border-bottom: none; }
.detail-section__title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* Service IDs */
.service-ids { display: flex; flex-direction: column; gap: 5px; }
.service-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
}
.service-id-label { color: var(--text-dim); min-width: 130px; font-size: 10.5px; }
.primary-id .service-id-label { color: var(--ht-gold-600); font-weight: 600; }

.copyable {
  cursor: pointer;
  color: var(--text);
  border-bottom: 1px dashed var(--border);
  font-family: var(--font-mono);
}
.copyable:hover { color: var(--ht-gold-600); border-color: var(--ht-gold-500); }
.copyable.copied { color: var(--ok-dark); }
.copyable-primary { font-weight: 600; color: var(--ht-gold-600); }

.data-source-info {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 11.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.data-label { color: var(--text-dim); }
.data-value { color: var(--text-muted); }

.info-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
  font-family: var(--font-mono);
}
.brand-badge { background: var(--ht-gold-100); color: var(--ht-olive-800); border-color: var(--ht-gold-300); }
.train-header { padding: 14px 16px 10px; }
.train-header h2 { font-size: 15px; font-weight: 700; margin: 0 0 6px; }
.train-info { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Station route (detail) */
.route-container {
  position: relative;
  padding: 4px 0;
}
.route-line {
  display: none; /* replaced by stn__rail */
}


/* =====================================================
   STATION TRACE (new design)
   ===================================================== */
.station-trace { padding: 4px 0; }

.stn {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  column-gap: 10px;
  padding: 8px 16px 8px 16px;
  position: relative;
  align-items: center;
}
.stn + .stn { border-top: 1px solid var(--border-soft); }
.stn:hover { background: var(--surface-0); }

.stn__rail {
  position: absolute;
  left: 29px;
  top: 0; bottom: 0;
  width: 2px;
  background: var(--ht-olive-200);
  pointer-events: none;
}
.stn:first-child .stn__rail { top: 50%; }
.stn:last-child .stn__rail  { bottom: 50%; }

.stn__dot {
  position: relative;
  z-index: 1;
  justify-self: center;
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--ht-olive-300);
  background: transparent;
  overflow: hidden;           /* clip children to the circle */
  display: flex;
  flex-direction: column;
}
/* Each half fills its semicircle; default = empty (surface colour) */
.stn__dot-half {
  flex: 1;
  width: 100%;
  background: var(--surface-0);
}
/* Dot-half status colours */
.dot--confirmed { background: var(--ht-olive-700); }   /* dark: actualTime present */
.dot--past      { background: #9ca3af; }               /* gray: estimated time already passed */
.dot--future    { background: var(--warn); }           /* orange: event still ahead */
.dot--err       { background: var(--err); }            /* red: cancelled */
.dot--none      { background: var(--surface-0); }      /* empty */

.stn--major .stn__dot {
  width: 12px; height: 12px;
  background: transparent;    /* halves control the fill */
  border-color: var(--ht-olive-500);
  box-shadow: 0 0 0 3px var(--ht-olive-100);
}
.stn--warn.stn--major .stn__dot {
  background: transparent;
  border-color: var(--warn);
  box-shadow: 0 0 0 3px var(--warn-bg);
}
.stn--err.stn--major .stn__dot {
  background: transparent;
  border-color: var(--err);
  box-shadow: 0 0 0 3px var(--err-bg);
}

/* Station trace dot legend — sticky at bottom of the scroll container */
.stn-legend {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 16px 8px;
  background: var(--surface-1);
  border-top: 1px solid var(--border-soft);
  font-size: 10px;
  color: var(--text-dim);
}
.stn-legend__item {
  display: flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
/* Reuses .stn__dot-half + .dot--* colour classes */
.stn-legend__dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  border: 2px solid var(--ht-olive-300);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.stn-legend__sep {
  margin-left: auto;   /* push to right edge */
  font-style: italic;
  opacity: 0.7;
  white-space: nowrap;
}

/* Station dot hover tooltip */
.dot-tooltip {
  position: fixed;
  z-index: 9999;
  background: var(--ht-olive-900);
  color: var(--ht-olive-100);
  border-radius: 6px;
  padding: 8px 11px 9px;
  font-size: 11px;
  font-family: var(--font-mono, monospace);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  white-space: nowrap;
  min-width: 170px;
}
.dot-tooltip.hidden { display: none; }
.dtt-head {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ht-olive-400);
  margin-top: 7px;
  margin-bottom: 2px;
}
.dtt-head:first-child { margin-top: 0; }
.dtt-sep {
  border-top: 1px solid var(--ht-olive-700);
  margin: 5px 0;
}
.dtt-row {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  line-height: 1.6;
}
.dtt-lbl { color: var(--ht-olive-400); }
.dtt-val { font-weight: 600; }
.dtt-nil { color: var(--ht-olive-600); font-weight: 400; }
.dtt-actual { color: #6ee7b7; }   /* green tint — confirmed actualTime */

.stn__body { min-width: 0; }
.stn__line1 { display: flex; align-items: center; gap: 6px; font-size: 12.5px; flex-wrap: wrap; }
.stn__name { font-weight: 600; color: var(--text); }
.stn--minor .stn__name { font-weight: 400; color: var(--text-dim); font-size: 11.5px; }
.stn__line2 { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 10.5px; color: var(--text-dim); }

.platform {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
  color: var(--ht-olive-800);
  background: var(--ht-olive-100);
  padding: 1px 6px; border-radius: 3px;
}
.platform--changed { color: var(--warn-dark); background: var(--warn-bg); }
.uic { font-family: var(--font-mono); font-size: 10px; color: var(--text-dim); }

.stn__times {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  font-family: var(--font-mono);
  font-size: 11.5px;
  min-width: 130px;
  text-align: right;
}
.stn__time-row { display: inline-flex; gap: 5px; align-items: baseline; }
.stn__time-label { font-size: 9.5px; color: var(--text-dim); letter-spacing: 0.04em; min-width: 26px; }
.stn__time-sched { color: var(--text-muted); }
.stn__time-arrow { color: var(--border-strong); }
.stn__time-actual { font-weight: 600; }
.stn__time-delay { font-size: 9.5px; font-weight: 700; color: var(--warn-dark); }

/* Station name quality indicators */
.station-name-replaced, .station-name-added {
  font-size: 9px;
  font-style: italic;
  color: var(--text-dim);
  border: 1px solid var(--border-soft);
  padding: 0 4px;
  border-radius: 2px;
}


/* =====================================================
   LOGS VIEWER (in detail section — legacy trace cards)
   ===================================================== */
.logs-viewer-section { padding: 12px 16px; }
.logs-tabs {
  display: flex;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  margin-bottom: 10px;
}
.logs-tab {
  flex: 1;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
}
.logs-tab.active {
  background: var(--surface-0);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

/* JSON viewer */
.json-viewer-section { padding: 12px 16px; }
.json-actions { display: flex; gap: 6px; margin-bottom: 8px; }
.json-toggle-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.json-toggle-btn:hover { background: var(--surface-2); color: var(--text); }
.json-viewer {
  background: var(--dark-1);
  border-radius: var(--r-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--dark-text);
  overflow-x: auto;
  white-space: pre;
  max-height: 400px;
  overflow-y: auto;
  line-height: 1.6;
}
.json-key { color: var(--ht-gold-300); }
.json-string { color: #9ece6a; }
.json-number { color: #ff9e64; }
.json-boolean { color: #7aa2f7; }
.json-null { color: var(--dark-muted); }
.json-bracket { color: var(--dark-text); }
.json-collapsible { cursor: pointer; user-select: none; }
.json-collapsible.json-expanded::before { content: '▼ '; font-size: 9px; opacity: 0.6; }
.json-collapsible.json-collapsed::before { content: '▶ '; font-size: 9px; opacity: 0.6; }
.json-content { padding-left: 16px; }


/* =====================================================
   LOGS PANEL (right sidebar — RTMDE trace logs)
   ===================================================== */
.logs-panel {
  background: var(--surface-0);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-left: 1px solid var(--border-soft);
  overflow: hidden;
}
.logs-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
.logs-head__row { display: flex; align-items: center; gap: 8px; }
.logs-head__title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ht-gold-600);
  display: flex; align-items: center; gap: 6px;
}
.logs-head__subject {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text);
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--surface-2);
}
.logs-head__actions { margin-left: auto; display: flex; gap: 2px; }
.log-iconbtn {
  width: 26px; height: 26px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  border-radius: 4px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.log-iconbtn:hover { background: var(--surface-2); color: var(--text); }

.logs-head__range { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.range-chip {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.range-chip:hover { color: var(--text); background: var(--surface-3); }
.range-chip.is-active {
  background: var(--ht-gold-500);
  color: var(--ht-olive-900);
  border-color: var(--ht-gold-600);
}
/* Provider Updates chip — visually de-emphasised (slow query) */
.range-chip[data-type="PROVIDER_UPDATE"] {
  opacity: 0.65;
  font-style: italic;
}
.range-chip[data-type="PROVIDER_UPDATE"]:hover,
.range-chip[data-type="PROVIDER_UPDATE"].is-active {
  opacity: 1;
  font-style: normal;
}

.logs-stream {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}

.logs-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 12.5px;
}

.logs-status-msg {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 6px 14px;
  border-top: 1px solid var(--border-soft);
  white-space: pre-wrap;
}
.logs-status-msg.success { color: var(--ok-dark); }
.logs-status-msg.error   { color: var(--err-dark); }
.logs-status-msg.loading { color: var(--text-muted); }
.logs-status-msg.warning { color: var(--warn-dark); }

.logs-foot {
  padding: 7px 14px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(45,157,110,0.2);
  animation: pulse 1.6s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%,100% { opacity: 1; box-shadow: 0 0 0 3px rgba(45,157,110,0.2); }
  50%      { opacity: 0.6; box-shadow: 0 0 0 6px rgba(45,157,110,0); }
}
.logs-count {
  padding: 4px 14px 6px;
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}


/* =====================================================
   PROVIDER UPDATE TRACE CARDS (in logs panel)
   ===================================================== */
.trace-card.provider-update,
.trace-card.consumer-get,
.trace-card.consumer-query {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  margin: 4px 10px;
  overflow: hidden;
  box-shadow: none;
}
.trace-card.provider-update:hover,
.trace-card.consumer-get:hover,
.trace-card.consumer-query:hover {
  border-color: var(--border);
  box-shadow: none;
}

.trace-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface-2);
  flex-wrap: wrap;
}
.trace-time { font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text); }
.trace-provider { font-family: var(--font-mono); font-size: 10.5px; color: var(--ht-gold-600); }
.trace-consumer { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); }
.trace-events-count { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

.trace-section { padding: 8px 12px; border-top: 1px solid var(--border-soft); }
.trace-section-title {
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.evt-section-header { cursor: pointer; }
.evt-section-header:hover { color: var(--text); }
.evt-expand-icon { color: var(--text-dim); font-size: 9px; }

.trace-flag {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 3px;
  font-size: 9.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}
.trace-flag.success { background: rgba(45,157,110,0.15); color: #6dd5a7; }
.trace-flag.info    { background: rgba(58,123,213,0.15); color: #8fb8f5; }
.trace-flag.warning { background: rgba(232,156,42,0.15); color: var(--ht-gold-400); }
.trace-flag.error   { background: rgba(216,69,69,0.15);  color: #ff8b8b; }

.trace-match-method { font-size: 11px; color: var(--text); font-family: var(--font-mono); }

.fuzzy-scores { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.fuzzy-total { font-family: var(--font-mono); font-size: 10px; font-weight: 700; color: var(--ht-gold-600); }
.score-item { display: flex; align-items: center; gap: 6px; }
.score-name { font-family: var(--font-mono); font-size: 9.5px; color: var(--text-muted); min-width: 80px; }
.score-bar { flex: 1; height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; }
.score-fill { height: 100%; border-radius: 2px; transition: width 0.3s; }

.change-badges { display: flex; flex-wrap: wrap; gap: 4px; }

.event-sel-summary { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 10.5px; margin-bottom: 6px; }
.event-sel-locations { color: var(--text-muted); }

.evt-detail-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.evt-detail-row {
  padding: 4px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 10.5px;
}
.evt-detail-row.modified { background: rgba(245,168,0,0.06); }
.evt-detail-main { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.evt-modify-icon { font-size: 10px; color: var(--text-dim); width: 14px; }
.evt-location { font-family: var(--font-mono); color: var(--text); }
.evt-location code { font-size: 9.5px; color: var(--text-dim); }
.evt-type { font-family: var(--font-mono); font-size: 9px; font-weight: 700; padding: 1px 4px; border-radius: 2px; }
.evt-type.arr { background: rgba(58,123,213,0.2); color: #8fb8f5; }
.evt-type.dep { background: rgba(45,157,110,0.2); color: #6dd5a7; }
.evt-significance { font-size: 9.5px; color: var(--text-muted); font-family: var(--font-mono); }
.evt-flag { display: inline-flex; padding: 1px 4px; border-radius: 2px; font-size: 9px; font-weight: 700; font-family: var(--font-mono); }
.evt-flag.newer  { background: rgba(245,168,0,0.15); color: var(--ht-gold-400); }
.evt-flag.master { background: rgba(58,123,213,0.15); color: #8fb8f5; }
.evt-flag.fwd    { background: rgba(45,157,110,0.15); color: #6dd5a7; }
.evt-times { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); margin-top: 2px; }
.evt-detail-timestamps { display: flex; gap: 12px; font-family: var(--font-mono); font-size: 9.5px; color: var(--text-dim); margin-top: 2px; }

.consolidation-summary, .dist-summary { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-muted); display: flex; gap: 10px; flex-wrap: wrap; }
.trace-validation-detail { font-family: var(--font-mono); font-size: 10px; color: #ff8b8b; word-break: break-all; }

.pipeline-track {
  position: relative;
  height: 28px;
  margin-top: 8px;
  background: var(--surface-3);
  border-radius: 3px;
}
.pipeline-total { font-family: var(--font-mono); font-size: 10px; font-weight: 600; color: var(--ht-gold-400); margin-left: 8px; }
.pipeline-step {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
}
.pipeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ht-gold-500); }
.pipeline-label { font-family: var(--font-mono); font-size: 8.5px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; }

.trace-ids, .trace-params, .trace-counts {
  padding: 6px 12px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-top: 1px solid var(--border-soft);
}
.trace-count { color: var(--text); }


/* =====================================================
   HISTOGRAM (provider updates)
   ===================================================== */
.histogram-section { padding: 10px 12px 6px; }
.histogram-title { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 6px; }
.histogram { display: flex; align-items: flex-end; gap: 2px; height: 44px; }
.hist-bar-wrap { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; justify-content: flex-end; position: relative; }
.hist-bar { width: 100%; border-radius: 2px 2px 0 0; background: var(--surface-3); min-height: 2px; }
.hist-bar.active { background: var(--ht-gold-500); opacity: 0.8; }
.hist-label { font-family: var(--font-mono); font-size: 7px; color: var(--text-dim); margin-top: 2px; }
.hist-count { font-family: var(--font-mono); font-size: 8px; color: var(--ht-gold-600); position: absolute; bottom: 18px; }

.hour-group { margin: 4px 10px; }
.hour-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  border: 1px solid var(--border-soft);
}
.hour-group-header:hover { background: var(--surface-3); }
.hour-group-time { font-weight: 700; color: var(--ht-gold-600); }
.hour-group-count { color: var(--text-muted); font-size: 10px; }
.hour-group-chevron { margin-left: auto; color: var(--text-dim); font-size: 10px; }
.hour-group.collapsed .hour-group-content { display: none; }
.hour-group.collapsed .hour-group-chevron::before { content: '▶'; }
.hour-group-content { margin-top: 4px; }


/* =====================================================
   SETTINGS MODAL
   ===================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31,34,26,0.5);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.settings-content {
  width: 640px;
  max-width: 94vw;
  background: var(--surface-0);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.settings-header h3 { font-size: 15px; font-weight: 600; margin: 0; }
.settings-close {
  width: 28px; height: 28px;
  border: none; background: transparent;
  font-size: 18px; color: var(--text-muted);
  cursor: pointer; border-radius: var(--r-sm);
  display: flex; align-items: center; justify-content: center;
}
.settings-close:hover { background: var(--surface-2); }
.settings-tabs {
  display: flex;
  gap: 2px;
  padding: 8px 24px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
  overflow-x: auto;
}
.settings-env-tab {
  padding: 5px 12px;
  border: 1px solid var(--border);
  background: var(--surface-0);
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  white-space: nowrap;
}
.settings-env-tab:hover { background: var(--surface-2); }
.settings-env-tab.active { background: var(--ht-olive-800); border-color: var(--ht-olive-800); color: #fff; }
.settings-env-tab.add-env { color: var(--ht-gold-600); border-color: var(--ht-gold-300); background: var(--ht-gold-50); }
.settings-panels { flex: 1; overflow-y: auto; padding: 16px 24px; }
.settings-panel { display: flex; flex-direction: column; gap: 12px; }
.settings-env-name { display: flex; align-items: center; gap: 8px; }
.settings-env-name label { font-size: 11px; color: var(--text-dim); min-width: 120px; }
.settings-input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--text);
  flex: 1;
}
.settings-input:focus { outline: none; border-color: var(--ht-gold-500); box-shadow: 0 0 0 3px rgba(245,168,0,0.15); }
.settings-group {
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-group legend { font-size: 11px; font-weight: 700; color: var(--text-muted); padding: 0 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.settings-group label { font-size: 10.5px; color: var(--text-dim); margin-top: 4px; }
.test-result { font-size: 12px; font-family: var(--font-mono); padding: 6px 0; color: var(--text-muted); }
.test-loading { color: var(--text-dim); }
.test-error { color: var(--err-dark); }
.btn-icon { background: transparent; border: none; color: var(--text-dim); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.btn-icon:hover { background: var(--err-bg); color: var(--err-dark); }
.remove-env-btn { color: var(--err-dark); }
.settings-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-1);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.btn-primary { background: var(--ht-gold-500); border-color: var(--ht-gold-600); color: var(--ht-olive-900); font-weight: 600; }
.btn-primary:hover { background: var(--ht-gold-400); }
.btn-secondary { background: var(--surface-0); border: 1px solid var(--border); color: var(--text-muted); }
.btn-secondary:hover { background: var(--surface-2); }

/* ─── Toggle switch (background subscription) ─────────────────────────────── */
.toggle-sw { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.toggle-sw input { display: none; }
.toggle-sw__knob {
  width: 32px; height: 18px;
  background: var(--border);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s;
}
.toggle-sw__knob::after {
  content: '';
  position: absolute;
  width: 12px; height: 12px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: left 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.toggle-sw input:checked + .toggle-sw__knob { background: var(--ok, #27ae60); }
.toggle-sw input:checked + .toggle-sw__knob::after { left: 17px; }

.bg-sub-row  { display: flex; align-items: center; gap: 8px; }
.bg-sub-label { font-size: 12px; color: var(--text-muted); flex: 1; }
.bg-sub-badge {
  font-size: 10px; font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-dim);
  white-space: nowrap;
}
.bg-sub-badge.is-active { color: var(--ok, #27ae60); }
.bg-sub-badge.is-error  { color: var(--err-dark); }
.bg-sub-hint {
  font-size: 10.5px;
  color: var(--text-dim);
  line-height: 1.45;
  padding-top: 2px;
}
.bg-sub-detail {
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  padding-top: 2px;
}
.bg-sub-detail.is-error { color: var(--err-dark); }

#settings-status {
  padding: 8px 24px;
  font-size: 12px;
  font-family: var(--font-mono);
  white-space: pre-wrap;
}

/* =====================================================
   NAV BADGE (unread live events count)
   ===================================================== */
.nav-badge {
  margin-left: auto;
  background: var(--ht-gold-500);
  color: var(--ht-olive-900);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  line-height: 1;
}

/* =====================================================
   LIVE VIEW — two-column layout
   ===================================================== */
.live-view {
  display: flex;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
}
.live-view.hidden { display: none; }

/* =====================================================
   LIVE SUBS — left panel (subscriptions)
   ===================================================== */
.live-subs {
  width: 300px;
  min-width: 260px;
  flex-shrink: 0;
  background: var(--surface-0);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.live-subs__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.live-subs__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.btn--sm {
  font-size: 11px;
  padding: 4px 10px;
  gap: 4px;
  height: 28px;
}

.subs-list {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.subs-empty {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  padding: 32px 16px;
}
.subs-empty--warn {
  color: var(--text-muted);
  font-style: italic;
}

.sub-card {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  position: relative;
}
.sub-card__name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}
.sub-card__meta {
  font-size: 10.5px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  line-height: 1.5;
}
.sub-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}
.sub-tag {
  font-size: 9.5px;
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.sub-card__del {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s;
}
.sub-card:hover .sub-card__del { opacity: 1; }
.sub-card__del:hover { background: var(--err-bg); color: var(--err-dark); }

.webhook-info-box {
  border-top: 1px solid var(--border-soft);
  padding: 10px 14px 12px;
  flex-shrink: 0;
}
.webhook-info-box__label {
  font-size: 9.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.webhook-info-box__url {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  word-break: break-all;
  margin-bottom: 6px;
  line-height: 1.4;
}
.webhook-info-box__copy {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}
.webhook-info-box__copy:hover { background: var(--surface-3, var(--surface-2)); color: var(--text-main); }

/* =====================================================
   LIVE STREAM — right panel (event feed)
   ===================================================== */
.live-stream {
  flex: 1 1 0;
  min-width: 0;
  background: var(--surface-0);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.live-stream__head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.live-stream__head-left {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.live-stream__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text);
}
.live-stream__subtitle {
  font-size: 10.5px;
  color: var(--text-dim);
}
.live-stream__count {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 1px 8px;
}
.live-stream__list {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Live event card */
.live-event {
  background: var(--surface-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  animation: slideInEvent 0.2s ease;
}
@keyframes slideInEvent {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.live-event__head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.live-event__time {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  flex-shrink: 0;
}
.live-event__count {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-left: auto;
}
.live-event__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.live-event__id {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  word-break: break-all;
  line-height: 1.4;
}
.live-event__actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
.live-event__open {
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.live-event__open:hover { background: var(--ht-gold-500); color: var(--ht-olive-900); border-color: var(--ht-gold-600); }

/* Slide-in animation for new (prepended) live events */
@keyframes liveSlideIn {
  from { opacity: 0; transform: translateY(-12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.live-event--new { animation: liveSlideIn 0.25s ease-out; }

/* Full UUID display */
.live-event__uuid {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-2, #aaa);
  letter-spacing: 0.02em;
  margin: 2px 0 4px;
  word-break: break-all;
}

/* Enriched train info line */
.live-event__train-info {
  font-size: 12px;
  color: var(--text-1, #ccc);
  margin: 2px 0 4px;
  opacity: 0.9;
  line-height: 1.5;
}
.enrich-brand {
  display: inline-block;
  background: var(--surface-3, #2a2a2a);
  border: 1px solid var(--border-soft, #444);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-0, #eee);
}
.enrich-num {
  font-weight: 600;
  color: var(--text-0, #eee);
}

/* Stats panel */
.live-stats-panel {
  padding: 12px 16px;
  background: var(--surface-1, #1e1e1e);
  border-bottom: 1px solid var(--border-soft, #333);
  font-size: 12px;
}
.live-stats-panel.hidden { display: none; }
.live-stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}
.live-stats-label {
  color: var(--text-2, #888);
  margin-right: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.live-stats-top5 {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.live-stats-top5 td { padding: 2px 8px 2px 0; color: var(--text-1, #ccc); }
.live-stats-top5 td:first-child { color: var(--text-2, #888); width: 20px; }

/* Icon button active state — use background+outline so emoji icons also show state clearly */
.iconbtn--active {
    color: var(--ht-amber, #f5a800) !important;
    background: rgba(245, 168, 0, 0.15) !important;
    outline: 1.5px solid var(--ht-amber, #f5a800);
    outline-offset: -1px;
}

/* Change indication badges */
.change-badge {
  font-size: 9px;
  font-weight: 700;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  border-radius: 4px;
  padding: 2px 6px;
  text-transform: uppercase;
  white-space: nowrap;
}
.change-badge--delay    { background: rgba(245,168,0,0.18); color: #f5a800; border: 1px solid rgba(245,168,0,0.3); }
.change-badge--platform { background: rgba(248,130,52,0.18); color: #f88234; border: 1px solid rgba(248,130,52,0.3); }
.change-badge--cancel   { background: rgba(220,60,60,0.18);  color: #e05252; border: 1px solid rgba(220,60,60,0.3); }
.change-badge--vehicle  { background: rgba(80,160,220,0.18); color: #50a0dc; border: 1px solid rgba(80,160,220,0.3); }
.change-badge--geo      { background: rgba(100,200,120,0.18); color: #64c878; border: 1px solid rgba(100,200,120,0.3); }
.change-badge--default  { background: var(--surface-3); color: var(--text-muted); border: 1px solid var(--border); }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15,18,10,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }


/* ═══════════════════════════════════
   SIDEBAR COLLAPSE (desktop + mobile)
   ═══════════════════════════════════ */

/* Desktop: sidebar width transition */
.sidebar { transition: width 0.25s ease; }

/* Desktop: icon-only collapsed state */
.sidebar-collapsed .sidebar {
  width: 52px;
  min-width: 52px;
}
.sidebar-collapsed .sidebar__brand-sub,
.sidebar-collapsed .nav-item span:not(.nav-item__icon),
.sidebar-collapsed .sidebar__section-title,
.sidebar-collapsed .sidebar__env, /* legacy, replaced by env-picker */
.sidebar-collapsed .sidebar__foot-meta,
.sidebar-collapsed .nav-badge {
  display: none;
}
.sidebar-collapsed .sidebar__brand {
  justify-content: center;
  padding: 18px 8px 20px;
}
.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px 0;
}
.sidebar-collapsed .nav-item__icon {
  margin: 0;
}
.sidebar-collapsed .sidebar__foot {
  justify-content: center;
  padding: 12px 8px;
}

/* Update grid column when collapsed — class is on <html> */
.sidebar-collapsed .rtmde-app {
  grid-template-columns: 52px 1fr;
}

/* Toggle button */
.sidebar-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  margin: 8px auto 4px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sidebar-toggle-btn:hover { background: var(--surface-2); color: var(--text); }

/* ═══════════════════════════════════
   MOBILE RESPONSIVE (≤ 767px)
   ═══════════════════════════════════ */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 6px;
  font-size: 18px;
  flex-shrink: 0;
}
.hamburger-btn:hover { background: var(--surface-2); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 149;
  background: rgba(0,0,0,0.55);
}

@media (max-width: 767px) {
  /* Show hamburger, hide desktop toggle */
  .hamburger-btn { display: flex; }
  .sidebar-toggle-btn { display: none; }

  /* Sidebar: fixed overlay from left */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 150;
    width: 240px !important;
    min-width: 240px !important;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: none;
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 32px rgba(0,0,0,0.6);
  }
  .sidebar-backdrop.mobile-open { display: block; }

  /* App grid: single column, sidebar removed from flow */
  .rtmde-app { grid-template-columns: 1fr !important; }
  .sidebar-collapsed .sidebar { width: 240px !important; min-width: 240px !important; }

  /* Topbar */
  .topbar { padding: 8px 10px; gap: 6px; }
  .topbar__title { font-size: 13px; }
  /* Hide load config button text, show icon only */
  .topbar .btn > span { display: none; }
  .topbar .btn { min-width: 0; padding: 0 10px; }

  /* Content: stack panels vertically */
  .content {
    flex-direction: column !important;
    overflow-y: auto;
    height: calc(100vh - 52px);
  }
  .search-panel {
    width: 100% !important;
    max-height: 260px;
    flex-shrink: 0;
    border-right: none !important;
    border-bottom: 1px solid var(--border-soft);
    overflow-y: auto;
  }
  .results {
    width: 100% !important;
    min-width: 0 !important;
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
  }

  /* Logs panel: horizontal strip at bottom */
  .logs-panel {
    width: 100% !important;
    min-width: 0 !important;
    height: 240px;
    flex-shrink: 0;
    border-left: none !important;
    border-top: 1px solid var(--border-soft);
    /* reset desktop collapsed sizing */
  }
  .logs-panel.collapsed {
    width: 100% !important;
    height: 32px !important;
    min-width: 0 !important;
  }
  .logs-toggle-tab {
    writing-mode: horizontal-tb !important;
    width: 100% !important;
    height: 32px !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: auto !important;
    transform: none !important;
    border-radius: 0 !important;
    border-top: 1px solid var(--border-soft);
    border-right: none !important;
    padding: 0 12px;
    text-align: left;
    justify-content: flex-start;
  }
  /* Expanded logs tab: back to absolute, but horizontal */
  .logs-panel:not(.collapsed) .logs-toggle-tab {
    position: relative;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    border-radius: 0 !important;
    width: 100% !important;
    height: 28px !important;
  }

  /* Live view: stack vertically */
  .live-view { flex-direction: column !important; }
  .live-subs {
    width: 100% !important;
    min-width: 0 !important;
    max-height: 220px;
    overflow-y: auto;
    border-right: none !important;
    border-bottom: 1px solid var(--border-soft);
  }
  .live-stream { flex: 1; overflow-y: auto; min-height: 200px; }

  /* Touch targets */
  .nav-item { min-height: 44px; }
  .tabs__tab { min-height: 40px; }
  .live-event__open { min-height: 40px; padding: 8px 14px; }
  .btn { min-height: 40px; }
  .iconbtn { width: 40px; height: 40px; }

  /* Fix: topbar must always stay visible — make .main scrollable,
     topbar sticky. This prevents mobile Safari from scrolling it off-screen. */
  .main {
    overflow-x: hidden;
    overflow-y: auto;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface-1);
  }

  /* Map: full-height on mobile */
  .map-view { height: calc(100svh - 52px); }
  .map-panel { max-width: calc(100vw - 20px); left: 10px; right: 10px; }
}

/* ═══════════════════════════════════════
   MAP VIEW
   ═══════════════════════════════════════ */

/* ─── Map view wrapper ─── */
.map-view {
  display: flex;
  flex-direction: row;
  height: calc(100vh - 52px);
  min-height: 300px;
  overflow: hidden;
}
.map-view.hidden { display: none; }

/* ─── Map area (left): contains Leaflet + floating panel ─── */
.map-area {
  flex: 1;
  position: relative;
  min-width: 0;
  overflow: hidden;
}

/* ─── Leaflet container fills the map area ─── */
#map-container {
  width: 100%;
  height: 100%;
  min-height: 300px;
  background: #e8e8e0;
}

/* ─── Train list sidebar (right) ─── */
.map-sidebar {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-0);
  border-left: 1px solid var(--border-soft);
  overflow: hidden;
}
.map-sidebar__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.map-sidebar__title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.map-sidebar__count {
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--surface-2);
  border-radius: 10px;
  padding: 1px 8px;
  color: var(--text-muted);
}
.map-sidebar__list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.map-sidebar__empty {
  padding: 20px 14px;
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
}

/* ─── Train list items ─── */
.map-train-item {
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-soft);
  transition: background 0.1s;
}
.map-train-item:hover { background: var(--surface-1); }
.map-train-item.is-active { background: var(--ht-gold-50); border-left: 3px solid var(--ht-gold-500); padding-left: 11px; }
.map-train-item__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 2px;
}
.map-train-item__name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.map-train-item__delay {
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 8px;
  flex-shrink: 0;
}
.map-train-item__delay--ok   { background: var(--ok-bg);   color: var(--ok-dark); }
.map-train-item__delay--warn { background: var(--warn-bg);  color: var(--warn-dark); }
.map-train-item__delay--err  { background: var(--err-bg);   color: var(--err-dark); }
.map-train-item__route {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.map-train-item__segment {
  font-size: 10.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Floating overlay panel (inside .map-area which is position:relative) ─── */
.map-panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 800;
  background: var(--surface-0);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  padding: 10px 14px;
  min-width: 220px;
  max-width: 300px;
  pointer-events: all;
}
.map-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.map-panel__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}
.map-panel__refresh {
  width: 26px; height: 26px;
  flex-shrink: 0;
}
.map-panel__stats {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1.4;
}
.map-panel__controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.map-layer-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.map-layer-toggle input[type=checkbox] { margin: 0; cursor: pointer; }
.map-panel__legend {
  font-size: 10px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding-top: 6px;
  border-top: 1px solid var(--border-soft);
}
.map-legend-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.map-legend-dot--outline {
  background: var(--surface-2);
  border: 1.5px solid var(--border-strong);
}

/* ─── Train markers (Leaflet DivIcon) ─── */
.train-marker {
  background: none !important;
  border: none !important;
}
.train-marker__pill {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px 3px 5px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35), 0 0 0 1.5px rgba(255,255,255,0.25);
  cursor: pointer;
  transition: transform 0.1s;
}
.train-marker__pill:hover { transform: scale(1.08); }
.train-marker__icon { font-size: 12px; line-height: 1; }

/* Pulsing dot for trains currently en route */
.train-marker__pill.is-en-route::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.8);
  animation: trainPulse 1.5s ease-in-out infinite;
  margin-right: 2px;
}
@keyframes trainPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ─── Popup content ─── */
.map-popup {
  font-family: var(--font-sans);
  font-size: 12px;
  min-width: 200px;
  line-height: 1.5;
}
.map-popup__name {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}
.map-popup__route {
  color: var(--text-muted);
  margin-bottom: 6px;
  font-size: 11px;
}
.map-popup__status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  margin-bottom: 6px;
}
.map-popup__status--ok   { background: var(--ok-bg);   color: var(--ok-dark); }
.map-popup__status--warn { background: var(--warn-bg);  color: var(--warn-dark); }
.map-popup__status--err  { background: var(--err-bg);   color: var(--err-dark); }
.map-popup__events {
  margin-top: 6px;
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.map-popup__event-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 11px;
  padding: 2px 0;
}
.map-popup__event-type {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  min-width: 24px;
}
.map-popup__event-station { flex: 1; color: var(--text); }
.map-popup__event-time    { font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); white-space: nowrap; }
/* Planned time when there's a delay (shown with strikethrough) */
.map-popup__plan--delayed { text-decoration: line-through; opacity: 0.55; }
/* Actual/estimated time variants */
.map-popup__act--late     { font-family: var(--font-mono); font-size: 10px; color: var(--warn-dark); font-weight: 600; white-space: nowrap; }
.map-popup__act--verylate { font-family: var(--font-mono); font-size: 10px; color: var(--err-dark);  font-weight: 600; white-space: nowrap; }
.map-popup__act--early    { font-family: var(--font-mono); font-size: 10px; color: var(--ok-dark);   font-weight: 600; white-space: nowrap; }
/* Cancelled stop marker inside popup */
.map-popup__stop-cancel   { color: var(--err-dark); font-size: 9px; font-weight: 700; }
.map-popup__event-row.is-past .map-popup__event-station,
.map-popup__event-row.is-past .map-popup__event-time { color: var(--text-dim); }
.map-popup__event-row.is-current { font-weight: 600; }
.map-popup__event-row.is-current .map-popup__event-station { color: var(--ht-gold-600); }

/* ─── Sidebar filters ────────────────────────────────────────── */
.map-sidebar__filters {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-0);
}
.map-filter-sep { width: 100%; height: 0; margin: 0; }
.map-filter-chip {
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: transparent;
  color: var(--text-dim);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  line-height: 1.6;
}
.map-filter-chip:hover { background: var(--surface-1); color: var(--text); }
.map-filter-chip.is-active { background: var(--ht-gold-500,#d4a843); color: #fff; border-color: transparent; }
.map-filter-chip.is-active.is-issue { background: var(--err-dark); }
/* Cancelled train row tint */
.map-train-item.is-cancelled { opacity: 0.75; }
/* Cancelled stop indicator dot */
.map-stop-cancel-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--err-bg);
  color: var(--err-dark);
  font-size: 9px;
  font-weight: 700;
  margin-left: 2px;
  vertical-align: middle;
}

/* ─── Map panel collapse ─── */
.map-panel__collapse-btn {
  color: var(--text-dim);
  transition: background 0.15s;
}
.map-panel__collapse-btn svg {
  transition: transform 0.2s ease;
}
.map-panel--collapsed .map-panel__collapse-btn svg {
  transform: rotate(180deg);
}
.map-panel--collapsed .map-panel__header {
  margin-bottom: 0;
}
.map-panel--collapsed .map-panel__stats,
.map-panel--collapsed .map-panel__controls,
.map-panel--collapsed .map-panel__legend {
  display: none;
}

/* ─── Map sidebar collapse ─── */
.map-sidebar {
  transition: width 0.2s ease;
}
.map-sidebar__collapse-btn {
  color: var(--text-dim);
  transition: background 0.15s;
}
.map-sidebar__collapse-btn svg {
  transition: transform 0.2s ease;
}
.map-sidebar--collapsed {
  width: 36px;
  min-width: 36px;
}
.map-sidebar--collapsed .map-sidebar__head {
  justify-content: center;
  padding: 10px 0;
}
.map-sidebar--collapsed .map-sidebar__title,
.map-sidebar--collapsed .map-sidebar__count,
.map-sidebar--collapsed .map-sidebar__filters,
.map-sidebar--collapsed .map-sidebar__list {
  display: none;
}
.map-sidebar--collapsed .map-sidebar__collapse-btn svg {
  transform: rotate(180deg);
}

/* ─── Route polylines: Leaflet adds these via JS ─── */
/* (no extra CSS needed — styled via L.polyline options) */

/* ─── Refresh spinner ─── */
.map-panel__refresh.is-loading svg {
  animation: mapRefreshSpin 0.8s linear infinite;
}
@keyframes mapRefreshSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* =========================================================
   ANALYTICS VIEW
   ========================================================= */

.analytics-view {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: var(--color-bg);
}

/* Topbar */
.analytics-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
    flex-wrap: wrap;
}
.analytics-topbar__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}
.analytics-topbar__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Scrollable body */
.analytics-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Card */
.analytics-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.analytics-card__head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-bg);
}
.analytics-card__icon {
    font-size: 1.1em;
    flex-shrink: 0;
}
.analytics-card__title {
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0;
    flex-shrink: 0;
}
.analytics-card__sub {
    font-size: 0.78rem;
    color: var(--color-text-muted, #6b7280);
    flex: 1;
    min-width: 0;
}
.analytics-card__body {
    padding: 14px 16px;
}

/* States */
.analytics-loading {
    color: var(--color-text-muted, #6b7280);
    font-size: 0.85rem;
    padding: 4px 0;
}
.analytics-error {
    color: #dc2626;
    font-size: 0.85rem;
}
.analytics-note {
    font-size: 0.82rem;
    color: var(--color-text-muted, #6b7280);
    margin: 4px 0;
    line-height: 1.5;
}

/* KPI row */
.analytics-kpi-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.analytics-kpi {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 80px;
}
.analytics-kpi__val {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-text, #111);
}
.analytics-kpi__val--green  { color: #16a34a; }
.analytics-kpi__val--amber  { color: #d97706; }
.analytics-kpi__val--blue   { color: #2563eb; }
.analytics-kpi__label {
    font-size: 0.72rem;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Section sub-title */
.analytics-section-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

/* Bar chart */
.analytics-bars {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.analytics-bar-row {
    display: grid;
    grid-template-columns: 140px 1fr 50px;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
}
.analytics-bar-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--color-text, #111);
}
.analytics-bar-track {
    height: 10px;
    background: var(--color-border, #e5e7eb);
    border-radius: 5px;
    overflow: hidden;
}
.analytics-bar-fill {
    height: 100%;
    background: #3b82f6;
    border-radius: 5px;
    transition: width 0.3s ease;
}
.analytics-bar-count {
    text-align: right;
    color: var(--color-text-muted, #6b7280);
}

/* Data table */
.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.analytics-table th {
    text-align: left;
    padding: 5px 8px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text-muted, #6b7280);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
}
.analytics-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--color-border, #e5e7eb);
    color: var(--color-text, #111);
}
.analytics-table tbody tr:last-child td {
    border-bottom: none;
}
.analytics-table tbody tr:hover td {
    background: var(--color-bg-hover, rgba(0,0,0,0.03));
}

/* Log tail */
.log-tail {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-family: ui-monospace, 'Cascadia Code', 'Fira Code', monospace;
    font-size: 0.72rem;
    max-height: 440px;
    overflow-y: auto;
}
.log-line {
    display: grid;
    grid-template-columns: 190px 45px 1fr;
    gap: 6px;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1.4;
}
.log-line:hover {
    background: var(--color-bg-hover, rgba(0,0,0,0.04));
}
.log-ts  { color: var(--color-text-muted, #9ca3af); white-space: nowrap; }
.log-lvl { font-weight: 700; }
.log-msg { word-break: break-all; color: var(--color-text, #111); }
.log-info .log-lvl  { color: #3b82f6; }
.log-warn .log-lvl  { color: #d97706; }
.log-error .log-lvl { color: #dc2626; }
.log-error          { background: rgba(220,38,38,0.05); }

/* ─── Users panel ────────────────────────────────────────────────────────── */
.users-view {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
}
.users-view__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 14px; border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.users-view__title { font-size: 1rem; font-weight: 600; color: var(--text); }
.users-view__body  { overflow-y: auto; flex: 1; padding: 16px 24px; }

.users-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.users-table th {
  text-align: left; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-dim);
  padding: 0 10px 8px; border-bottom: 1px solid var(--border-soft);
}
.users-table td {
  padding: 10px 10px; border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.users-table tr:last-child td { border-bottom: none; }
.ut-name   { font-weight: 500; color: var(--text); }
.ut-actions{ text-align: right; white-space: nowrap; }
.ut-actions .btn { margin-left: 6px; }

.role-tag {
  display: inline-block; padding: 2px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; margin-right: 3px;
}
.role-tag--consumer { background: #dbeafe; color: #1e40af; }
.role-tag--provider { background: #f3e8ff; color: #6d28d9; }
.role-tag--map      { background: #dcfce7; color: #166534; }
.role-tag--admin    { background: #fef3c7; color: #92400e; }

.org-badge {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 4px; font-size: 11px; font-weight: 500;
  background: #e0f2fe; color: #0369a1;
}
.org-badge--global {
  background: #dcfce7; color: #166534;
}

/* ─── Edit page (user / org — replaces modals) ───────────────────────────── */
.edit-view {
  display: flex; flex-direction: column; height: 100%;
  background: var(--surface-0);
}
.edit-view__header {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0; background: var(--surface-0);
}
.edit-view__title { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0; }
.edit-view__body  { flex: 1; overflow-y: auto; padding: 24px; background: var(--surface-1); }
.edit-view__form  {
  max-width: 600px; background: #fff;
  border: 1px solid var(--border-soft); border-radius: 10px; padding: 24px;
}
.edit-view__footer {
  padding: 12px 24px; border-top: 1px solid var(--border-soft);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-0); flex-shrink: 0;
}
.form-section-title {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-muted);
  margin: 20px 0 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border-soft);
}
.form-section-sub { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-dim); }
.form-section-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.btn--file-load {
  font-size: 11.5px; padding: 4px 10px;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 6px; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  transition: background .15s, color .15s;
}
.btn--file-load:hover { background: var(--ht-olive-100); color: var(--text); }
.file-load-status {
  font-size: 11px; color: #166534; background: #dcfce7;
  padding: 2px 8px; border-radius: 4px; display: none;
}

/* ─── User / Org form fields ──────────────────────────────────────────────── */
.form-row { margin-bottom: 14px; }
.form-row .field__label {
  display: block; font-size: 11.5px; font-weight: 600;
  color: var(--text-dim); margin-bottom: 5px;
}
.field__hint {
  font-size: 11px; color: var(--text-dim); margin-top: 2px; line-height: 1.5;
}
.form-error {
  margin-top: 10px; padding: 8px 12px; background: #fef2f2;
  border-radius: 6px; font-size: 12px; color: #dc2626;
}

.role-checkboxes { display: flex; flex-direction: column; gap: 6px; }
.role-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--text); cursor: pointer;
}
.role-check input[type="checkbox"] { width: 14px; height: 14px; cursor: pointer; }
.role-hint { font-size: 11px; color: var(--text-dim); }

.um-env-block {
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 12px 14px; margin-bottom: 10px;
}
.um-env-title {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-dim); margin-bottom: 10px;
}
.um-env-row {
  display: grid; grid-template-columns: 140px 1fr;
  align-items: center; gap: 8px; margin-bottom: 8px;
}
.um-env-row:last-child { margin-bottom: 0; }
.um-env-label { font-size: 11px; color: var(--text-dim); }
.field__input--sm { padding: 6px 9px; font-size: 12px; }

/* ─── Sidebar logout button ──────────────────────────────────────────────── */
.sidebar__foot { position: relative; }
.sidebar__foot-user {
  font-size: 10px; color: var(--text-dim); margin-top: 1px; font-style: italic;
}
.sidebar__logout-btn {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; padding: 6px; border-radius: 6px;
  transition: background .15s, color .15s;
}
.sidebar__logout-btn:hover { background: var(--surface-2); color: var(--text); }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn--danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fca5a5; }
.btn--danger:hover { background: #fecaca; }
.btn--sm { padding: 4px 10px; font-size: 12px; }

/* ─── Monitoring dashboard ────────────────────────────────────────────────── */
.monitor-kpis {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.monitor-kpi {
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: 8px; padding: 10px 16px; min-width: 100px;
}
.monitor-kpi__val   { font-size: 20px; font-weight: 700; color: var(--text); line-height: 1.2; }
.monitor-kpi__label { font-size: 11px; color: var(--text-dim); margin-top: 2px; text-transform: uppercase; letter-spacing: .04em; }

.monitor-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.monitor-chart  { background: var(--surface-1); border: 1px solid var(--border-soft); border-radius: 8px; padding: 12px 14px; }
.monitor-chart__label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

.sparkline-wrap { }
.sparkline-range {
  display: flex; justify-content: space-between; margin-top: 4px;
  font-size: 10.5px; color: var(--text-dim);
}
.sparkline-last { font-weight: 600; }

.monitor-note { font-size: 12.5px; color: var(--text-dim); font-style: italic; padding: 8px 0; }
.monitor-sub-title { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin: 18px 0 8px; }

.monitor-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.monitor-table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-dim);
  padding: 6px 10px; border-bottom: 1px solid var(--border-soft);
}
.monitor-table td { padding: 7px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
.monitor-table tr:last-child td { border-bottom: none; }

.monitor-event-bars { display: flex; flex-direction: column; gap: 6px; }
.monitor-event-bar  { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.monitor-event-bar__label { width: 130px; flex-shrink: 0; color: var(--text); }
.monitor-event-bar__track { flex: 1; background: var(--surface-1); border-radius: 4px; height: 8px; overflow: hidden; }
.monitor-event-bar__fill  { height: 100%; background: #4f6bb8; border-radius: 4px; transition: width .4s; }
.monitor-event-bar__count { width: 36px; text-align: right; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Activity feed */
.act-feed { display: flex; flex-direction: column; gap: 0; font-size: 12.5px; }
.act-feed__row {
  display: grid;
  grid-template-columns: 22px 90px 100px 1fr auto;
  gap: 8px; align-items: center;
  padding: 6px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.act-feed__row:last-child { border-bottom: none; }
.act-feed__icon  { text-align: center; }
.act-feed__user  { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-feed__org   { color: var(--text-dim); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-feed__event { color: var(--text); }
.act-feed__env   { display: inline-block; background: var(--surface-2); border-radius: 3px; font-size: 10px; padding: 1px 5px; margin-left: 4px; font-weight: 600; color: var(--text-dim); }
.act-feed__time  { color: var(--text-dim); font-size: 11px; white-space: nowrap; }

/* ─── Account button + dropdown ──────────────────────────────────────────── */
.account-wrap {
  position: relative;
}
.account-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: var(--r-md);
  background: var(--surface-1); border: 1px solid var(--border-soft);
  color: var(--text); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s;
  white-space: nowrap;
}
.account-btn:hover { background: var(--surface-2); }
.account-btn__name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.account-btn__caret { color: var(--text-dim); flex-shrink: 0; }

.account-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--surface-0);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.13);
  min-width: 190px;
  z-index: 9999;
  padding: 6px 0;
}
.account-menu__user {
  padding: 8px 14px 6px;
  font-size: 12px; font-weight: 600;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 4px;
}
.account-menu__item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 14px;
  background: none; border: none;
  font-size: 13px; color: var(--text);
  cursor: pointer; text-align: left;
  transition: background .12s;
}
.account-menu__item:hover { background: var(--surface-1); }
.account-menu__item--danger { color: #b91c1c; }
.account-menu__item--danger:hover { background: #fef2f2; }
.account-menu__sep {
  height: 1px; background: var(--border-soft); margin: 4px 0;
}

/* ── Changelog / Version History ────────────────────────────── */
.changelog-view {
  flex: 1 1 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.changelog-inner {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 28px 32px;
  max-width: 760px;
}
.cl-version {
  margin-bottom: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border-soft);
}
.cl-version:last-child {
  border-bottom: none;
}
.cl-version__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.cl-version__num {
  font-size: 15px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text);
  letter-spacing: -0.02em;
}
.cl-version__tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  letter-spacing: 0.02em;
}
.cl-version__date {
  font-size: 11.5px;
  color: var(--text-dim);
  margin-left: auto;
  font-family: var(--font-mono);
}
.cl-version__list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cl-version__list li {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}
.cl-version__list li::marker {
  color: var(--border);
}

/* ── Backup & Restore card ───────────────────────────────────── */
.backup-section { padding: 4px 0 12px; }
.backup-section__title {
  font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-dim); margin-bottom: 6px;
}
.backup-section__desc {
  font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.5;
}
.backup-section__desc code {
  font-family: var(--font-mono); background: var(--surface-2);
  padding: 1px 5px; border-radius: 3px; font-size: 11.5px;
}
.backup-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.backup-divider {
  height: 1px; background: var(--border-soft); margin: 16px 0;
}
.backup-filename {
  font-size: 12px; color: var(--text-muted); font-family: var(--font-mono);
}
.restore-preview {
  margin: 10px 0; padding: 10px 14px;
  background: var(--surface-1); border: 1px solid var(--border-soft);
  border-radius: 6px; font-size: 12.5px; line-height: 1.6;
}
.restore-preview.hidden { display: none; }
.backup-status { margin-top: 8px; font-size: 12.5px; min-height: 18px; }
.backup-status--ok      { color: var(--ok-dark); }
.backup-status--error   { color: #b91c1c; }
.backup-status--loading { color: var(--text-dim); }
.btn--danger {
  background: #dc2626; color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px; font-size: 12.5px;
  font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background .12s;
}
.btn--danger:hover { background: #b91c1c; }
