:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #1e2530;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #388bfd;
  --green: #3fb950;
  --yellow: #d29922;
  --red: #f85149;
  --bus: #f78166;
  --metro: #79c0ff;
  --train: #56d364;
  --tram: #e3b341;
  --ship: #a5d6ff;
  --radius: 10px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
}

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Header ─────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stop-icon {
  font-size: 2.2rem;
  line-height: 1;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.updated-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-align: right;
}

.updated-time {
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  min-width: 50px;
  text-align: right;
}

/* ── Progress ring ───────────────────────────────── */
.progress-ring { transform: rotate(-90deg); }
.progress-bg { fill: none; stroke: var(--surface2); stroke-width: 3; }
.progress-bar {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-dasharray: 94.2; /* 2πr, r=15 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}

/* ── Error banner ────────────────────────────────── */
.error-banner {
  background: #2d1b1b;
  border: 1px solid var(--red);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
}
.hidden { display: none !important; }

/* ── Departures table ────────────────────────────── */
.departures-table {
  width: 100%;
  border-collapse: collapse;
}

.departures-table thead th {
  padding: 8px 12px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.departures-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.departures-table tbody tr:last-child { border-bottom: none; }

.departures-table tbody tr:hover { background: var(--surface2); }

.departures-table td {
  padding: 13px 12px;
  vertical-align: middle;
}

/* ── Line badge ──────────────────────────────────── */
.line-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  border: 2px solid currentColor;
}

.mode-bus   { color: var(--bus);   border-color: var(--bus);   background: rgba(247,129,102,.12); }
.mode-metro { color: var(--metro); border-color: var(--metro); background: rgba(121,192,255,.12); }
.mode-train { color: var(--train); border-color: var(--train); background: rgba(86,211,100,.12); }
.mode-tram  { color: var(--tram);  border-color: var(--tram);  background: rgba(227,179,65,.12); }
.mode-ship  { color: var(--ship);  border-color: var(--ship);  background: rgba(165,214,255,.12); }

/* ── Destination cell ────────────────────────────── */
.destination-cell { max-width: 260px; }

.destination-name {
  font-weight: 500;
  font-size: 1rem;
}

.deviation-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--yellow);
  background: rgba(210,153,34,.15);
  border: 1px solid rgba(210,153,34,.4);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── Time cell ───────────────────────────────────── */
.time-cell {
  text-align: right;
  white-space: nowrap;
}

.time-minutes {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.time-minutes.now { color: var(--green); }
.time-minutes.soon { color: var(--yellow); }

.time-clock {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}

.time-delayed {
  font-size: 0.75rem;
  color: var(--red);
  margin-top: 1px;
}

/* ── State badge ─────────────────────────────────── */
.state-cancelled {
  display: inline-block;
  padding: 3px 8px;
  background: rgba(248,81,73,.15);
  border: 1px solid var(--red);
  color: var(--red);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ── Skeleton loading ────────────────────────────── */
.skeleton-rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}

.skeleton-row {
  height: 58px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface2) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  border-radius: var(--radius);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Footer ──────────────────────────────────────── */
footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
}
footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* ── Stop selector ───────────────────────────────── */
.stop-selector-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stop-label {
  color: var(--text-muted);
  font-size: 0.85rem;
  white-space: nowrap;
}

.select-wrapper {
  position: relative;
  flex: 1;
}

.select-wrapper::after {
  content: '▾';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1rem;
}

#stop-select {
  width: 100%;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
  font-weight: 600;
  padding: 10px 40px 10px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

#stop-select:hover { border-color: var(--accent); }
#stop-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,139,253,.2); }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 600px) {
  h1 { font-size: 1.35rem; }
  .departures-table td { padding: 10px 8px; }
  .time-minutes { font-size: 1.2rem; }
  .col-stop { display: none; }
}
