:root {
  color-scheme: light;
  --page-bg: #303030;
  --surface: #ffffff;
  --surface-soft: #f7f7f7;
  --ink: #111111;
  --muted: #737373;
  --faint: #a7a7a7;
  --line: #e3e3e3;
  --line-strong: #d3d3d3;
  --blue: #2d83b7;
  --blue-strong: #176c9f;
  --green: #208766;
  --amber: #a76512;
  --red: #d11224;
  --port-empty: #8e8e8e;
  --hub-shadow: 0 26px 48px rgb(0 0 0 / 12%);
  --panel-shadow: 0 28px 80px rgb(0 0 0 / 28%);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 18% 18%, rgb(255 255 255 / 6%), transparent 24rem),
    var(--page-bg);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  font: inherit;
}

.app-shell {
  width: min(1280px, calc(100% - 48px));
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 12px 0;
  display: grid;
  align-items: center;
}

.dashboard-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  height: calc(100vh - 24px);
  height: calc(100dvh - 24px);
  min-height: 0;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--panel-shadow);
}

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 36px 14px;
  border-bottom: 1px solid var(--line);
}

.hub-identity {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 24px;
  min-width: 0;
}

.hub-thumb {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 86px;
  border-right: 1px solid var(--line);
}

.hub-thumb__placeholder {
  display: grid;
  place-items: center;
  width: 84px;
  height: 72px;
}

.hub-thumb__body {
  position: relative;
  width: 74px;
  height: 48px;
  transform: rotate(-28deg);
  border: 1px solid #dedede;
  border-radius: 9px;
  background: linear-gradient(135deg, #ffffff 0 58%, #ffd617 58% 100%);
  box-shadow: 0 14px 22px rgb(0 0 0 / 10%);
}

.hub-thumb__body::before,
.hub-thumb__body::after {
  position: absolute;
  top: 10px;
  width: 10px;
  height: 10px;
  border: 1px solid #d1d1d1;
  border-radius: 50%;
  background: #ffffff;
  content: "";
}

.hub-thumb__body::before {
  left: 10px;
}

.hub-thumb__body::after {
  right: 10px;
}

.hub-thumb__image {
  display: block;
  width: 84px;
  height: 72px;
  object-fit: contain;
  object-position: center;
  filter: drop-shadow(0 14px 20px rgb(0 0 0 / 12%));
}

.hub-summary {
  min-width: 0;
}

h1 {
  margin: 0;
  overflow-wrap: anywhere;
  color: #050505;
  font-size: clamp(30px, 3.3vw, 40px);
  font-weight: 760;
  line-height: 1.05;
  letter-spacing: 0;
}

.hub-status-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 8px;
  color: var(--muted);
}

.state-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  white-space: nowrap;
}

.state-pill--ready {
  color: var(--green);
  border-color: rgb(32 135 102 / 30%);
  background: #effaf6;
}

.state-pill--busy {
  color: var(--blue-strong);
  border-color: rgb(23 108 159 / 28%);
  background: #eef7fc;
}

.state-pill--error {
  color: var(--red);
  border-color: rgb(209 18 36 / 25%);
  background: #fff2f3;
}

.scan-stamp,
.port-count {
  font-size: 13px;
  white-space: nowrap;
}

.hub-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 12px 0 0;
}

.hub-meta div {
  min-width: 86px;
}

.hub-meta dt {
  color: var(--muted);
  font-size: 12px;
}

.hub-meta dd {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 720;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  min-width: 290px;
}

.button {
  --button-color: #303030;
  --button-border: #cfcfcf;
  --button-bg: var(--surface);
  --button-hover-bg: #f7f7f7;
  --button-hover-border: #b9b9b9;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 156px;
  min-height: 46px;
  border: 2px solid var(--button-border);
  border-radius: 999px;
  padding: 0 22px;
  color: var(--button-color);
  background: var(--button-bg);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: none;
  text-transform: none;
  transition:
    background-color 120ms ease,
    border-color 120ms ease,
    color 120ms ease;
  white-space: nowrap;
}

.button:hover:not(:disabled) {
  border-color: var(--button-hover-border);
  background: var(--button-hover-bg);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 1;
  color: color-mix(in srgb, var(--button-color) 68%, white);
  border-color: color-mix(in srgb, var(--button-border) 56%, white);
  background: var(--surface);
}

