:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --delay-red: #ef4444;
  --on-time-green: #10b981;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  padding-bottom: 90px;
}

.app-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 16px;
}

.view {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

/* NAGŁÓWKI */
.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

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

/* WYSZUKIWARKA & AUTOCOMPLETE */
.search-section {
  position: relative;
  margin-bottom: 24px;
}

.search-box {
  position: relative;
}

#stationInput {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 1rem;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#stationInput:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.autocomplete-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  z-index: 100;
  list-style: none;
}

.autocomplete-list li {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border-color);
}

.autocomplete-list li:hover {
  background: #f1f5f9;
}

/* TABLICA ODJAZDÓW */
.departures-section {
  margin-top: 16px;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.section-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.btn-text {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
}

.departures-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.departure-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.btn-add {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 12px;
  font-weight: 600;
  cursor: pointer;
}

.btn-add:disabled {
  background: #cbd5e1;
  cursor: default;
}

/* KAFELKI POCIĄGÓW */
.monitored-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.monitored-card {
  position: relative;
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.monitored-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-right: 36px;
}

.train-info h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.train-number {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.btn-delete {
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s, transform 0.15s;
  line-height: 1;
}

.btn-delete:hover {
  background: #fee2e2;
  transform: scale(1.1);
}

.card-route {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.route-arrow {
  color: var(--text-muted);
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  font-size: 0.9rem;
}

.delay-tag {
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
}

.delay-tag.delayed {
  background: #fef2f2;
  color: var(--delay-red);
}

.delay-tag.on-time {
  background: #ecfdf5;
  color: var(--on-time-green);
}

/* EMPTY STATE */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px dashed var(--border-color);
}

.empty-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 12px;
}

/* WIDOK SZCZEGÓŁÓW (BIEG POCIĄGU) */
.details-header {
  margin-bottom: 24px;
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  margin-bottom: 20px;
  transition: background 0.2s;
  box-shadow: var(--shadow);
}

.btn-back:hover {
  background: #f1f5f9;
}

.train-summary {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.train-title-group h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.train-number-badge {
  display: inline-block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.total-delay-badge {
  font-size: 1.1rem;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 20px;
}

.total-delay-badge.delayed {
  background: #fef2f2;
  color: var(--delay-red);
}

.total-delay-badge.on-time {
  background: #ecfdf5;
  color: var(--on-time-green);
}

/* TIMELINE STACJI */
.route-timeline-container {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

.route-timeline-container h3 {
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-item:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: -28px;
  top: 6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card-bg);
  border: 3px solid var(--text-muted);
  z-index: 2;
}

/* STATUSY STACJI */
.timeline-item.status-past .timeline-marker {
  background: #cbd5e1;
  border-color: #cbd5e1;
}

.timeline-item.status-past {
  opacity: 0.65;
}

.timeline-item.status-current .timeline-marker {
  background: var(--primary);
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.timeline-item.status-upcoming .timeline-marker {
  border-color: var(--primary);
}

.station-card {
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
}

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

.station-name {
  font-size: 1rem;
  font-weight: 600;
}

.station-status-badge {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
}

.status-past .station-status-badge {
  background: #e2e8f0;
  color: #64748b;
}

.status-current .station-status-badge {
  background: #dbeafe;
  color: var(--primary);
}

.status-upcoming .station-status-badge {
  background: #f1f5f9;
  color: #475569;
}

.station-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 8px;
}

.station-times {
  display: flex;
  gap: 10px;
  align-items: center;
}

.time-actual {
  font-weight: 700;
  color: var(--text-main);
}

.platform-track {
  background: #ffffff;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-size: 0.8rem;
  color: #334155;
  font-weight: 500;
}

/* FAB - PŁYWAJĄCY PRZYCISK ODŚWIEŻANIA */
.fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  transition: transform 0.2s, background 0.2s;
  z-index: 1000;
}

.fab:hover {
  background: var(--primary-hover);
  transform: scale(1.08);
}

.fab.spinning .fab-icon {
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
