.bn-tv,
.bn-tv * {
  box-sizing: border-box;
}

.bn-tv {
  --bn-bg: #0a0c0e;
  --bn-surface: #13181c;
  --bn-band: #20262b;
  --bn-border: #2b353b;
  --bn-text: #eef1f2;
  --bn-muted: #8d9aa1;
  --bn-red: #c8261c;
  --bn-green: #20df74;
  --bn-amber: #e8b13a;
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 1.2vh;
  overflow: hidden;
  padding: 1.6vh 1.3vw;
  background: var(--bn-bg);
  color: var(--bn-text);
  font-family: 'Barlow Semi Condensed', 'Arial Narrow', sans-serif;
  font-size: clamp(14px, 1.8vh, 22px);
}

.bn-tv button,
.bn-tv select {
  font: inherit;
}

.bn-tv__header {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 2vw;
  min-height: 9.2vh;
  padding-bottom: 1vh;
  border-bottom: 0.3vh solid var(--bn-band);
}

.bn-tv__identity,
.bn-tv__summary,
.bn-tv__header-actions,
.bn-tv__filters,
.bn-tv__rotation,
.bn-legend {
  display: flex;
  align-items: center;
}

.bn-tv__identity {
  min-width: 0;
  gap: 1vw;
}

.bn-tv__identity > div {
  min-width: 0;
}

