:root {
  --bg: #f4f0e8;
  --paper: rgba(255, 252, 247, 0.94);
  --ink: #182126;
  --muted: #60707b;
  --line: rgba(24, 33, 38, 0.1);
  --zet-blue: #005baa;
  --stop-a: #f2c300;
  --stop-b: #d72638;
  --shadow: 0 20px 60px rgba(24, 33, 38, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(242, 195, 0, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(0, 91, 170, 0.18), transparent 28%),
    var(--bg);
}

.data-attribution {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font: 400 0.75rem/1.45 "Segoe UI", sans-serif;
}

.data-attribution a {
  color: var(--zet-blue);
}

/* Aplikacija zauzima cijeli ekran: karta je fiksna, a samo panel se skrola. */
.shell {
  display: grid;
  grid-template-columns: 360px 1fr;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px;
  background: var(--paper);
  backdrop-filter: blur(18px);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
  z-index: 2;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-head h1 { flex: 1; }

h1 {
  margin: 0 0 24px;
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 0.95;
}

.panel-head h1 {
  margin-bottom: 0;
}

.view-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 12px 0 18px;
  padding: 4px;
  border-radius: 16px;
  background: rgba(0, 91, 170, 0.08);
}

.view-tab {
  padding: 10px 12px;
  color: var(--zet-blue);
  background: transparent;
  border-color: transparent;
}

.view-tab.active {
  color: white;
  background: var(--zet-blue);
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel {
  min-height: 0;
}

.compact-field {
  margin-bottom: 10px;
}

.compact-field select,
.compact-field input {
  padding: 10px 12px;
}

.stop-picker-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
}

.stop-picker-box input {
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}

.stop-picker.has-selection .stop-picker-box input {
  display: none;
}

/* Odabrana stanica: pozadina je široka samo koliko i naziv, a ne cijeli panel. */
.stop-picker.has-selection .stop-picker-box {
  width: fit-content;
  max-width: 100%;
}

.stop-picker.has-selection .stop-list {
  justify-items: start;
}

.stop-picker.has-selection .stop-list-item {
  width: auto;
  max-width: 100%;
  gap: 16px;
}

.stop-list {
  display: grid;
  gap: 6px;
  max-height: min(38vh, 360px);
  overflow-y: auto;
  padding: 6px;
}

.stop-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  text-align: left;
  color: var(--ink);
  background: white;
  border-radius: 12px;
}

.stop-list-item.active {
  color: white;
  background: var(--zet-blue);
  border-color: var(--zet-blue);
}

.stop-list-close {
  font: 700 1.2rem/1 "Segoe UI", sans-serif;
}

.back-link {
  display: grid;
  place-items: center;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: white;
  border: 1px solid var(--line);
  color: var(--zet-blue);
  text-decoration: none;
  font: 700 1.6rem/1 "Segoe UI", sans-serif;
}

.back-link:hover {
  background: #eef6ff;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span,
.stat-label,
.meta,
.legend,
.back-link {
  font-family: "Segoe UI", sans-serif;
}

select,
input,
button {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--line);
  font-size: 1rem;
}

select,
input {
  padding: 14px 16px;
  background: white;
}

button {
  padding: 14px 16px;
  background: var(--zet-blue);
  color: white;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled,
select:disabled,
input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button[hidden] {
  display: none;
}

.meta {
  color: var(--muted);
  line-height: 1.5;
}

.meta p {
  margin: 8px 0;
}

.refresh-time.stale,
.realtime-unavailable {
  color: #b42318;
  font-weight: 700;
}

.feed-notice {
  display: block;
  margin-top: 4px;
  color: #b42318;
  font-weight: 600;
}

.refresh-meta.unavailable {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(180, 35, 24, 0.35);
  border-radius: 12px;
  background: rgba(180, 35, 24, 0.08);
}

.service-alert-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid rgba(180, 83, 9, 0.35);
  border-radius: 14px;
  background: #fff7ed;
  color: #7c2d12;
  font: 600 0.86rem/1.45 "Segoe UI", sans-serif;
}

.service-alert-banner a {
  color: #9a3412;
}

.vehicle-list-wrap {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.arrivals-wrap {
  margin-top: 14px;
}

.vehicle-list-wrap h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.vehicle-lists {
  display: grid;
  gap: 12px;
}

.vehicle-group {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
}

.vehicle-group h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-family: "Segoe UI", sans-serif;
}

