:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f6;
  --line: #d8e0e6;
  --text: #17212b;
  --muted: #5d6875;
  --green: #1c8f5a;
  --green-2: #e7f5ee;
  --blue: #1e6fb7;
  --amber: #b87909;
  --amber-2: #fff2cf;
  --red: #bd3b3b;
  --black: #101316;
  --shadow: 0 8px 22px rgba(24, 36, 48, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 7px 13px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #aebbc6;
  background: #f8fafb;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.primary {
  border-color: #176a43;
  background: var(--green);
  color: #ffffff;
}

button.primary:hover:not(:disabled) {
  background: #157d4e;
}

button.secondary {
  background: var(--surface-2);
}

button.small {
  min-height: 30px;
  padding: 4px 10px;
}

button.wide {
  width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.landing-header,
.app-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.landing-header {
  justify-content: space-between;
}

.landing-header h1,
.app-header h1 {
  margin: 0;
  font-size: 1.45rem;
}

.header-status,
.connection-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--muted);
  font-weight: 600;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--red);
  display: inline-block;
}

.status-dot.online {
  background: var(--green);
}

.status-dot.warning {
  background: var(--amber);
}

.status-dot.offline {
  background: var(--red);
}

.landing-shell {
  padding: 20px;
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
}

.app-card {
  min-height: 156px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.app-card h2 {
  margin: 8px 0 2px;
  font-size: 1rem;
}

.app-card p {
  margin: 0;
  color: var(--muted);
}

.app-card-active {
  border-color: #88bda3;
}

.app-card-active:hover {
  border-color: var(--green);
  transform: translateY(-1px);
}

.app-icon {
  width: 58px;
  height: 58px;
  object-fit: contain;
}

.placeholder {
  box-shadow: none;
  background: #f9fbfc;
  color: #6c7580;
}

.placeholder-icon {
  width: 40px;
  height: 40px;
  border: 1px dashed #a8b3bd;
  border-radius: 8px;
}

.app-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--green-2);
  color: #176a43;
  font-size: 0.75rem;
  font-weight: 700;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
}

.back-link {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted);
  background: #fbfcfd;
  font-weight: 700;
}

.product-mark {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.product-title {
  flex: 1;
}

.workbench {
  padding: 14px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.tab-button {
  border-color: transparent;
  background: transparent;
  min-height: 34px;
}

.tab-button.active {
  background: var(--black);
  color: #ffffff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-grid {
  display: grid;
  gap: 12px;
}

.serial-grid {
  grid-template-columns: minmax(300px, 1fr) minmax(260px, 0.8fr) minmax(280px, 0.8fr);
}

.set-grid,
.run-grid,
.simulation-layout {
  grid-template-columns: minmax(520px, 1.3fr) minmax(340px, 0.7fr);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  box-shadow: var(--shadow);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.panel-title h2 {
  margin: 0;
  font-size: 1rem;
}

.small-status {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
}

.form-grid.compact,
.form-grid.three-col {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select,
textarea {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  padding: 7px 9px;
}

input[type="checkbox"] {
  min-height: 0;
  width: auto;
  accent-color: var(--green);
}

input[type="range"] {
  padding: 0;
  accent-color: var(--green);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
}

.toggle-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 10px 0 0;
  color: var(--text);
}

.status-list,
.register-table,
.sim-metrics {
  display: grid;
  gap: 8px;
}

.status-list div,
.register-table div,
.sim-metrics div,
.button-indicator {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fbfcfd;
}

.status-list span,
.register-table span,
.sim-metrics span,
.button-indicator span {
  color: var(--muted);
}

.reference-table {
  width: 100%;
  border-collapse: collapse;
}

.reference-table th,
.reference-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 6px;
  text-align: left;
  vertical-align: top;
}

.reference-table th {
  width: 110px;
  color: var(--muted);
}

.write-list {
  display: grid;
  gap: 10px;
}

.write-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  align-items: end;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.icon-layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 12px;
}

.selected-icon-panel {
  display: grid;
  gap: 10px;
  align-content: start;
}

.qr-send-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fbfcfd;
}

.preview-box {
  min-height: 220px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #000000;
  border: 1px solid #111111;
}

.preview-box img {
  max-width: 100%;
  max-height: 210px;
  object-fit: contain;
}

.icon-board-panel {
  min-height: 620px;
}

.icon-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
  max-height: calc(100vh - 230px);
  overflow: auto;
  padding-right: 3px;
}

.icon-tile {
  min-height: 142px;
  display: grid;
  grid-template-rows: 86px auto;
  align-items: center;
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.icon-tile.active {
  border-color: var(--green);
  background: var(--green-2);
}

.icon-tile img {
  max-width: 78px;
  max-height: 82px;
  object-fit: contain;
  justify-self: center;
  background: #000000;
}

.icon-tile span {
  color: var(--text);
  font-size: 0.75rem;
  line-height: 1.2;
}

.simulation-layout {
  display: grid;
  gap: 12px;
}

.lift-panel {
  display: grid;
  grid-template-columns: 230px minmax(220px, 1fr);
  gap: 16px;
  align-items: stretch;
}

.lift-scene {
  min-height: 420px;
  display: grid;
  place-items: center;
  background: #eaf0f4;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.shaft {
  position: relative;
  width: 120px;
  height: 360px;
  background: #d5dde4;
  border: 2px solid #95a2ad;
  overflow: hidden;
}

.floor-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #95a2ad;
}

.floor-line.top {
  top: 30px;
}

.floor-line.middle {
  top: 176px;
}

.floor-line.bottom {
  bottom: 30px;
}

.car {
  position: absolute;
  left: 18px;
  bottom: 42px;
  width: 80px;
  height: 96px;
  border: 2px solid #263442;
  background: #f8fafb;
  transition: bottom 650ms ease;
  overflow: hidden;
}

.car.moving {
  bottom: 220px;
}

.car-door {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: #cdd6de;
  border: 1px solid #8996a1;
  transition: transform 350ms ease;
}

.car-door.left {
  left: 0;
}

.car-door.right {
  right: 0;
}

.car.open .car-door.left {
  transform: translateX(-76%);
}

.car.open .car-door.right {
  transform: translateX(76%);
}

.flow-nodes {
  display: grid;
  gap: 8px;
  align-content: center;
}

.flow-node {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
}

.flow-node.active {
  border-color: var(--amber);
  background: var(--amber-2);
}

.flow-node.done {
  border-color: #93c9ad;
  background: var(--green-2);
}

.flow-node strong {
  display: block;
}

.flow-node span {
  color: var(--muted);
  font-size: 0.82rem;
}

.log-panel textarea {
  min-height: 560px;
  font-family: Consolas, "Courier New", monospace;
  resize: vertical;
}

@media (max-width: 1100px) {
  .app-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

  .serial-grid,
  .set-grid,
  .run-grid,
  .simulation-layout,
  .lift-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .landing-header,
  .app-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .app-grid,
  .form-grid,
  .form-grid.compact,
  .form-grid.three-col,
  .icon-layout {
    grid-template-columns: 1fr;
  }

  .write-row {
    grid-template-columns: 1fr;
  }

  .icon-board {
    max-height: none;
  }
}
