* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1f27; color: #d8dde6; font: 12px/1.35 system-ui, "Segoe UI", sans-serif; }
#app { position: fixed; inset: 0; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { background: #2c3340; color: #d8dde6; border: 1px solid #414b5c; border-radius: 4px; padding: 4px 8px; cursor: pointer; font: inherit; }
button:hover { background: #374052; }
button.on { background: #2f6fb0; border-color: #4a8bd0; color: #fff; }
button:disabled { opacity: .4; cursor: default; }
input[type=number], .search { background: #151920; color: #d8dde6; border: 1px solid #3a4352; border-radius: 3px; padding: 2px 4px; font: inherit; width: 100%; }
.muted { color: #8a93a3; }
.bad { color: #ff7070; }
.grow { flex: 1; }

.bar { position: absolute; left: 0; right: 0; display: flex; align-items: center; gap: 10px; padding: 6px 10px; background: rgba(20,24,31,.88); backdrop-filter: blur(4px); z-index: 5; }
.bar.top { top: 0; border-bottom: 1px solid #2c3340; }
.bar.bottom { bottom: 0; border-top: 1px solid #2c3340; }
.brand { font-size: 13px; margin-right: 6px; }
.grp { display: flex; gap: 4px; align-items: center; padding-right: 10px; border-right: 1px solid #2c3340; }
.chk { display: flex; gap: 3px; align-items: center; color: #aab3c2; }
.net { color: #e07070; } .net.ok { color: #6fcf8a; }
.big { font-size: 15px; width: 38px; }
.clock { min-width: 140px; } .speed { width: 220px; } .spd { min-width: 46px; }

.panel { position: absolute; top: 42px; bottom: 46px; width: 300px; background: rgba(20,24,31,.9); z-index: 4; display: flex; flex-direction: column; overflow: hidden; }
.panel.left { left: 0; border-right: 1px solid #2c3340; }
.panel.right { right: 0; width: 330px; border-left: 1px solid #2c3340; overflow-y: auto; padding-bottom: 230px; }
.ph { font-weight: 600; padding: 6px 8px; color: #e8edf5; display: flex; align-items: center; gap: 6px; }
.sub { padding: 0 8px 4px; color: #aab3c2; }
.search { margin: 0 8px 6px; width: auto; }
.tree { overflow-y: auto; flex: 1; }
.row { display: flex; align-items: center; gap: 5px; padding: 2px 6px; cursor: pointer; white-space: nowrap; }
.row:hover { background: #262d39; } .row.sel { background: #2f4a6b; }
.idx { color: #6c7585; width: 18px; text-align: right; font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.bid { font-family: Consolas, monospace; color: #9fd0ff; }
.bname { color: #8a93a3; overflow: hidden; text-overflow: ellipsis; }

.card { border-bottom: 1px solid #2c3340; padding-bottom: 8px; }
.card details { padding: 2px 8px; } .card summary { cursor: pointer; color: #9fb4d0; padding: 3px 0; }
.card label { display: block; margin: 3px 0; color: #aab3c2; }
.kv { display: flex; gap: 6px; padding: 1px 8px; align-items: center; }
.kv span { color: #8a93a3; } .kv b { margin-right: 8px; font-variant-numeric: tabular-nums; }
.energy { position: relative; margin: 4px 8px; height: 16px; background: #151920; border-radius: 3px; overflow: hidden; }
.energy .fill { height: 100%; transition: width .1s; }
.energy span { position: absolute; inset: 0; text-align: center; font-size: 11px; line-height: 16px; }
.modes { display: flex; gap: 3px; padding: 2px 8px 6px; }
.dof { margin: 4px 6px; padding: 4px 2px; border: 1px solid #2c3340; border-radius: 4px; }
.dofh { padding: 0 6px 2px; }
.torque { position: relative; height: 12px; margin: 3px 8px; background: #151920; border-radius: 2px; display: flex; justify-content: center; }
.torque .neg, .torque .pos { position: absolute; top: 0; bottom: 0; }
.torque .neg { right: 50%; background: #c2853a; } .torque .pos { left: 50%; background: #3a9ac2; }
.torque span { position: relative; font-size: 10px; line-height: 12px; }
.range { display: flex; align-items: center; gap: 4px; padding: 0 8px; }
.range input { flex: 1; } .range span { font-size: 10px; white-space: nowrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 8px; }

.eye { position: absolute; right: 340px; bottom: 56px; width: 320px; height: 210px; border: 2px solid #4a8bd0; border-radius: 4px; z-index: 6; cursor: grab; touch-action: none; }
.eye span { position: absolute; left: 4px; top: 3px; font-size: 10px; background: rgba(0,0,0,.55); padding: 1px 4px; border-radius: 2px; pointer-events: none; }

.script { position: absolute; left: 310px; bottom: 56px; width: 560px; height: 360px; z-index: 7; background: rgba(20,24,31,.96); border: 1px solid #414b5c; border-radius: 4px; display: flex; flex-direction: column; }
.script textarea { flex: 1; background: #12151b; color: #cfe3ff; border: 0; border-top: 1px solid #2c3340; font: 12px/1.4 Consolas, monospace; padding: 6px; resize: none; }
.script .log { height: 80px; margin: 0; overflow: auto; background: #0e1116; color: #9fe0a8; padding: 4px 6px; font-size: 11px; }

/* HDNC */
.hdnc { height: 520px; width: 640px; }
.hdnc select { background: #12151b; color: #e8edf5; border: 1px solid #414b5c; }
.hdnc-desc { padding: 0 8px 4px; font-size: 11px; }
.hdnc-agents { width: 100%; border-collapse: collapse; font: 11px/1.35 Consolas, monospace; color: #cfe3ff; }
.hdnc-agents td { padding: 1px 6px; border-top: 1px solid #232a35; white-space: nowrap; }
.hdnc-agents td:first-child { color: #8a96a8; width: 24px; }
.hdnc-agents tr.warn td { color: #ffcf7a; }
.hdnc .log { flex: 1; height: auto; min-height: 120px; }
.hdnc-report { margin: 0; padding: 4px 8px; background: #10161f; color: #ffe2a8; font: 11px/1.35 Consolas, monospace; border-top: 1px solid #2c3340; max-height: 200px; overflow: auto; }
.hdnc-brain { padding: 4px 8px; color: #9fd0ff; font: 12px/1.4 Consolas, monospace; background: #0f1a26; border-top: 1px solid #2c3340; }
.hdnc.remote { left: auto; right: 8px; top: 56px; bottom: 56px; height: auto; width: min(620px, 46vw); }

/* Сховані бокові панелі: вікна зсуваються до краю */
.eye.wide { right: 10px; }
.script.wide { left: 10px; }

/* Віддалений перегляд: без нижньої панелі часу */
:root { --pw: min(620px, 46vw); }
.hdnc.remote { bottom: 8px; width: var(--pw); }
.hdnc.remote .log { white-space: pre-wrap; overflow-wrap: anywhere; }
#view.sheet { width: calc(100% - var(--pw) - 16px); } /* сцена поруч із панеллю, робот не ховається під нею */
.eye.remote { right: auto; left: 8px; bottom: 8px; }
.bar.top { overflow-x: auto; scrollbar-width: none; padding-top: max(6px, env(safe-area-inset-top)); }
.bar.top::-webkit-scrollbar { display: none; }
.bar > * { flex: none; }
.bar > .grow { flex: 1; }

/* Середні екрани (Fold7 розкладений, планшет) */
@media (max-width: 1000px) {
  :root { --pw: 44vw; }
}

/* Вузькі екрани (Fold7 складений, телефон): панель — шторка знизу, сцена над нею */
@media (max-width: 700px) {
  .brand-t { display: none; }
  .bar { gap: 6px; padding: 5px 6px; }
  button { padding: 6px 10px; }
  .hdnc.remote { left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 46vh; border-radius: 10px 10px 0 0; border-left: 0; border-right: 0; padding-bottom: env(safe-area-inset-bottom); }
  #view.sheet { width: 100%; height: 54vh; }
  .hdnc .ph { flex-wrap: wrap; row-gap: 2px; }
  .hdnc-agents { font-size: 10px; }
  .hdnc-agents td:last-child { white-space: normal; }
  .hdnc .log { font-size: 10px; min-height: 60px; white-space: pre-wrap; overflow-wrap: anywhere; }
  .eye { width: 150px; height: 100px; }
  .eye.remote { top: 48px; bottom: auto; }
  .eye span { display: none; }
}