.vehicle-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.arrival-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.arrival-columns.single {
  grid-template-columns: 1fr;
}

.arrival-direction-button {
  all: unset;
  display: block;
  box-sizing: border-box;
  width: 100%;
  cursor: pointer;
  color: var(--zet-blue);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.arrival-direction-button:focus-visible {
  outline: 2px solid var(--zet-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.stop-direction-back,
.arrival-show-more {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--zet-blue);
  font: 600 0.85rem "Segoe UI", sans-serif;
  cursor: pointer;
}

.stop-direction-back {
  margin: 0 0 8px;
  text-align: left;
}

.arrival-column {
  padding: 8px;
  min-width: 0;
}

.arrival-column h3 {
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.arrival-column ul {
  gap: 6px;
}

.arrival-column .vehicle-item {
  padding: 6px 8px;
  border-radius: 10px;
}

.arrival-column .vehicle-title {
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.arrival-column .vehicle-subtitle,
.arrival-column .vehicle-meta {
  font-size: 0.75rem;
}

.vehicle-item {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.vehicle-item:hover {
  transform: translateY(-1px);
}

/* Vozilo koje je upravo prošlo odabranu stanicu: zasivljeno u popisu i na karti. */
.vehicle-item.passed {
  background: #eef0f1;
  filter: grayscale(1);
  opacity: 0.7;
}

.leaflet-marker-icon.is-passed {
  filter: grayscale(1);
}

.vehicle-item.active {
  border-color: var(--zet-blue);
  box-shadow: 0 0 0 3px rgba(0, 91, 170, 0.12);
}

.vehicle-title {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.vehicle-subtitle {
  display: block;
  font-size: 0.9rem;
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
}

.vehicle-meta {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
  margin-top: 2px;
}

.vehicle-empty {
  margin: 0;
  color: var(--muted);
  font-family: "Segoe UI", sans-serif;
}

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 24px;
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: auto;
  padding-top: 24px;
}

.stat {
  padding: 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.8rem;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-right: 8px;
}

.dot-stop-a {
  background: var(--stop-a);
}

.dot-stop-b {
  background: var(--stop-b);
}

.dot-vehicle {
  background: var(--zet-blue);
}

.panel > * {
  flex-shrink: 0;
}

.map-wrap,
#map {
  height: 100%;
  min-height: 0;
}

.map-wrap {
  position: relative;
  overflow: hidden;
}

#map {
  width: 100%;
}

#vehicle-list-desktop-slot:empty {
  display: none;
}

#vehicle-list-desktop-slot {
  flex: 1 1 auto;
}

.stop-marker {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stop-marker.direction-a {
  background: var(--stop-a);
}

.stop-marker.direction-b {
  background: var(--stop-b);
}

.stop-marker.terminal {
  width: 15px;
  height: 15px;
  border-width: 3px;
}

.vehicle-marker {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: var(--zet-blue);
  border: 2px solid white;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25);
  color: white;
  font: 800 0.72rem/1 "Segoe UI", sans-serif;
}

.vehicle-heading {
  position: absolute;
  left: 50%;
  top: -11px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 10px solid currentColor;
  transform-origin: 5px 26px;
}

.vehicle-marker.highlighted {
  border-color: #f2c300;
  box-shadow: 0 0 0 4px rgba(242, 195, 0, 0.25), 0 5px 15px rgba(0, 0, 0, 0.25);
}

.leaflet-popup-content {
  font-family: "Segoe UI", sans-serif;
  line-height: 1.45;
}

@media (max-width: 900px) {
  /* Mobilni prikaz: karta je fiksno na vrhu ekrana, a samo panel ispod nje se skrola. */
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh minmax(0, 1fr);
    grid-template-rows: 55dvh minmax(0, 1fr);
  }

  .map-wrap {
    order: -1;
    border-bottom: 1px solid var(--line);
  }

  .panel {
    padding: 14px;
    border-right: 0;
    box-shadow: none;
  }

  /* Na širokom prozoru s uskim rasporedom sadržaj panela ne ide preko cijele širine (kartice, pozadine). */
  .panel > * {
    width: 100%;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
  }

  .panel-head { gap: 10px; margin-bottom: 6px; }
  .panel-head h1 { font-size: 1.35rem; align-self: center; }
  .panel-head .back-link { width: 34px; height: 34px; }

  .view-tabs { margin: 8px 0 12px; }
  .view-tab { padding: 8px 10px; }

  .field { margin-bottom: 10px; }

  .stats { padding-top: 12px; gap: 8px; }
  .stat { padding: 8px 12px; border-radius: 12px; }
  .stat strong { margin-top: 2px; font-size: 1.3rem; }

  .vehicle-list-wrap { margin-top: 14px; padding-top: 12px; }

  .data-attribution { font-size: 0.7rem; margin-top: 14px; padding-top: 10px; }

}

