:root {
  --work: #eef1f5;
  --card: #ffffff;
  --line: #d9dfe6;
  --text: #1f2933;
  --muted: #66727f;
  --side: #2b3038;
  --side2: #343a44;
  --side-line: #444c57;
  --side-text: #e7ecf2;
  --side-muted: #a4afbb;
  --brand: #1467ff;
  --chA: #1467ff;
  --chB: #ff2a2a;
  --chC: #12b84a;
  --chD: #7a2cc4;
  --ok: #12b84a;
  --warn: #e39b00;
  --danger: #e03131;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--work);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}
button, select, input { font: inherit; }
.hidden { display: none !important; }

/* ---------- barra superior ---------- */
.topbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 12px; background: #fff; border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.logo { height: 36px; margin-right: 6px; }
.logo-link { display: flex; border-radius: 6px; }
.logo-link:hover .logo { opacity: .85; }
.tb-group { display: flex; align-items: center; gap: 4px; padding: 0 8px; border-left: 1px solid var(--line); }
.tb-group.right { margin-left: auto; border-left: 0; }
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 58px; padding: 4px 8px; border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: #3a4450; cursor: pointer; font-size: 11.5px;
}
.tool svg { width: 22px; height: 22px; }
.tool:hover:not(:disabled) { background: #f0f4fa; border-color: var(--line); }
.tool:disabled { opacity: 0.35; cursor: default; }
.tool.icon { min-width: 30px; padding: 4px; }
.tool.run { color: var(--ok); }
.tool.run.running { color: var(--danger); }
.tool.primary { flex-direction: row; gap: 6px; background: var(--brand); color: #fff; font-size: 13px; font-weight: 600; padding: 8px 12px; }
.tool.primary svg { width: 18px; height: 18px; }
.tool.primary:hover { background: #0f56d6; }
.topbar select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text); max-width: 230px; }
.memory input[type=range] { width: 120px; }
.mem-info { font-size: 11.5px; color: var(--muted); min-width: 88px; }

/* ---------- pantalla ---------- */
.layout { flex: 1; display: grid; grid-template-columns: 1fr 330px; min-height: 0; }
.screen { display: flex; flex-direction: column; padding: 10px 12px; gap: 8px; min-width: 0; min-height: 0; overflow-y: auto; }
.infobar { display: flex; gap: 16px; align-items: center; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.pill { padding: 2px 10px; border-radius: 999px; background: #e7ebf0; color: var(--muted); font-weight: 600; font-size: 12px; }
.pill.ok { background: #dff6e7; color: #0b7a33; }
.pill.warn { background: #fff2d6; color: #8a5a00; }
.pill.err { background: #fde2e2; color: #a61e1e; }
.canvas-wrap { flex: 1 0 auto; min-height: 460px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05); overflow: hidden; }
#scope { width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.meas { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.meas th, .meas td { padding: 5px 12px; text-align: right; border-bottom: 1px solid #eef1f4; }
.meas th { color: var(--muted); font-weight: 600; background: #f7f9fb; }
.meas td:first-child, .meas th:first-child { text-align: left; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* ---------- panel lateral oscuro ---------- */
.panel { display: flex; flex-direction: column; background: var(--side); color: var(--side-text); padding: 8px 12px 12px; overflow-y: auto; }
.group { border-bottom: 1px solid var(--side-line); padding: 10px 0 12px; display: flex; flex-direction: column; gap: 8px; }
.group h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--side-muted); }
.group label { display: flex; justify-content: space-between; align-items: center; gap: 8px; color: var(--side-muted); font-size: 13px; }
.panel select, .panel input[type=number] {
  background: var(--side2); color: var(--side-text); border: 1px solid var(--side-line); border-radius: 6px; padding: 5px 8px; width: 150px;
}
.panel #preset { width: 100%; }
.panel input[type=range] { width: 150px; accent-color: var(--brand); }
.guide { background: var(--side2); border-left: 3px solid var(--brand); padding: 8px 10px; border-radius: 4px; font-size: 12.5px; color: var(--side-text); }
.small { background: var(--side2); color: var(--side-text); border: 1px solid var(--side-line); border-radius: 6px; padding: 6px 10px; cursor: pointer; }
.small:hover { border-color: var(--brand); }
.sw { width: 18px; height: 18px; accent-color: var(--brand); }

.chcard { border: 1px solid var(--side-line); border-left: 4px solid var(--c); border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; background: #30353e; display: flex; flex-direction: column; gap: 6px; }
.chcard.off { opacity: 0.55; }
.chhead { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.chhead .badge { background: var(--c); color: #fff; border-radius: 4px; padding: 0 7px; font-size: 13px; }
.chhead .sub { color: var(--side-muted); font-weight: 400; font-size: 12px; margin-right: auto; }
.chbody { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; }
.chbody .fields { display: flex; flex-direction: column; gap: 6px; }
.chbody .fields label select, .chbody .fields label input { width: 96px; }

/* ---------- perilla ---------- */
.knob { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.knob-label { font-size: 11px; color: var(--side-muted); text-transform: uppercase; letter-spacing: .5px; }
.knob-body { display: flex; align-items: center; gap: 2px; }
.knob-step { background: transparent; border: 0; color: var(--side-muted); font-size: 20px; cursor: pointer; padding: 0 3px; line-height: 1; }
.knob-step:hover { color: #fff; }
.knob-dial { width: 62px; height: 62px; cursor: ns-resize; touch-action: none; outline: none; }
.knob-dial:focus-visible .knob-ring { stroke: var(--brand); }
.knob-ring { fill: #22262d; stroke: #4b535e; stroke-width: 1.5; }
.knob-cap { fill: url(#none); fill: #3d444f; stroke: #58616d; stroke-width: 1; }
.knob-pointer { stroke-width: 3.5; stroke-linecap: round; }
.knob-value { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 13px; color: #fff; background: #1f2329; border: 1px solid var(--side-line); border-radius: 5px; padding: 1px 8px; min-width: 72px; text-align: center; }
.knob-row { display: flex; justify-content: center; }

.btnrow { display: flex; gap: 8px; }
.small.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.panel input[type=text] { background: var(--side2); color: var(--side-text); border: 1px solid var(--side-line); border-radius: 6px; padding: 5px 8px; width: 150px; }
.hint { margin: 0; font-size: 11.5px; color: var(--side-muted); }
.chcard.active { box-shadow: 0 0 0 1px var(--c); }
.legal { font-size: 11px; color: var(--side-muted); }
.legal a { color: var(--side-muted); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .tb-group.right { margin-left: 0; flex-wrap: wrap; max-width: 100%; }
  .topbar select { max-width: 100%; }
  .canvas-wrap { min-height: 260px; }
}
@media print {
  .topbar, .panel { display: none; }
}

/* ---------- reglas y analisis ---------- */
.below { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.below .meas { flex: 1 1 520px; }
.rules, .analysis { background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; overflow: hidden; }
.rules table, .analysis table { border-collapse: collapse; }
.rules th, .rules td, .analysis td { padding: 4px 10px; border-bottom: 1px solid #eef1f4; text-align: right; }
.rules th { background: #f7f9fb; color: var(--muted); font-weight: 600; }
.rules td:first-child, .analysis td:first-child { text-align: left; color: var(--muted); }
.box-title { background: #f7f9fb; color: var(--text); font-weight: 700; padding: 5px 10px; border-bottom: 1px solid var(--line); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.analysis .note, .health .note { padding: 6px 10px; color: var(--text); }
.analysis .note.warn, .health .note.warn { color: #8a5a00; background: #fff7e0; }
.analysis .note.ok, .health .note.ok { color: #0b7a33; background: #e9f9ef; }

/* ---------- barra de modulos ---------- */
.modbar { display: flex; align-items: center; gap: 4px; padding: 0 12px; background: #fff; border-bottom: 1px solid var(--line); overflow-x: auto; }
.modbtn { display: flex; align-items: center; gap: 7px; padding: 8px 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; }
.modbtn:hover { color: var(--text); }
.modbtn.active { color: var(--brand); border-bottom-color: var(--brand); }
.modbtn.locked { opacity: 0.55; }
.modbtn svg { width: 18px; height: 18px; }
.panel .group[data-module] { display: none; }
body[data-module="osc"] .panel .group[data-module="osc"],
body[data-module="auto"] .panel .group[data-module="auto"],
body[data-module="motor"] .panel .group[data-module="motor"],
body[data-module="can"] .panel .group[data-module="can"],
body[data-module="lin"] .panel .group[data-module="lin"],
body[data-module="elec"] .panel .group[data-module="elec"],
body[data-module="importar"] .panel .group[data-module="importar"] { display: flex; }

/* ---------- tabla de tramas ---------- */
.bus { background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; flex: 1 1 100%; max-height: 260px; overflow: auto; }
.bus table { border-collapse: collapse; width: 100%; }
.bus th { position: sticky; top: 0; background: #f7f9fb; color: var(--muted); font-weight: 600; text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.bus td { padding: 3px 8px; border-bottom: 1px solid #eef1f4; white-space: nowrap; }
.bus td.mono { font-family: ui-monospace, Consolas, monospace; }
.bus .ok { color: #0b7a33; font-weight: 600; }
.bus .bad { color: #c92a2a; font-weight: 600; }
.bus .muted { color: var(--muted); }

.panel .group[data-module] { order: -1; }

.health, .obd, .monitor { background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; font-variant-numeric: tabular-nums; overflow: auto; }
.health { flex: 1 1 300px; }
.obd { flex: 1 1 380px; max-height: 320px; }
.monitor { flex: 1 1 100%; max-height: 300px; }
.health table, .obd table, .monitor table { border-collapse: collapse; width: 100%; }
.health td, .obd td, .monitor td { padding: 3px 10px; border-bottom: 1px solid #eef1f4; white-space: nowrap; }
.monitor th, .obd th { position: sticky; top: 0; background: #f7f9fb; color: var(--muted); font-weight: 600; text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.health td:first-child, .obd td:first-child { color: var(--muted); }
.st-ok { color: #0b7a33; font-weight: 700; }
.st-warn { color: #b76e00; font-weight: 700; }
.st-bad { color: #c92a2a; font-weight: 700; }
.vin { font-family: ui-monospace, Consolas, monospace; font-size: 15px; font-weight: 700; letter-spacing: 1px; color: var(--text); }
.chip { display: inline-block; background: #fde2e2; color: #a61e1e; border-radius: 4px; padding: 1px 7px; margin: 1px 3px 1px 0; font-family: ui-monospace, Consolas, monospace; font-weight: 700; }
tr.changed td.mono { background: #fff8db; }

.modtabs { display: flex; gap: 4px; }
.modbrand { margin-left: auto; display: flex; align-items: center; gap: 6px; padding-left: 16px; color: var(--muted); font-weight: 800; letter-spacing: .5px; }
.modbrand img { height: 26px; }
.sidebrand { margin-top: auto; padding: 18px 0 6px; text-align: center; }
.sidebrand img { width: 78%; max-width: 250px; opacity: .9; border-radius: 6px; }
/* marca de agua en el area de trabajo */
.screen { background: url(../assets/logo-fondo.png) no-repeat right 28px bottom 20px / 380px auto; }
/* menu de canales */
.chmenu-wrap { position: relative; }
.chmenu { position: absolute; top: 54px; left: 0; z-index: 20; width: 300px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.chmenu-title { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.chmenu label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.chmenu .badge { color: #fff; border-radius: 4px; padding: 0 7px; font-weight: 700; font-size: 12px; }
.chmenu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; width: 100%; }
.chmenu .hint { color: var(--muted); }
.chmenu.hidden { display: none; }
body.hide-off .chcard.off { display: none; }
.idname { font-weight: 700; color: var(--text); }
.idedit { border: 0; background: transparent; cursor: pointer; color: var(--brand); font-size: 13px; padding: 0 4px; }
.idinfo { font-size: 11px; line-height: 1.35; }
.iddata { color: #0b5cd6; }
.probable { font-size: 9px; background: #fff3c4; color: #8a6d00; border-radius: 3px; padding: 0 3px; }
.box-title .hint { font-size: 11px; font-weight: normal; text-transform: none; letter-spacing: 0; color: var(--muted); }
.monitor td.idinfo { white-space: normal; min-width: 300px; }

/* informe electrico */
.elec td.hint2 { color: var(--muted); font-size: 11px; }
.elec .bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding: 8px 10px 4px; border-top: 1px solid var(--line); }
.elec .bar { flex: 1; max-width: 60px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; }
.elec .bar i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: #1467ff; }
.elec .bar i.warn { background: #e0a100; }
.elec .bar i.bad { background: #e02424; }
.elec .bars.thin .bar { max-width: 14px; }
.elec .cap { font-size: 11px; color: var(--muted); padding: 2px 10px 6px; }
.health.elec { flex: 1 1 100%; }
.elec td { white-space: normal; }
.elec td:first-child { white-space: nowrap; }
.analysis .note { max-width: 320px; }

/* informe Px */
#pxBox.px { flex: 1 1 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; }
.px-grid { display: grid; grid-template-columns: minmax(300px, 1.1fr) minmax(300px, 1fr) minmax(240px, 0.8fr); gap: 8px; padding: 8px; align-items: start; }
.px-tables table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.px-tables td { padding: 3px 6px; border-bottom: 1px solid #eef1f4; }
.px-tables td:first-child { color: var(--muted); }
.px-tables .sub { font-weight: 700; color: var(--text); padding-top: 8px; }
.px-tables td.hint2 { color: var(--muted); font-size: 11px; }
.px-polar canvas { width: 100%; aspect-ratio: 1; display: block; }
.px-anim canvas { width: 100%; height: 380px; display: block; background: #f9fafb; border-radius: 6px; }
.px-ctrl { display: flex; gap: 6px; align-items: center; padding-top: 6px; }
.px-ctrl input[type=range] { flex: 1; }
.px-ctrl .small { background: #eef2f6; color: var(--text); border-color: var(--line); }
#pxNotes .note { padding: 6px 10px; }
@media (max-width: 1100px) { .px-grid { grid-template-columns: 1fr 1fr; } .px-tables { grid-column: 1 / -1; } }
.px-legend { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.6; }
.px-legend span { color: var(--c); font-weight: 700; margin: 0 6px; }
.px-legend span::before { content: ''; display: inline-block; width: 10px; height: 3px; background: var(--c); margin-right: 4px; vertical-align: middle; }
.px-info { display: flex; justify-content: space-between; font-size: 12px; padding-top: 4px; font-variant-numeric: tabular-nums; }
.px-info b { font-size: 13px; }

/* ---------- pestaña Importar ---------- */
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 16px 10px; border: 2px dashed var(--side-line); border-radius: 10px; background: var(--side2); text-align: center; color: var(--side-text); font-size: 13px; }
.drop.over { border-color: var(--brand); background: #2f3b4f; }
.drop .hint { word-break: break-all; }
.imp-err { background: #4a2326; color: #ffd5d5; border-left: 3px solid var(--danger); padding: 8px 10px; border-radius: 4px; font-size: 12.5px; }
.imp-card { display: flex; flex-direction: column; gap: 8px; }
.imp-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 14px; }
.conf { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.conf.alta { background: #1d4d33; color: #8ff0b4; }
.conf.media { background: #4d3d12; color: #ffd679; }
.conf.baja { background: #4d1d1d; color: #ffb0b0; }
.imp-kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 12.5px; }
.imp-kv dt { color: var(--side-muted); }
.imp-kv dd { margin: 0; color: var(--side-text); word-break: break-word; }
.imp-avisos { margin: 0; padding: 6px 10px 6px 24px; background: #3f3720; border-left: 3px solid var(--warn); border-radius: 4px; font-size: 12px; color: #ffe7a8; }
.imp-avisos li + li { margin-top: 3px; }
.imp-rate { display: flex; gap: 4px; }
.panel .imp-rate input { width: 92px; }
.panel .imp-rate select { width: 70px; }
.imp-ch { border: 1px solid var(--side-line); border-left: 4px solid var(--c); border-radius: 6px; padding: 6px 8px; display: flex; flex-direction: column; gap: 5px; background: #30353e; }
.imp-ch-name { font-weight: 700; font-size: 13px; }
.imp-ch-name span { color: var(--side-muted); font-weight: 400; }
.panel .imp-ch select { width: 170px; }
.imp-frame { min-width: 54px; text-align: right; font-variant-numeric: tabular-nums; color: var(--side-text); }
.imp-preview { width: 100%; height: 130px; border-radius: 6px; display: block; }
.hint.warn { color: #ffd679; }
.hint.bad { color: #ffb0b0; }
.pill.file { background: #ede4fb; color: #5a2a9c; display: inline-flex; align-items: center; gap: 8px; }
.pill.file button { border: 1px solid #b89be6; background: #fff; color: #5a2a9c; border-radius: 999px; padding: 0 8px; font-size: 11.5px; font-weight: 600; cursor: pointer; }
@media (max-width: 900px) { .panel .imp-ch select { width: 60%; } }

/* ---------- ayuda del driver USB ---------- */
.drv-dlg { width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px); border: 0; border-radius: 12px; padding: 0; box-shadow: 0 20px 60px rgba(0,0,0,.35); color: #1d2430; }
.drv-dlg::backdrop { background: rgba(15,20,30,.55); }
.drv-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #e3e7ee; position: sticky; top: 0; background: #fff; }
.drv-head h3 { margin: 0; font-size: 17px; }
.drv-x { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; color: #6a7484; }
.drv-why { margin: 12px 18px 0; padding: 8px 12px; background: #fff4e0; border-left: 3px solid #f0a020; border-radius: 4px; font-size: 13.5px; }
.drv-body { padding: 6px 18px 18px; font-size: 14px; line-height: 1.45; }
.drv-card { border: 1px solid #dfe4ec; border-radius: 10px; padding: 12px 14px; margin-top: 12px; }
.drv-card.on { border-color: #1467ff; box-shadow: 0 0 0 2px rgba(20,103,255,.15); }
.drv-card h4 { margin: 0 0 8px; font-size: 15px; }
.drv-card ol { margin: 10px 0 6px; padding-left: 20px; }
.drv-card li + li { margin-top: 4px; }
.drv-dl { display: inline-block; background: #1467ff; color: #fff; text-decoration: none; font-weight: 600; padding: 7px 14px; border-radius: 8px; font-size: 13.5px; }
.drv-dl:hover { background: #0f55d6; }
.drv-note { margin: 6px 0 0; font-size: 12.5px; color: #5d6676; }
.drv-pre { background: #1e2330; color: #e6edf6; padding: 10px 12px; border-radius: 8px; font-size: 12px; overflow-x: auto; white-space: pre; }

/* ---------- diagnostico guiado ---------- */
body[data-module="diag"] .panel .group[data-module="diag"] { display: flex; }
.diag-stage { display: none; }
body[data-module="diag"] .diag-stage { display: block; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px; padding: 10px 14px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
body:not([data-module="diag"]) #diagBox { display: none; }
.dg-empty { font-size: 13.5px; color: var(--text); }
.dg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dg-head h2 { margin: 0; font-size: 17px; }
.dg-n { background: var(--brand); color: #fff; border-radius: 999px; padding: 2px 10px; font-weight: 700; font-size: 12px; }
.dg-group { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
.dg-cond { margin-left: auto; background: #fff3d6; color: #8a5a00; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.dg-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 2px; }
.dg-tool { background: #eaf1ff; color: #0b4fc4; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; }
.dg-prep { margin: 6px 0; padding-left: 20px; font-size: 13px; line-height: 1.45; }
.dg-cyls { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.dg-cyl { border: 1px solid var(--line); background: #f7f9fb; border-radius: 8px; padding: 5px 12px; cursor: pointer; font-weight: 700; color: var(--text); display: flex; flex-direction: column; align-items: center; min-width: 64px; }
.dg-cyl small { font-weight: 600; color: var(--muted); font-size: 11px; }
.dg-cyl.done { background: #e9f9ef; border-color: #9fd9b4; }
.dg-cyl.bad { background: #fde8e8; border-color: #f3a5a5; }
.dg-cyl.cur { outline: 2px solid var(--brand); outline-offset: 1px; }
.dg-now { font-size: 13px; margin: 4px 0; }
.dg-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.dg-actions .tool { flex-direction: row; gap: 6px; font-size: 13px; padding: 7px 12px; border: 1px solid var(--line); }
.dg-actions .tool.primary { border-color: var(--brand); }
.dg-captxt { margin-left: auto; color: var(--muted); font-size: 12px; }
.dg-live { margin-top: 8px; border-radius: 8px; padding: 8px 12px; background: #eef4ff; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.dg-live.hot { background: #ffe9e5; animation: dgPulse .8s ease-in-out infinite alternate; }
@keyframes dgPulse { from { box-shadow: 0 0 0 0 rgba(224,49,49,.0); } to { box-shadow: 0 0 0 4px rgba(224,49,49,.25); } }
.dg-phase { font-size: 22px; font-weight: 800; color: var(--text); }
.dg-live.hot .dg-phase { color: #c92a2a; }
.dg-remain { font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--brand); }
.dg-prog { grid-column: 1 / -1; height: 6px; background: #d8e3f7; border-radius: 3px; overflow: hidden; }
.dg-prog i { display: block; height: 100%; background: var(--brand); transition: width .1s linear; }
.dg-trendlive { grid-column: 1 / -1; font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
.dg-box { flex: 1 1 100%; background: #fff; border: 1px solid var(--line); border-radius: 8px; font-size: 12.5px; order: -1; }
.dg-grid { display: grid; grid-template-columns: minmax(300px, 0.9fr) minmax(320px, 1.3fr); gap: 0; }
.dg-plan { border-right: 1px solid var(--line); }
.dg-plan table, .dg-detail table { border-collapse: collapse; width: 100%; }
.dg-plan th { text-align: left; color: var(--muted); font-weight: 600; background: #f7f9fb; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.dg-plan td { padding: 4px 8px; border-bottom: 1px solid #eef1f4; vertical-align: top; }
.dg-plan tr.cur td { background: #eef4ff; }
.dg-plan tr.off td { opacity: .5; }
.dg-plan a { color: var(--text); font-weight: 600; text-decoration: none; }
.dg-plan a:hover { color: var(--brand); }
.hint2 { color: var(--muted); font-size: 11px; }
.pad { padding: 6px 8px; }
.dg-detail td { padding: 3px 8px; border-bottom: 1px solid #eef1f4; }
.dg-detail td:first-child { color: var(--muted); }
.dg-detail td.hint2 { white-space: normal; }
.dg-detail .note, .dg-box .note { padding: 6px 10px; }
.dg-box .note.warn { color: #8a5a00; background: #fff7e0; }
.dg-box .note.bad { color: #a61e1e; background: #fde8e8; }
.dg-box .note.ok { color: #0b7a33; background: #e9f9ef; }
.dg-sub { font-weight: 700; padding: 8px 10px 4px; color: var(--text); text-transform: uppercase; font-size: 11.5px; letter-spacing: .4px; }
.dg-chip { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; background: #eef1f4; color: var(--muted); white-space: nowrap; }
.dg-chip.ok { background: #e9f9ef; color: #0b7a33; }
.dg-chip.warn { background: #fff3d6; color: #8a5a00; }
.dg-chip.bad { background: #fde8e8; color: #a61e1e; }
.dg-chip.off { opacity: .7; }
.dg-bars { display: flex; align-items: flex-end; gap: 6px; height: 110px; padding: 8px 10px 4px; border-top: 1px solid var(--line); }
.dg-bars .bar { flex: 1; max-width: 60px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; }
.dg-bars .bar i { display: block; width: 100%; border-radius: 3px 3px 0 0; background: #1467ff; }
.dg-bars .bar i.warn { background: #e0a100; }
.dg-bars .bar i.bad { background: #e02424; }
.dg-detail .cap { font-size: 11px; color: var(--muted); padding: 2px 10px 6px; }
.dg-btns, .dg-add { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 10px; }
.small2 { background: #f3f5f8; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; font-size: 12.5px; }
.small2:hover { border-color: var(--brand); }
.small2.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.dg-add select { padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; max-width: 260px; }
.dg-hr { border: 0; border-top: 1px solid var(--side-line); width: 100%; margin: 2px 0; }
/* dialogos */
.dg-dlg { border: 0; border-radius: 12px; padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.3); color: var(--text); }
.dg-dlg.wide { width: min(900px, calc(100vw - 32px)); }
.dg-dlg::backdrop { background: rgba(20, 26, 34, .45); }
.dg-form { display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.dg-form h3 { margin: 0; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 15px; }
.dg-dlgbody { padding: 10px 16px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.dg-dlgbtns { display: flex; justify-content: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--line); }
.dg-cols { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 12px; }
.dg-cols label, .dg-row { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.dg-form input:not([type=checkbox]):not([type=radio]):not([type=file]), .dg-form select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; color: var(--text); background: #fff; }
.dg-check { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.dg-syms { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 12px; }
.dg-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dg-mode { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; cursor: pointer; font-size: 13px; }
.dg-mode span { grid-column: 2; color: var(--muted); font-size: 12px; }
.dg-mode:has(input:checked) { border-color: var(--brand); background: #eef4ff; }
.dg-tbl { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.dg-tbl th, .dg-tbl td { border-bottom: 1px solid #eef1f4; padding: 4px 6px; text-align: left; }
.dg-tbl th { color: var(--muted); background: #f7f9fb; }
.dg-newsensor { background: #f7f9fb; border-radius: 8px; padding: 8px; }
.dg-file { position: relative; overflow: hidden; display: inline-block; }
.dg-file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
@media (max-width: 900px) { .dg-grid { grid-template-columns: 1fr; } .dg-plan { border-right: 0; } .dg-modes { grid-template-columns: 1fr; } .dg-captxt { margin-left: 0; } }
@media print { .diag-stage, #diagBox { display: none !important; } }
#injBox.health { flex: 1 1 100%; }
#injBox th { text-align: left; padding: 4px 10px; background: #f7f9fb; border-bottom: 1px solid var(--line); }
#injBox td { vertical-align: top; }
/* boton y menu de rejilla */
.tool.on { color: var(--brand); background: #eaf1ff; }
#gridMenu { width: 320px; }
#gridMenu .gridlvl { justify-content: space-between; }
#gridMenu .gridlvl input { width: 150px; accent-color: var(--brand); }

/* ---------- vista: pestañas / panel / pantalla completa ---------- */
.viewbtns { margin-left: auto; display: flex; gap: 6px; }
.vbtn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: #fff; color: var(--muted); border-radius: 7px; padding: 4px 9px; font-size: 12.5px; font-weight: 600; cursor: pointer; }
.vbtn svg { width: 16px; height: 16px; }
.vbtn:hover { border-color: var(--brand); color: var(--brand); }
.vbtn.on { color: var(--brand); background: #eaf1ff; border-color: #c9dafc; }
body.no-tabs .modbar { display: none; }
body.no-panel .layout { grid-template-columns: 1fr; }
body.no-panel .panel { display: none; }
#modelSel { max-width: 260px; }
.canvas-wrap { position: relative; }
.fs-bar { display: none; }
/* pantalla completa: solo la pantalla de señales */
.canvas-wrap:fullscreen, body.pseudo-fs .canvas-wrap { min-height: 0; border: 0; border-radius: 0; box-shadow: none; background: #fff; }
.canvas-wrap:fullscreen { width: 100vw; height: 100vh; }
.canvas-wrap:-webkit-full-screen { width: 100vw; height: 100vh; }
body.pseudo-fs .canvas-wrap { position: fixed; inset: 0; z-index: 1000; width: 100vw; height: 100vh; height: 100dvh; }
body.in-fs .fs-bar { display: flex; position: absolute; top: 8px; right: 10px; gap: 6px; align-items: center; opacity: .35; transition: opacity .2s; }
body.in-fs .fs-bar:hover { opacity: 1; }
.fs-hint { font-size: 12px; color: var(--muted); background: rgba(255,255,255,.9); padding: 3px 8px; border-radius: 6px; }
@media (max-width: 900px) { .viewbtns { margin-left: 0; } .vbtn span { display: none; } .fs-hint { display: none; } }
@media print { .viewbtns, .fs-bar { display: none !important; } }
