:root {
  --bg: #0e1418; --bg2: #151d23; --bg3: #1c2730; --line: #2a3843; --tx: #dbe6ee; --tx2: #8fa4b3; --acc: #4cc38a; --acc2: #3aa0ff; --warn: #ffb74d; --bad: #ef5350;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tx); font: 13px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; overflow: hidden; }
#app { display: grid; grid-template-columns: 350px 1fr 340px; grid-template-rows: auto 1fr; height: 100vh; grid-template-areas: "top top top" "left stage right"; }
#top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 5px 10px; min-height: 46px; background: var(--bg2); border-bottom: 1px solid var(--line); }
#left { grid-area: left; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
#right { grid-area: right; background: var(--bg2); border-left: 1px solid var(--line); overflow-y: auto; padding: 8px; }
#stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; background: #223; }
#c3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.rlabel { position: absolute; left: 0; top: 0; pointer-events: auto; cursor: pointer; font-size: 10px; text-align: center; will-change: transform; display: none; }
.rlabel .rn { display: inline-block; background: rgba(10,16,20,.78); border: 1px solid; border-radius: 4px; padding: 0 4px; color: #fff; font-weight: 600; }
.rlabel i { display: block; height: 3px; width: 28px; margin: 1px auto 0; background: rgba(0,0,0,.6); border-radius: 2px; overflow: hidden; }
.rlabel i b { display: block; height: 100%; background: #66bb6a; }
.rlabel.sel .rn { background: #fff; color: #000; }
.rlabel.bad .rn { background: #b71c1c; }
#hudTL { position: absolute; left: 10px; top: 10px; background: rgba(12,18,23,.82); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; font-size: 12px; pointer-events: none; min-width: 190px; backdrop-filter: blur(4px); }
#hudTL .big { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
#hudBL { position: absolute; left: 10px; bottom: 10px; background: rgba(12,18,23,.82); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px; font-size: 11px; max-width: 360px; pointer-events: none; }
#hudBL .lg { display: flex; align-items: center; gap: 6px; margin: 2px 0; }
#hudBL .sw { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
#banner { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); background: rgba(20,60,40,.95); border: 1px solid var(--acc); border-radius: 10px; padding: 8px 16px; font-weight: 600; box-shadow: 0 4px 20px rgba(0,0,0,.4); max-width: 80%; text-align: center; }
#banner[hidden] { display: none; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--bg); font-size: 16px; color: var(--tx2); }

/* верхняя панель */
.logo { font-weight: 800; letter-spacing: .3px; color: var(--acc); margin-right: 6px; font-size: 15px; }
.logo small { color: var(--tx2); font-weight: 400; font-size: 10px; display: block; line-height: 1; }
button, select, input[type=text], input[type=number] { font: inherit; color: var(--tx); background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; padding: 4px 9px; }
button { cursor: pointer; }
button:hover { border-color: var(--acc2); }
button.pri { background: var(--acc); color: #04210f; border-color: var(--acc); font-weight: 700; }
button.pri:hover { filter: brightness(1.1); }
button.warn { background: #5a2b2b; border-color: #8a3a3a; }
button.sm { padding: 2px 7px; font-size: 12px; }
button.on { background: #1e4a64; border-color: var(--acc2); }
select { max-width: 220px; }
.sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.chk { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; user-select: none; color: var(--tx2); font-size: 12px; }
.chk input { accent-color: var(--acc); }
.tgl { padding: 3px 8px; font-size: 12px; }

/* вкладки */
#tabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 6px 0; border-bottom: 1px solid var(--line); }
#tabs button { border-radius: 6px 6px 0 0; border-bottom: none; background: transparent; color: var(--tx2); padding: 5px 8px; font-size: 12px; }
#tabs button.act { background: var(--bg3); color: var(--tx); border-color: var(--line); }
#panels { flex: 1; overflow-y: auto; padding: 10px; min-height: 0; }
.panel { display: none; }
.panel.act { display: block; }
h3 { margin: 12px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--tx2); }
h3:first-child { margin-top: 0; }
.row { display: grid; grid-template-columns: 1fr 120px 54px; align-items: center; gap: 6px; margin: 4px 0; }
.row.two { grid-template-columns: 1fr 1fr; }
.row label { color: var(--tx2); font-size: 12px; }
.row input[type=range] { width: 100%; accent-color: var(--acc); }
.row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--tx); font-size: 12px; }
.card { background: var(--bg3); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; margin: 6px 0; }
.card.act { border-color: var(--acc); box-shadow: inset 0 0 0 1px var(--acc); }
.card.dis { opacity: .45; }
.muted { color: var(--tx2); font-size: 12px; }
.tag { display: inline-block; font-size: 10px; padding: 0 6px; border-radius: 9px; background: #25414f; color: #9fd3ea; margin-left: 4px; vertical-align: middle; }
.tag.a { background: #3a2a52; color: #cfb2ff; }
.tag.g { background: #3b3a22; color: #e6d98a; }
.tag.bad { background: #5a2b2b; color: #ffb4ab; }
.tag.ok { background: #1f4a35; color: #9ee6bf; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { padding: 3px 5px; text-align: right; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
th { color: var(--tx2); font-weight: 600; cursor: default; position: sticky; top: 0; background: var(--bg2); }
tr.best td { background: rgba(76,195,138,.13); }
tr.sel td { background: rgba(58,160,255,.15); }
tr.clk { cursor: pointer; }
tr.clk:hover td { background: rgba(255,255,255,.04); }
.stepper { display: inline-flex; align-items: center; gap: 3px; }
.stepper button { width: 22px; padding: 0; text-align: center; }
.stepper span { min-width: 22px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: -1px; }
.bar { height: 7px; background: #0b1013; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: var(--acc); }
.kpi { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; font-size: 12px; }
.kpi div:nth-child(odd) { color: var(--tx2); }
.kpi div:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
canvas.chart { width: 100%; height: 130px; background: #0b1013; border-radius: 6px; border: 1px solid var(--line); display: block; }
canvas.prev { width: 100%; height: 150px; border-radius: 6px; background: linear-gradient(#26384a,#1b2a36); display: block; }
.alg { cursor: pointer; }
.alg b { font-size: 13px; }
.alg p { margin: 3px 0 0; color: var(--tx2); font-size: 11.5px; }
.chip { display: inline-block; padding: 0 6px; border-radius: 9px; font-size: 10.5px; margin: 1px 2px 1px 0; color: #111; }
.log { font-size: 11px; color: var(--tx2); max-height: 150px; overflow-y: auto; }
.log div { padding: 1px 0; border-bottom: 1px dotted #26333c; }
.hint { font-size: 11.5px; color: #b9cad6; background: #14232c; border-left: 3px solid var(--acc2); padding: 6px 8px; border-radius: 4px; margin: 5px 0; }
.hint.w { border-color: var(--warn); background: #2a2315; }
.prog { position: relative; height: 16px; background: #0b1013; border-radius: 4px; border: 1px solid var(--line); overflow: hidden; margin: 3px 0; }
.prog i { position: absolute; inset: 0 auto 0 0; background: var(--acc); opacity: .85; }
.prog span { position: absolute; left: 6px; right: 6px; top: 0; line-height: 15px; font-size: 11px; display: flex; justify-content: space-between; text-shadow: 0 0 3px #000; }
.sec { margin-bottom: 10px; }
.flex { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2f414e; border-radius: 4px; }
@media (max-width: 1150px) {
  #app { grid-template-columns: 300px 1fr; grid-template-areas: "top top" "left stage"; }
  #right { display: none; }
}
@media (max-width: 700px) {
  html, body { height: auto; min-height: 100%; overflow: auto; }
  #app {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(360px, 55vh) auto auto;
    grid-template-areas: "top" "stage" "left" "right";
    height: auto;
    min-height: 100vh;
  }
  #top { flex-wrap: wrap; gap: 6px; padding: 8px; }
  #stage { min-height: 360px; }
  #left { border-right: 0; border-top: 1px solid var(--line); min-height: 0; }
  #right { display: block; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
  #panels { overflow: visible; }
  #tabs { display: flex; flex-wrap: wrap; }
  #tabs button { flex: 1 1 30%; min-height: 40px; }
  .row { grid-template-columns: minmax(0, 1fr) 105px 48px; }
  select { max-width: 100%; }
  button, select, input { min-height: 36px; }
  #hudTL { max-width: calc(100% - 40px); min-width: 0; }
  #hudBL { max-width: calc(100% - 40px); }
}