.bn-tv__identity h1 {
  margin: 0;
  color: var(--bn-text);
  font-family: 'Archivo', 'Arial Narrow', sans-serif;
  font-size: clamp(28px, 4.35vh, 54px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 0.98;
  white-space: nowrap;
}

.bn-tv__identity h1 em {
  color: var(--bn-red);
  font-style: normal;
}

.bn-tv__filters {
  flex-wrap: wrap;
  gap: 0.5vw;
  margin-top: 0.65vh;
}

.bn-tv__filters span {
  max-width: 25vw;
  overflow: hidden;
  padding: 0.35vh 0.6vw;
  border-radius: 0.35vh;
  background: #ccd5da;
  color: #0d1114;
  font-family: 'Archivo', 'Arial Narrow', sans-serif;
  font-size: clamp(12px, 1.65vh, 19px);
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bn-tv__filters span + span {
  background: #1e262b;
  color: var(--bn-muted);
}

.bn-tv__summary {
  flex: none;
  justify-content: flex-end;
  gap: 1.5vw;
}

.bn-tv__header-actions {
  flex: none;
  gap: 0.45vw;
}

.bn-tv__metric,
.bn-tv__refresh-clock {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 6.5vh;
  padding-left: 1.5vw;
  border-left: 0.18vh solid #39444a;
}

.bn-tv__metric span,
.bn-tv__refresh-clock > span {
  color: var(--bn-muted);
  font-size: clamp(11px, 1.35vh, 17px);
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.bn-tv__metric strong,
.bn-tv__refresh-clock strong {
  font-family: 'Archivo', 'Arial Narrow', sans-serif;
  font-size: clamp(27px, 4.1vh, 50px);
  font-weight: 800;
  line-height: 1.05;
}

.bn-tv__refresh-clock strong {
  color: #c3ccd1;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(26px, 3.5vh, 43px);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.bn-tv .is-green { color: var(--bn-green); }
.bn-tv .is-red { color: #f13d34; }
.bn-tv .is-amber { color: var(--bn-amber); }

.bn-icon-button {
  display: grid;
  flex: none;
  width: 4.2vh;
  height: 4.2vh;
  min-width: 34px;
  min-height: 34px;
  place-items: center;
  padding: 0;
  border: 0.2vh solid #2a3338;
  border-radius: 0.5vh;
  background: #13181c;
  color: #aab6bc;
  cursor: pointer;
}

.bn-icon-button:hover,
.bn-icon-button:focus-visible {
  border-color: #3d4a52;
  background: #1c2328;
  color: var(--bn-text);
  outline: none;
}

.bn-icon-button svg {
  width: 55%;
  height: 55%;
  stroke-width: 2;
}

.bn-refresh-button,
.bn-back-button {
  width: 4.6vh;
  height: 4.6vh;
}

.bn-back-button {
  text-decoration: none;
}

.bn-refresh-button.is-refreshing svg {
  animation: bn-spin 0.85s linear infinite;
}

@keyframes bn-spin {
  to { transform: rotate(360deg); }
}

.bn-tv__board {
  display: flex;
  flex: 1;
  min-height: 0;
}

.bn-board-scroll {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: auto;
  scrollbar-color: #465158 #0a0c0e;
}

.bn-board-grid {
  display: grid;
  grid-template-columns: var(--bn-columns);
  align-items: center;
  gap: 0.3vw;
  min-width: 1420px;
}

.bn-board-grid--header {
  flex: none;
  min-height: 7.2vh;
  padding: 0.7vh 0.6vw 0.8vh 0.5vw;
  border-bottom: 0.35vh solid var(--bn-red);
  border-radius: 0.4vh;
  background: #2b2d2f;
  color: #b9b9b9;
  font-size: clamp(12px, 1.55vh, 19px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.bn-stage-heading {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: center;
  gap: 0.15vh;
  color: #f2f2f2;
  font-family: 'Archivo', 'Arial Narrow', sans-serif;
  font-size: clamp(13px, 1.75vh, 22px);
  line-height: 1.05;
  white-space: nowrap;
}

.bn-stage-heading b {
  min-width: 2.8vh;
  padding: 0.25vh 0.3vw;
  border-radius: 0.3vh;
  background: #44474a;
  color: #fff;
  font-size: clamp(12px, 1.55vh, 19px);
  font-weight: 800;
  text-align: center;
}

.bn-board-grid__delivery {
  text-align: right;
}

.bn-board-grid__rows {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 0.5vh;
  padding-top: 0.5vh;
}

.bn-board-row {
  display: grid;
  flex: 1;
  grid-template-columns: var(--bn-columns);
  align-items: center;
  gap: 0.3vw;
  min-height: 58px;
  padding: 0 0.6vw 0 0.5vw;
  border-top: 0.15vh solid #171d21;
  border-left: 0.4vw solid #2c353b;
  border-radius: 0.3vh;
  background: #0b0f12;
  color: inherit;
  text-decoration: none;
  transition: background 140ms ease, border-color 140ms ease;
}

.bn-board-row:nth-child(odd) {
  border-top-color: #2b353b;
  background: #1e262b;
}

.bn-board-row--late { border-left-color: #c8261c; }
.bn-board-row--warning { border-left-color: var(--bn-amber); }

.bn-board-row:hover,
.bn-board-row:focus-visible {
  border-left-color: #e14439;
  background: #252e34;
  outline: none;
}

.bn-row-order,
.bn-row-vehicle strong,
.bn-row-due {
  font-family: 'Archivo', 'Arial Narrow', sans-serif;
  font-size: clamp(16px, 2.5vh, 31px);
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.05;
}

.bn-row-order {
  white-space: nowrap;
}

.bn-row-vehicle,
.bn-row-status {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  gap: 0.35vh;
  overflow: hidden;
}

.bn-row-vehicle strong,
.bn-row-vehicle small,
.bn-row-status small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bn-row-vehicle small,
.bn-row-status small {
  color: #b7c3ca;
  font-size: clamp(12px, 1.75vh, 22px);
  font-weight: 500;
  line-height: 1.1;
}

.bn-row-status small {
  color: #9dabb2;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(10px, 1.5vh, 18px);
}

.bn-document-status {
  display: flex;
  gap: 0.22vw;
  white-space: nowrap;
}

.bn-document-status b {
  padding: 0.2vh 0.35vw;
  border-radius: 0.25vh;
  font-size: clamp(12px, 1.8vh, 22px);
  font-weight: 700;
  line-height: 1.15;
}

.bn-document-status .is-ok {
  background: #20df74;
  color: #0d1411;
}

.bn-document-status .is-pending {
  background: #c8261c;
  color: #fff3f0;
}

.bn-stage-cell {
  position: relative;
  display: grid;
  min-width: 0;
  height: 100%;
  place-items: center;
}

.bn-stage-location {
  position: absolute;
  right: 0;
  bottom: 0.35vh;
  left: 0;
  overflow: hidden;
  color: #b7c3ca;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(8px, 1.2vh, 13px);
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bn-stage-cell::before {
  position: absolute;
  right: 0;
  left: 0;
  height: 0.25vh;
  background: #222a2f;
  content: '';
}

.bn-stage-cell--done::before,
.bn-stage-cell--done-late::before,
.bn-stage-cell--active-ok::before,
.bn-stage-cell--active-warning::before,
.bn-stage-cell--active-late::before,
.bn-stage-cell--paused::before {
  background: #4a555b;
}

.bn-stage-cell--done::before,
.bn-stage-cell--active-ok::before {
  background: #20df74;
}

.bn-stage-cell--done-late::before,
.bn-stage-cell--active-late::before {
  background: #e43b32;
}

.bn-stage-node {
  position: relative;
  display: grid;
  width: 1.1vh;
  height: 1.1vh;
  min-width: 9px;
  min-height: 9px;
  place-items: center;
  border: 0.22vh solid #20282d;
  border-radius: 50% !important;
  background: #20282d;
  color: transparent;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(9px, 1.3vh, 16px);
  font-weight: 600;
  line-height: 1;
}

.bn-stage-node--done,
.bn-stage-node--done-late {
  width: 2.5vh;
  height: 2.5vh;
  border-color: #4a555b;
  background: #39444a;
  color: #20df74;
}

.bn-stage-node--done-late {
  color: #f13d34;
}

.bn-stage-node svg {
  width: 70%;
  height: 70%;
}

.bn-stage-node--active-ok,
.bn-stage-node--active-warning,
.bn-stage-node--active-late,
.bn-stage-node--paused {
  width: 3.3vh;
  height: 3.3vh;
  color: #0d1411;
  font-size: clamp(11px, 1.7vh, 21px);
}

.bn-stage-node--active-ok {
  border: 0.35vh solid #20df74;
  background: #20df74;
  box-shadow: 0 0 0 0.28vh #0b0f12;
}

.bn-stage-node--active-warning,
.bn-stage-node--paused {
  border: 0.35vh solid var(--bn-amber);
  background: var(--bn-amber);
  box-shadow: 0 0 0 0.28vh #0b0f12;
}

.bn-stage-node--active-late {
  border: 0.35vh solid #e43b32;
  background: #e43b32;
  box-shadow: 0 0 0 0.28vh #0b0f12;
}

.bn-stage-node--waiting {
  width: 2vh;
  height: 2vh;
  border-color: #39444a;
  background: #39444a;
}

.bn-row-due {
  overflow: hidden;
  font-family: 'IBM Plex Mono', monospace;
  font-size: clamp(13px, 2.1vh, 26px);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bn-row-due--ok { color: var(--bn-green); }
.bn-row-due--warning { color: var(--bn-amber); }
.bn-row-due--late { color: #f13d34; }
.bn-row-due--unknown { color: #8d9aa1; font-size: clamp(11px, 1.45vh, 18px); }

.bn-board-state {
  display: grid;
  flex: 1;
  min-height: 200px;
  place-items: center;
  color: var(--bn-muted);
  font-family: 'Archivo', 'Arial Narrow', sans-serif;
  font-size: clamp(18px, 2.2vh, 28px);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.bn-board-state--error {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  color: #ef554b;
}

.bn-board-state button,
.bn-primary-button {
  border: 0;
  border-radius: 0.5vh;
  background: var(--bn-red);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.bn-board-state button {
  padding: 0.8rem 1.2rem;
  font-size: 0.9rem;
}

.bn-tv__footer {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 2vw;
  min-height: 5vh;
  padding: 0 0.5vw;
}

.bn-legend {
  min-width: 0;
  flex-wrap: wrap;
  gap: 0.8vw;
  color: #93a0a7;
  font-size: clamp(10px, 1.35vh, 16px);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.bn-legend > span {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.35vw;
  white-space: nowrap;
}

.bn-legend-dot {
  width: 1.8vh;
  height: 1.8vh;
  border-radius: 50%;
  background: currentColor;
}

.bn-legend-divider {
  align-self: stretch;
  width: 1px;
  margin: 0 0.25vw;
  background: #39444a;
}

.bn-legend-chip {
  padding: 0.18vh 0.3vw;
  border-radius: 0.25vh;
  background: #20df74;
  color: #0d1411;
  font-size: 0.95em;
}

.bn-legend-chip.is-pending {
  background: #ed3838;
  color: #fff;
}

.bn-tv__rotation {
  flex: none;
  gap: 0.7vw;
  color: #8d9aa1;
  font-size: clamp(10px, 1.5vh, 18px);
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.bn-page-button {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  padding: 0;
  border: 1px solid #2f393f;
  border-radius: 0.3rem;
  background: #13181c;
  color: #aab6bc;
  cursor: pointer;
}

.bn-page-button:hover,
.bn-page-button:focus-visible {
  border-color: #3d4a52;
  background: #1c2328;
  color: var(--bn-text);
  outline: none;
}

.bn-page-button svg {
  width: 70%;
  height: 70%;
}

.bn-progress {
  width: 8vw;
  height: 0.6vh;
  overflow: hidden;
  border-radius: 0.3vh;
  background: #242c32;
}

.bn-progress i {
  display: block;
  width: 100%;
  height: 100%;
  background: #7c8a92;
  transform-origin: left center;
  transition: transform 200ms linear;
}

.bn-tv__connection {
  display: inline-flex;
  align-items: center;
  gap: 0.35vw;
}

.bn-tv__connection i {
  width: 0.7vh;
  height: 0.7vh;
  border-radius: 50%;
}

.bn-tv__connection .is-connected { background: var(--bn-green); }
.bn-tv__connection .is-updating { background: var(--bn-amber); }

.bn-dialog-backdrop {
  position: fixed;
  z-index: 5;
  inset: 0;
  display: grid;
  overflow: auto;
  place-items: center;
  padding: 4vh 2vw;
  background: rgb(4 6 8 / 78%);
}

.bn-dialog {
  display: flex;
  width: min(760px, 92vw);
  max-height: 92vh;
  flex-direction: column;
  gap: 1.4rem;
  overflow: auto;
  padding: 1.6rem 1.5rem;
  border: 1px solid #2a3338;
  border-radius: 0.6rem;
  background: #0a0a0a;
  box-shadow: 0 2vh 6vh rgb(0 0 0 / 50%);
}

.bn-dialog__header,
.bn-dialog__footer,
.bn-setting-heading,
.bn-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.bn-dialog__header {
  padding-bottom: 1rem;
  border-bottom: 1px solid #222a30;
}

.bn-dialog__header h2 {
  margin: 0;
  font-family: 'Archivo', sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
}

.bn-dialog__section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bn-dialog__section > h3,
.bn-setting-heading h3 {
  margin: 0;
  color: #e0453a;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.bn-setting-row {
  min-height: 2.8rem;
  color: #c6d0d5;
  font-size: 1rem;
  font-weight: 600;
}

.bn-setting-row select {
  width: 54%;
  min-height: 2.65rem;
  padding: 0 0.75rem;
  border: 1px solid #2f393f;
  border-radius: 0.4rem;
  background: #0b0f12;
  color: var(--bn-text);
  cursor: pointer;
}

.bn-setting-heading > div {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}

.bn-setting-heading span {
  color: #76838a;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.bn-stage-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(84px, 1fr));
  gap: 0.4rem;
}

.bn-stage-toggle {
  display: flex;
  min-width: 0;
  height: 2.5rem;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  overflow: hidden;
  padding: 0 0.35rem;
  border: 1px solid #2e2e2e;
  border-radius: 0.3rem;
  background: #161616;
  color: #8d9aa1;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.bn-stage-toggle span {
  color: inherit;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.76em;
}

.bn-stage-toggle.is-selected {
  border-color: var(--bn-red);
  background: var(--bn-red);
  color: #fff;
}

.bn-text-button,
.bn-secondary-button,
.bn-primary-button {
  min-height: 2.65rem;
  padding: 0 0.95rem;
  border-radius: 0.35rem;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  cursor: pointer;
}

.bn-text-button {
  border: 1px solid #2f393f;
  background: transparent;
  color: #aab6bc;
}

.bn-text-button:hover,
.bn-secondary-button:hover {
  background: #1c2328;
  color: var(--bn-text);
}

.bn-secondary-button {
  border: 1px solid #2f393f;
  background: #171d21;
  color: var(--bn-text);
}

.bn-primary-button {
  margin-left: 0.5rem;
  padding-inline: 1.3rem;
  background: var(--bn-red);
  color: #fff;
}

.bn-primary-button:hover,
.bn-board-state button:hover {
  background: #e0302a;
}

.bn-dialog__footer {
  padding-top: 1rem;
  border-top: 1px solid #222a30;
}

.bn-dialog__footer > div {
  display: flex;
}

@media (max-width: 1000px) {
  .bn-tv {
    gap: 0.8rem;
    padding: 0.8rem;
  }

  .bn-tv__header {
    align-items: flex-start;
    gap: 1rem;
  }

  .bn-tv__identity h1 {
    font-size: clamp(24px, 4vw, 40px);
  }

  .bn-tv__summary {
    flex-wrap: wrap;
    gap: 0.6rem;
  }

  .bn-tv__metric,
  .bn-tv__refresh-clock {
    min-height: 3.5rem;
    padding-left: 0.65rem;
  }

  .bn-tv__metric span,
  .bn-tv__refresh-clock > span {
    font-size: 0.64rem;
  }

  .bn-tv__metric strong,
  .bn-tv__refresh-clock strong {
    font-size: 1.55rem;
  }

  .bn-tv__footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.7rem;
  }

  .bn-legend {
    gap: 0.5rem;
  }
}

@media (max-width: 600px) {
  .bn-tv__header {
    flex-direction: column;
  }

  .bn-tv__summary {
    width: 100%;
    justify-content: space-between;
  }

  .bn-tv__metric,
  .bn-tv__refresh-clock {
    padding-left: 0.5rem;
  }

  .bn-tv__refresh-clock > span {
    white-space: normal;
  }

  .bn-tv__identity h1 {
    font-size: clamp(22px, 7vw, 30px);
  }

  .bn-tv__rotation {
    width: 100%;
    justify-content: space-between;
  }

  .bn-progress {
    width: 22vw;
  }

  .bn-dialog {
    width: 100%;
    padding: 1rem;
  }

  .bn-dialog__footer {
    align-items: stretch;
    flex-direction: column;
  }

  .bn-dialog__footer > div {
    justify-content: flex-end;
  }
}

@media (prefers-reduced-motion: reduce) {
  .bn-tv *,
  .bn-tv *::before,
  .bn-tv *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
