.compact-body {
  height: 100vh;
  overflow: hidden;
}

.compact-dashboard {
  width: min(1600px, 98vw);
  height: 100vh;
  margin: 0 auto;
  padding: 12px 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.compact-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.compact-topbar h1 {
  margin: 0;
  font-size: clamp(21px, 2vw, 30px);
}

.compact-topbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.compact-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.compact-header-actions a {
  text-decoration: none;
  white-space: nowrap;
}

.compact-connection {
  min-width: 220px;
  padding: 9px 13px;
  border-radius: 14px;
}

.compact-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.72fr) minmax(350px, 0.88fr);
  gap: 10px;
}

.compact-grid .card {
  border-radius: 18px;
  padding: 14px;
}

.compact-card-header {
  margin-bottom: 10px;
}

.compact-card-header h2 {
  font-size: 17px;
}

.compact-card-header p {
  margin-top: 2px;
  font-size: 12px;
}

.compact-camera-card,
.compact-tank-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.compact-camera {
  min-height: 0;
  flex: 1;
  padding: 0;
  border-radius: 14px;
}

.compact-camera img {
  width: 100%;
  height: 100%;
  max-width: none;
  aspect-ratio: auto;
  object-fit: cover;
}

.compact-fullscreen {
  margin-top: 9px;
  padding: 10px 14px;
}

.compact-tank-content {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 8px;
}

.compact-process-visual {
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 310px;
}

.compact-tank {
  width: min(190px, 80%);
  height: calc(100% - 10px);
  min-height: 300px;
  max-height: 520px;
  border-width: 7px;
  left: -5px;
}

.compact-process-visual .pump-unit {
  left: -25px;
  transform: scale(0.78);
  transform-origin: left center;
}

.compact-process-visual .valve-unit {
  right: 30px;
  transform: scale(0.78);
  transform-origin: right center;
}

.compact-process-visual .outlet-jet {
  right: 0;
  height: 58px;
}

.compact-tank .inlet-jet {
  left: 62px;
}

.compact-process-visual .inlet-pipe {
  left: 24px;
}

.compact-process-visual .outlet-pipe {
  right: 10px;
}

.compact-level-info h3 {
  font-size: 38px;
}

.compact-level-info p {
  margin: 0;
}

.compact-mini-data {
  min-width: 150px;
  margin-top: 7px;
  padding: 9px;
}

.compact-control-column {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(100px, 1fr);
  gap: 10px;
}

.compact-panel {
  min-height: 0;
}

.compact-status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.compact-status-grid .status-item {
  padding: 9px 11px;
  border-radius: 11px;
}

.compact-status-grid .status-item strong {
  font-size: 14px;
}

.compact-controls {
  gap: 8px;
}

.compact-controls .btn {
  padding: 11px 8px;
}

.compact-setpoint-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.compact-setpoint-row input {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--panel-light);
  color: white;
  font-size: 16px;
}

.compact-events {
  display: flex;
  flex-direction: column;
}

.compact-log {
  min-height: 0;
  height: auto;
  flex: 1;
  padding: 10px;
  font-size: 11px;
  line-height: 1.35;
}

@media (max-width: 1050px), (max-height: 650px) {
  .compact-body {
    height: auto;
    overflow: auto;
  }

  .compact-dashboard {
    height: auto;
    min-height: 100vh;
  }

  .compact-grid {
    grid-template-columns: 1fr 1fr;
  }

  .compact-control-column {
    grid-column: span 2;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: auto auto;
  }
}

@media (max-width: 720px) {
  .compact-topbar,
  .compact-header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .compact-grid {
    grid-template-columns: 1fr;
  }

  .compact-control-column {
    grid-column: auto;
    display: grid;
    grid-template-columns: 1fr;
  }

  .compact-camera {
    min-height: 300px;
  }
}
