﻿/* =========================================================
   TableroRIC Pro — page styles (loaded after styles.css + app.css)
   Uses the site tokens; adds board-specific tokens per theme.
   ========================================================= */
:root {
  --elec: #2563eb;
  --elec-soft: rgba(37, 99, 235, 0.12);
  --elec-glow: rgba(37, 99, 235, 0.35);
  --neon-warn: #f59e0b;
  --neon-bad: #ef4444;
  --cab: #e6e9ef;
  --cab-edge: rgba(16, 19, 27, 0.16);
  --cab-dot: rgba(16, 19, 27, 0.09);
  --plate: #eef0f4;
  --din-a: #d5d9e1;
  --din-b: #a7aebb;
  --din-hole: rgba(16, 19, 27, 0.22);
  --slot-line: rgba(16, 19, 27, 0.08);
  --mod: #fbfbf9;
  --mod-2: #e9e8e3;
  --mod-face: #f4f3ef;
  --mod-edge: rgba(16, 19, 27, 0.28);
  --mod-ink: #151924;
  --mod-muted: #6a7182;
  --mod-slot: #262b36;
  --lever: #1d212b;
  --screw: #c9ccd3;
  --mod-shadow: rgba(16, 19, 27, 0.22);
  --copper-a: #e9a46a;
  --copper-b: #b8692f;
  --uni-grid: rgba(16, 19, 27, 0.05);
}
:root[data-theme="dark"] {
  --elec: #4d8dff;
  --elec-soft: rgba(77, 141, 255, 0.14);
  --elec-glow: rgba(77, 141, 255, 0.45);
  --neon-warn: #fbbf24;
  --neon-bad: #ff5b5b;
  --cab: #0a0e18;
  --cab-edge: rgba(255, 255, 255, 0.1);
  --cab-dot: rgba(255, 255, 255, 0.06);
  --plate: #0d1220;
  --din-a: #5a6375;
  --din-b: #2b3242;
  --din-hole: rgba(0, 0, 0, 0.45);
  --slot-line: rgba(255, 255, 255, 0.06);
  --mod: #e8eaee;
  --mod-2: #cfd3da;
  --mod-face: #dfe2e8;
  --mod-edge: rgba(0, 0, 0, 0.45);
  --mod-ink: #0f131c;
  --mod-muted: #4f5666;
  --mod-slot: #1a1e27;
  --lever: #151821;
  --screw: #b5bac4;
  --mod-shadow: rgba(0, 0, 0, 0.6);
  --uni-grid: rgba(255, 255, 255, 0.04);
}

.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.print-only { display: none; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 5px; border-radius: 6px; font: 700 11px var(--font-mono); color: var(--text); background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--line-2), inset 0 0 0 1px var(--line); }

/* ---------- head ---------- */
.tb-eyebrow { display: inline-flex; align-items: center; gap: 10px; font: 500 12px var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px !important; }
.tb-eyebrow__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--elec); box-shadow: 0 0 0 4px var(--elec-soft), 0 0 12px var(--elec-glow); }
.tb-head .app-head__actions .btn { height: 38px; padding: 0 14px; }
.tb-head .app-head__actions .btn .i { width: 17px; height: 17px; }
@media (hover: hover) and (pointer: fine) { .tb-head .app-head__actions .btn:hover .i, .docs .btn:hover .i, .insp .btn:hover .i, .phases .btn:hover .i { transform: none; } }

/* ---------- KPIs ---------- */
.kpis { margin: 0 0 16px; }
.kpi { position: relative; overflow: hidden; }
.kpi > span { display: flex; align-items: center; gap: 6px; }
.kpi b span { font-size: inherit; color: inherit; font-weight: inherit; }
.kpi b small { font-size: 0.5em; color: var(--muted); font-weight: 700; }
.kpi > small { font-variant-numeric: tabular-nums; }
.kpi__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); }
.kpi__bar i { position: absolute; inset: 0; background: var(--elec); transform-origin: 0 50%; transform: scaleX(0); transition: transform 300ms var(--ease-out); }
.kpi__bar i.is-warn { background: var(--neon-warn); }
.kpi--status b { display: flex; align-items: center; min-height: 37px; }
.kpi--status .badge { font-size: 14px; padding: 8px 14px; }
.kpi--status .badge--ok { box-shadow: 0 0 18px -4px rgba(16, 185, 129, 0.55); }
.kpi--status .badge--bad { box-shadow: 0 0 20px -4px rgba(239, 68, 68, 0.6); }
.kpi--status.is-bad { box-shadow: inset 0 0 0 1px rgba(239, 68, 68, 0.35); }

