:root {
  color-scheme: dark;
  --bg: #25272a;
  --bar: #2c2f33;
  --card: #3a3e43;
  --panel: #2c2f33;
  --deep: #1d2024;
  --line: #44484d;
  --text: #e7e9ec;
  --muted: #a3a7ad;
  --blue: #168cff;
  --sim-black: #101112;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.35 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  height: 56px;
  border-bottom: 2px solid #44494e;
  background: #292c30;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding: 0 18px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { margin-right: 18px; color: #c8cbd0; font-weight: 800; white-space: nowrap; }
.version { font-size: 10px; font-weight: 600; color: #969ba2; margin-left: 4px; }
.top-controls { display: flex; align-items: center; gap: 8px; }
.top-controls label { display: flex; align-items: center; gap: 9px; background: #353a40; padding: 6px 9px; border-radius: 8px; color: #b8bdc4; font-weight: 700; white-space: nowrap; }
.top-controls input, .top-controls select { height: 31px; min-width: 0; padding: 0 7px; font-weight: 800; }
.top-controls input { width: 56px; }
.top-controls select { min-width: 44px; width: 44px; padding: 0 7px; }
.top-controls button { height: 38px; }

button, select, input, textarea { font: inherit; color: var(--text); border: 1px solid transparent; border-radius: 7px; background: #1d2024; }
button { padding: 8px 13px; background: #363b41; font-weight: 800; cursor: pointer; }
button:hover { background: #454b52; }
button.primary { background: #3b4147; border-color: #535a62; }

.layout { display: grid; grid-template-columns: 24% minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar { padding: 16px 10px 28px 4px; border-right: 1px solid #3f4449; background: #292c30; overflow: auto; }
.content { padding: 10px; min-width: 0; }

.quick-controls { display: grid; grid-template-columns: 1fr 27px 1fr 27px; gap: 7px; align-items: end; margin-bottom: 27px; }
.quick-controls label { color: #b4b8be; font-size: 12px; }
.quick-controls input { display: block; margin-top: 6px; width: 100%; height: 35px; padding: 0 9px; font-weight: 700; }
.quick-controls > span { color: #b0b4ba; padding-bottom: 9px; }

.section { padding: 0 0 18px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.section-title { font-size: 14px; font-weight: 850; margin-bottom: 13px; }
.section-title span { float: right; color: #a1a5ab; font-weight: 600; font-size: 12px; }
.dimension-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dimension-grid label { display: block; padding: 9px; background: #2c3035; border-radius: 7px; color: #b9bec5; }
.dimension-grid label span { display: block; font-size: 10px; font-weight: 800; letter-spacing: .08em; margin-bottom: 6px; color: #8f959c; }
.dimension-grid input { width: 100%; height: 34px; padding: 0 9px; font-weight: 800; }

.driver-card { background: var(--card); border-radius: 9px; padding: 11px 12px 12px; border-left: 5px solid var(--blue); box-shadow: 0 4px 14px #0002; }
.driver-card-head { display: grid; grid-template-columns: 1fr; gap: 8px; align-items: center; margin-bottom: 10px; }
.driver-card-head strong { display: block; font-size: 15px; }
.driver-card-head small { display: block; color: #aeb3ba; font-size: 11px; margin-top: 2px; }
.icon-btn { padding: 0; background: transparent; color: #e9ebed; font-size: 22px; line-height: 1; }
.driver-card textarea { width: 100%; height: 184px; padding: 9px; resize: vertical; line-height: 1.45; border-color: #454a50; outline: none; }
.button-row { display: flex; gap: 8px; margin-top: 9px; }
.button-row button { flex: 1; padding: 8px 6px; }
.port-response { margin-top: 14px; padding: 11px 12px 12px; border: 1px solid #555047; border-left: 5px solid #ffd400; border-radius: 9px; background: #3a3e43; box-shadow: 0 4px 14px #0002; }
.port-response strong { display: block; color: #ffd400; font-size: 13px; }
.port-response small { display: block; color: #aeb3ba; font-size: 11px; margin: 2px 0 7px; }
.port-response textarea { width: 100%; height: 115px; padding: 9px; resize: vertical; line-height: 1.45; border-color: #454a50; outline: none; }
.port-level { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 8px; color: #c8cbd0; }
.port-level span { margin-right: auto; color: #aeb3ba; font-size: 11px; font-weight: 700; }
.port-level b { min-width: 44px; text-align: center; color: #ffd400; font-size: 12px; }
.port-level button { width: 30px; height: 28px; padding: 0; color: #25272a; background: #ffd400; font-size: 18px; line-height: 1; }
.port-actions { display: flex; gap: 8px; margin-top: 8px; }
.port-actions button { flex: 1; }
.output-section { border-bottom: 0; }
.hint { color: #9499a0; font-size: 11px; margin: 9px 0 0; }
.merge-btn { width: 100%; margin-top: 14px; background: #45404a; border: 1px solid #ff4db8; color: #f1dbea; }
.merge-notice { color: #ffd36a; font-size: 11px; margin: 8px 0 0; }

.panel { background: #202328; border-radius: 9px; box-shadow: 0 4px 16px #0003; overflow: hidden; }
.hero-panel { min-height: 0; padding-bottom: 0; }
.phase-panel { margin-top: 0; }
.panel-head { min-height: 52px; padding: 13px 10px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; background: #24272b; }
.panel-head strong { font-size: 14px; }
.panel-head .sub { display: block; color: #969ba2; font-size: 11px; margin-top: 2px; font-weight: 600; }
.metric { margin-left: auto; display: flex; align-items: baseline; gap: 6px; color: #9fa4aa; }
.metric + .metric { margin-left: 4px; }
.metric b { font-size: 15px; color: #eef0f3; }
.metric small { color: #969ba2; }
.chart-visibility { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-left: auto; color: #c8cbd0; font-size: 11px; }
.chart-visibility label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.chart-visibility input { accent-color: #aeb4bc; }
.hero-panel canvas { width: 100%; height: 600px; display: block; background: #2c2f33; }
.phase-panel canvas { width: 100%; height: 300px; display: block; background: #2c2f33; }
.hidden { display: none !important; }

@media (max-width: 1100px) {
  .topbar { justify-content: flex-start; flex-wrap: wrap; height: auto; min-height: 56px; padding: 9px; }
  .brand { margin-right: auto; }
  .layout { grid-template-columns: 320px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: 0; border-bottom: 1px solid #44494e; padding-right: 12px; }
  .top-controls { flex-wrap: wrap; }
  .content { padding: 8px; }
  .hero-panel { min-height: 420px; }
}
