:root {
  color-scheme: dark;
  --bg: #0b1220;
  --bg-soft: #121b2d;
  --panel: rgba(18, 27, 45, 0.92);
  --line: rgba(148, 163, 184, 0.18);
  --text: #e5eefb;
  --muted: #91a4c6;
  --accent: #ff4d4f;
  --accent-soft: rgba(255, 77, 79, 0.12);
  --ok: #34d399;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 77, 79, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.12), transparent 26%),
    var(--bg);
  color: var(--text);
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 48px 0 56px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: #ff9b9c;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  max-width: 760px;
  font-size: clamp(2.25rem, 4vw, 4rem);
  line-height: 1.02;
}

.lede {
  max-width: 760px;
  color: var(--muted);
  font-size: 1.05rem;
}

.hero-actions {
  margin-top: 18px;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(139, 214, 255, 0.22);
  border-radius: 999px;
  padding: 10px 16px;
  background: rgba(56, 189, 248, 0.08);
  color: #b8e7ff;
  text-decoration: none;
  font-weight: 700;
  transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.hero-link:hover {
  background: rgba(56, 189, 248, 0.14);
  border-color: rgba(139, 214, 255, 0.34);
  transform: translateY(-1px);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.controls-panel,
.table-panel {
  padding: 22px;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

select,
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
}

select {
  padding: 12px 14px;
}

button {
  max-width: 260px;
  padding: 12px 16px;
  background: linear-gradient(135deg, #ff4d4f, #ff7b54);
  border: none;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 18px;
}

.meta-text,
.results-text,
.subtle {
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 22px 0;
}

.stat-card {
  padding: 22px;
}

.stat-card strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.8rem, 3vw, 3rem);
}

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

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 15px 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

thead th {
  color: var(--muted);
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.train-row {
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}

.train-row:hover,
.train-row.is-open {
  background: rgba(148, 163, 184, 0.05);
}

.train-row:focus-visible {
  outline: none;
}

.train-row:focus-visible td {
  box-shadow: inset 0 0 0 1px rgba(139, 214, 255, 0.38);
}

.detail-row td {
  padding: 0;
  border-top: none;
}

.detail-cell {
  background: rgba(8, 14, 26, 0.7);
}

.detail-panel {
  margin: 0 12px 14px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(56, 189, 248, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(18, 27, 45, 0.92), rgba(10, 16, 28, 0.98));
  padding: 18px 18px 20px;
}

.detail-summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.detail-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.detail-pill-strong {
  background: rgba(56, 189, 248, 0.12);
  color: #8bd6ff;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 12px;
}

.timeline-rail {
  position: relative;
}

.timeline-rail::before {
  content: '';
  position: absolute;
  left: 11px;
  top: -10px;
  bottom: -10px;
  width: 2px;
  background: linear-gradient(180deg, rgba(56, 189, 248, 0.28), rgba(148, 163, 184, 0.08));
}

.timeline-item.is-first .timeline-rail::before {
  top: 18px;
}

.timeline-item.is-last .timeline-rail::before {
  bottom: 18px;
}

.timeline-node {
  position: relative;
  z-index: 1;
  display: inline-flex;
  width: 22px;
  height: 22px;
  border: 4px solid rgba(11, 18, 32, 0.95);
  border-radius: 999px;
  background: #6b7280;
}

.timeline-item.is-start .timeline-node {
  background: #34d399;
  box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.12);
}

.timeline-item.is-end .timeline-node {
  background: #ff7b54;
  box-shadow: 0 0 0 6px rgba(255, 123, 84, 0.12);
}

.timeline-item.is-stopover .timeline-node {
  background: #8bd6ff;
}

.timeline-item.is-cancelled .timeline-node {
  background: #ff4d4f;
  box-shadow: 0 0 0 6px rgba(255, 77, 79, 0.14);
}

.timeline-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(148, 163, 184, 0.04);
  padding: 14px;
}

.timeline-item.is-cancelled .timeline-card {
  border-color: rgba(255, 77, 79, 0.22);
  background: rgba(255, 77, 79, 0.06);
}

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

.timeline-head strong {
  font-size: 0.98rem;
}

.timeline-kind {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.timeline-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  font-size: 0.82rem;
}

.timeline-chip.is-updated {
  background: rgba(250, 204, 21, 0.14);
  color: #fde68a;
}

.timeline-chip-muted {
  color: rgba(229, 238, 251, 0.66);
  font-size: 0.75rem;
}

.timeline-gap {
  margin-left: 36px;
  padding: 2px 0 6px;
}

.timeline-gap-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(148, 163, 184, 0.06);
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline-gap-button {
  border: 1px solid var(--line);
  cursor: pointer;
}

.timeline-gap-button:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.12);
  color: #8bd6ff;
}

.timeline-gap-button:disabled {
  opacity: 0.8;
  cursor: wait;
}

.detail-loading,
.detail-error {
  margin: 0 12px 14px;
  border-radius: 16px;
  padding: 18px;
}

.detail-loading {
  border: 1px dashed var(--line);
  color: var(--muted);
}

.detail-error {
  border: 1px solid rgba(255, 77, 79, 0.22);
  background: rgba(255, 77, 79, 0.08);
  color: #ffb0b1;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
}

.status.cancelled {
  background: var(--accent-soft);
  color: #ffb0b1;
}

.status.delayed {
  background: rgba(250, 204, 21, 0.14);
  color: #fde68a;
}

.status.running {
  background: rgba(52, 211, 153, 0.14);
  color: #7de4bf;
}

.time-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.time-planned {
  color: var(--muted);
  font-size: 0.84rem;
}

.time-planned-strike {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
  text-decoration-color: rgba(255, 77, 79, 0.7);
}

.time-actual {
  font-weight: 700;
}

.time-actual-ontime {
  color: #7de4bf;
}

.time-actual-delayed {
  color: #8bd6ff;
}

.empty-state {
  margin-top: 18px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 22px;
  background: rgba(148, 163, 184, 0.05);
}

.hidden {
  display: none;
}

@media (max-width: 900px) {
  .controls-grid,
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .actions-row,
  .table-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .page {
    width: min(100vw - 20px, 1180px);
    padding: 24px 0 32px;
  }

  .controls-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .controls-panel,
  .table-panel,
  .stat-card {
    padding: 18px;
  }

  button {
    max-width: none;
  }
}
