:root {
  --navy-950: #041436;
  --navy-900: #071f52;
  --navy-800: #083072;
  --blue-700: #005dd6;
  --blue-500: #0784ff;
  --blue-200: #d9ecff;
  --cyan-300: #56d9ff;
  --green-500: #43e34a;
  --lime-400: #a7ff3c;
  --yellow-400: #ffd839;
  --red-500: #f03737;
  --panel-bg: rgba(255, 255, 255, 0.96);
  --panel-line: rgba(26, 92, 190, 0.36);
  --text-main: #09214f;
  --muted: #607398;
  --shadow: 0 14px 32px rgba(1, 18, 58, 0.22);

  /* Escala tipografica unica del sistema (Arial en toda la app) */
  --font-app: Arial, "Helvetica Neue", Helvetica, sans-serif;
  --fs-brand-title: 16px;
  --fs-brand-sub: 11px;
  --fs-brand-tag: 9px;
  --fs-panel-title: 12px;
  --fs-section-title: 11px;
  --fs-action: 11px;
  --fs-lib-button: 10px;
  --fs-label: 9px;
  --fs-value: 13px;
  --fs-body: 11px;
  --fs-small: 9px;
  --fs-svg-room: 11px;
  --fs-svg-room-title: 11px;
  --fs-svg-room-size: 9px;
  --tracking-label: 0.4px;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  color: var(--text-main);
  font-family: var(--font-app);
  font-size: var(--fs-body);
  background:
    radial-gradient(circle at top left, rgba(20, 196, 255, 0.28), transparent 28rem),
    linear-gradient(135deg, #071a43 0%, #0b3b91 50%, #07215c 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  padding: 3px;
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr);
  gap: 3px;
  overflow: hidden;
}

