:root {
  --bg: #111418;
  --panel: #1a1f26;
  --panel-2: #202733;
  --border: #313a47;
  --text: #e8edf3;
  --muted: #a8b3c2;
  --ok: #2fb36d;
  --warn: #ffb020;
  --bad: #e45d5d;
  --accent: #e6b84a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
}

.container {
  max-width: 1480px;
  margin: 0 auto;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
}

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

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

.header-text {
  display: flex;
  flex-direction: column;
}

.header-icon i {
  display: block;
  font-size: 46px;
  line-height: 1;
}

h1,
h2,
h3 {
  margin: 0 0 8px;
}

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

.panel {
  margin-bottom: 16px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.nested-panel {
  margin-bottom: 0;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

label,
.group-label {
  font-size: 14px;
  color: var(--muted);
}

input {
  width: 100%;
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.actions-block {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.subtle-meta {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: end;
  gap: 10px;
}

button {
  padding: 12px 16px;
  font-weight: 700;
  color: #081120;
  cursor: pointer;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
}

button.connect {
  background: var(--ok);
}

button.connect:hover:not(:disabled) {
  background: #35c47a;
}

button.disconnect {
  background: var(--bad);
}

button.disconnect:hover:not(:disabled) {
  background: #ff6f6f;
}

button.update {
  color: var(--text);
  background: #3a4556;
}

button.update:hover:not(:disabled) {
  background: #465266;
}

button.secondary {
  color: var(--text);
  background: #343f4f;
}

button:disabled,
button:disabled:hover {
  color: #7f8a99 !important;
  cursor: not-allowed;
  background: #2a313d !important;
  box-shadow: none;
  opacity: 0.65;
}

button i {
  font-size: 14px;
  line-height: 1;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
}

.filters-right {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 24px;
  margin-left: auto;
}

.segmented-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.segmented-btn {
  padding: 10px 14px;
  color: var(--text);
  background: transparent;
  border-radius: 10px;
}

.segmented-btn.active {
  color: #081120;
  background: var(--accent);
}

.segmented-traffic .segmented-btn {
  min-width: 64px;
  text-align: center;
}

.station-inline {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
}

.station-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 42px;
  padding: 0 16px;
  font-weight: 600;
  line-height: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
}

.station-chip-warning {
  color: var(--warn);
  background: rgba(255, 176, 32, 0.1);
  border-color: rgba(255, 176, 32, 0.38);
}

.station-chip-warning .station-chip-separator,
.station-chip-warning #stationInternalCode {
  color: var(--warn);
}

.station-chip-warning #stationName {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--warn);
}

.station-chip-separator {
  color: var(--muted);
}

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

.status.connected {
  color: #88e0ae;
  background: rgba(47, 179, 109, 0.15);
  border: 1px solid rgba(47, 179, 109, 0.3);
}

.status.connecting {
  color: #ffd27d;
  background: rgba(255, 176, 32, 0.15);
  border: 1px solid rgba(255, 176, 32, 0.3);
}

.status.disconnected {
  color: #ff9a9a;
  background: rgba(228, 93, 93, 0.15);
  border: 1px solid rgba(228, 93, 93, 0.3);
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  margin: 0;
}

.summary div {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

dt {
  font-size: 13px;
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 600;
}

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

.table-wrap {
  overflow: auto;
}

.panel-table {
  width: 100%;
  min-width: 900px;
  table-layout: fixed;
  border-collapse: collapse;
}

.col-time {
  width: 92px;
}

.col-location {
  width: 46%;
}

.col-train {
  width: 90px;
}

.col-product {
  width: 16%;
}

.col-platform {
  width: 72px;
}

.col-status {
  width: 110px;
}

.panel-table thead th {
  padding: 12px 10px;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.panel-table tbody td {
  padding: 12px 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.panel-table tbody td:nth-child(2),
.panel-table tbody td:nth-child(4),
.panel-table tbody td:nth-child(6),
.cell-location,
.location-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel-table tbody td:nth-child(4) {
  vertical-align: middle;
  overflow: visible;
}

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

.time-cell {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.time-scheduled {
  font-size: 18px;
  font-weight: 700;
}

.time-cell-cancelled .time-scheduled,
.time-scheduled-cancelled {
  color: #ff9a9a;
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  text-decoration-color: rgba(255, 107, 107, 0.95);
}

.time-actual {
  margin-top: 4px;
  font-size: 12px;
}

.time-actual.delayed {
  font-weight: 600;
  color: var(--bad);
}

.status-badge {
  display: inline-block;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
}

.status-running {
  color: #88e0ae;
  background: rgba(47, 179, 109, 0.15);
}

.status-delayed {
  color: #ff9a9a;
  background: rgba(228, 93, 93, 0.15);
}

.status-delayed-blinking {
  color: #ff9a9a;
  background: rgba(228, 93, 93, 0.2);
  animation: blink 1s infinite;
}

.status-scheduled {
  color: #ffd27d;
  background: rgba(255, 176, 32, 0.15);
}

.status-boarding,
.status-arriving {
  color: #88e0ae;
  background: rgba(47, 179, 109, 0.2);
  animation: blink 1s infinite;
}

.status-arrived {
  color: #a5d8ff;
  background: rgba(120, 200, 255, 0.15);
}

.status-cancelled {
  color: #ff6b6b;
  background: rgba(228, 93, 93, 0.25);
}

.status-default {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.08);
}

.status-immediate-departure,
.status-immediate-arrival {
  color: #a8c7ff;
  background: rgba(118, 169, 255, 0.2);
  animation: blink 1s infinite;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

.block {
  max-height: 340px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
  white-space: pre-wrap;
  background: #0c1015;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
}

.hidden {
  display: none !important;
}

.product-cell-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  vertical-align: middle;
}

.product-logo {
  display: block;
  flex: 0 0 auto;
  width: auto;
  max-width: 110px;
  height: 28px;
  object-fit: contain;
}

.product-line-logo {
  display: block;
  flex: 0 0 auto;
  width: auto;
  max-width: 52px;
  height: 28px;
  object-fit: contain;
}

.product-text {
  display: inline-block;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.train-numbers {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.05;
}

.train-number-line {
  display: block;
  white-space: nowrap;
}

.station-search-wrap {
  position: relative;
}

.stations-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  left: 0;
  z-index: 1000;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.station-option {
  padding: 12px 14px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.station-option:last-child {
  border-bottom: 0;
}

.station-option:hover,
.station-option.active {
  background: rgba(90, 115, 150, 0.18);
}

.station-option-name {
  font-weight: 600;
}

.station-option-code {
  margin-left: 8px;
  font-size: 12px;
  color: var(--muted);
}

.disclaimer {
  margin-top: 24px;
  padding: 12px 16px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  text-align: center;
  opacity: 0.7;
}

.disclaimer:hover {
  opacity: 1;
}

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

  .filters {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
  }

  .filters-right {
    width: 100%;
    margin-left: 0;
    justify-content: flex-start;
  }

  .actions-block {
    align-items: stretch;
  }

  .subtle-meta {
    text-align: left;
  }
}

@media (max-width: 720px) {
  body {
    padding: 16px;
  }
}