.button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
}

.button--primary {
  --button-color: #247fa8;
  --button-border: #8dc5dc;
  --button-hover-border: #6fb3d0;
  --button-hover-bg: #edf8fc;
}

.button--danger {
  --button-color: var(--red);
  --button-border: var(--red);
  --button-hover-border: #aa0c1a;
  --button-hover-bg: #fff6f7;
}

.dashboard-tabs {
  position: relative;
  display: flex;
  justify-content: center;
  gap: 18px;
  min-height: 46px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  border: 0;
  padding: 0 10px;
  color: #686868;
  background: transparent;
  font-size: 16px;
  text-transform: uppercase;
  cursor: pointer;
}

.tab:focus-visible {
  outline: 2px solid rgb(45 131 183 / 32%);
  outline-offset: 6px;
  border-radius: 3px;
}

.tab--active {
  color: var(--ink);
}

.tab--active::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--ink);
  content: "";
}

.dashboard-stage {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: 0;
  padding: clamp(20px, 3vh, 30px) 50px 14px;
  background: #ffffff;
}

.tab-panel {
  position: relative;
  height: 100%;
  min-height: 0;
}

.motor-test-panel {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 14px;
  height: 100%;
}

.motor-control-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 16px;
  height: 100%;
  min-height: 0;
}

.motor-test-controls,
.motor-control-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  min-height: 54px;
}

.field-label {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.field-control {
  min-height: 38px;
  min-width: 110px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}

.field-control:disabled {
  color: var(--faint);
  background: var(--surface-soft);
}

.field-control--number {
  width: 118px;
}

.field-unit {
  margin-left: -8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.motor-test-button,
.motor-control-button {
  min-width: 132px;
  min-height: 38px;
  padding: 0 16px;
}

.motor-test-status,
.motor-control-status,
.motor-control-angle,
.motor-control-result {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
}

.motor-control-angle,
.motor-control-result {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
}

.motor-control-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 2px;
}

.motor-action {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #ffffff;
}

.motor-action--wide {
  grid-column: 1 / -1;
}

.motor-action__header {
  display: grid;
  gap: 2px;
  margin-bottom: 12px;
}

.motor-action__header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.2;
}

.motor-action__header span {
  color: var(--muted);
  font-size: 13px;
}

.motor-action__buttons,
.motor-action__fields {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.motor-action__fields--distance {
  display: grid;
  grid-template-columns: auto minmax(92px, 120px) auto auto minmax(92px, 120px) auto auto minmax(92px, 120px) minmax(104px, auto) auto;
}

.motor-control-preview {
  min-width: 104px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.motor-control-result {
  flex: 1 1 280px;
  min-width: min(100%, 280px);
}

.motor-progress {
  display: grid;
  gap: 6px;
  max-width: 520px;
}

.motor-progress[hidden] {
  display: none;
}

.motor-progress__header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.motor-progress__track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.motor-progress__fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width 160ms ease;
}

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

.motor-metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #ffffff;
}

