:root {
  --bg: #050b12;
  --panel: #071727;
  --panel-2: #0b2034;
  --line: #24496a;
  --line-soft: rgba(105, 151, 190, .22);
  --text: #f4f8fb;
  --muted: #9fb8ca;
  --yellow: #ffd200;
  --green: #35d07f;
  --red: #ff4d4d;
  --orange: #ff9f1c;
  --cyan: #6bd6ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

button {
  font: inherit;
}

.sdip-shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(14, 40, 64, .94), rgba(2, 8, 15, .98)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 12px);
}

.alert-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 24px;
  border-bottom: 2px solid var(--orange);
  color: #07111a;
  background: var(--yellow);
  font-size: 20px;
  font-weight: 900;
}

.alert-bar[hidden] {
  display: none;
}

.alert-bar strong {
  text-transform: uppercase;
}

.alert-bar.critical {
  border-bottom-color: var(--red);
  color: #fff;
  background: var(--red);
}

.sdip-header {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 2px solid var(--line);
  background: linear-gradient(180deg, #123a61, #0b2540);
}

.station-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: 12px 24px 14px;
}

.board-label {
  color: var(--yellow);
  font-size: clamp(34px, 4.4vw, 68px);
  font-weight: 800;
  line-height: .94;
  letter-spacing: 0;
}

h1 {
  margin: 4px 0 0;
  color: var(--text);
  font-size: clamp(18px, 2vw, 30px);
  font-weight: 700;
  letter-spacing: 0;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 20px;
  border-left: 1px solid var(--line-soft);
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  background: #061522;
}

.mode-button,
.fullscreen-button {
  border: 0;
  color: var(--text);
  background: transparent;
  cursor: pointer;
}

.mode-button {
  min-width: 104px;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.mode-button.active {
  color: #07111a;
  background: var(--yellow);
}

.clock {
  min-width: 120px;
  color: var(--yellow);
  font-size: 28px;
  font-weight: 800;
  text-align: right;
}

.fullscreen-button {
  width: 46px;
  height: 46px;
  border: 1px solid var(--line);
  color: var(--yellow);
  background: #061522;
  font-size: 26px;
}

.sdip-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  min-height: 0;
  padding: 18px;
  overflow: hidden;
}

.board-area {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel-2), #061321);
}

.status-strip {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  background: #061522;
  font-size: 15px;
  font-weight: 700;
}

.status-strip.ok {
  color: var(--green);
}

.status-strip.warning {
  color: var(--orange);
}

.status-strip.error {
  color: var(--red);
}

.train-board {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.train-board th {
  height: 42px;
  padding: 8px 10px;
  border-bottom: 2px solid var(--line);
  color: var(--yellow);
  background: #102f4e;
  font-size: 15px;
  text-align: left;
  text-transform: uppercase;
}

.train-board td {
  height: 58px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  overflow: hidden;
}

.train-board tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, .035);
}

.col-time {
  width: 112px;
}

.col-train {
  width: 132px;
}

.col-direction {
  width: 32%;
}

.col-via {
  width: 34%;
}

.col-platform,
.col-track {
  width: 74px;
  text-align: center;
}

.col-status {
  width: 130px;
}

.time-cell {
  color: var(--yellow);
  font-size: 30px;
  font-weight: 900;
  padding-right: 18px;
  white-space: nowrap;
}

.actual-time {
  display: block;
  margin-top: 2px;
  color: var(--orange);
  font-size: 15px;
  line-height: 1;
}

.train-cell {
  color: var(--cyan);
  font-size: 20px;
  font-weight: 800;
}

.category {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.direction-cell {
  color: var(--text);
  font-size: 24px;
  font-weight: 800;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.via-cell {
  position: relative;
  color: var(--muted);
  font-size: 17px;
  white-space: nowrap;
  text-overflow: clip;
  mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 28px), transparent 100%);
}