.topbar {
  position: relative;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 4px 6px;
  border: 1px solid rgba(91, 180, 255, 0.5);
  border-radius: 16px 16px 8px 8px;
  color: #fff;
  background: linear-gradient(90deg, #061439 0%, #082e80 56%, #061439 100%);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.logo-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 3px solid var(--lime-400);
  border-radius: 14px;
  color: var(--lime-400);
  font-size: 20px;
  box-shadow: inset 0 0 16px rgba(167, 255, 60, 0.25);
}

.brand h1,
.brand h2,
.brand p {
  margin: 0;
  line-height: 1;
}

.brand h1 {
  font-size: var(--fs-brand-title);
  font-weight: 800;
  letter-spacing: 0.5px;
}

.brand h2 {
  margin-top: 2px;
  color: var(--lime-400);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.brand h2 span {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 5px;
  border: 1px solid #fff;
  border-radius: 6px;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  vertical-align: middle;
}

.brand p {
  margin-top: 4px;
  color: #d7e8ff;
  font-size: var(--fs-brand-tag);
  font-weight: 400;
  line-height: 1.25;
}

.workflow {
  display: none;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
  width: 760px;
  max-width: 100%;
  overflow: hidden;
}

.step,
.toolbar button {
  min-height: 28px;
  border: 1px solid rgba(117, 195, 255, 0.38);
  border-radius: 10px;
  color: #fff;
  text-transform: uppercase;
  background: linear-gradient(180deg, #0c57cb, #061f64);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-app);
  font-size: var(--fs-panel-title);
  font-weight: 800;
  min-width: 0;
  width: auto;
  max-width: none;
  flex: none;
  padding: 4px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.step b {
  display: inline-grid;
  flex: none;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  color: #052252;
  font-size: 10px;
  font-weight: 900;
  background: radial-gradient(circle at 30% 25%, #6fd0ff, #0b99ff 65%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

.step.active {
  outline: 2px solid var(--cyan-300);
}

.toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.toolbar button {
  height: 32px;
  padding: 0 14px;
  font-family: var(--font-app);
  font-weight: 700;
  font-size: var(--fs-action);
  letter-spacing: 0.3px;
  white-space: nowrap;
}

#demoMenuButton {
  background: linear-gradient(180deg, #ff9a3d, #c2590a);
  border-color: rgba(255, 198, 130, 0.55);
}

.demo-menu {
  position: absolute;
  top: 54px;
  right: 16px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 10px;
  background: #0b1f4d;
  border: 1px solid rgba(117, 195, 255, 0.38);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.demo-menu[hidden] {
  display: none;
}

.demo-menu button {
  min-height: 32px;
  padding: 6px 14px;
  border: 1px solid rgba(117, 195, 255, 0.38);
  border-radius: 8px;
  color: #fff;
  font-family: var(--font-app);
  font-size: var(--fs-action);
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
  background: linear-gradient(180deg, #0c57cb, #061f64);
  cursor: pointer;
}

.demo-menu button:hover {
  outline: 2px solid var(--cyan-300);
}

.workspace {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr) 122px;
  gap: 5px;
  min-height: 0;
  height: 100%;
  margin-top: 0;
  overflow: hidden;
  padding-right: 0;
}

.panel {
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  background: var(--panel-bg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-title {
  padding: 7px 9px;
  color: #fff;
  font-family: var(--font-app);
  font-size: var(--fs-panel-title);
  font-weight: 800;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: linear-gradient(180deg, #0d7cff 0%, #063692 100%);
}

.left-rail {
  display: grid;
  grid-auto-rows: max-content;
  gap: 3px;
  min-height: 0;
  position: relative;
  z-index: 110;
  width: 122px;
  overflow: auto;
}

.left-dock-panel {
  width: 122px;
  height: auto;
  min-height: 0;
  position: relative;
  z-index: 105;
  background: linear-gradient(180deg, #08398f 0%, #05183f 100%);
}

.left-dock-panel .panel-title {
  display: flex;
  width: 100%;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 6px;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-family: var(--font-app);
  font-size: var(--fs-panel-title);
  font-weight: 800;
  letter-spacing: var(--tracking-label);
  color: #fff;
  text-align: center;
  text-transform: uppercase;
  line-height: 1.1;
  background: linear-gradient(180deg, #0e79ff, #0a42aa);
}

.left-dock-panel.collapsed {
  width: 122px;
}

.left-dock-panel.collapsed .panel-title {
  height: 28px;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.left-dock-panel.collapsed .left-menu-content {
  display: none;
}

.left-dock-panel.expanded {
  position: relative;
  left: auto;
  top: auto;
  bottom: auto;
  width: 122px;
  height: auto;
}

.ambient-menu.expanded {
  bottom: auto;
  height: auto;
  max-height: none;
}

.board-menu.expanded {
  bottom: auto;
  height: auto;
  max-height: none;
}

.equipment-library.expanded {
  top: auto;
}

.left-menu-content {
  width: 100%;
  max-height: 430px;
  overflow: auto;
}

.ambient-menu-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 5px;
}

.terrain-menu.expanded {
  bottom: auto;
  height: auto;
  max-height: none;
}

.terrain-menu-content {
  display: grid;
  gap: 5px;
  padding: 5px;
}

.terrain-menu-content label {
  display: grid;
  gap: 3px;
  color: #d7e8ff;
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.terrain-menu-content input,
.terrain-menu-content select {
  width: 100%;
  height: 26px;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid #9ac5f5;
  border-radius: 7px;
  color: #09214f;
  font-family: var(--font-app);
  font-size: var(--fs-body);
  background: #fff;
}

.terrain-menu.expanded .panel-title {
  min-height: 28px;
  color: #fff;
  font-size: var(--fs-panel-title);
  background: linear-gradient(180deg, #0e79ff, #0a42aa);
}

.ambient-menu-content button {
  min-height: 26px;
  border: 1px solid rgba(166, 214, 255, 0.25);
  border-radius: 8px;
  color: #eaf5ff;
  font-family: var(--font-app);
  font-size: var(--fs-lib-button);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.1);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 5px;
  padding: 5px 6px;
  border-radius: 8px;
  background: #fff;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text-main);
}

.library-list {
  height: auto;
  max-height: 280px;
  padding: 0 7px 7px;
  overflow: auto;
}

.category-title {
  margin: 9px 0 5px;
  color: #fff;
  font-family: var(--font-app);
  font-size: var(--fs-label);
  font-weight: 800;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.equipment-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

.equipment-button {
  min-height: 28px;
  padding: 4px;
  border: 1px solid rgba(166, 214, 255, 0.25);
  border-radius: 7px;
  color: #eaf5ff;
  background: rgba(255, 255, 255, 0.08);
}

.equipment-button:hover {
  color: #fff;
  background: rgba(0, 132, 255, 0.32);
}

.equipment-icon {
  display: inline-block;
  margin-right: 4px;
  font-size: var(--fs-lib-button);
}

.equipment-name {
  display: inline;
  margin-top: 0;
  font-family: var(--font-app);
  font-size: var(--fs-lib-button);
  font-weight: 600;
}

.equipment-button[draggable="true"] {
  cursor: grab;
}

.equipment-button[draggable="true"]:active {
  cursor: grabbing;
}

.secondary-action {
  display: block;
  width: calc(100% - 14px);
  margin: 0 5px 5px;
  padding: 6px 4px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(180deg, #18a6ff, #0645c0);
}

.design-area {
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  gap: 3px;
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow: hidden;
}

.step-panel {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 8px;
  margin-bottom: 6px;
  background: linear-gradient(180deg, #ffffff, #e9f3ff);
}

.step-panel strong {
  display: block;
  color: #092d76;
  font-family: var(--font-app);
  font-size: var(--fs-action);
  font-weight: 700;
  text-transform: uppercase;
}

.step-panel span {
  display: block;
  margin-top: 3px;
  color: #607398;
  font-size: var(--fs-small);
}

.step-panel button {
  padding: 7px 10px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(180deg, #1da2ff, #0648bd);
}

.view-actions {
  display: flex;
  gap: 7px;
  min-width: 0;
  overflow: hidden;
}

.view-actions button {
  padding: 6px 9px;
  border-radius: 7px;
  color: #0e2f6a;
  font-weight: 800;
  background: #edf6ff;
}

.view-actions button.active {
  color: #fff;
  background: #0b76ff;
}

.room-manager {
  display: block;
  min-height: 42px;
  padding: 6px 8px;
  margin-bottom: 0;
  background: linear-gradient(180deg, #f8fcff, #deecff);
  min-width: 0;
  overflow: visible;
}

.room-manager.is-hidden {
  display: none;
}

.context-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
}

.room-manager strong {
  display: block;
  color: #092d76;
  font-family: var(--font-app);
  font-size: var(--fs-action);
  font-weight: 700;
  text-transform: uppercase;
}

.room-manager span {
  display: block;
  margin-top: 3px;
  color: #607398;
  font-size: var(--fs-small);
}

.room-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  min-width: 0;
  overflow: hidden;
}

.room-actions button {
  padding: 5px 7px;
  border-radius: 7px;
  color: #fff;
  font-family: var(--font-app);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: linear-gradient(180deg, #13a2ff, #0647b9);
}

.module-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 7px;
}

.module-controls label {
  display: grid;
  gap: 2px;
  min-width: 0;
  color: #ffffff;
  font-family: var(--font-app);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  overflow-wrap: break-word;
  word-break: break-word;
  line-height: 1.15;
}

.module-controls input,
.module-controls select {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 25px;
  padding: 3px 6px;
  border: 1px solid #abc8ec;
  border-radius: 7px;
  color: #09214f;
  font-family: var(--font-app);
  font-size: var(--fs-lib-button);
  font-weight: 600;
  background: #fff;
}

.module-controls button,
.control-button {
  height: 25px;
  align-self: end;
  padding: 3px 7px;
  border-radius: 7px;
  color: #fff;
  font-family: var(--font-app);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: linear-gradient(180deg, #1595ff, #0648bd);
}

.module-controls .wide-control {
  grid-column: span 2;
}

.module-status {
  grid-column: span 2;
  padding: 5px 8px;
  border-radius: 8px;
  color: #0c3f91;
  font-family: var(--font-app);
  font-size: var(--fs-lib-button);
  font-weight: 700;
  background: #eef6ff;
}

.floor-plan {
  height: 100%;
  min-height: 0;
  padding: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #f6fbff, #e8f2ff);
}

#floorPlan {
  width: 100%;
  height: 100%;
}

.room {
  filter: url(#roomShadow);
  cursor: pointer;
}

.room rect {
  stroke: #151515;
  stroke-width: 1.5;
}

.terrain-boundary {
  fill: rgba(216, 235, 255, 0.55);
  stroke: #0a4fb3;
  stroke-width: 3;
  stroke-dasharray: 10 7;
}

.terrain-label {
  fill: #0a3f99;
  font-size: 13px;
  font-weight: 900;
  text-anchor: middle;
}

.terrain-label-start {
  text-anchor: start;
}

.terrain-label-vertical {
  dominant-baseline: middle;
  text-anchor: middle;
}

.resize-handle {
  fill: transparent;
  stroke: none;
  pointer-events: all;
}

.resize-handle.resize-se,
.resize-handle.resize-sw,
.resize-handle.resize-ne,
.resize-handle.resize-nw {
  fill: #11a5ff;
  fill-opacity: 0.85;
  rx: 1.5;
}

.room.dragging rect {
  stroke: #43e34a;
}

.room.selected rect {
  stroke: #11a5ff;
  stroke-width: 2.5;
}

.room text {
  pointer-events: none;
  fill: #1b1b1b;
  font-family: var(--font-app);
  font-size: var(--fs-svg-room);
  font-weight: 400;
  text-anchor: middle;
  text-transform: uppercase;
}

.room .room-title-text {
  font-family: var(--font-app);
  font-size: var(--fs-svg-room-title);
  font-weight: 700;
}

.room .room-size {
  fill: #38506f;
  font-family: var(--font-app);
  font-size: var(--fs-svg-room-size);
  font-weight: 400;
  text-transform: none;
}

.equipment-symbol {
  cursor: move;
}

.equipment-symbol text {
  dominant-baseline: middle;
  text-anchor: middle;
  font-size: 11px;
  pointer-events: none;
}

.symbol-badge {
  fill: #fff9d9;
  stroke: #e2af00;
  stroke-width: 1.5;
}

.symbol-badge.selected-equipment {
  fill: #e8f8ff;
  stroke: #0b99ff;
  stroke-width: 2.5;
}

.right-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 120px;
  gap: 6px;
  min-width: 0;
  height: auto;
  bottom: 6px;
  overflow: visible;
  position: fixed;
  right: 6px;
  top: 70px;
  width: 42px;
  z-index: 90;
}

.right-sidebar[hidden] {
  display: none !important;
}

.right-sidebar > .panel,
.side-dashboard > .panel {
  cursor: pointer;
  height: 120px;
  min-height: 0;
  overflow: hidden;
  position: relative;
  transition: box-shadow 160ms ease, transform 160ms ease;
}

.right-sidebar > .panel:hover,
.side-dashboard > .panel:hover {
  transform: translateX(-2px);
  box-shadow: 0 12px 28px rgba(0, 19, 75, 0.35);
}

.right-sidebar > .panel > :not(.panel-title),
.side-dashboard > .panel > :not(.panel-title) {
  display: none;
}

.right-sidebar .panel-title {
  align-items: center;
  display: flex;
  min-height: 120px;
}

.right-sidebar > .panel:not(.expanded) .panel-title,
.side-dashboard > .panel:not(.expanded) .panel-title {
  justify-content: center;
  padding: 8px 2px;
  font-size: 9px;
  letter-spacing: 0.4px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.right-sidebar > .panel.expanded .panel-title,
.side-dashboard > .panel.expanded .panel-title {
  writing-mode: horizontal-tb;
}

.right-sidebar > .panel.expanded,
.side-dashboard > .panel.expanded {
  cursor: default;
  bottom: 6px;
  height: auto;
  min-height: 0;
  position: fixed;
  right: 6px;
  top: 70px;
  width: min(520px, calc(100vw - 235px));
  z-index: 120;
}

.right-sidebar > .panel.expanded:hover,
.side-dashboard > .panel.expanded:hover {
  transform: none;
}

.right-sidebar > .panel.expanded > :not(.panel-title),
.side-dashboard > .panel.expanded > :not(.panel-title) {
  display: block;
}

.right-sidebar > .panel.expanded .metrics-grid,
.side-dashboard > .panel.expanded .metrics-grid,
.right-sidebar > .panel.expanded .breaker-preview,
.side-dashboard > .panel.expanded .breaker-preview,
.right-sidebar > .panel.expanded .phase-grid,
.side-dashboard > .panel.expanded .phase-grid {
  display: grid;
}

.side-dashboard {
  display: contents;
}

.selected-room {
  height: 100%;
  min-height: 0;
}

.room-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-title button {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.2);
}

.room-equipment,
.room-data {
  padding: 7px;
}

.environment-module {
  display: none;
  height: calc(100% - 56px);
  overflow: auto;
  padding: 8px;
  background: linear-gradient(180deg, #f8fbff, #eef5ff);
}

.selected-room.expanded .environment-module {
  display: block;
}

.env-stage {
  padding: 10px;
  border-radius: 10px;
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(86, 217, 255, 0.32), transparent 45%),
    linear-gradient(135deg, #09235a, #0b6ee8);
}

.env-stage span {
  display: block;
  font-family: var(--font-app);
  font-size: var(--fs-small);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.env-stage strong {
  display: block;
  margin-top: 3px;
  font-family: var(--font-app);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
}

.env-section {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #d2e3f8;
  border-radius: 10px;
  background: #fff;
}

.env-section h3 {
  margin: 0 0 7px;
  color: #0a3f99;
  font-family: var(--font-app);
  font-size: var(--fs-section-title);
  font-weight: 800;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.env-mini-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.env-mini-grid label {
  padding: 6px;
  border-radius: 7px;
  color: #61769a;
  font-family: var(--font-app);
  font-size: var(--fs-label);
  font-weight: 600;
  background: #eef6ff;
}

.env-mini-grid strong {
  display: block;
  margin-top: 2px;
  color: #09214f;
  font-size: var(--fs-value);
  font-weight: 700;
}

.orientation-tabs,
.floor-tabs,
.ambient-library,
.env-tools {
  display: grid;
  gap: 6px;
}

.orientation-tabs {
  grid-template-columns: repeat(4, 1fr);
  margin-top: 7px;
}

.floor-tabs {
  grid-template-columns: repeat(4, 1fr);
}

.ambient-library {
  grid-template-columns: repeat(2, 1fr);
}

.orientation-tabs button,
.floor-tabs button,
.ambient-library button,
.env-tools button {
  padding: 7px 6px;
  border-radius: 7px;
  color: #0a3f99;
  font-family: var(--font-app);
  font-size: var(--fs-lib-button);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: #eaf4ff;
}

.floor-tabs button.active,
.orientation-tabs button:first-child {
  color: #fff;
  background: linear-gradient(180deg, #1595ff, #0648bd);
}

.env-tools {
  grid-template-columns: repeat(2, 1fr);
}

.env-tools .danger-tool {
  color: #fff;
  background: linear-gradient(180deg, #ff5a5a, #b91515);
}

.room-equipment h3,
.room-data h3 {
  margin: 0 0 6px;
  color: #174287;
  font-family: var(--font-app);
  font-size: var(--fs-label);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
}

.room-equipment {
  min-height: 0;
  max-height: 45%;
  overflow: auto;
}

.room-equipment-item {
  display: grid;
  grid-template-columns: 14px 1fr auto 18px;
  gap: 3px;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid #e4eefb;
  font-family: var(--font-app);
  font-size: var(--fs-small);
}

.room-equipment-item b {
  color: #111b31;
}

.room-equipment-item span:last-child {
  color: #111b31;
  font-weight: 700;
}

.room-data p {
  display: flex;
  justify-content: space-between;
  margin: 6px 0;
  font-size: var(--fs-lib-button);
}

.room-data span {
  color: var(--muted);
}

.outline-action {
  width: 100%;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid #9abdea;
  border-radius: 8px;
  color: #0a3f99;
  font-family: var(--font-app);
  font-size: var(--fs-action);
  font-weight: 700;
  text-transform: uppercase;
  background: #f8fbff;
}

.danger-action {
  width: 100%;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid #f3b1b1;
  border-radius: 8px;
  color: #a31414;
  font-family: var(--font-app);
  font-size: var(--fs-action);
  font-weight: 700;
  text-transform: uppercase;
  background: #fff6f6;
}

.danger-action:disabled {
  cursor: not-allowed;
  color: #9aa6ba;
  background: #eef2f7;
  border-color: #d5deea;
}

.single-line {
  height: 100%;
  min-height: 0;
  background: #fff;
}

#singleLineDiagram {
  display: block;
  width: 100%;
  height: calc(100% - 39px);
}

.side-dashboard {
  display: contents;
}

.summary-card,
.panel-board,
.materials-card,
.load-card {
  height: 100%;
  min-height: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  padding: 4px;
}

.metrics-grid div {
  min-height: 28px;
  padding: 3px;
  border-left: 4px solid #0a82ff;
  border-radius: 8px;
  background: #edf6ff;
}

.metrics-grid span {
  display: block;
  color: #52719c;
  font-family: var(--font-app);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.metrics-grid strong {
  display: block;
  margin-top: 3px;
  color: #071f52;
  font-family: var(--font-app);
  font-size: var(--fs-lib-button);
  font-weight: 700;
}

.breaker-preview {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  margin: 5px 8px 3px;
  padding: 4px;
  border-radius: 8px;
  background: linear-gradient(180deg, #a9bac9, #e1e8f0);
}

.breaker-preview span {
  height: 20px;
  border: 2px solid #42536c;
  border-radius: 4px;
  background: linear-gradient(180deg, #f8fbff 0 55%, #ff6a38 55% 68%, #dbe3ee 68%);
}

.panel-board p {
  margin: 1px 8px;
  font-family: var(--font-app);
  font-size: var(--fs-small);
}

.status-ok {
  color: #118437;
  font-weight: 700;
}

.materials-card ul {
  margin: 5px 8px 0;
  padding-left: 14px;
  font-family: var(--font-app);
  font-size: var(--fs-small);
}

.materials-card li {
  margin: 3px 0;
}

.materials-card button {
  width: calc(100% - 16px);
  margin: 5px 8px 0;
  padding: 4px;
  font-family: var(--font-app);
  font-size: var(--fs-small);
}

.donut {
  position: relative;
  display: grid;
  width: 64px;
  height: 64px;
  margin: 9px auto 4px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#f03737 0 34%, #ffd839 34% 67%, #0a82ff 67% 100%);
}

.donut::after {
  position: absolute;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #fff;
  content: "";
}

.donut span {
  position: relative;
  z-index: 1;
  color: #118437;
  font-family: var(--font-app);
  font-size: var(--fs-small);
  font-weight: 700;
  text-transform: uppercase;
}

.phase-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 0 12px;
  color: #42536c;
  font-family: var(--font-app);
  font-size: var(--fs-label);
  text-align: center;
}

.action-bar {
  display: none;
  grid-template-columns: 120px repeat(5, minmax(0, 1fr)) 110px;
  gap: 5px;
  min-height: 0;
  margin-top: 0;
  padding: 4px;
  border: 1px solid rgba(91, 180, 255, 0.44);
  border-radius: 10px;
  background: linear-gradient(180deg, #071f58, #041232);
}

.action-bar button {
  min-height: 0;
  height: 38px;
  border: 1px solid rgba(121, 194, 255, 0.28);
  border-radius: 9px;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
  background: linear-gradient(180deg, #0a347e, #061a4c);
}

.empty-state {
  fill: #28527d;
  font-size: 18px;
  font-weight: 800;
  text-anchor: middle;
}

.drop-target rect {
  stroke: #43e34a;
  stroke-width: 9;
}

.room-equipment-item button {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  background: #d72828;
}

@media (max-width: 1150px) {
  .app-shell {
    grid-template-rows: 66px minmax(0, 1fr);
    gap: 3px;
    padding: 3px;
  }

  .topbar {
    grid-template-columns: 220px minmax(0, 1fr);
    padding: 4px 6px;
  }

  .brand h1,
  .brand h2 {
    font-size: 18px;
  }

  .brand p {
    font-size: 9px;
  }

  .workflow {
    gap: 5px;
    width: 720px;
    max-width: 100%;
  }

  .step {
    font-size: 8px;
    width: auto;
    max-width: none;
    flex-basis: auto;
  }

  .workspace {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 3px;
    padding-right: 3px;
  }

  .panel-title {
    padding: 7px 9px;
  }

  .search-box {
    margin: 7px;
    padding: 6px 7px;
  }

  .equipment-grid {
    gap: 5px;
  }

  .equipment-button {
    min-height: 44px;
  }

  .equipment-icon {
    font-size: 18px;
  }

  .view-actions button {
    padding: 7px 10px;
    font-size: var(--fs-action);
  }

  .step-panel {
    min-height: 40px;
    padding: 5px 8px;
    margin-bottom: 6px;
  }

  .room-manager {
    min-height: 40px;
    padding: 5px 8px;
    margin-bottom: 6px;
  }

  .floor-plan {
    height: 100%;
  }

  .right-sidebar {
    grid-template-columns: 1fr;
    gap: 4px;
    width: 42px;
    top: 66px;
    bottom: 3px;
  }

  .room-equipment,
  .room-data {
    padding: 7px;
  }

  .room-data p {
    margin: 7px 0;
  }

  .outline-action,
  .danger-action {
    padding: 7px;
  }

  .breaker-preview {
    margin: 6px 9px 4px;
    padding: 6px;
  }

  .breaker-preview span {
    height: 22px;
  }

  .panel-board p {
    margin: 1px 10px;
  }

  .materials-card li {
    margin: 3px 0;
  }

  .action-bar {
    grid-template-columns: 100px repeat(5, minmax(0, 1fr)) 95px;
  }

  .action-bar button {
    height: 34px;
    min-height: 0;
    font-size: var(--fs-small);
  }
}

.action-bar small {
  display: block;
  margin-top: 2px;
  font-size: var(--fs-label);
  font-weight: 600;
}

.run-button {
  background: linear-gradient(180deg, #22c849, #08731f);
  font-size: 13px;
}

.export-button {
  background: linear-gradient(180deg, #8848ff, #4c1ab9);
}

dialog {
  width: min(780px, 90vw);
  border: 0;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.45);
}

dialog::backdrop {
  background: rgba(1, 11, 35, 0.7);
}

dialog form {
  margin: 0;
}

dialog h2 {
  margin: 0;
  padding: 16px 20px;
  color: #fff;
  background: linear-gradient(180deg, #0d7cff, #063692);
}

#dialogContent {
  max-height: 62vh;
  overflow: auto;
  padding: 18px 20px;
}

#dialogContent table {
  width: 100%;
  border-collapse: collapse;
}

#dialogContent th,
#dialogContent td {
  padding: 9px;
  border-bottom: 1px solid #dbe8fb;
  text-align: left;
}

dialog menu {
  margin: 0;
  padding: 14px 20px 18px;
  text-align: right;
}

dialog menu button {
  padding: 10px 18px;
  border-radius: 8px;
  color: #fff;
  font-weight: 800;
  background: #0b65df;
}

/* --- Botones laterales colapsados (icono + texto del paso) --- */
.left-dock-panel.collapsed .panel-title {
  font-size: var(--fs-panel-title);
  font-weight: 800;
}

/* --- Columnas laterales: ancho uniforme fijo --- */
.project-menu,
.terrain-menu,
.ambient-menu,
.board-menu,
.equipment-library,
.action-rail .step {
  width: 122px;
}

/* --- Panel Tableros --- */
.board-menu-content {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  padding: 5px;
}

.board-group-title {
  display: block;
  padding: 4px 2px 2px;
  font-size: 9px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #7fb8ff;
}

.board-menu-content button {
  min-height: 26px;
  border: 1px solid rgba(255, 198, 130, 0.35);
  border-radius: 8px;
  color: #ffe4b0;
  font-family: var(--font-app);
  font-size: var(--fs-lib-button);
  font-weight: 700;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: rgba(255, 160, 50, 0.15);
  cursor: pointer;
}

.board-menu-content button:hover {
  background: rgba(255, 160, 50, 0.3);
}

/* --- Lista de tableros en el panel --- */
.board-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
}

.board-list-empty {
  font-size: 10px;
  color: #7fb8ff;
  padding: 4px 2px;
}

.board-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  padding: 4px 5px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.board-list-item.selected {
  border-color: #ffb347;
  background: rgba(255, 180, 60, 0.18);
}

.board-list-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.board-list-item-info strong {
  font-size: 9px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.board-list-item-info span {
  font-size: 8px;
  color: #aac7f8;
}

.board-list-item-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.board-list-item-actions button {
  width: 18px;
  height: 18px;
  min-height: unset;
  padding: 0;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
}

.board-list-item-actions .danger-tool {
  color: #ff8080;
  border-color: rgba(255, 128, 128, 0.4);
}

/* --- Dialogo de asignacion de equipos al tablero auxiliar --- */
#boardEquipmentDialog {
  width: min(520px, 92vw);
}

#boardEquipmentDialog h2 {
  background: linear-gradient(180deg, #c2790a, #7a4200);
}

.board-dialog-hint {
  margin: 0;
  padding: 10px 20px 0;
  font-size: 12px;
  color: #666;
}

.board-equipment-list {
  max-height: 55vh;
  overflow-y: auto;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.board-equipment-row {
  display: grid;
  grid-template-columns: 22px 26px 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: #f5f9ff;
  border: 1px solid #dce8fb;
  cursor: pointer;
  font-size: 12px;
}

.board-equipment-row:hover {
  background: #e8f2ff;
}

.board-equipment-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #c2790a;
}

.board-equipment-icon {
  font-size: 16px;
  text-align: center;
}

.board-equipment-name {
  font-weight: 700;
  color: #1a2744;
}

.board-equipment-room {
  font-size: 11px;
  color: #666;
  text-align: right;
}

.board-equipment-power {
  font-size: 11px;
  font-weight: 700;
  color: #c2790a;
  white-space: nowrap;
}

#saveBoardEquipment {
  background: linear-gradient(180deg, #c2790a, #7a4200) !important;
}

.project-menu .panel-title,
.terrain-menu .panel-title,
.terrain-menu.expanded .panel-title,
.ambient-menu .panel-title,
.ambient-menu.expanded .panel-title,
.board-menu .panel-title,
.board-menu.expanded .panel-title,
.equipment-library .panel-title,
.equipment-library.expanded .panel-title {
  min-height: 28px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: var(--fs-panel-title);
  font-weight: 800;
  line-height: 1.1;
  writing-mode: horizontal-tb;
  text-orientation: mixed;
}

.project-menu .panel-title b {
  width: 14px;
  height: 14px;
  margin-right: 3px;
  font-size: var(--fs-small);
}

.project-menu-content,
.terrain-menu-content,
.ambient-menu-content,
.board-menu-content,
.equipment-library .left-menu-content {
  width: 122px;
  padding: 5px;
  background: linear-gradient(180deg, #073481, #061b4b);
}

.project-menu-content .room-manager {
  display: block;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.project-menu-content .context-header {
  display: grid;
  gap: 5px;
}

.project-menu-content #contextPanelTitle {
  color: #fff;
  font-size: var(--fs-lib-button);
}

.project-menu-content #roomRuleText {
  color: #d7e8ff;
  font-size: var(--fs-small);
  line-height: 1.2;
}

.project-menu-content #roomRuleText:empty {
  display: none;
}

.project-menu-content .room-actions,
.project-menu-content .module-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
}

.project-menu-content .module-controls label,
.project-menu-content .module-controls input,
.project-menu-content .module-controls select,
.project-menu-content .module-controls button {
  width: 100%;
  min-width: 0;
  font-size: var(--fs-lib-button);
}

.action-rail {
  display: grid;
  align-content: start;
  gap: 9px;
  width: 122px;
  min-height: 0;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(91, 180, 255, 0.35);
}

.action-rail .step {
  width: 122px;
  height: 36px;
  padding: 4px 8px;
  color: #fff;
  background: linear-gradient(180deg, #0a6fb0, #053f63);
  border: 1px solid #0c84cf;
}

.action-rail .step.active,
.left-dock-panel .panel-title.active,
.left-dock-panel.expanded > .panel-title {
  outline: 2px solid var(--cyan-300);
}

.workspace {
  grid-template-columns: 122px minmax(0, 1fr) 360px;
  gap: 5px;
}

.design-area {
  width: 100%;
  max-width: 100%;
}

.floor-plan {
  min-width: 0;
}

.report-viewer {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.viewer-title {
  padding: 8px 10px;
  color: #fff;
  font-family: var(--font-app);
  font-size: var(--fs-panel-title);
  font-weight: 800;
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  background: linear-gradient(180deg, #0d7cff 0%, #063692 100%);
  flex: none;
}

.viewer-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  cursor: grab;
  background: #fff;
  user-select: none;
}

.viewer-body.dragging {
  cursor: grabbing;
}

.viewer-body.highlight-pulse {
  animation: viewerPulse 0.9s ease;
}

@keyframes viewerPulse {
  0% { box-shadow: inset 0 0 0 3px rgba(13, 124, 255, 0.65); }
  100% { box-shadow: inset 0 0 0 0 rgba(13, 124, 255, 0); }
}

.viewer-canvas {
  width: max-content;
  min-width: 100%;
  padding: 12px;
}

.viewer-canvas,
.viewer-canvas * {
  font-family: var(--font-app) !important;
  font-size: 10px !important;
  line-height: 1.45;
}

.viewer-canvas h3 {
  margin: 12px 0 6px;
  color: #0a3f99;
  font-weight: 800;
  text-transform: uppercase;
}

.viewer-canvas h3:first-child {
  margin-top: 0;
}

.viewer-canvas p {
  margin: 4px 0;
  color: #1b2942;
}

.viewer-canvas table {
  border-collapse: collapse;
  margin: 6px 0;
  white-space: nowrap;
}

.viewer-canvas th,
.viewer-canvas td {
  padding: 4px 8px;
  border: 1px solid #d6e3f5;
  text-align: left;
}

.viewer-canvas th {
  color: #fff;
  background: #0a3f99;
}

.viewer-canvas ul {
  margin: 4px 0;
  padding-left: 16px;
}

.viewer-canvas svg {
  display: block;
  margin: 8px auto;
}

.viewer-empty {
  color: #7a8cab;
  text-align: center;
  padding: 30px 10px;
}