.motor-metric__label {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.motor-metric__value {
  overflow: hidden;
  margin-top: 3px;
  color: var(--ink);
  font-size: 20px;
  font-weight: 740;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.motor-metric__detail {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.motor-charts {
  height: auto;
  min-height: 260px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.motor-chart-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
}

.motor-chart-title {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
}

.motor-chart-shell {
  min-width: 0;
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.motor-chart {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 260px;
}

.chart-grid {
  stroke: #e8e8e8;
  stroke-width: 1;
}

.chart-axis,
.chart-axis-zero {
  stroke: #b9b9b9;
  stroke-width: 1.4;
}

.chart-axis-zero {
  stroke: #9d9d9d;
}

.chart-line {
  fill: none;
  stroke: var(--blue);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chart-point {
  fill: #ffffff;
  stroke: var(--blue);
  stroke-width: 2;
}

.chart-tick,
.chart-label,
.chart-empty {
  fill: var(--muted);
  font-size: 13px;
}

.chart-label {
  font-weight: 650;
}

.chart-label--vertical {
  writing-mode: tb;
  glyph-orientation-vertical: 0;
}

.chart-empty {
  fill: var(--faint);
  font-size: 18px;
}

.imu-panel {
  position: absolute;
  top: clamp(22px, 4vh, 44px);
  left: clamp(18px, 2.8vw, 42px);
  z-index: 2;
  display: grid;
  gap: 8px;
  min-width: 132px;
  color: #989898;
  font-size: 16px;
  line-height: 1.1;
  pointer-events: none;
}

.imu-row {
  display: grid;
  grid-template-columns: 66px minmax(42px, auto);
  gap: 7px;
  align-items: baseline;
}

.imu-value {
  color: #777777;
  font-weight: 560;
  white-space: nowrap;
}

.hub-dashboard {
  --dashboard-gap: clamp(18px, 3.2vw, 46px);
  --port-line-length: calc(var(--dashboard-gap) + 18px);
  --hub-visual-height: min(100%, 455px);
  --row-y-1: 23%;
  --row-y-2: 50%;
  --row-y-3: 77%;
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-columns: minmax(160px, 250px) minmax(220px, 320px) minmax(160px, 250px);
  gap: var(--dashboard-gap);
  align-items: center;
  justify-content: center;
}

.port-column {
  position: relative;
  height: var(--hub-visual-height);
  display: block;
  min-width: 0;
}

.hub-dashboard[data-port-count="2"] {
  --row-y-1: 50%;
}

.hub-dashboard[data-port-count="4"] {
  --row-y-1: 35%;
  --row-y-2: 65%;
}

.hub-canvas {
  display: grid;
  place-items: center;
  height: var(--hub-visual-height);
  min-width: 0;
}

.hub-body {
  position: relative;
  width: auto;
  height: 100%;
  max-width: 100%;
  aspect-ratio: 0.66;
  border: 1px solid #d2d6d9;
  border-radius: 18px;
  background:
    linear-gradient(180deg, #f4f6f7 0%, #eceff1 100%),
    #eef0f2;
  box-shadow: 0 18px 46px rgb(0 0 0 / 14%);
  opacity: 1;
}

.hub-body::before {
  content: none;
}

.hub-slot,
.hub-screw,
.hub-brand,
.hub-screen,
.hub-grid,
.hub-button,
.hub-paddle {
  display: none;
}

.hub-port-label {
  position: absolute;
  transform: translateY(-50%);
  color: #72777a;
  font-size: clamp(19px, 2vw, 24px);
  font-weight: 800;
  line-height: 1;
}

.hub-port-label--a,
.hub-port-label--b {
  top: var(--row-y-1);
}

.hub-port-label--c,
.hub-port-label--d {
  top: var(--row-y-2);
}

.hub-port-label--e,
.hub-port-label--f {
  top: var(--row-y-3);
}

.hub-port-label--a,
.hub-port-label--c,
.hub-port-label--e {
  left: 16%;
}

.hub-port-label--b,
.hub-port-label--d,
.hub-port-label--f {
  right: 16%;
}

.port-tile {
  position: relative;
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 0 12px;
  align-items: center;
  min-height: 86px;
  color: var(--muted);
}

.port-column .port-tile {
  position: absolute;
  top: var(--port-row-y);
  right: 0;
  left: 0;
  width: 100%;
  transform: translateY(-50%);
}

.port-tile--row-1 {
  --port-row-y: var(--row-y-1);
}

.port-tile--row-2 {
  --port-row-y: var(--row-y-2);
}

.port-tile--row-3 {
  --port-row-y: var(--row-y-3);
}

.port-column--left .port-tile {
  grid-template-columns: minmax(0, 1fr) 60px;
}

.port-column--left .device-icon {
  grid-column: 2;
}

.port-column--left .port-content {
  grid-column: 1;
  grid-row: 1;
  text-align: right;
}

.port-tile::after {
  position: absolute;
  top: 50%;
  width: var(--port-line-length);
  height: 4px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, #a8afb3 0 14px, transparent 14px 22px);
  content: "";
}

.port-column--left .port-tile::after {
  right: calc(0px - var(--port-line-length));
}

.port-column--right .port-tile::after {
  left: calc(0px - var(--port-line-length));
}

.device-icon {
  --icon-color: var(--port-empty);
  position: relative;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border: 3px solid var(--icon-color);
  border-radius: 50%;
}

.device-icon__core {
  position: relative;
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--icon-color);
  box-shadow: 0 -16px 0 var(--icon-color), 16px 0 0 var(--icon-color), 0 16px 0 var(--icon-color), -16px 0 0 var(--icon-color);
}

.device-icon--sensor {
  border-radius: 12px;
}

.device-icon--sensor .device-icon__core {
  width: 28px;
  height: 28px;
  border: 3px solid var(--icon-color);
  background: transparent;
  box-shadow: none;
}

.device-icon--sensor .device-icon__core::before {
  position: absolute;
  inset: 7px;
  border-radius: 50%;
  background: var(--icon-color);
  content: "";
}

.device-icon--empty {
  border-style: dashed;
  border-radius: 12px;
}

.device-icon--empty .device-icon__core {
  width: 26px;
  height: 14px;
  border: 3px solid var(--icon-color);
  border-radius: 999px;
  background: transparent;
  box-shadow: none;
}

.port-tile--device .device-icon {
  --icon-color: var(--blue);
}

.port-tile--unknown .device-icon {
  --icon-color: var(--amber);
}

.port-tile--error .device-icon {
  --icon-color: var(--red);
}

.port-tile--unavailable {
  opacity: 0.36;
}

.port-content {
  min-width: 0;
}

.port-device {
  overflow: visible;
  color: var(--blue);
  font-size: 16px;
  font-weight: 720;
  line-height: 1.16;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.port-detail {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.port-detail--live {
  color: var(--blue);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.12;
}

.port-mode-display {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
}

.port-column--left .port-mode-display {
  justify-content: flex-end;
}

.port-mode-button {
  border: 0;
  padding: 0;
  color: var(--blue);
  background: transparent;
  cursor: pointer;
  text-align: inherit;
}

.port-mode-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.port-mode-value {
  min-width: 0;
  overflow: hidden;
  color: var(--blue);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.port-mode-button::after {
  flex: 0 0 auto;
  display: inline-block;
  width: 0;
  height: 0;
  margin-left: 7px;
  transform: translateY(1px);
  border-top: 5px solid currentColor;
  border-right: 4px solid transparent;
  border-left: 4px solid transparent;
  content: "";
  opacity: 0.62;
}

.port-mode-button:focus-visible {
  outline: 2px solid rgb(45 131 183 / 32%);
  outline-offset: 4px;
  border-radius: 4px;
}

.port-mode-menu {
  position: absolute;
  z-index: 20;
  width: min(220px, calc(100% - 24px));
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgb(0 0 0 / 14%);
}

.port-mode-menu__item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.port-mode-menu__item:hover,
.port-mode-menu__item:focus-visible {
  outline: none;
  background: var(--surface-soft);
}

.port-mode-menu__item[aria-checked="true"] {
  color: var(--blue);
  font-weight: 700;
}

.port-mode-menu__check {
  color: var(--blue);
  text-align: center;
}

.port-mode-menu__label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.port-mode-menu__value {
  max-width: 86px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.port-tile--device .port-device,
.port-tile--unknown .port-device {
  color: var(--blue);
}

.port-tile--error .port-device {
  color: var(--red);
}

.port-tile--unavailable .port-device,
.port-tile:not(.port-tile--device):not(.port-tile--unknown):not(.port-tile--error) .port-device {
  color: var(--muted);
}

.message-box {
  min-height: 22px;
  margin-top: 10px;
  color: var(--muted);
  text-align: center;
}

.message-box--error {
  color: var(--red);
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 28px, 1280px);
    align-items: start;
  }

  .dashboard-panel {
    min-height: calc(100vh - 28px);
  }

  .dashboard-header {
    flex-direction: column;
    padding: 24px 26px 18px;
  }

  .toolbar {
    justify-content: flex-start;
    min-width: 0;
  }

  .dashboard-stage {
    padding: 32px 28px 24px;
  }

  .imu-panel {
    left: 22px;
  }

  .hub-dashboard {
    --dashboard-gap: 30px;
    --port-line-length: 48px;
    grid-template-columns: minmax(150px, 220px) minmax(230px, 320px) minmax(150px, 220px);
    gap: var(--dashboard-gap);
  }

  .port-tile::after {
    width: var(--port-line-length);
  }

  .port-column--left .port-tile::after {
    right: calc(0px - var(--port-line-length));
  }

  .port-column--right .port-tile::after {
    left: calc(0px - var(--port-line-length));
  }
}

@media (max-height: 780px) and (min-width: 761px) {
  .app-shell {
    padding: 8px 0;
  }

  .dashboard-panel {
    height: calc(100vh - 16px);
    height: calc(100dvh - 16px);
  }

  .dashboard-header {
    padding: 14px 30px 10px;
  }

  .hub-identity {
    grid-template-columns: 84px minmax(0, 1fr);
    gap: 18px;
  }

  .hub-thumb {
    min-height: 72px;
  }

  .hub-thumb__placeholder,
  .hub-thumb__image {
    width: 60px;
    height: 54px;
  }

  .hub-thumb__body {
    width: 60px;
    height: 40px;
  }

  h1 {
    font-size: clamp(28px, 3vw, 34px);
  }

  .hub-meta {
    margin-top: 8px;
  }

  .button {
    min-height: 36px;
    padding: 0 14px;
  }

  .dashboard-tabs {
    min-height: 40px;
  }

  .dashboard-stage {
    padding: 14px 42px 10px;
  }

  .imu-panel {
    top: 16px;
    left: 24px;
    font-size: 14px;
  }

  .hub-dashboard {
    --hub-visual-height: min(100%, 394px);
  }

  .port-tile {
    min-height: 76px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: 100%;
    padding: 0;
  }

  .dashboard-panel {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    overflow: visible;
    border-radius: 0;
  }

  .hub-identity {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 18px;
  }

  .hub-thumb {
    min-height: 82px;
  }

  .hub-thumb__placeholder,
  .hub-thumb__image {
    width: 56px;
    height: 48px;
  }

  .hub-thumb__body {
    width: 56px;
    height: 38px;
  }

  h1 {
    font-size: 30px;
  }

  .hub-meta {
    gap: 10px 18px;
  }

  .toolbar {
    width: 100%;
  }

  .button {
    flex: 1 1 132px;
    min-height: 42px;
    padding: 0 12px;
  }

  .dashboard-tabs {
    justify-content: flex-start;
    overflow-x: auto;
    padding-left: 18px;
  }

  .dashboard-stage {
    padding: 24px 18px 20px;
  }

  .motor-charts {
    grid-template-columns: 1fr;
    height: auto;
  }

  .motor-control-actions {
    grid-template-columns: 1fr;
  }

  .motor-action__fields--distance {
    grid-template-columns: auto minmax(92px, 1fr) auto;
  }

  .motor-action__fields--distance .motor-control-button {
    grid-column: 1 / -1;
  }

  .motor-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .imu-panel {
    position: static;
    margin-bottom: 18px;
    pointer-events: auto;
  }

  .hub-dashboard {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .hub-canvas {
    order: -1;
    height: auto;
  }

  .hub-body {
    width: min(70vw, 300px);
    height: auto;
  }

  .port-column {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: none;
    height: auto;
    gap: 18px;
    align-content: initial;
    padding-block: 0;
  }

  .port-column .port-tile {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    width: auto;
    transform: none;
  }

  .hub-dashboard[data-port-count="2"] .port-column,
  .hub-dashboard[data-port-count="4"] .port-column {
    grid-template-rows: none;
    gap: 18px;
    padding-block: 0;
  }

  .port-tile {
    grid-template-columns: 52px minmax(0, 1fr);
    min-height: 86px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  .port-column--left .port-tile {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .port-column--left .device-icon,
  .port-column--left .port-content {
    grid-column: auto;
    grid-row: auto;
    text-align: left;
  }

  .port-tile::after {
    display: none;
  }

  .device-icon {
    width: 46px;
    height: 46px;
    border-width: 2px;
  }

  .device-icon__core {
    width: 9px;
    height: 9px;
    box-shadow: 0 -14px 0 var(--icon-color), 14px 0 0 var(--icon-color), 0 14px 0 var(--icon-color), -14px 0 0 var(--icon-color);
  }

  .port-device {
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  .dashboard-header {
    padding: 18px 16px 16px;
  }

  .hub-identity {
    grid-template-columns: 1fr;
  }

  .hub-thumb {
    display: none;
  }

  .port-column {
    grid-template-columns: 1fr;
  }

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

  .motor-action__fields--distance {
    grid-template-columns: 1fr;
  }

  .field-unit {
    margin-left: 0;
  }
}