.map-toolbar {
  position: absolute;
  z-index: 800;
  top: 10px;
  left: 58px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-filter {
  display: flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
}

.mode-filter button {
  width: auto;
  padding: 7px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--zet-blue);
  font: 600 0.85rem "Segoe UI", sans-serif;
  cursor: pointer;
}

.mode-filter button.active {
  background: var(--zet-blue);
  color: #fff;
}

.back-link[hidden] {
  display: none;
}

.mode-filter button:disabled {
  opacity: 0.6;
  cursor: default;
}

.debug-panel {
  position: absolute;
  z-index: 800;
  right: 10px;
  bottom: 28px;
  display: grid;
  gap: 4px;
  max-width: min(320px, calc(100% - 20px));
  max-height: 40%;
  overflow-y: auto;
  padding: 10px;
  border: 1px solid rgba(180, 35, 24, 0.4);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
  font: 400 0.8rem/1.3 "Segoe UI", sans-serif;
}

.debug-panel[hidden] {
  display: none;
}

.debug-panel button {
  padding: 5px 8px;
  border-radius: 8px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.vehicle-marker.off-route {
  outline: 3px dashed #d72638;
  outline-offset: 2px;
}

@media (max-width: 900px) {
  .debug-panel {
    bottom: 60px;
  }
}

.debug-panel button.at-terminus {
  background: #eef1f4;
  color: var(--muted);
  border-color: var(--line);
}

.vehicle-popup {
  min-width: 220px;
  font-family: "Segoe UI", sans-serif;
  font-size: 0.85rem;
  line-height: 1.35;
}

/* Detalji: fiksna širina, da se popup ne mijenja pri otvaranju veza; duži tekst prelazi u novi red. */
.vehicle-popup.details {
  width: min(300px, calc(100vw - 90px));
  overflow-wrap: anywhere;
}

.vehicle-popup-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  padding-right: 14px;
  font-size: 0.9rem;
}

.popup-nav {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

.popup-nav a {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #eef3f9;
  font-size: 1.1rem;
  line-height: 1;
}

.vehicle-popup-note {
  color: var(--muted);
}

.vehicle-popup-stops {
  display: grid;
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.vehicle-popup-stops li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.vehicle-popup-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.vehicle-popup-time small {
  color: var(--muted);
  font-weight: 400;
}

.vehicle-marker.garage {
  filter: grayscale(1);
  opacity: 0.7;
}

.vehicle-popup-note {
  margin-bottom: 4px;
}

.vehicle-popup-warn {
  color: #b42318;
  font-weight: 600;
}

.bajs-toggle {
  width: auto;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.16);
  color: #0080ff;
  font: italic 800 0.85rem "Segoe UI", sans-serif;
  cursor: pointer;
}

.bajs-toggle[aria-pressed="true"] {
  background: #0080ff;
  border-color: #0080ff;
  color: #fff;
}

/* BAJS stanica: krug plave boje s logotipa (#0080ff) i oznakom "B-<broj>"; broj je zelen, narančast ili crven
   prema dostupnosti (4 i više / 1 do 3 / 0). */
.bajs-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  width: 38px;
  height: 38px;
  border: 3px solid #0080ff;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: #0080ff;
  font: 800 0.72rem/1 "Segoe UI", sans-serif;
  letter-spacing: -0.2px;
}

.bajs-marker.big { font-size: 0.62rem; }

.bajs-marker.inactive {
  border-color: #868e96;
  color: #868e96;
}