.via-marquee {
  display: inline-flex;
  gap: 72px;
  min-width: max-content;
  animation: via-scroll 42s linear infinite;
  will-change: transform;
}

.via-marquee span {
  flex: 0 0 auto;
}

.platform-cell,
.track-cell {
  color: var(--yellow);
  font-size: 28px;
  font-weight: 900;
  text-align: center;
}

.status-pill {
  display: inline-block;
  width: 100%;
  color: var(--green);
  font-size: 15px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.delayed {
  color: var(--orange);
}

.status-pill.cancelled {
  color: var(--red);
}

.empty-row {
  height: 220px;
  color: var(--muted);
  font-size: 24px;
  font-weight: 700;
  text-align: center;
}

.side-rail {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  min-height: 0;
}

.operator-panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #0a2137, #061421);
  padding: 16px;
  min-height: 0;
}

.operator-panel h2 {
  margin: 0 0 14px;
  color: var(--yellow);
  font-size: 22px;
  letter-spacing: 0;
}

.operator-panel dl,
.operator-panel p {
  margin: 0;
}

.operator-panel div {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}

.operator-panel dt {
  color: var(--muted);
  font-weight: 700;
}

.operator-panel dd {
  margin: 0;
  color: var(--text);
  font-weight: 800;
}

.operator-panel p {
  color: var(--text);
  font-size: 18px;
  line-height: 1.45;
}

.info-ticker {
  overflow: hidden;
  border-top: 2px solid var(--line);
  color: var(--yellow);
  background: #061522;
  font-size: 17px;
  font-weight: 800;
  white-space: nowrap;
}

.info-ticker span {
  display: inline-block;
  padding: 9px 0 9px 100%;
  animation: ticker-scroll 34s linear infinite;
}

body.fullscreen-mode .sdip-main {
  grid-template-columns: 1fr;
  padding: 12px;
}

body.fullscreen-mode .side-rail {
  display: none;
}

body.fullscreen-mode .train-board td {
  height: 72px;
}

body.fullscreen-mode .time-cell {
  font-size: 34px;
}

body.fullscreen-mode .actual-time {
  font-size: 17px;
}

body.fullscreen-mode .direction-cell {
  font-size: 28px;
}

body.fullscreen-mode .train-cell {
  font-size: 23px;
}

body.fullscreen-mode .platform-cell,
body.fullscreen-mode .track-cell {
  font-size: 34px;
}

body.fullscreen-mode .sdip-header {
  min-height: 118px;
}

body.fullscreen-mode .board-label {
  font-size: clamp(48px, 5vw, 82px);
}

body.fullscreen-mode h1 {
  font-size: clamp(22px, 2vw, 34px);
}

body.fullscreen-mode .status-strip {
  font-size: 17px;
}

body.fullscreen-mode .info-ticker {
  font-size: 20px;
}

@keyframes via-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(calc(-50% - 36px));
  }
}

@keyframes ticker-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

@media (max-width: 1100px) {
  .sdip-header,
  .header-controls {
    flex-wrap: wrap;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
    border-left: 0;
    border-top: 1px solid var(--line-soft);
  }

  .sdip-main {
    grid-template-columns: 1fr;
    overflow: auto;
  }

  .side-rail {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-height: 900px) {
  .sdip-main {
    padding: 12px;
    gap: 12px;
  }

  .train-board td {
    height: 54px;
    padding-block: 6px;
  }

  .time-cell {
    font-size: 28px;
  }

  .direction-cell {
    font-size: 22px;
  }

  .platform-cell,
  .track-cell {
    font-size: 26px;
  }
}

@media (max-width: 760px) {
  .sdip-main {
    padding: 10px;
  }

  .side-rail,
  .header-controls,
  .mode-switch {
    grid-template-columns: 1fr;
  }

  .train-board {
    min-width: 860px;
  }

  .board-area {
    overflow-x: auto;
  }
}