/* ---------- settings ---------- */
.tb-settings { margin-bottom: 16px; }
.tb-settings__grid { display: grid; grid-template-columns: minmax(200px, 1.6fr) minmax(210px, 1.2fr) repeat(4, minmax(110px, 1fr)); gap: 10px; padding: 12px; align-items: stretch; }
.tb-settings .num input, .tb-settings .num select { font-size: 17px; }
.tb-settings__name input { font: 700 16px/1.4 var(--font-body); }
.num > span { display: flex; align-items: center; gap: 6px; }
.tb-field { display: grid; gap: 6px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); align-content: space-between; }
.tb-label { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.tb-field .seg { background: var(--surface); }
.tb-field .seg button { padding: 6px 10px; }
.seg button { transition: color 200ms ease, transform 160ms var(--ease-out); }
.seg button:active { transform: scale(0.97); }
.seg__thumb { transition: transform 300ms var(--ease-out), opacity 150ms ease; }

/* ---------- workspace layout ---------- */
.ws { display: grid; grid-template-columns: 232px minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ws > * { min-width: 0; }
.ws.is-split { grid-template-columns: 232px minmax(0, 1fr); }
.ws.is-split .cat { grid-row: 1 / span 2; }
.ws.is-split .side { grid-column: 2; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.side { display: grid; gap: 16px; }
@media (max-width: 1180px) {
  .ws, .ws.is-split { grid-template-columns: 216px minmax(0, 1fr); }
  .cat, .ws.is-split .cat { grid-row: 1 / span 2; }
  .side, .ws.is-split .side { grid-column: 2; display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
  .tb-settings__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- catalog ---------- */
.cat { position: sticky; top: calc(var(--nav-h) + 12px); overflow: hidden; transition: box-shadow 200ms ease; }
.cat__head { padding: 14px 16px; flex-wrap: wrap; }
.cat__hint { font-size: 11.5px; color: var(--muted); }
.cat__body { padding: 10px 12px 14px; display: grid; gap: 14px; max-height: calc(100svh - var(--nav-h) - 110px); overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.cg h3 { font: 700 11px var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.cg__opts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.mini { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.mini button { padding: 4px 8px; border-radius: 7px; font: 700 12px var(--font-mono); color: var(--muted); transition: background-color 150ms ease, color 150ms ease, transform 140ms var(--ease-out); }
.mini button:active { transform: scale(0.95); }
.mini button[aria-checked="true"] { background: var(--elec); color: #fff; }
.mini-sel { height: 30px; padding: 0 6px; border-radius: 9px; border: 0; font: 700 12px var(--font-mono); color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; }
.mini-sel option { background: var(--surface); color: var(--text); }
.cg__items { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.ci { min-width: 0; }
.ci__txt { min-width: 0; overflow-wrap: break-word; }
.ci {
  position: relative; display: grid; grid-template-rows: 64px auto; gap: 6px; padding: 8px 8px 9px; border-radius: 14px; text-align: left;
  background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab;
  transition: transform 180ms var(--ease-out), box-shadow 200ms ease;
}
.ci:active { transform: scale(0.97); }
.ci__prev { display: grid; place-items: center; height: 64px; }
.ci__prev .dm__svg { height: 64px; width: auto; max-width: 100%; filter: drop-shadow(0 3px 4px var(--mod-shadow)); }
.ci__comb { width: 100%; height: 14px; display: block; }
.ci__txt b { display: block; font-size: 12px; line-height: 1.25; }
.ci__txt small { display: block; font: 500 10.5px var(--font-mono); color: var(--muted); margin-top: 2px; }
@media (hover: hover) and (pointer: fine) {
  .ci:hover { transform: translateY(-2px); box-shadow: inset 0 0 0 1px var(--elec), 0 10px 24px -14px var(--elec-glow); }
  .ci:active { transform: scale(0.97); }
}
.cat__drop {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 8px; font-weight: 800; color: var(--neon-bad);
  background: color-mix(in srgb, var(--surface) 86%, var(--neon-bad)); border-radius: inherit; box-shadow: inset 0 0 0 2px var(--neon-bad);
  opacity: 0; pointer-events: none; transition: opacity 160ms var(--ease-out);
}
.cat__drop .i { width: 30px; height: 30px; }
.cat.is-remove .cat__drop { opacity: 1; }

/* ---------- stage ---------- */
.stage__bar { flex-wrap: wrap; padding: 12px 14px 12px 18px; }
.stage__bar h2 { font-size: 15px; }
.stage__seg { min-width: 270px; }
.stage__seg button { padding: 7px 12px; }
.stage__views { display: grid; gap: 16px; padding: 14px; }
.stage__views[data-view="board"] .view--uni, .stage__views[data-view="uni"] .view--board { display: none; }
.stage__views[data-view="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.view { min-width: 0; }
.stage__rule, .stage__keys { font-size: 12.5px; color: var(--muted); margin-top: 10px !important; }
.stage__rule b { color: var(--text); }
.stage__keys { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
@media (hover: none) { .stage__keys { display: none; } }

.board-scroll { overflow-x: auto; overflow-y: hidden; overscroll-behavior-x: contain; padding: 2px 2px 10px; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }

/* ---------- cabinet + rails ---------- */
.cabinet {
  --mw: 36px; --mh: calc(var(--mw) * 3.5556);
  position: relative; display: inline-block; vertical-align: top; min-width: 100%;
  padding: 22px 22px 18px 18px; border-radius: 20px;
  background: radial-gradient(var(--cab-dot) 1px, transparent 1.2px) 0 0 / 14px 14px, var(--cab);
  box-shadow: inset 0 0 0 1px var(--cab-edge), inset 0 2px 18px -6px var(--mod-shadow);
}
.cab__screw { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, var(--screw), var(--din-b)); box-shadow: 0 1px 2px var(--mod-shadow); }
.cab__screw::after { content: ""; position: absolute; left: 2px; right: 2px; top: 4.5px; height: 1px; background: var(--din-hole); transform: rotate(-35deg); }
.cab__plate { display: grid; gap: 14px; width: max-content; margin-inline: auto; }
.rail-row { display: grid; grid-template-columns: 42px auto; gap: 8px; align-items: center; }
.rail-row__label { display: grid; justify-items: center; text-align: center; line-height: 1.1; padding-top: 30px; }
.rail-row__label b { font: 800 13px var(--font-mono); color: var(--elec); }
.rail-row__label small { font: 500 9.5px var(--font-mono); color: var(--muted); }
.rail { position: relative; width: calc(var(--n) * var(--mw)); height: calc(14px + 20px + var(--mh) + 18px); }
.rail__ticks { position: absolute; left: 0; right: 0; top: 0; height: 14px; display: flex; }
.rail__ticks span { width: var(--mw); flex: none; text-align: center; font: 500 9px/14px var(--font-mono); color: var(--muted); opacity: 0.65; }
.rail__band { position: absolute; left: 0; right: 0; top: 14px; height: 20px; }
.rail__bed {
  position: absolute; left: 0; right: 0; top: 34px; height: var(--mh); border-radius: 6px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(var(--mw) - 1px), var(--slot-line) calc(var(--mw) - 1px) var(--mw));
  box-shadow: inset 0 0 0 1px var(--slot-line);
}
.rail__din {
  position: absolute; left: -10px; right: -10px; top: 34%; height: 32%; border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, transparent 0 9px, var(--din-hole) 9px 21px, transparent 21px 30px) center / 100% 26% no-repeat,
    linear-gradient(180deg, var(--din-b) 0 8%, var(--din-a) 14% 40%, var(--din-b) 50%, var(--din-a) 60% 86%, var(--din-b) 92%);
  box-shadow: 0 2px 6px -2px var(--mod-shadow);
}
.rail__bus { position: absolute; left: 0; right: 0; top: calc(34px + var(--mh)); height: 18px; border-radius: 0 0 6px 6px; background: repeating-linear-gradient(90deg, transparent 0 calc(var(--mw) - 1px), var(--slot-line) calc(var(--mw) - 1px) var(--mw)); opacity: 0.6; }

/* tags + RCD group bars */
.rtag {
  position: absolute; left: calc(var(--x) * var(--mw)); width: calc(var(--w) * var(--mw)); top: 0; height: 14px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  font: 800 10px/1 var(--font-mono); color: var(--muted); white-space: nowrap; overflow: hidden;
}
.rtag small { font-size: 8.5px; color: var(--elec); font-weight: 700; }
.rtag--rcd { color: var(--elec); }
.rtag--main { color: var(--sun-ink); }
.grp { position: absolute; left: calc(var(--x) * var(--mw) + 3px); width: calc(var(--w) * var(--mw) - 6px); bottom: 1px; height: 3px; border-radius: 2px; background: var(--elec); box-shadow: 0 0 8px var(--elec-glow); }
.grp::before, .grp::after { content: ""; position: absolute; bottom: 0; width: 2px; height: 7px; border-radius: 1px; background: inherit; }
.grp::before { left: 0; } .grp::after { right: 0; }
.grp--300 { background: color-mix(in srgb, var(--elec) 45%, var(--muted)); box-shadow: none; }

/* DIN modules */
.dm {
  position: absolute; top: 34px; left: calc(var(--x) * var(--mw)); width: calc(var(--w) * var(--mw)); height: var(--mh);
  padding: 0; border-radius: 6px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform 200ms var(--ease-out), opacity 200ms ease; z-index: 1;
}
.dm__svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 4px 5px var(--mod-shadow)); pointer-events: none; }
.dm::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: 0 14px 22px -10px var(--mod-shadow); opacity: 0; transition: opacity 200ms ease; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .dm:hover { transform: translateY(-2px); }
  .dm:hover::after { opacity: 1; }
}
.dm:active { transform: scale(0.985); }
.dm:focus-visible { outline: 2px solid var(--sun); outline-offset: 3px; border-radius: 6px; }
.dm.is-sel { outline: 2px solid var(--elec); outline-offset: 3px; z-index: 2; }
.dm.is-sel::before { content: ""; position: absolute; inset: -3px; border-radius: 8px; box-shadow: 0 0 16px 1px var(--elec-glow); pointer-events: none; }
.dm.is-src { opacity: 0.28; }
.dm.is-bad::before, .dm.is-warn::before { content: ""; position: absolute; inset: -2px; border-radius: 8px; pointer-events: none; }
.dm.is-bad::before { box-shadow: 0 0 0 2px var(--neon-bad), 0 0 18px 2px color-mix(in srgb, var(--neon-bad) 60%, transparent); }
.dm.is-warn::before { box-shadow: 0 0 0 2px var(--neon-warn), 0 0 16px 1px color-mix(in srgb, var(--neon-warn) 55%, transparent); }
.dm__flag { position: absolute; top: -4px; right: -4px; width: 11px; height: 11px; border-radius: 50%; background: var(--neon-bad); box-shadow: 0 0 0 2px var(--cab), 0 0 10px var(--neon-bad); pointer-events: none; }
.dm.is-warn .dm__flag { background: var(--neon-warn); box-shadow: 0 0 0 2px var(--cab), 0 0 10px var(--neon-warn); }
.snap-ring { position: absolute; inset: -4px; border-radius: 9px; box-shadow: 0 0 0 2px var(--elec), 0 0 22px 2px var(--elec-glow); pointer-events: none; }

/* comb / busbar (bus layer, below modules) */
.dm--comb { top: calc(34px + var(--mh) + 3px); height: 13px; border-radius: 4px; z-index: 3; }
.comb__bar {
  position: absolute; inset: 0; border-radius: 4px;
  background: linear-gradient(180deg, var(--copper-a), var(--copper-b) 70%, #8d4c1f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 3px 6px -2px var(--mod-shadow);
}
.comb__bar::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 100%; height: 6px;
  background: repeating-linear-gradient(90deg, transparent 0 calc(var(--mw, 36px) / 2 - 2px), var(--copper-b) calc(var(--mw, 36px) / 2 - 2px) calc(var(--mw, 36px) / 2 + 2px), transparent calc(var(--mw, 36px) / 2 + 2px) var(--mw, 36px));
}
.comb__t { position: relative; display: block; font: 800 8px/13px var(--font-mono); color: #3a1d08; text-align: center; letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; }
.ci__comb { position: relative; --mw: 16px; margin-top: 24px; }

/* SVG paint (modules) */
.m-body { fill: var(--mod); stroke: var(--mod-edge); stroke-width: 0.5; }
.m-term { fill: var(--mod-2); }
.m-face { fill: var(--mod-face); stroke: var(--mod-edge); stroke-width: 0.35; }
.m-screw { fill: var(--screw); stroke: var(--mod-edge); stroke-width: 0.4; }
.m-screwslot { stroke: var(--mod-slot); stroke-width: 0.7; stroke-linecap: round; opacity: 0.7; }
.m-div { stroke: var(--mod-edge); stroke-width: 0.3; opacity: 0.6; }
.m-slot { fill: var(--mod-slot); }
.m-lever { fill: var(--lever); }
.m-lever--main { fill: var(--sun); }
.m-lever--rcd { fill: var(--elec); }
.m-lever-hi { fill: #fff; opacity: 0.25; }
.m-rate { font-family: var(--font-mono); font-weight: 700; font-size: 6.2px; fill: var(--mod-ink); }
.m-sub { font-family: var(--font-mono); font-weight: 500; font-size: 3.3px; fill: var(--mod-muted); letter-spacing: 0.02em; }
.m-sens { font-family: var(--font-mono); font-weight: 700; font-size: 4.2px; fill: var(--elec); }
.m-accent { fill: var(--elec); }
.m-test { fill: var(--sun); stroke: rgba(0, 0, 0, 0.3); stroke-width: 0.4; }
.m-testt { font-family: var(--font-mono); font-weight: 800; font-size: 3.6px; fill: #2a2100; }
.m-cls { fill: none; stroke: var(--mod-ink); stroke-width: 0.4; }
.m-clst { font-family: var(--font-mono); font-weight: 800; font-size: 3.4px; fill: var(--mod-ink); }
.m-load { fill: var(--muted); }
.m-load--alumbrado { fill: #f5c800; }
.m-load--enchufes { fill: var(--elec); }
.m-load--fuerza { fill: #8b5cf6; }
.m-load--clima { fill: #14b8a6; }
.m-load--otro { fill: #9aa1ae; }
.m-load--main { fill: var(--sun); }
.m-lcd { fill: #0d2b27; stroke: rgba(0, 0, 0, 0.4); stroke-width: 0.4; }
.m-lcdt { font-family: var(--font-mono); font-weight: 700; fill: #6ff2c4; letter-spacing: 0.04em; }
.m-led { fill: #ff4d4d; }
.m-okwin { fill: var(--mod-slot); }
.m-ok { fill: #22c55e; }
.m-bolt { fill: var(--sun); stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.35; }
.m-foot { fill: var(--din-b); }
.m-tb { stroke: rgba(0, 0, 0, 0.35); stroke-width: 0.4; }
.m-tb--N { fill: #2f6fe0; }
.m-tb--F { fill: #8a909c; }
.m-tb--PE { fill: url(#tbPe); }
.m-tbwin { fill: rgba(0, 0, 0, 0.35); }
.m-tbt { font-family: var(--font-mono); font-weight: 800; font-size: 5px; fill: #fff; paint-order: stroke; stroke: rgba(0, 0, 0, 0.55); stroke-width: 1px; }

/* ghost + drag avatar */
.ghost {
  position: absolute; left: 0; top: 34px; width: calc(var(--w) * var(--mw)); height: var(--mh); border-radius: 7px;
  transform: translateX(calc(var(--x, 0) * var(--mw))); transition: transform 120ms var(--ease-out);
  border: 2px dashed var(--elec); background: var(--elec-soft); box-shadow: 0 0 18px -2px var(--elec-glow), inset 0 0 16px -6px var(--elec-glow);
  pointer-events: none; z-index: 4;
}
.ghost--bus { top: calc(34px + var(--mh) + 2px); height: 15px; border-radius: 4px; }
.ghost.is-bad { border-color: var(--neon-bad); background: color-mix(in srgb, var(--neon-bad) 14%, transparent); box-shadow: 0 0 18px -2px color-mix(in srgb, var(--neon-bad) 60%, transparent); }
.drag-av { position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; will-change: transform; }
.drag-av__in { width: 100%; height: 100%; transform: scale(1.04) rotate(-1deg); filter: drop-shadow(0 18px 18px var(--mod-shadow)); opacity: 0.96; }
.drag-av .dm__svg { filter: none; }
.drag-av--comb .drag-av__in { --mw: 36px; position: relative; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }

/* ---------- unilineal ---------- */
.uni-scroll {
  overflow: auto; border-radius: 16px; padding: 8px; max-height: 640px; overscroll-behavior: contain; scrollbar-width: thin;
  background: linear-gradient(var(--uni-grid) 1px, transparent 1px) 0 0 / 20px 20px, linear-gradient(90deg, var(--uni-grid) 1px, transparent 1px) 0 0 / 20px 20px, var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.uni { display: block; height: auto; max-width: none; margin-inline: auto; }
.stage__views[data-view="uni"] .uni { min-width: 100%; }
.u-l { fill: none; stroke: var(--text); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.u-bus { stroke-width: 3.2; }
.u-sub { stroke-width: 2.2; stroke: var(--elec); }
.u-e { stroke: var(--elec); }
.u-dash { stroke-dasharray: 2 2.5; stroke-width: 1; }
.u-dot { fill: var(--text); }
.u-arrow { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-linecap: round; stroke-linejoin: round; }
.u-bad { stroke: var(--neon-bad); }
.u-t { font-family: var(--font-mono); font-size: 9.5px; fill: var(--text); }
.u-t--b { font-weight: 700; font-size: 10.5px; }
.u-t--m { fill: var(--muted); }
.u-t--s { font-size: 8px; font-weight: 700; }
.u-t--n { font-family: var(--font-body); font-size: 10px; fill: var(--muted); }
.u-et { fill: var(--elec); }
.u-badt { fill: var(--neon-bad); font-weight: 700; }
.u-bg { paint-order: stroke; stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round; }

/* ---------- inspector ---------- */
.insp__body { padding: 14px 16px 16px; }
.insp__empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 14px 4px; font-size: 14px; }
.insp__empty .i { width: 30px; height: 30px; color: var(--elec); }
.insp__empty .muted { font-size: 13px; }
.insp__pos { font-size: 11.5px; color: var(--muted); margin-bottom: 10px !important; }
.insp__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.insp__grid .span2 { grid-column: 1 / -1; }
.insp__grid .num { padding: 8px 12px; }
.insp__grid .num input, .insp__grid .num select { font-size: 15px; font-family: var(--font-body); font-weight: 700; }
.insp__grid .num input[type="number"] { font-family: var(--font-display); font-size: 17px; }
.insp__grid .num input:disabled { color: var(--muted); }
.insp__calc { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--tint); box-shadow: inset 0 0 0 1px var(--line); }
.insp__calc div { display: grid; text-align: center; flex: 1; }
.insp__calc span { font: 700 11px var(--font-mono); color: var(--muted); }
.insp__calc b { font: 700 18px var(--font-display); font-variant-numeric: tabular-nums; }
.insp__calc i { font: 800 18px var(--font-mono); font-style: normal; }
.insp__calc i.ok { color: var(--green); }
.insp__calc i.bad { color: var(--neon-bad); text-shadow: 0 0 10px color-mix(in srgb, var(--neon-bad) 60%, transparent); }
.insp__f { font-size: 11.5px; color: var(--muted); margin-top: 8px !important; overflow-wrap: anywhere; }
.insp__list { margin-top: 12px; padding: 10px 12px; border-radius: 14px; background: var(--tint); box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; }
.insp__list span { font: 700 11px var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.insp__act { display: flex; gap: 8px; margin-top: 14px; }
.insp__act .btn { flex: 1; height: 38px; }
.btn--danger { color: var(--red); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--red) 45%, transparent); }
@media (hover: hover) and (pointer: fine) { .btn--danger:hover { background: color-mix(in srgb, var(--red) 10%, transparent); } }

/* ---------- assistant ---------- */
.phases { display: grid; gap: 8px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.phases__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.phases__head b { display: flex; align-items: center; gap: 6px; }
.phases__head .muted { font-size: 12.5px; flex-basis: 100%; }
.ph { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.ph > b { font: 800 13px var(--font-mono); }
.ph__track { position: relative; height: 12px; border-radius: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.ph__track i { position: absolute; inset: 0; border-radius: inherit; transform-origin: 0 50%; transition: transform 300ms var(--ease-out); }
.ph--R .ph__track i { background: var(--elec); }
.ph--S .ph__track i { background: var(--sun); }
.ph--T .ph__track i { background: var(--violet); }
.ph__v { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.phases__f { font-size: 11px; color: var(--muted); }
.phases .btn { height: 38px; }
.prop { padding: 12px; border-radius: 14px; background: var(--elec-soft); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--elec) 40%, transparent); font-size: 13px; animation: propIn 220ms var(--ease-out); }
.prop ul { margin: 8px 0; padding-left: 18px; display: grid; gap: 3px; }
.prop__act { display: flex; gap: 8px; }
.prop__act .btn { flex: 1; height: 36px; }
@keyframes propIn { from { opacity: 0; transform: translateY(-4px); } }

.fds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fd__in { display: flex; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 12px; text-align: left; transition: background-color 150ms ease, transform 140ms var(--ease-out); }
button.fd__in:active { transform: scale(0.99); }
@media (hover: hover) and (pointer: fine) { button.fd__in:hover { background: var(--hover); } }
.fd__dot { width: 10px; height: 10px; border-radius: 50%; flex: none; margin-top: 5px; background: currentColor; }
.fd--ok { color: var(--green); }
.fd--info { color: var(--sky); }
.fd--warn { color: var(--neon-warn); }
.fd--bad { color: var(--neon-bad); }
.fd--warn .fd__dot, .fd--bad .fd__dot { box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 22%, transparent), 0 0 10px currentColor; }
.fd--warn .fd__in { background: color-mix(in srgb, var(--neon-warn) 8%, transparent); }
.fd--bad .fd__in { background: color-mix(in srgb, var(--neon-bad) 8%, transparent); }
.fd__txt { display: grid; gap: 2px; min-width: 0; color: var(--text); }
.fd__txt b { font-size: 13.5px; line-height: 1.3; }
.fd__txt > span { font-size: 12.5px; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.fd__txt small { font: 500 10.5px var(--font-mono); color: var(--muted); opacity: 0.85; }
:root:not([data-theme="dark"]) .fd--warn { color: #b45309; }

/* ---------- docs ---------- */
.docs { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; margin: 16px 0; }
.docs > * { min-width: 0; }
.docs .panel__head { flex-wrap: wrap; }
.docs__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.docs__actions .btn { height: 38px; padding: 0 14px; }
.num--inline { min-width: 210px; padding: 6px 12px; }
.num--inline input { font-size: 16px; }
.docs__meta { font-size: 13px; color: var(--muted); margin-bottom: 10px !important; }
.docs__meta b { color: var(--text); }
.docs__note { font-size: 12px; color: var(--muted); margin-top: 10px !important; }
.t-bad { color: var(--neon-bad); font-weight: 700; }
.tbl-wrap { overflow-x: auto; border-radius: 14px; box-shadow: inset 0 0 0 1px var(--line); scrollbar-width: thin; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font: 700 10.5px var(--font-mono); letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding: 10px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .r { text-align: right; }
.tbl .b { font-weight: 800; }
.tbl td.mono { font-size: 12px; white-space: nowrap; }
.tbl tfoot td { font-weight: 800; background: var(--tint); border-top: 1px solid var(--line-2); border-bottom: 0; }
.tbl tr.is-bad td:first-child { box-shadow: inset 3px 0 0 var(--neon-bad); color: var(--neon-bad); }
.tbl tr.is-warn td:first-child { box-shadow: inset 3px 0 0 var(--neon-warn); }
.tbl tr.is-cable td { background: var(--tint); }
.tbl__empty { text-align: center; color: var(--muted); padding: 22px !important; }
.disclaimer { margin-top: 4px; }

/* ---------- tablet / phone ---------- */
@media (max-width: 900px) {
  .ws, .ws.is-split { grid-template-columns: minmax(0, 1fr); }
  .side, .ws.is-split .side { grid-template-columns: minmax(0, 1fr); grid-column: auto; }
  .stage__seg button[data-v="split"] { display: none; }
  .stage__seg { min-width: 0; }
  .tb-settings__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tb-settings__name, .tb-field { grid-column: 1 / -1; }
  .res--4.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* catalog becomes a horizontal strip; horizontal swipe scrolls, vertical drag picks up */
  .cat, .ws.is-split .cat { position: relative; top: auto; grid-row: auto; }
  .cat__head { padding: 12px 14px; }
  .cat__body { display: flex; gap: 14px; overflow-x: auto; overflow-y: hidden; max-height: none; padding: 10px 14px 14px; scroll-snap-type: x proximity; scroll-padding-inline: 14px; }
  .cg { flex: none; display: flex; flex-direction: column; scroll-snap-align: start; }
  .cg__opts { flex-wrap: nowrap; }
  .cg__items { display: flex; gap: 8px; }
  .ci { width: 96px; flex: none; touch-action: pan-x; }
  .cabinet { --mw: 32px; padding: 18px 14px 14px 10px; }
  .rail-row { grid-template-columns: 30px auto; gap: 4px; }
  .rail-row__label small { display: none; }
}
@media (max-width: 560px) {
  .app-head h1 { font-size: 32px; }
  .tb-head .app-head__actions { width: 100%; }
  .tb-head .app-head__actions .btn { flex: 1 1 auto; }
  .kpi { padding: 12px !important; }
  .kpi b { font-size: 22px !important; }
  .kpi > small { font-size: 11px; }
  .kpi--status .badge { font-size: 12px; padding: 6px 10px; }
  .insp__grid { grid-template-columns: minmax(0, 1fr); }
  .panel__body { padding: 14px; }
  .stage__views { padding: 10px; }
  .num--inline { min-width: 0; flex: 1 1 100%; }
  .docs__actions { width: 100%; }
}

/* ---------- motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  .tb *, .tb *::before, .tb *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; }
}

/* ---------- print ---------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  :root { --elec: #1d4ed8; --neon-bad: #c00; --neon-warn: #b45309; --uni-grid: transparent; }
  body.tb { font-size: 11px; }
  .tip, .ws, .tb-settings, .tb-head .app-head__actions, .tb-eyebrow, .tb-head p { display: none !important; }
  .print-only { display: block !important; }
  .tb-head { margin: 0 0 6px; }
  .tb-head h1 { font-size: 22px; }
  .print-head h2 { font-size: 18px; margin: 0 0 2px; }
  .print-head p { font-size: 11px; color: #444; margin-bottom: 8px; }
  .kpis { gap: 6px; margin-bottom: 8px; }
  .kpi { padding: 8px !important; border: 1px solid #ccc; }
  .kpi b { font-size: 18px !important; }
  .kpi__bar { display: none; }
  .kpi .badge, .kpi--status .badge { box-shadow: none; border: 1px solid currentColor; }
  .docs { gap: 8px; margin: 0; }
  .panel__head { padding: 6px 10px; }
  .panel__body { padding: 8px 10px; }
  .uni-print svg { width: 100%; height: auto; max-height: 170mm; }
  .uni-print { break-after: page; }
  .tbl-wrap { overflow: visible; box-shadow: none; }
  .tbl { font-size: 9.5px; }
  .tbl th, .tbl td { padding: 4px 5px; border: 1px solid #bbb; }
  .tbl th { background: #eee !important; color: #000; }
  .tbl td.mono { font-size: 9px; }
  .fds { gap: 2px; }
  .fd__in { padding: 3px 0; background: none !important; }
  .fd__dot { box-shadow: none !important; }
  .fd__txt > span { color: #333; }
  .disclaimer { font-size: 10px; border: 1px solid #ccc; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
