:root {
  --bg: #0b0907;
  --panel: rgba(26, 21, 17, 0.88);
  --panel-2: rgba(40, 33, 27, 0.92);
  --gold: #d6b96f;
  --gold-2: #f1d994;
  --green: #38c172;
  --blue: #54a7d8;
  --orange: #ed9a4a;
  --red: #e65f58;
  --line: rgba(214, 185, 111, 0.18);
  --text: #fff7e7;
  --muted: rgba(255, 247, 231, 0.62);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  background:
    radial-gradient(circle at 15% 15%, rgba(84, 167, 216, 0.12), transparent 28%),
    linear-gradient(135deg, #090705 0%, #17110d 48%, #0e0b09 100%);
}

button {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 24px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

.shell {
  width: min(100vw, 1920px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px;
}

.statusbar,
.workbench,
.brand,
.status-strip,
.controls,
.panel-head,
.section-title,
.order-flow,
.device-panel,
.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
}

.statusbar {
  height: 76px;
  justify-content: space-between;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 22px;
  background: rgba(12, 9, 7, 0.82);
  backdrop-filter: blur(18px);
}

.brand {
  gap: 14px;
}

.brand img {
  width: 42px;
  height: 42px;
}

.brand strong,
.rail-title strong,
.section-title strong,
.metric strong,
.modal-head strong {
  display: block;
  letter-spacing: 0;
}

.brand span,
.rail-title span,
.section-title span,
.metric span,
.hero-copy span,
.hero-badge span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.status-strip {
  gap: 22px;
  color: var(--muted);
  font-size: 15px;
}

.status-strip b {
  color: var(--text);
}

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

.ghost {
  min-height: 42px;
  padding: 0 16px;
  color: var(--gold-2);
  font-size: 14px;
}

.language-switch {
  display: flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.045);
}

.language-switch button {
  min-height: 34px;
  border-color: transparent;
  padding: 0 10px;
  font-size: 12px;
}

.language-switch button.active {
  color: #160f08;
  background: var(--gold-2);
}

.workbench {
  align-items: stretch;
  gap: 18px;
  padding-top: 18px;
}

.left-rail,
.right-rail {
  width: 330px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rail-title,
.io-card,
.metrics,
.alarms,
.command-log,
.process-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.rail-title {
  padding: 18px;
}

.recipe-list {
  display: grid;
  gap: 12px;
}

.recipe-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 14px;
  min-height: 118px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.055);
  cursor: pointer;
}

.recipe-card.active {
  border-color: color-mix(in srgb, var(--accent), white 20%);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent), transparent 72%), rgba(255, 255, 255, 0.06));
}

.recipe-card img {
  width: 86px;
  height: 96px;
  object-fit: cover;
  border-radius: 7px;
}

.recipe-card strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.recipe-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.recipe-meta {
  color: var(--gold-2);
  font-weight: 800;
}

.stage {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(380px, 54vh) 1fr;
  gap: 18px;
}

.hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #140f0b;
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-shade {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(9, 7, 5, 0.9), rgba(9, 7, 5, 0.46) 50%, rgba(9, 7, 5, 0.06));
}

.hero-copy {
  position: absolute;
  left: 46px;
  bottom: 42px;
  width: min(640px, 70%);
}

.hero-copy span {
  color: var(--gold-2);
  letter-spacing: 0.18em;
}

.hero-copy h1 {
  margin: 12px 0 10px;
  font-size: clamp(42px, 5vw, 86px);
  line-height: 1;
  letter-spacing: 0;
}

.hero-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 22px;
}

.hero-badge {
  position: absolute;
  right: 30px;
  bottom: 30px;
  min-width: 142px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 18px;
  background: rgba(10, 8, 6, 0.74);
  text-align: center;
}

.hero-badge strong {
  display: block;
  font-size: 34px;
}

.process-panel {
  padding: 20px;
}

.panel-head {
  justify-content: space-between;
  gap: 20px;
}

.panel-head span {
  color: var(--muted);
}

.panel-head strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
}

.progress-ring {
  position: relative;
  width: 108px;
  height: 108px;
}

.progress-ring svg {
  width: 108px;
  height: 108px;
  transform: rotate(-90deg);
}

.progress-ring circle {
  fill: none;
  stroke-width: 10;
  stroke: rgba(255, 255, 255, 0.12);
}