.bajs-n.good { color: #2b9a3f; }
.bajs-n.low { color: #e8710a; }
.bajs-n.zero { color: #d62839; }

/* Popup vozila: detalji, stanice, veze */
.popup-actions {
  margin: 2px 0 6px;
}

.vehicle-popup a[data-popup-action] {
  color: var(--zet-blue);
  cursor: pointer;
  text-decoration: none;
}

.vehicle-popup a[data-popup-action]:hover {
  text-decoration: underline;
}

.popup-scroll {
  max-height: min(46vh, 360px);
  overflow-y: auto;
  padding-right: 4px;
}

.popup-all-stops {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.popup-stop-main {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.popup-stop-link {
  font-weight: 600;
}

.popup-veze-toggle {
  display: inline-block;
  margin-top: 1px;
  font-size: 0.78rem;
}

.popup-veze-toggle::after { content: " ▾"; }
.popup-veze-toggle.open::after { content: " ▴"; }

.popup-veze {
  display: grid;
  gap: 4px;
  margin: 4px 0 2px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f3f6fa;
  list-style: none;
}

.popup-line-badge {
  display: inline-block;
  min-width: 26px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  text-align: center;
}

.popup-conn-arrivals {
  margin: 3px 0 2px 8px;
  padding-left: 8px;
  border-left: 2px solid #c5d3e3;
}

.popup-conn-arrivals .popup-before {
  color: var(--muted);
}

.popup-bajs {
  color: #0080ff;
}

.bajs-types {
  display: grid;
  gap: 2px;
  margin: 4px 0 2px;
  padding: 0;
  list-style: none;
}

.bajs-types li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.bajs-types strong {
  color: #0080ff;
}

@media (max-width: 900px) {
  .popup-scroll {
    max-height: min(30dvh, 260px);
  }
}

/* Veze odmah uz stanicu: brojke u krugu (tramvaj, bus) i BAJS "B-n". */
.popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 3px 0 2px;
}

.vehicle-popup a.popup-badge {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
}

.vehicle-popup a.popup-badge.small {
  font-size: 0.62rem;
}

.vehicle-popup a.popup-badge:hover {
  box-shadow: 0 0 0 2px rgba(0, 128, 255, 0.4);
  text-decoration: none;
}

.vehicle-popup a.popup-badge.bus {
  background: #0057b8;
  color: #fff;
}

.vehicle-popup a.popup-badge.bajs {
  padding: 0 7px;
  border: 2px solid #0080ff;
  background: #fff;
  color: #0080ff;
}

.popup-tip {
  position: fixed;
  z-index: 2000;
  max-width: 300px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
  font: 400 0.8rem/1.35 "Segoe UI", sans-serif;
  pointer-events: none;
}

.popup-tip small {
  color: var(--muted);
}

.stall-tag {
  color: #b42318;
  font-weight: 600;
}

.vehicle-popup .popup-actions {
  margin-top: 6px;
}

.popup-conn-gap {
  height: 6px;
}


/* Natrag / naprijed uz kartice Linije i Stanice. */
.nav-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
}

.nav-row .view-tabs {
  flex: 1;
  min-width: 0;
  margin: 0;
}

.nav-row .back-link {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  font-size: 1.3rem;
}

.back-link.disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* Naslov kao oznaka na karti (dolje desno, iznad atribucije). */
.map-wrap .map-title {
  position: absolute;
  z-index: 800;
  right: 10px;
  bottom: 26px;
  margin: 0;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  color: var(--zet-blue);
  font: 800 1rem/1.3 "Segoe UI", sans-serif;
  pointer-events: none;
}

.map-expand {
  display: none;
}

/* Detalji vožnje preko cijelog ekrana (mobitel). */
/* Računalo: fiksni panel s desne strane karte, veličine prilagođene prozoru; mobitel: cijeli ekran (niže). */
.details-screen {
  position: fixed;
  z-index: 1500;
  top: 64px;
  right: 12px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  width: clamp(300px, 28vw, 440px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

@media (max-width: 900px) {
  .details-screen {
    z-index: 3000;
    inset: 0;
    width: auto;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

.details-screen[hidden] {
  display: none;
}

.details-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  font: 700 1.05rem "Segoe UI", sans-serif;
}

.details-head button {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 999px;
  background: #fff;
  color: var(--zet-blue);
  font: 700 1.4rem/1 "Segoe UI", sans-serif;
}

.details-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px 28px;
  overscroll-behavior: contain;
}

.details-body .vehicle-popup {
  min-width: 0;
  font-size: 1rem;
}

.details-body .vehicle-popup.details {
  width: auto;
}

.details-body .popup-scroll {
  max-height: none;
  overflow: visible;
  padding-right: 0;
}

/* Odabir stanice silaska: odbrojavanje, vozila koja stižu na tu stanicu i BAJS. */
.popup-badges {
  align-items: center;
}

.popup-dest-link {
  margin-left: auto;
  font-size: 0.78rem;
  font-weight: 600;
}

.dest-head {
  margin-bottom: 4px;
}

.dest-big {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--zet-blue);
}

.dest-big small {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.dest-big.imminent {
  color: #b42318;
}

.dest-alert {
  margin: 8px 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: #fff1e6;
  color: #b42318;
  font-weight: 800;
  animation: dest-pulse 1.2s ease-in-out infinite;
}

@keyframes dest-pulse {
  50% { background: #ffd9b8; }
}

@media (prefers-reduced-motion: reduce) {
  .dest-alert { animation: none; }
}

.dest-section {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.dest-section h3 {
  margin: 0 0 4px;
  font-size: 0.9rem;
}

.dest-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

.dest-route {
  display: inline-grid;
  place-items: center;
  flex: none;
  min-width: 26px;
  height: 26px;
  padding: 0 4px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.dest-row-main {
  flex: 1;
  min-width: 0;
}

@media (max-width: 900px) {
  .nav-row .back-link {
    flex-basis: 34px;
    width: 34px;
    height: 34px;
  }

  .map-expand {
    position: absolute;
    z-index: 800;
    left: 50%;
    bottom: 12px;
    display: grid;
    place-items: center;
    width: 46px;
    height: 30px;
    padding: 0;
    transform: translateX(-50%);
    border: 1px solid rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--zet-blue);
    backdrop-filter: blur(4px);
  }

  .shell.map-expanded {
    grid-template-rows: minmax(0, 1fr);
  }

  .shell.map-expanded .panel {
    display: none;
  }

  .shell.map-expanded .map-expand svg {
    transform: rotate(180deg);
  }
}

/* Podloga karte: gumb ispod kontrola za zumiranje + izbornik. */
.basemap-toggle {
  position: absolute;
  z-index: 800;
  top: 84px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  background: #fff;
  color: #333;
  cursor: pointer;
}

.basemap-toggle:hover {
  background: #f4f4f4;
}

.basemap-menu {
  position: absolute;
  z-index: 801;
  top: 84px;
  left: 52px;
  display: grid;
  min-width: 150px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
}

.basemap-menu[hidden] {
  display: none;
}

.basemap-menu button {
  width: auto;
  padding: 9px 14px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 0.85rem "Segoe UI", sans-serif;
  text-align: left;
  cursor: pointer;
}

.basemap-menu button:hover {
  background: #eef3f9;
}

.basemap-menu button.active {
  background: var(--zet-blue);
  color: #fff;
}

.timetable-link {
  align-self: flex-end;
  margin: 6px 2px 0;
  color: var(--zet-blue);
  font: 600 0.82rem "Segoe UI", sans-serif;
  text-decoration: none;
}

.timetable-link:hover {
  text-decoration: underline;
}

/* Red vožnje (?view=redvoznje): zamjenjuje kartu. */
body.timetable-mode .shell,
body.timetable-mode .details-screen {
  display: none;
}

.timetable[hidden] {
  display: none;
}

.timetable {
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 16px 48px;
  font-family: "Segoe UI", sans-serif;
}

.tt-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}

.tt-head h1 {
  margin: 0;
  font-size: 1.5rem;
}

.tt-back {
  color: var(--zet-blue);
  font-weight: 600;
  text-decoration: none;
}

.tt-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 14px;
}

.timetable .mode-filter {
  background: #fff;
}

.tt-date {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tt-date button,
.tt-lines-head button {
  width: auto;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--zet-blue);
  font: 600 0.82rem "Segoe UI", sans-serif;
  cursor: pointer;
}

.tt-date input {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 400 0.85rem "Segoe UI", sans-serif;
}

.tt-lines-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tt-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 18px;
}

.tt-chip {
  width: auto;
  min-width: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--route-color);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font: 700 0.9rem "Segoe UI", sans-serif;
  cursor: pointer;
}

.tt-chip[aria-pressed="true"] {
  background: var(--zet-blue);
  border-color: var(--zet-blue);
  border-left-color: var(--route-color);
  color: #fff;
}

.tt-line {
  margin-bottom: 22px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.tt-line h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.tt-badge {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  padding: 3px 8px;
  border-left: 6px solid var(--route-color);
  border-radius: 6px;
  background: #182126;
  color: #fff;
  font-weight: 800;
}

.tt-dir h3 {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  margin: 14px 0 6px;
  font-size: 0.95rem;
  font-weight: 400;
}

.tt-count {
  color: var(--muted);
  font-size: 0.8rem;
}

.tt-hours {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.tt-hours th,
.tt-hours td {
  padding: 4px 6px;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.tt-hours th {
  width: 40px;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: right;
}

.tt-hours td span {
  display: inline-block;
  min-width: 26px;
  margin: 1px 4px 1px 0;
  padding: 1px 3px;
  border-radius: 5px;
  text-align: center;
}

.tt-hours td span.past {
  color: #9aa6ae;
}

.tt-hours td span.next {
  background: #f2c300;
  font-weight: 800;
}

.tt-hint,
.tt-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.tt-error {
  color: #b42318;
}

/* Dolasci koji stižu prije našeg: svjetliji font. */
.arr-early,
.dest-row.early {
  color: #9aa6ae;
  font-weight: 400;
}

.arr-early small,
.dest-row.early small {
  color: #aab4bb;
}

.dest-row.early .dest-route {
  opacity: 0.6;
}

/* Više od tri autobusne linije: jedna elipsa "bus N linija". */
.vehicle-popup a.popup-badge.bus-group {
  min-width: 0;
  padding: 0 10px;
  font-size: 0.7rem;
  white-space: nowrap;
}

.popup-conn-dir {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

/* Moja lokacija: gumb ispod gumba podloge + popis najbližih stanica. */
.locate-toggle {
  top: 124px;
}

.locate-toggle.busy {
  color: #1a73e8;
  animation: locate-pulse 1s ease-in-out infinite;
}

@keyframes locate-pulse {
  50% { opacity: 0.45; }
}

.nearby {
  margin: 8px 0 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font: 400 0.85rem "Segoe UI", sans-serif;
}

.nearby[hidden] {
  display: none;
}

.nearby-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.nearby-head button {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.nearby-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nearby-item {
  width: auto;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef3f9;
  color: var(--zet-blue);
  font: 600 0.82rem "Segoe UI", sans-serif;
  cursor: pointer;
}

.nearby-item small {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 400;
}

.nearby-message {
  margin: 0;
  color: var(--muted);
}

/* Lokacija blokirana: koraci za omogućavanje + ponovni pokušaj. */
.nearby-help {
  flex: 1 1 100%;
}

.nearby-steps {
  margin: 6px 0 8px;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.4;
}

.nearby-steps li + li {
  margin-top: 4px;
}

.nearby-retry {
  width: auto;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--zet-blue);
  color: #fff;
  font: 600 0.85rem "Segoe UI", sans-serif;
  cursor: pointer;
}

.nearby-device {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.nearby-en {
  color: var(--muted);
  font-size: 0.8rem;
}

/* Vrijeme dolaska: uvijek skroz desno i poravnato; ispred njega koliko još minuta. */
.t-cells {
  display: inline-flex;
  flex: none;
  gap: 8px;
  margin-left: auto;
  justify-content: flex-end;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.t-rel {
  min-width: 4.2em;
  color: var(--muted);
  font-size: 0.85em;
  text-align: right;
}

.t-clock {
  min-width: 2.9em;
  font-weight: 600;
  text-align: right;
}

.conn-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.conn-note {
  color: var(--muted);
  font-size: 0.78rem;
}

.arr-early .t-rel,
.arr-early .t-clock,
.dest-row.early .t-rel,
.dest-row.early .t-clock {
  color: #9aa6ae;
  font-weight: 400;
}

/* Gdje je stajalište veze: isto, suprotni smjer ili izdvojeno. */
.conn-rel {
  display: inline-block;
  margin-left: 4px;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.conn-rel.same {
  background: #e3f4e8;
  color: #1c6b3a;
}

.conn-rel.opposite {
  background: #fdecc8;
  color: #8a5a00;
}

.conn-rel.separate {
  background: #e8ecf3;
  color: #44556a;
}