#progressArc {
  stroke: var(--gold-2);
  stroke-linecap: round;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
}

.progress-ring b {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 21px;
}

.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  margin: 14px 0;
  padding: 0;
  list-style: none;
}

.steps li {
  min-height: 108px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.steps li.active {
  border-color: var(--gold);
  background: rgba(214, 185, 111, 0.14);
}

.steps li.done {
  border-color: rgba(56, 193, 114, 0.42);
}

.steps li.error {
  border-color: rgba(230, 95, 88, 0.58);
  background: rgba(230, 95, 88, 0.14);
}

.steps b {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

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

.order-flow {
  gap: 10px;
  margin-top: 16px;
  overflow: hidden;
}

.option-panel {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.option-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.045);
}

.option-group > span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.option-group small {
  display: block;
  min-height: 34px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.segmented button {
  min-height: 40px;
  padding: 0 8px;
  font-size: 14px;
}

.segmented button.active {
  border-color: rgba(241, 217, 148, 0.5);
  color: #160f08;
  background: linear-gradient(135deg, var(--gold-2), var(--orange));
}

.flow-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 112px;
  color: var(--muted);
  font-weight: 800;
}

.flow-item b {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
}

.flow-item.active,
.flow-item.done {
  color: var(--text);
}

.flow-item.active b,
.flow-item.done b {
  border-color: rgba(56, 193, 114, 0.6);
  color: #07120b;
  background: var(--green);
}

.flow-line {
  width: 34px;
  height: 1px;
  background: var(--line);
}

.order-code {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  color: var(--gold-2);
  background: rgba(255, 255, 255, 0.045);
  font-weight: 800;
  white-space: nowrap;
}

.device-panel {
  display: grid;
  grid-template-columns: 1.1fr 1.5fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.device-panel div {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.device-panel span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

.device-panel strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 17px;
}

.controls {
  gap: 12px;
}

.primary {
  border-color: rgba(241, 217, 148, 0.5);
  color: #160f08;
  background: linear-gradient(135deg, var(--gold-2), var(--orange));
}

.danger {
  border-color: rgba(230, 95, 88, 0.48);
  background: rgba(230, 95, 88, 0.22);
}

.io-card,
.alarms,
.command-log {
  padding: 18px;
}

.section-title {
  justify-content: space-between;
  margin-bottom: 14px;
}

.io-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.io-grid div,
.metric,
.alarms li {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.io-grid b,
.io-grid span {
  display: block;
}

.io-grid span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
}

.metric strong {
  margin-top: 8px;
  font-size: 23px;
}

.alarms {
  flex: 1;
}

.alarms ul {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.alarms li.warning {
  border-color: rgba(237, 154, 74, 0.45);
}

.alarms li.error {
  border-color: rgba(230, 95, 88, 0.58);
}

.alarms li strong {
  display: block;
  margin-bottom: 5px;
}

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

.command-log {
  max-height: 250px;
  overflow: hidden;
}

.command-log ol {
  display: grid;
  gap: 8px;
  max-height: 178px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.command-log li {
  border-left: 3px solid var(--gold);
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.045);
  font-size: 12px;
  line-height: 1.35;
}

.command-log time {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
}

.command-log code {
  color: var(--gold-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.maint-dialog {
  width: min(1560px, calc(100vw - 40px));
  max-height: calc(100vh - 36px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: var(--panel-2);
}

.maint-dialog::backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.maint {
  padding: 22px;
}

.modal-head,
.modal-actions {
  justify-content: space-between;
  gap: 12px;
}

.modal-head button {
  width: 44px;
  min-height: 44px;
  padding: 0;
}

.modal-head span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 14px;
}

.maint-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 18px;
  min-height: 680px;
  margin: 20px 0;
}

.maint-nav {
  display: grid;
  align-content: start;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.maint-nav button {
  justify-content: flex-start;
  width: 100%;
  min-height: 58px;
  border-color: transparent;
  color: var(--muted);
  text-align: left;
}

.maint-nav button.active {
  border-color: rgba(241, 217, 148, 0.38);
  color: #140f08;
  background: linear-gradient(135deg, var(--gold-2), var(--orange));
}

.maint-content {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.04);
  overflow: auto;
}

.maint-tab {
  display: none;
}

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

.maint-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.maint-section-title span {
  color: var(--muted);
}

.maint-section-title strong {
  font-size: 24px;
}

.maint-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 0 0 18px;
}

.control-layer {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px minmax(260px, 1.4fr);
  gap: 12px;
  margin-bottom: 18px;
}

.control-layer label,
.control-status {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.control-layer select {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  font-size: 18px;
}

.control-status {
  align-content: center;
  color: var(--gold-2);
  font-weight: 800;
}

.maint-grid.compact {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.maint-grid label,
.stock-grid label,
.capsule-total label {
  position: relative;
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.maint-grid input,
.maint-grid select,
.stock-grid input,
.capsule-total input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  font-size: 18px;
}

.maint-grid input[type="range"] {
  min-height: 24px;
  padding: 0;
  accent-color: var(--gold);
}

.maint-grid output {
  color: var(--gold-2);
  font-weight: 800;
}

.stock-grid,
.capsule-grid,
.toggle-grid,
.maint-actions-grid,
.recognition-panel {
  display: grid;
  gap: 12px;
}

.stock-grid {
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-bottom: 18px;
}

.stock-grid b,
.capsule-total b {
  position: absolute;
  right: 24px;
  bottom: 25px;
  color: var(--muted);
}

.maint-actions-grid {
  grid-template-columns: repeat(4, 1fr);
}

.maint-actions-grid button,
.toggle-grid button,
.capsule-grid button,
.capsule-total button,
.module-groups button {
  color: #102018;
  background: #3d8d64;
}

.capsule-total {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 190px;
  gap: 12px;
  margin-bottom: 16px;
}

.recognition-panel {
  grid-template-columns: 180px 220px 180px 1fr;
  margin-bottom: 16px;
}

.recognition-panel label,
.recognition-result {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.045);
}

.recognition-panel input,
.recognition-panel select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  font-size: 17px;
}

.recognition-result {
  align-content: center;
  color: var(--gold-2);
  font-weight: 800;
}

.capsule-grid {
  grid-template-columns: repeat(5, 1fr);
}

.capsule-grid button {
  min-height: 62px;
  line-height: 1.25;
}

.capsule-grid button.filled {
  background: #3d8d64;
}

.capsule-grid button.low {
  background: #b9732d;
}

.toggle-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 18px;
}

.toggle-grid button.off {
  color: var(--text);
  background: rgba(230, 95, 88, 0.24);
}

.device-info {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 18px 22px;
  margin: 0;
  font-size: 22px;
}

.device-info dt {
  color: var(--muted);
}

.device-info dd {
  margin: 0;
  text-align: right;
}

.module-groups {
  display: grid;
  gap: 18px;
}

.module-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.module-group strong {
  display: block;
  margin-bottom: 12px;
  font-size: 20px;
}

.module-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

@media (max-width: 1180px) {
  .workbench {
    display: grid;
  }

  .left-rail,
  .right-rail {
    width: auto;
  }

  .recipe-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .steps {
    grid-template-columns: repeat(2, 1fr);
  }

  .device-panel,
  .order-flow,
  .option-panel {
    display: grid;
  }

  .device-panel {
    grid-template-columns: 1fr;
  }

  .maint-layout {
    grid-template-columns: 1fr;
  }

  .maint-nav,
  .stock-grid,
  .maint-actions-grid,
  .toggle-grid,
  .capsule-grid,
  .module-actions,
  .control-layer {
    grid-template-columns: repeat(2, 1fr);
  }

  .recognition-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .statusbar,
  .status-strip,
  .controls,
  .maint-grid {
    display: grid;
  }

  .statusbar {
    height: auto;
    gap: 14px;
    padding: 16px;
  }

  .recipe-list,
  .io-grid,
  .metrics,
  .steps,
  .device-panel {
    grid-template-columns: 1fr;
  }

  .order-flow {
    grid-template-columns: 1fr 1fr;
  }

  .flow-line {
    display: none;
  }

  .hero-copy {
    left: 22px;
    bottom: 24px;
    width: calc(100% - 44px);
  }

  .hero-badge {
    top: 18px;
    right: 18px;
    bottom: auto;
  }

  .maint-grid,
  .stock-grid,
  .maint-actions-grid,
  .toggle-grid,
  .capsule-grid,
  .capsule-total,
  .recognition-panel,
  .option-panel,
  .module-actions,
  .device-info,
  .control-layer {
    grid-template-columns: 1fr;
  }

  .device-info dd {
    text-align: left;
  }
}
