:root {
      --bg: #07101f;
      --panel: rgba(12, 24, 43, 0.94);
      --panel-soft: rgba(19, 35, 58, 0.82);
      --canvas: #f4f7fb;
      --canvas-grid: rgba(57, 76, 104, 0.09);
      --text: #e9f0f8;
      --muted: #9aabc0;
      --dark-text: #182338;
      --dark-muted: #617089;
      --line: rgba(255, 255, 255, 0.10);
      --line-dark: rgba(21, 37, 60, 0.14);
      --primary: #3a8bfd;
      --primary-strong: #176fe5;
      --success: #20b486;
      --warning: #f2a93b;
      --danger: #ef5b67;
      --purple: #8b6df6;
      --cyan: #19a7bd;
      --shadow: 0 18px 44px rgba(0, 0, 0, 0.26);
      --radius: 16px;
      --radius-sm: 10px;
      --sidebar-width: 250px;
      --properties-width: 316px;
      --topbar-height: 68px;
      --statusbar-height: 38px;
    }

    * { box-sizing: border-box; }

    html, body {
      width: 100%;
      height: 100%;
      margin: 0;
      overflow: hidden;
      font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      background: var(--bg);
      color: var(--text);
    }

    button, input, select, textarea { font: inherit; }
    button { border: 0; }

    button:focus-visible,
    input:focus-visible,
    select:focus-visible,
    textarea:focus-visible {
      outline: 3px solid rgba(58, 139, 253, 0.32);
      outline-offset: 2px;
    }

    .app {
      display: grid;
      grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--properties-width);
      grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--statusbar-height);
      width: 100%;
      height: 100%;
    }

    .topbar {
      grid-column: 1 / -1;
      display: grid;
      grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--properties-width);
      align-items: center;
      border-bottom: 1px solid var(--line);
      background:
        radial-gradient(circle at 15% 10%, rgba(58, 139, 253, 0.18), transparent 26%),
        linear-gradient(90deg, #0a1527, #0b1422);
      z-index: 30;
    }

    .brand {
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
      padding: 6px 14px;
      border-right: 1px solid var(--line);
      overflow: hidden;
    }

    .brand-logo-link {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      padding: 3px 8px;
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.98);
      box-shadow: 0 7px 18px rgba(0, 0, 0, 0.18);
      transition: transform 160ms ease, box-shadow 160ms ease;
    }

    .brand-logo-link:hover {
      transform: translateY(-1px);
      box-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
    }

    .brand-logo {
      display: block;
      width: min(190px, 100%);
      max-height: 50px;
      object-fit: contain;
      filter: drop-shadow(0 7px 16px rgba(0, 0, 0, 0.18));
      pointer-events: none;
    }

    .toolbar {
      display: flex;
      align-items: center;
      gap: 8px;
      min-width: 0;
      padding: 0 14px;
      overflow-x: auto;
      scrollbar-width: none;
    }
    .toolbar::-webkit-scrollbar { display: none; }

    .toolbar-group {
      display: flex;
      align-items: center;
      gap: 7px;
      flex: 0 0 auto;
    }

    .toolbar-divider {
      width: 1px;
      height: 28px;
      flex: 0 0 auto;
      margin: 0 3px;
      background: var(--line);
    }

    .tool-button {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 7px;
      min-height: 36px;
      padding: 0 11px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.045);
      color: var(--text);
      cursor: pointer;
      transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
      white-space: nowrap;
      font-size: 12px;
      font-weight: 700;
    }

    .tool-button:hover {
      transform: translateY(-1px);
      border-color: rgba(58, 139, 253, 0.52);
      background: rgba(58, 139, 253, 0.12);
    }

    .tool-button.primary {
      border-color: transparent;
      background: linear-gradient(145deg, var(--primary), var(--primary-strong));
      box-shadow: 0 9px 20px rgba(23, 111, 229, 0.24);
    }

    .tool-button.danger:hover {
      border-color: rgba(239, 91, 103, 0.55);
      background: rgba(239, 91, 103, 0.12);
    }

    .tool-button.active {
      border-color: rgba(58, 139, 253, 0.65);
      background: rgba(58, 139, 253, 0.20);
      color: #ffffff;
    }

    .tool-button.icon-only {
      width: 36px;
      padding: 0;
    }

    .speed-control {
      display: flex;
      align-items: center;
      gap: 8px;
      height: 36px;
      padding: 0 10px;
      border: 1px solid var(--line);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.045);
    }

    .speed-control span {
      color: var(--muted);
      font-size: 11px;
      font-weight: 700;
    }

    .speed-control select {
      border: 0;
      background: transparent;
      color: var(--text);
      font-size: 12px;
      font-weight: 800;
      cursor: pointer;
    }

    .speed-control option { background: #0d1a2c; }

    .top-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      gap: 8px;
      height: 100%;
      padding: 0 16px;
      border-left: 1px solid var(--line);
    }

    .top-actions .tool-button {
      width: auto;
    }

    .action-icon {
      display: none;
      font-size: 13px;
      line-height: 1;
    }

    .sidebar, .properties {
      min-height: 0;
      background: var(--panel);
      overflow-y: auto;
      scrollbar-width: thin;
      scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
    }

    .sidebar {
      grid-column: 1;
      grid-row: 2;
      border-right: 1px solid var(--line);
    }

    .properties {
      --text: #172237;
      --muted: #66758a;
      --line: rgba(21, 37, 60, 0.13);
      grid-column: 3;
      grid-row: 2;
      border-left: 1px solid #d7e0eb;
      background: linear-gradient(180deg, #ffffff 0%, #f6f8fc 100%);
      color: var(--text);
      box-shadow: -10px 0 30px rgba(23, 40, 67, 0.08);
      scrollbar-color: rgba(70, 91, 120, 0.28) transparent;
    }

    .properties .panel-section {
      padding: 16px;
      border-bottom-color: #e4e9f1;
    }

    .properties .panel-title h2 {
      color: #172237;
      letter-spacing: 0.10em;
    }

    .properties .panel-title span {
      color: #748198;
    }

    .properties .field label {
      color: #66758a;
    }

    .properties .field input,
    .properties .field select,
    .properties .field textarea {
      border-color: #d8e0eb;
      background: #ffffff;
      color: #172237;
      box-shadow: 0 1px 2px rgba(19, 33, 54, 0.03);
    }

    .properties .field input:hover,
    .properties .field select:hover,
    .properties .field textarea:hover {
      border-color: rgba(58, 139, 253, 0.58);
      background: #ffffff;
    }

    .properties .field select option {
      background: #ffffff;
      color: #172237;
    }

    .properties .properties-empty {
      color: #748198;
      background: #ffffff;
      border: 1px dashed #d9e1eb;
      border-radius: 12px;
      padding: 18px;
    }

    .properties .properties-empty strong {
      color: #172237;
    }

    .properties .property-button {
      border-color: #d8e0eb;
      background: #ffffff;
      color: #172237;
      box-shadow: 0 2px 7px rgba(23, 40, 67, 0.05);
    }

    .properties .property-button:hover {
      border-color: rgba(58, 139, 253, 0.52);
      background: #eef5ff;
    }

    .properties .metric-card {
      border-color: #dfe6ef;
      background: #ffffff;
      box-shadow: 0 5px 14px rgba(25, 43, 70, 0.06);
    }

    .properties .metric-card span {
      color: #718096;
    }

    .properties .metric-card strong {
      color: #16233a;
    }

    .properties .metric-card.balance-card {
      grid-column: 1 / -1;
      padding: 14px 15px;
      border-color: rgba(58, 139, 253, 0.24);
      background: linear-gradient(135deg, #eef6ff 0%, #ffffff 58%, #edfdf7 100%);
      box-shadow: 0 8px 22px rgba(41, 103, 184, 0.10);
    }

    .properties .metric-card.balance-card span {
      color: #42658f;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .properties .metric-card.balance-card strong {
      margin-top: 7px;
      font-size: 24px;
      color: #0f4fa8;
    }

    .metric-positive { color: #11835f !important; }
    .metric-negative { color: #c54250 !important; }

    .properties .chart {
      border-color: #dfe6ef;
      background-color: #ffffff;
      background-image: linear-gradient(rgba(37, 59, 91, 0.06) 1px, transparent 1px);
      box-shadow: 0 5px 14px rgba(25, 43, 70, 0.05);
    }

    .properties .record-item {
      border-color: #dfe6ef;
      background: #ffffff;
      box-shadow: 0 4px 12px rgba(25, 43, 70, 0.05);
    }

    .properties .record-item strong { color: #172237; }
    .properties .record-item span { color: #67758b; }

    .panel-section {
      padding: 18px;
      border-bottom: 1px solid var(--line);
    }

    .panel-title {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 13px;
    }

    .panel-title h2 {
      margin: 0;
      font-size: 12px;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }

    .panel-title span {
      color: var(--muted);
      font-size: 11px;
    }

    .palette { display: grid; gap: 9px; }

    .palette-item {
      display: grid;
      grid-template-columns: 42px minmax(0, 1fr);
      align-items: center;
      gap: 10px;
      min-height: 62px;
      padding: 9px;
      border: 1px solid var(--line);
      border-radius: 13px;
      background: rgba(255, 255, 255, 0.035);
      cursor: grab;
      user-select: none;
      transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
    }

    .palette-item:hover {
      transform: translateX(3px);
      border-color: rgba(58, 139, 253, 0.46);
      background: rgba(58, 139, 253, 0.09);
    }

    .palette-item:active { cursor: grabbing; }

    .palette-icon {
      display: grid;
      place-items: center;
      width: 42px;
      height: 42px;
      border-radius: 12px;
      color: #ffffff;
      font-size: 17px;
      font-weight: 900;
    }

    .palette-copy strong { display: block; font-size: 12px; }
    .palette-copy span {
      display: block;
      margin-top: 4px;
      color: var(--muted);
      font-size: 10px;
      line-height: 1.35;
    }

    .source-color { background: linear-gradient(145deg, #22b487, #148863); }
    .queue-color { background: linear-gradient(145deg, #f0ab3d, #d47b22); }
    .process-color { background: linear-gradient(145deg, #3a8bfd, #2365d1); }
    .decision-color { background: linear-gradient(145deg, #8b6df6, #674bd8); }
    .sink-color { background: linear-gradient(145deg, #ef5b67, #cf3948); }

    .tip-card {
      padding: 13px;
      border: 1px solid rgba(58, 139, 253, 0.23);
      border-radius: 13px;
      background: rgba(58, 139, 253, 0.08);
    }

    .tip-card strong { display: block; margin-bottom: 6px; font-size: 11px; }
    .tip-card p {
      margin: 0;
      color: var(--muted);
      font-size: 10px;
      line-height: 1.55;
    }

    .workspace {
      position: relative;
      grid-column: 2;
      grid-row: 2;
      min-width: 0;
      min-height: 0;
      overflow: hidden;
      background: #dce4ef;
    }

    .workspace-summary {
      position: absolute;
      top: 8px;
      left: 198px;
      right: 8px;
      z-index: 18;
      min-height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      padding: 5px 7px 5px 11px;
      border: 1px solid rgba(16, 35, 59, 0.10);
      border-left: 3px solid var(--primary);
      border-radius: 10px;
      background: rgba(255, 255, 255, 0.91);
      box-shadow: 0 6px 16px rgba(27, 42, 62, 0.10);
      backdrop-filter: blur(12px);
      color: var(--dark-text);
    }

    .workspace-summary > div:first-child { min-width: 0; }
    .workspace-summary strong {
      display: block;
      margin-top: 1px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 11px;
      line-height: 1.18;
    }

    .workspace-kicker {
      color: var(--dark-muted);
      font-size: 6.5px;
      font-weight: 900;
      letter-spacing: 0.13em;
    }

    .workspace-summary-actions {
      display: flex;
      align-items: center;
      gap: 6px;
      flex: 0 0 auto;
    }

    .ready-badge {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      min-height: 32px;
      padding: 0 10px;
      border: 1px solid rgba(32, 180, 134, 0.20);
      border-radius: 999px;
      background: rgba(32, 180, 134, 0.08);
      color: #137356;
      font-size: 10px;
      font-weight: 900;
    }

    .ready-badge i {
      width: 7px;
      height: 7px;
      border-radius: 999px;
      background: var(--success);
      box-shadow: 0 0 0 4px rgba(32, 180, 134, 0.13);
    }


    .capital-badge {
      display: inline-flex;
      align-items: center;
      min-height: 28px;
      padding: 0 10px;
      border: 1px solid rgba(58, 139, 253, 0.18);
      border-radius: 999px;
      background: rgba(58, 139, 253, 0.08);
      color: #1f5da8;
      font-size: 9px;
      font-weight: 900;
      white-space: nowrap;
    }

    .scenario-fields {
      display: grid;
      gap: 9px;
    }

    .scenario-fields label {
      display: block;
      margin-bottom: 5px;
      color: var(--muted);
      font-size: 9px;
      font-weight: 800;
      letter-spacing: .04em;
      text-transform: uppercase;
    }

    .scenario-fields input {
      width: 100%;
      min-height: 38px;
      padding: 0 10px;
      border: 1px solid var(--line);
      border-radius: 9px;
      background: rgba(255,255,255,.055);
      color: var(--text);
    }

    .quick-run-button {
      min-height: 28px;
      padding: 0 10px;
      border-radius: 8px;
      background: linear-gradient(145deg, var(--primary), var(--primary-strong));
      box-shadow: 0 6px 14px rgba(23, 111, 229, 0.20);
      color: #ffffff;
      cursor: pointer;
      font-size: 9px;
      font-weight: 900;
      transition: transform 160ms ease, box-shadow 160ms ease;
    }

    .quick-run-button:hover {
      transform: translateY(-1px);
      box-shadow: 0 11px 23px rgba(23, 111, 229, 0.28);
    }

    .canvas-toolbar {
      position: absolute;
      top: 8px;
      left: 8px;
      z-index: 18;
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 4px;
      border: 1px solid rgba(16, 35, 59, 0.10);
      border-radius: 13px;
      background: rgba(255, 255, 255, 0.90);
      box-shadow: 0 12px 30px rgba(27, 42, 62, 0.13);
      backdrop-filter: blur(10px);
    }

    .canvas-tool {
      display: grid;
      place-items: center;
      width: 30px;
      height: 30px;
      border-radius: 9px;
      background: transparent;
      color: var(--dark-text);
      cursor: pointer;
      font-size: 14px;
      font-weight: 900;
    }

    .canvas-tool:hover, .canvas-tool.active {
      background: rgba(58, 139, 253, 0.12);
      color: var(--primary-strong);
    }

    .zoom-label {
      min-width: 42px;
      color: var(--dark-muted);
      text-align: center;
      font-size: 11px;
      font-weight: 800;
    }

    .canvas-wrap {
      position: absolute;
      top: 56px;
      right: 0;
      bottom: 0;
      left: 0;
      overflow: auto;
      scrollbar-width: thin;
      scrollbar-color: rgba(42, 60, 85, 0.25) transparent;
    }

    .canvas {
      position: relative;
      width: 2400px;
      height: 1400px;
      transform-origin: top left;
      background-color: var(--canvas);
      background-image:
        linear-gradient(var(--canvas-grid) 1px, transparent 1px),
        linear-gradient(90deg, var(--canvas-grid) 1px, transparent 1px),
        linear-gradient(rgba(57, 76, 104, 0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(57, 76, 104, 0.045) 1px, transparent 1px);
      background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
      overflow: hidden;
    }

    .canvas.drag-over { box-shadow: inset 0 0 0 4px rgba(58, 139, 253, 0.25); }

    .connections {
      position: absolute;
      inset: 0;
      width: 100%;
      height: 100%;
      overflow: visible;
      pointer-events: none;
      z-index: 2;
    }

    .edge-group { pointer-events: auto; cursor: pointer; }

    .edge-visible {
      fill: none;
      stroke: #6c7c90;
      stroke-width: 3;
      marker-end: url(#arrow);
      transition: stroke 140ms ease, stroke-width 140ms ease;
    }

    .edge-hit { fill: none; stroke: transparent; stroke-width: 18; }

    .edge-group:hover .edge-visible,
    .edge-group.selected .edge-visible {
      stroke: var(--primary);
      stroke-width: 4;
    }

    .edge-label-bg {
      fill: rgba(255, 255, 255, 0.94);
      stroke: rgba(24, 35, 56, 0.12);
      stroke-width: 1;
    }

    .edge-label {
      fill: #34445c;
      font-size: 11px;
      font-weight: 800;
      text-anchor: middle;
      dominant-baseline: middle;
      pointer-events: none;
    }

    .nodes-layer { position: absolute; inset: 0; z-index: 5; }

    .node {
      position: absolute;
      width: 188px;
      min-height: 108px;
      border: 2px solid transparent;
      border-radius: 15px;
      background: rgba(255, 255, 255, 0.97);
      box-shadow: 0 12px 28px rgba(30, 45, 68, 0.14);
      color: var(--dark-text);
      cursor: pointer;
      user-select: none;
      touch-action: none;
      isolation: isolate;
      transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
    }

    .node::before {
      content: "";
      position: absolute;
      inset: -8px;
      z-index: -1;
      border-radius: 21px;
    }

    .node:hover {
      transform: translateY(-2px);
      box-shadow: 0 16px 35px rgba(30, 45, 68, 0.18);
    }

    .node.selected {
      border-color: var(--primary);
      box-shadow:
        0 0 0 5px rgba(58, 139, 253, 0.24),
        0 18px 38px rgba(30, 45, 68, 0.22);
    }

    .node.selected .node-header {
      background: linear-gradient(90deg, rgba(58, 139, 253, 0.12), transparent);
      border-radius: 12px 12px 0 0;
    }

    .node.connection-origin {
      border-color: var(--purple);
      box-shadow: 0 0 0 5px rgba(139, 109, 246, 0.18), 0 18px 36px rgba(30, 45, 68, 0.18);
    }

    .node-header {
      display: grid;
      grid-template-columns: 37px minmax(0, 1fr) auto;
      align-items: center;
      gap: 9px;
      padding: 10px 10px 7px;
    }

    .node-icon {
      display: grid;
      place-items: center;
      width: 37px;
      height: 37px;
      border-radius: 11px;
      color: #ffffff;
      font-size: 15px;
      font-weight: 900;
    }

    .node-title { min-width: 0; }
    .node-title strong {
      display: block;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      font-size: 12px;
    }

    .node-title span {
      display: block;
      margin-top: 3px;
      color: var(--dark-muted);
      font-size: 9px;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.06em;
    }

    .node-status {
      min-width: 27px;
      min-height: 23px;
      padding: 0 7px;
      border-radius: 999px;
      background: #eef2f7;
      color: var(--dark-muted);
      font-size: 10px;
      font-weight: 900;
      display: grid;
      place-items: center;
      text-align: center;
    }

    .node-details {
      padding: 0 11px 7px;
      color: var(--dark-muted);
      font-size: 9px;
      line-height: 1.45;
    }

    .node-details b { color: var(--dark-text); }

    .node-body {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      padding: 8px 11px 10px;
      border-top: 1px solid #edf1f5;
    }

    .node-metric { min-width: 0; }
    .node-metric span { display: block; color: var(--dark-muted); font-size: 9px; }
    .node-metric strong { display: block; margin-top: 2px; font-size: 11px; }

    .node-controls {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      flex: 0 0 auto;
    }

    .mini-step {
      width: 22px;
      height: 22px;
      display: grid;
      place-items: center;
      border-radius: 7px;
      background: #eff3f8;
      color: var(--dark-text);
      font-size: 13px;
      font-weight: 900;
      cursor: pointer;
      border: 1px solid rgba(23,35,56,.08);
    }

    .mini-step:hover {
      background: rgba(58, 139, 253, 0.14);
      border-color: rgba(58, 139, 253, 0.35);
      color: var(--primary-strong);
    }

    .mini-value {
      min-width: 24px;
      text-align: center;
      font-size: 11px;
      font-weight: 900;
      color: var(--dark-text);
    }

    .node-indicator {
      width: 9px;
      height: 9px;
      flex: 0 0 auto;
      border-radius: 999px;
      background: #b9c4d1;
      box-shadow: 0 0 0 4px rgba(185, 196, 209, 0.20);
    }

    .node-indicator.active {
      background: var(--success);
      box-shadow: 0 0 0 4px rgba(32, 180, 134, 0.18);
    }

    .node-port {
      position: absolute;
      top: 50%;
      width: 12px;
      height: 12px;
      margin-top: -6px;
      border: 2px solid #ffffff;
      border-radius: 999px;
      background: #91a0b4;
      box-shadow: 0 0 0 2px rgba(33, 48, 70, 0.10);
    }
    .node-port.in { left: -7px; }
    .node-port.out { right: -7px; background: var(--primary); }

    .entity-layer {
      position: absolute;
      inset: 0;
      z-index: 8;
      pointer-events: none;
    }

    .entity {
      position: absolute;
      display: grid;
      place-items: center;
      width: 20px;
      height: 20px;
      margin-left: -10px;
      margin-top: -10px;
      border: 2px solid #ffffff;
      border-radius: 999px;
      background: linear-gradient(145deg, #1f4a8f, #173563);
      box-shadow: 0 4px 11px rgba(20, 34, 55, 0.32);
      color: #ffffff;
      font-size: 10px;
      line-height: 1;
    }

    .entity::after {
      content: attr(data-code);
      position: absolute;
      left: 13px;
      top: -9px;
      min-width: 38px;
      height: 16px;
      display: grid;
      place-items: center;
      padding: 0 5px;
      border: 1.5px solid #ffffff;
      border-radius: 999px;
      background: var(--transaction-color, #3a8bfd);
      box-shadow: 0 3px 8px rgba(20, 34, 55, 0.24);
      color: #ffffff;
      font-size: 6.5px;
      font-weight: 900;
      letter-spacing: .01em;
      white-space: nowrap;
    }

    .empty-state {
      position: absolute;
      left: 50%;
      top: 50%;
      z-index: 1;
      width: min(460px, calc(100% - 48px));
      padding: 26px;
      border: 1px dashed rgba(41, 65, 96, 0.22);
      border-radius: 18px;
      transform: translate(-50%, -50%);
      text-align: center;
      color: var(--dark-muted);
      background: rgba(255, 255, 255, 0.54);
      backdrop-filter: blur(8px);
    }

    .empty-state strong { display: block; color: var(--dark-text); font-size: 18px; }
    .empty-state p { margin: 9px 0 0; font-size: 12px; line-height: 1.6; }

    .field { margin-bottom: 13px; }
    .field:last-child { margin-bottom: 0; }

    .field label {
      display: block;
      margin-bottom: 6px;
      color: var(--muted);
      font-size: 10px;
      font-weight: 800;
      letter-spacing: 0.035em;
      text-transform: uppercase;
    }

    .field input, .field select, .field textarea {
      width: 100%;
      min-height: 38px;
      border: 1px solid var(--line);
      border-radius: 9px;
      background: rgba(255, 255, 255, 0.055);
      color: var(--text);
      padding: 9px 10px;
      transition: border-color 150ms ease, background 150ms ease;
    }
    .field textarea { resize: vertical; min-height: 72px; }

    .field input:hover, .field select:hover, .field textarea:hover {
      border-color: rgba(58, 139, 253, 0.44);
    }

    .field select option { background: #0f1c2f; }

    .field-row {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 9px;
    }

    .properties-empty {
      padding: 22px 18px;
      color: var(--muted);
      font-size: 11px;
      line-height: 1.6;
    }

    .properties-empty strong {
      display: block;
      margin-bottom: 6px;
      color: var(--text);
      font-size: 13px;
    }

    .property-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-top: 16px;
    }

    .property-button {
      min-height: 38px;
      border: 1px solid var(--line);
      border-radius: 9px;
      background: rgba(255, 255, 255, 0.055);
      color: var(--text);
      cursor: pointer;
      font-size: 11px;
      font-weight: 800;
    }

    .property-button:hover {
      border-color: rgba(58, 139, 253, 0.46);
      background: rgba(58, 139, 253, 0.10);
    }

    .property-button.danger:hover {
      border-color: rgba(239, 91, 103, 0.55);
      background: rgba(239, 91, 103, 0.11);
    }

    .metrics-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 10px;
    }

    .metric-card {
      min-width: 0;
      padding: 11px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: rgba(255, 255, 255, 0.035);
    }

    .metric-card span { display: block; color: var(--muted); font-size: 9px; }
    .metric-card strong {
      display: block;
      margin-top: 5px;
      overflow: hidden;
      text-overflow: ellipsis;
      color: var(--text);
      font-size: 17px;
      white-space: nowrap;
    }

    .chart {
      position: relative;
      height: 120px;
      margin-top: 11px;
      border: 1px solid var(--line);
      border-radius: 12px;
      background: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
      background-size: 100% 30px;
      overflow: hidden;
    }

    .chart svg { width: 100%; height: 100%; }
    .chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; vector-effect: non-scaling-stroke; }
    .chart-area { fill: url(#chartGradient); }

    .records-list {
      display: grid;
      gap: 8px;
      margin-top: 10px;
      max-height: 260px;
      overflow-y: auto;
    }

    .record-item {
      padding: 10px;
      border: 1px solid var(--line);
      border-radius: 11px;
      background: rgba(255,255,255,.035);
      font-size: 10px;
      line-height: 1.45;
    }

    .record-item strong { display:block; font-size:11px; color:var(--text); margin-bottom:4px; }
    .record-item span { display:block; color:var(--muted); }

    .developer-credit {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      margin-left: auto;
      color: #b8c6d8;
      text-decoration: none;
      font-size: 10px;
      font-weight: 700;
      transition: color 150ms ease, transform 150ms ease;
    }

    .developer-credit strong {
      color: #ffffff;
      font-weight: 900;
    }

    .developer-credit:hover {
      color: #ffffff;
      transform: translateY(-1px);
    }

    .statusbar {
      grid-column: 1 / -1;
      grid-row: 3;
      display: grid;
      grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--properties-width);
      align-items: center;
      border-top: 1px solid var(--line);
      background: #081323;
      color: var(--muted);
      font-size: 10px;
      z-index: 40;
    }

    .status-left, .status-center, .status-right {
      display: flex;
      align-items: center;
      gap: 12px;
      height: 100%;
      padding: 0 16px;
      white-space: nowrap;
    }

    .status-left { border-right: 1px solid var(--line); }
    .status-center { min-width: 0; overflow: hidden; }
    .status-right { justify-content: flex-end; border-left: 1px solid var(--line); }

    .status-dot {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      background: #6f8096;
    }

    .status-dot.running {
      background: var(--success);
      box-shadow: 0 0 0 4px rgba(32, 180, 134, 0.15);
    }

    .toast-container {
      position: fixed;
      right: 18px;
      bottom: 55px;
      z-index: 100;
      display: grid;
      gap: 9px;
      width: min(340px, calc(100% - 36px));
      pointer-events: none;
    }

    .toast {
      padding: 13px 14px;
      border: 1px solid rgba(255, 255, 255, 0.10);
      border-radius: 12px;
      background: rgba(9, 21, 37, 0.95);
      box-shadow: var(--shadow);
      color: var(--text);
      font-size: 11px;
      line-height: 1.45;
      animation: toastIn 220ms ease both;
    }

    .toast.success { border-left: 4px solid var(--success); }
    .toast.warning { border-left: 4px solid var(--warning); }
    .toast.error { border-left: 4px solid var(--danger); }

    @keyframes toastIn {
      from { opacity: 0; transform: translateY(9px); }
      to { opacity: 1; transform: translateY(0); }
    }

    .hidden { display: none !important; }
    .mobile-toggle { display: none; }

    @media (max-width: 1180px) {
      :root { --sidebar-width: 220px; --properties-width: 268px; }
      .tool-button .label { display: none; }
      .tool-button { width: 36px; padding: 0; }
    }

    @media (max-width: 1100px) {
      .workspace-summary { left: 190px; right: 8px; top: 8px; min-height: 40px; }
      .canvas-wrap { top: 56px; }
      .ready-badge, .capital-badge { display: none; }
      .app {
        grid-template-columns: 1fr;
        grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--statusbar-height);
      }
      .topbar { grid-template-columns: 132px minmax(0, 1fr) auto; }
      .brand {
        display: flex;
        width: 132px;
        padding: 5px 8px;
      }
      .brand-logo { width: 112px; max-height: 42px; }
      .toolbar { min-width: 0; }
      .top-actions { grid-column: 2; padding: 0 8px; gap: 5px; }
      .top-actions .tool-button { width: 34px; min-height: 34px; padding: 0; }
      .top-actions .action-label { display: none; }
      .top-actions .action-icon { display: inline; }
      .workspace { grid-column: 1; }
      .sidebar, .properties {
        position: fixed;
        top: var(--topbar-height);
        bottom: var(--statusbar-height);
        z-index: 60;
        width: min(320px, 86vw);
        box-shadow: var(--shadow);
        transition: transform 220ms ease;
      }
      .sidebar { left: 0; transform: translateX(-105%); }
      .properties { right: 0; transform: translateX(105%); }
      .sidebar.open, .properties.open { transform: translateX(0); }
      .mobile-toggle { display: inline-flex; }
      .statusbar { grid-template-columns: 1fr auto; }
      .status-left { display: none; }
      .status-center { grid-column: 1; }
      .status-right { grid-column: 2; }
    }

    @media (max-width: 620px) {
      .canvas-toolbar { top: 6px; left: 6px; padding: 3px; }
      .canvas-tool { width: 28px; height: 28px; }
      .zoom-label { min-width: 38px; font-size: 10px; }
      .workspace-summary {
        top: 44px;
        left: 6px;
        right: 6px;
        min-height: 38px;
        gap: 6px;
        padding: 4px 5px 4px 9px;
      }
      .canvas-wrap { top: 88px; }
      .workspace-summary strong { max-width: 150px; font-size: 10px; }
      .workspace-kicker { font-size: 6px; }
      .quick-run-button { min-height: 26px; padding: 0 8px; font-size: 8px; }
      .topbar { grid-template-columns: 98px minmax(0, 1fr); }
      .brand {
        display: flex;
        width: 98px;
        padding: 5px 6px;
      }
      .brand-logo { width: 84px; max-height: 38px; }
      .toolbar { grid-column: 2; padding: 0 6px; }
      .top-actions { display: none; }
      .toolbar-divider { display: none; }
      .speed-control span { display: none; }
      .status-right { display: none; }
      .statusbar { grid-template-columns: 1fr; }
      .status-center { justify-content: center; }
      .status-center > span { display: none; }
      .developer-credit { margin-left: 0; }
      .mobile-model-actions { display: grid !important; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    }

    @media (min-width: 621px) and (max-width: 1100px) and (orientation: landscape) {
      .workspace-summary { left: 190px; top: 8px; right: 8px; }
      .canvas-wrap { top: 56px; }
      .sidebar, .properties { max-width: 320px; }
    }

    @media (max-width: 1100px) and (max-height: 600px) {
      .workspace-summary { min-height: 36px; }
      .canvas-wrap { top: 52px; }
      .quick-run-button { min-height: 25px; }
    }

    @media (prefers-reduced-motion: reduce) {
      *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
      }
    }


    /* ===== INTERFAZ BLANCA PROFESIONAL ===== */
    html, body {
      background: #eef3f8;
      color: #172237;
    }

    .topbar {
      border-bottom-color: #dbe3ed;
      background: rgba(255, 255, 255, 0.98);
      box-shadow: 0 8px 28px rgba(20, 42, 72, 0.08);
    }

    .toolbar-divider,
    .brand,
    .top-actions {
      border-color: #e1e7ef;
    }

    .tool-button,
    .speed-control {
      border-color: #d7e0ea;
      background: #ffffff;
      color: #172237;
      box-shadow: 0 2px 7px rgba(21, 41, 68, 0.05);
    }

    .tool-button:hover {
      border-color: rgba(58, 139, 253, 0.55);
      background: #eef5ff;
    }

    .tool-button.primary,
    .quick-run-button {
      color: #ffffff;
      border-color: transparent;
      background: linear-gradient(145deg, #3a8bfd, #176fe5);
    }

    .speed-control span { color: #65748a; }
    .speed-control select { color: #172237; }
    .speed-control option { background: #ffffff; color: #172237; }

    .sidebar,
    .properties {
      background: #ffffff;
      color: #172237;
      border-color: #dbe3ed;
      scrollbar-color: rgba(70, 91, 120, 0.28) transparent;
    }

    .sidebar .panel-section,
    .properties .panel-section {
      border-bottom-color: #e4e9f1;
    }

    .sidebar .panel-title h2,
    .sidebar .palette-copy strong,
    .sidebar .tip-card strong {
      color: #172237;
    }

    .sidebar .panel-title span,
    .sidebar .palette-copy span,
    .sidebar .tip-card p,
    .sidebar .scenario-fields label {
      color: #6d7c91;
    }

    .sidebar .palette-item,
    .sidebar .tip-card,
    .sidebar .property-button,
    .sidebar .scenario-fields input,
    .sidebar .scenario-fields select,
    .sidebar .service-card {
      border-color: #dbe3ed;
      background: #ffffff;
      color: #172237;
      box-shadow: 0 4px 14px rgba(25, 43, 70, 0.05);
    }

    .sidebar .palette-item:hover,
    .sidebar .property-button:hover {
      border-color: rgba(58, 139, 253, 0.52);
      background: #eef5ff;
    }

    .workspace {
      background: #edf2f7;
    }

    .workspace-summary,
    .canvas-toolbar {
      border-color: #d8e1ec;
      background: rgba(255, 255, 255, 0.96);
      box-shadow: 0 8px 24px rgba(24, 45, 73, 0.10);
    }

    .statusbar {
      border-top-color: #dbe3ed;
      background: #ffffff;
      color: #64748b;
      box-shadow: 0 -5px 18px rgba(24, 45, 73, 0.06);
    }

    .status-left,
    .status-right { border-color: #e1e7ef; }

    .developer-credit { color: #49647f; }

    .scenario-period-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 9px;
      margin-top: 9px;
    }

    .scenario-note {
      margin-top: 9px;
      padding: 10px;
      border: 1px solid #dbe3ed;
      border-radius: 10px;
      background: #f7f9fc;
      color: #6d7c91;
      font-size: 9px;
      line-height: 1.55;
    }

    .date-day-label {
      display: block;
      min-height: 15px;
      margin-top: 4px;
      color: #3f5f82;
      font-size: 9px;
      font-weight: 800;
      text-transform: capitalize;
    }

    .weekday-selector {
      margin-top: 10px;
      padding: 10px;
      border: 1px solid #dbe3ed;
      border-radius: 11px;
      background: #f8fafc;
    }

    .weekday-selector-title {
      display: block;
      margin-bottom: 8px;
      color: #53657b;
      font-size: 9px;
      font-weight: 900;
      letter-spacing: .04em;
      text-transform: uppercase;
    }

    .weekday-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 6px;
    }

    .weekday-grid label {
      position: relative;
      display: block;
      cursor: pointer;
    }

    .weekday-grid input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }

    .weekday-grid span {
      display: flex;
      align-items: center;
      justify-content: center;
      min-height: 30px;
      padding: 0 7px;
      border: 1px solid #dbe3ed;
      border-radius: 8px;
      background: #ffffff;
      color: #65758a;
      font-size: 9px;
      font-weight: 800;
      transition: border-color 150ms ease, background 150ms ease, color 150ms ease, box-shadow 150ms ease;
    }

    .weekday-grid input:checked + span {
      border-color: rgba(58, 139, 253, .48);
      background: #eaf3ff;
      color: #1764c0;
      box-shadow: inset 0 0 0 1px rgba(58, 139, 253, .12);
    }

    .weekday-grid label:hover span {
      border-color: rgba(58, 139, 253, .42);
    }

    .service-list {
      display: grid;
      gap: 8px;
    }

    .service-card {
      display: grid;
      grid-template-columns: 34px minmax(0, 1fr);
      gap: 9px;
      align-items: center;
      padding: 9px;
      border: 1px solid #dbe3ed;
      border-radius: 11px;
    }

    .service-card i {
      display: grid;
      place-items: center;
      width: 34px;
      height: 34px;
      border-radius: 9px;
      background: #eef5ff;
      color: #176fe5;
      font-style: normal;
      font-size: 15px;
    }

    .service-card strong { display: block; color: #172237; font-size: 10px; }
    .service-card span { display: block; margin-top: 2px; color: #718096; font-size: 9px; line-height: 1.35; }

    .entity.angry {
      background: linear-gradient(145deg, #f05b67, #c83e4b);
      animation: angryPulse 700ms ease-in-out infinite alternate;
    }

    .entity.angry::after { background: #d94b58; }

    @keyframes angryPulse {
      from { transform: scale(1); }
      to { transform: scale(1.14); }
    }

    .mood-pill {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      margin-left: 5px;
      padding: 2px 6px;
      border-radius: 999px;
      background: #fff0f1;
      color: #bf3c48;
      font-size: 8px;
      font-weight: 900;
    }

    .properties .field-help {
      margin: -4px 0 13px;
      padding: 9px 10px;
      border: 1px solid #dbe3ed;
      border-radius: 9px;
      background: #f7f9fc;
      color: #69788d;
      font-size: 9px;
      line-height: 1.5;
    }

    .config-disclosure {
      margin: 0 0 13px;
      border: 1px solid #dbe3ed;
      border-radius: 11px;
      background: #ffffff;
      overflow: hidden;
    }

    .config-disclosure summary {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      min-height: 40px;
      padding: 0 11px;
      cursor: pointer;
      list-style: none;
      color: #24344d;
      background: #f7f9fc;
      font-size: 10px;
      font-weight: 900;
      letter-spacing: .025em;
    }

    .config-disclosure summary::-webkit-details-marker { display: none; }
    .config-disclosure summary::after {
      content: "+";
      color: #176fe5;
      font-size: 16px;
      font-weight: 900;
    }
    .config-disclosure[open] summary::after { content: "−"; }

    .config-disclosure-body {
      padding: 11px 11px 3px;
      border-top: 1px solid #e4eaf1;
    }

    .config-disclosure .field label {
      color: #5d6c80;
      font-size: 9px;
    }

    .config-disclosure .property-button {
      margin-bottom: 10px;
      color: #24344d;
      background: #f7f9fc;
      border-color: #dbe3ed;
    }

    @media (max-width: 620px) {
      .scenario-period-grid { grid-template-columns: 1fr; }
      .workspace-summary-actions .capital-badge:nth-of-type(1) { display: inline-flex; }
    }



    /* Módulos avanzados de decisión: añadidos sin modificar la estructura base */
    .advanced-grid {
      display: grid;
      grid-template-columns: repeat(2, minmax(0, 1fr));
      gap: 9px;
    }

    .advanced-grid .field-compact {
      min-width: 0;
    }

    .field-compact label {
      display: block;
      margin-bottom: 5px;
      color: var(--muted);
      font-size: 9px;
      font-weight: 800;
      letter-spacing: .025em;
      text-transform: uppercase;
    }

    .field-compact input,
    .field-compact select {
      width: 100%;
      min-height: 36px;
      padding: 0 9px;
      border: 1px solid var(--line);
      border-radius: 9px;
      background: #ffffff;
      color: var(--dark-text);
    }

    .module-actions {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 8px;
      margin-top: 10px;
    }

    .decision-panel {
      display: grid;
      gap: 9px;
    }

    .decision-insight {
      padding: 10px 11px;
      border: 1px solid #dfe7f1;
      border-left: 4px solid var(--primary);
      border-radius: 10px;
      background: #f8fbff;
      color: #43536a;
      font-size: 10px;
      line-height: 1.5;
    }

    .decision-insight.warning { border-left-color: var(--warning); background: #fffbf2; }
    .decision-insight.danger { border-left-color: var(--danger); background: #fff7f8; }
    .decision-insight.success { border-left-color: var(--success); background: #f4fcf8; }

    .snapshot-list {
      display: grid;
      gap: 8px;
      margin-top: 9px;
      max-height: 240px;
      overflow-y: auto;
    }

    .snapshot-card {
      padding: 10px;
      border: 1px solid #dde6f0;
      border-radius: 11px;
      background: #ffffff;
      color: var(--dark-text);
    }

    .snapshot-card strong { display: block; font-size: 11px; }
    .snapshot-card span { display: block; margin-top: 3px; color: var(--dark-muted); font-size: 9px; line-height: 1.45; }

    .advanced-kpi-card {
      background: linear-gradient(145deg, #ffffff, #f8fbff) !important;
      border-color: #dfe8f3 !important;
    }

    .advanced-kpi-card strong { color: #14233b !important; }

    .comparison-modal {
      position: fixed;
      inset: 0;
      z-index: 150;
      display: none;
      align-items: center;
      justify-content: center;
      padding: 22px;
      background: rgba(8, 19, 35, .68);
      backdrop-filter: blur(5px);
    }

    .comparison-modal.open { display: flex; }

    .comparison-dialog {
      width: min(1080px, 96vw);
      max-height: 88vh;
      overflow: auto;
      border-radius: 18px;
      background: #ffffff;
      box-shadow: 0 28px 80px rgba(0,0,0,.32);
      color: var(--dark-text);
    }

    .comparison-header {
      position: sticky;
      top: 0;
      z-index: 2;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 16px 18px;
      border-bottom: 1px solid #e2e8f0;
      background: rgba(255,255,255,.96);
      backdrop-filter: blur(10px);
    }

    .comparison-header h3 { margin: 0; font-size: 15px; }
    .comparison-header p { margin: 4px 0 0; color: var(--dark-muted); font-size: 10px; }

    .comparison-close {
      width: 34px;
      height: 34px;
      border-radius: 9px;
      background: #eef3f8;
      color: var(--dark-text);
      cursor: pointer;
      font-weight: 900;
    }

    .comparison-body { padding: 16px 18px 20px; }

    .comparison-table-wrap { overflow-x: auto; }
    .comparison-table {
      width: 100%;
      min-width: 820px;
      border-collapse: separate;
      border-spacing: 0;
      font-size: 10px;
    }

    .comparison-table th,
    .comparison-table td {
      padding: 10px;
      border-right: 1px solid #e3eaf2;
      border-bottom: 1px solid #e3eaf2;
      text-align: right;
      white-space: nowrap;
    }

    .comparison-table th:first-child,
    .comparison-table td:first-child { text-align: left; border-left: 1px solid #e3eaf2; }
    .comparison-table thead th { background: #f4f7fb; font-weight: 900; }
    .comparison-table thead tr:first-child th { border-top: 1px solid #e3eaf2; }

    .event-banner {
      position: absolute;
      left: 50%;
      bottom: 14px;
      z-index: 19;
      transform: translateX(-50%);
      display: none;
      max-width: calc(100% - 36px);
      padding: 9px 13px;
      border: 1px solid rgba(239,91,103,.30);
      border-radius: 999px;
      background: rgba(255,247,248,.95);
      box-shadow: 0 10px 24px rgba(28,42,61,.16);
      color: #a82d3b;
      font-size: 10px;
      font-weight: 800;
    }

    .event-banner.show { display: block; }

    @media (max-width: 620px) {
      .advanced-grid,
      .module-actions { grid-template-columns: 1fr; }
      .comparison-modal { padding: 8px; }
      .comparison-dialog { max-height: 94vh; border-radius: 13px; }
    }

  

    /* ===== PANELES OCULTABLES Y RESPONSIVE REFORZADO ===== */
    .app {
      transition: grid-template-columns 220ms ease;
    }

    .panel-toggle {
      position: relative;
      flex: 0 0 auto;
    }

    .panel-toggle[aria-pressed="true"] {
      border-color: rgba(58, 139, 253, 0.60);
      background: #eaf3ff;
      color: #145ebd;
    }

    .app.sidebar-collapsed {
      grid-template-columns: 0 minmax(0, 1fr) var(--properties-width);
    }

    .app.properties-collapsed {
      grid-template-columns: var(--sidebar-width) minmax(0, 1fr) 0;
    }

    .app.sidebar-collapsed.properties-collapsed {
      grid-template-columns: 0 minmax(0, 1fr) 0;
    }

    .app.sidebar-collapsed .sidebar,
    .app.properties-collapsed .properties {
      width: 0;
      min-width: 0;
      padding: 0;
      border: 0;
      opacity: 0;
      overflow: hidden;
      pointer-events: none;
    }

    .app.sidebar-collapsed .statusbar {
      grid-template-columns: 0 minmax(0, 1fr) var(--properties-width);
    }

    .app.properties-collapsed .statusbar {
      grid-template-columns: var(--sidebar-width) minmax(0, 1fr) 0;
    }

    .app.sidebar-collapsed.properties-collapsed .statusbar {
      grid-template-columns: 0 minmax(0, 1fr) 0;
    }

    .app.sidebar-collapsed .status-left,
    .app.properties-collapsed .status-right {
      display: none;
    }

    .panel-head {
      position: sticky;
      top: 0;
      z-index: 5;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      min-height: 48px;
      padding: 10px 14px;
      border-bottom: 1px solid #e3e9f1;
      background: rgba(255, 255, 255, 0.97);
      backdrop-filter: blur(12px);
    }

    .panel-head strong {
      color: #172237;
      font-size: 12px;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }

    .panel-close {
      display: grid;
      place-items: center;
      width: 32px;
      height: 32px;
      flex: 0 0 auto;
      border: 1px solid #d8e0eb;
      border-radius: 9px;
      background: #ffffff;
      color: #26364d;
      cursor: pointer;
      font-size: 16px;
      font-weight: 900;
    }

    .panel-close:hover {
      border-color: rgba(58, 139, 253, 0.50);
      background: #eef5ff;
      color: #176fe5;
    }

    .panel-backdrop {
      position: fixed;
      inset: var(--topbar-height) 0 var(--statusbar-height) 0;
      z-index: 55;
      display: none;
      background: rgba(12, 24, 43, 0.38);
      backdrop-filter: blur(2px);
    }

    .panel-backdrop.visible {
      display: block;
    }

    .developer-credit {
      color: #4d5f76;
      text-decoration: none;
      font-weight: 700;
    }

    .developer-credit strong {
      color: #176fe5;
    }

    .developer-credit:hover strong {
      text-decoration: underline;
    }

    @media (min-width: 1101px) {
      .panel-head {
        display: none;
      }

      .sidebar,
      .properties {
        transition: width 220ms ease, opacity 180ms ease;
      }
    }

    @media (max-width: 1100px) {
      .app,
      .app.sidebar-collapsed,
      .app.properties-collapsed,
      .app.sidebar-collapsed.properties-collapsed {
        grid-template-columns: minmax(0, 1fr);
      }

      .app.sidebar-collapsed .sidebar,
      .app.properties-collapsed .properties {
        width: min(360px, 92vw);
        opacity: 1;
        pointer-events: auto;
      }

      .panel-toggle {
        display: inline-flex;
      }

      .sidebar,
      .properties {
        width: min(360px, 92vw);
        max-width: none;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }

      .sidebar.open,
      .properties.open {
        transform: translateX(0);
      }

      .topbar {
        grid-template-columns: 122px minmax(0, 1fr) auto;
      }

      .toolbar {
        gap: 5px;
        padding: 0 8px;
      }

      .tool-button,
      .speed-control {
        min-height: 34px;
      }

      .statusbar,
      .app.sidebar-collapsed .statusbar,
      .app.properties-collapsed .statusbar,
      .app.sidebar-collapsed.properties-collapsed .statusbar {
        grid-template-columns: minmax(0, 1fr);
      }

      .status-center {
        grid-column: 1;
        justify-content: center;
        min-width: 0;
      }

      .status-center #statusMessage,
      .status-center #statusSelection {
        display: none;
      }

      .developer-credit {
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 10px;
      }
    }

    @media (max-width: 700px) {
      :root {
        --topbar-height: 58px;
        --statusbar-height: 42px;
      }

      .topbar {
        grid-template-columns: 82px minmax(0, 1fr);
      }

      .brand {
        width: 82px;
        min-width: 82px;
        padding: 4px;
      }

      .brand-logo-link {
        padding: 2px 4px;
      }

      .brand-logo {
        width: 72px;
        max-height: 34px;
      }

      .toolbar {
        grid-column: 2;
        padding: 0 5px;
        gap: 4px;
      }

      .toolbar-group {
        gap: 4px;
      }

      .tool-button {
        width: 32px;
        min-width: 32px;
        min-height: 32px;
        padding: 0;
        border-radius: 8px;
        font-size: 11px;
      }

      .speed-control {
        height: 32px;
        min-height: 32px;
        padding: 0 6px;
        border-radius: 8px;
      }

      .speed-control select {
        max-width: 52px;
        font-size: 10px;
      }

      .toolbar-divider {
        display: none;
      }

      .top-actions {
        display: none;
      }

      .workspace-summary {
        top: 40px;
        left: 5px;
        right: 5px;
        min-height: 34px;
        padding: 4px 5px 4px 8px;
      }

      .workspace-summary strong {
        max-width: 138px;
        font-size: 9px;
      }

      .workspace-kicker {
        font-size: 6px;
      }

      .quick-run-button {
        min-height: 25px;
        padding: 0 7px;
        font-size: 8px;
      }

      .canvas-toolbar {
        top: 4px;
        left: 4px;
      }

      .canvas-wrap {
        top: 80px;
      }

      .sidebar,
      .properties,
      .app.sidebar-collapsed .sidebar,
      .app.properties-collapsed .properties {
        top: var(--topbar-height);
        bottom: var(--statusbar-height);
        width: 100vw;
        max-width: 100vw;
      }

      .panel-section {
        padding: 14px;
      }

      .field-row,
      .metrics-grid {
        grid-template-columns: minmax(0, 1fr);
      }

      .property-actions {
        grid-template-columns: minmax(0, 1fr);
      }

      .palette-item {
        min-height: 58px;
      }

      .status-center {
        padding: 0 8px;
      }

      .developer-credit {
        font-size: 9px;
      }
    }

    @media (max-width: 420px) {
      .brand {
        width: 68px;
        min-width: 68px;
      }

      .topbar {
        grid-template-columns: 68px minmax(0, 1fr);
      }

      .brand-logo {
        width: 60px;
      }

      .toolbar {
        overflow-x: auto;
        scroll-snap-type: x proximity;
      }

      .toolbar > * {
        scroll-snap-align: start;
      }

      .speed-control {
        display: none;
      }
    }

  
    /* Mejoras visuales finales */
    .workspace-summary {
      left: 164px;
      right: 10px;
      top: 10px;
      min-height: 44px;
      gap: 12px;
      padding: 7px 10px 7px 12px;
      border-radius: 14px;
      border-left-width: 4px;
      background: rgba(255, 255, 255, 0.96);
      box-shadow: 0 10px 24px rgba(27, 42, 62, 0.10);
    }

    .workspace-summary strong {
      margin-top: 2px;
      font-size: 12px;
      line-height: 1.2;
      white-space: normal;
    }

    .workspace-kicker {
      font-size: 7px;
      letter-spacing: 0.16em;
    }

    .workspace-summary-actions {
      flex-wrap: wrap;
      justify-content: flex-end;
      gap: 6px;
      max-width: 72%;
    }

    .capital-badge {
      min-height: 26px;
      padding: 0 10px;
      border-radius: 999px;
      font-size: 9px;
      box-shadow: inset 0 0 0 1px rgba(58, 139, 253, 0.04);
    }

    .ready-badge {
      min-height: 26px;
      padding: 0 10px;
      font-size: 9px;
    }

    .quick-run-button {
      min-height: 30px;
      padding: 0 12px;
      border-radius: 10px;
      font-size: 9px;
      white-space: nowrap;
    }

    .canvas-toolbar {
      top: 10px;
      left: 10px;
      gap: 6px;
      padding: 6px 8px;
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.97);
      box-shadow: 0 10px 24px rgba(27, 42, 62, 0.12);
    }

    .canvas-tool {
      width: 34px;
      height: 34px;
      border-radius: 10px;
      font-size: 15px;
    }

    .zoom-label {
      min-width: 54px;
      padding: 0 2px;
      font-size: 12px;
      font-weight: 900;
      color: #44556f;
    }

    .canvas-wrap {
      top: 64px;
    }

    @media (max-width: 1280px) {
      .workspace-summary { left: 150px; }
      .workspace-summary-actions { max-width: 68%; }
      .capital-badge { font-size: 8.5px; padding: 0 8px; }
    }

    @media (max-width: 920px) {
      .workspace-summary {
        left: 10px;
        right: 10px;
        top: 58px;
        min-height: auto;
        padding: 9px 10px;
        align-items: flex-start;
        flex-direction: column;
      }
      .workspace-summary strong { font-size: 11px; }
      .workspace-summary-actions {
        width: 100%;
        max-width: none;
        justify-content: flex-start;
      }
      .capital-badge, .ready-badge { font-size: 8px; }
      .quick-run-button { min-height: 28px; font-size: 8.5px; }
      .canvas-toolbar { top: 10px; left: 10px; }
      .canvas-wrap { top: 122px; }
    }

    @media (max-width: 620px) {
      .canvas-toolbar { gap: 4px; padding: 5px 7px; }
      .canvas-tool { width: 32px; height: 32px; }
      .zoom-label { min-width: 50px; font-size: 11px; }
      .workspace-summary { top: 56px; }
      .workspace-summary-actions { gap: 5px; }
      .capital-badge:nth-child(2) { max-width: 100%; }
      .capital-badge, .ready-badge, .quick-run-button { width: auto; }
      .canvas-wrap { top: 126px; }
    }


    /* Refinamiento visual de la cabecera del escenario */
    .workspace-summary {
      left: 126px;
      right: 12px;
      top: 12px;
      min-height: 56px;
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 14px;
      padding: 10px 14px;
      border: 1px solid rgba(21, 37, 60, 0.08);
      border-left: 4px solid var(--primary);
      border-radius: 16px;
      background: rgba(255, 255, 255, 0.98);
      box-shadow: 0 10px 28px rgba(26, 42, 62, 0.10);
      backdrop-filter: blur(10px);
    }

    .workspace-summary > div:first-child {
      min-width: 0;
      display: flex;
      flex-direction: column;
      justify-content: center;
      gap: 3px;
    }

    .workspace-kicker {
      font-size: 8px;
      letter-spacing: 0.16em;
      color: #6a7890;
    }

    .workspace-summary strong {
      margin-top: 0;
      font-size: 15px;
      line-height: 1.12;
      font-weight: 800;
      color: #17243a;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .workspace-summary-actions {
      display: flex;
      align-items: center;
      justify-content: flex-end;
      flex-wrap: nowrap;
      gap: 8px;
      max-width: none;
    }

    .capital-badge,
    .ready-badge {
      min-height: 32px;
      padding: 0 12px;
      font-size: 10px;
      font-weight: 800;
      border-radius: 999px;
      white-space: nowrap;
    }

    .capital-badge {
      background: #f3f7ff;
      border: 1px solid rgba(58, 139, 253, 0.18);
      color: #245ea9;
    }

    .ready-badge {
      background: #eefaf5;
      border: 1px solid rgba(32, 180, 134, 0.20);
      color: #147557;
    }

    .ready-badge i {
      width: 8px;
      height: 8px;
      box-shadow: 0 0 0 4px rgba(32, 180, 134, 0.14);
    }

    .quick-run-button {
      min-height: 34px;
      padding: 0 14px;
      border-radius: 11px;
      font-size: 10px;
      font-weight: 800;
      white-space: nowrap;
      box-shadow: 0 8px 18px rgba(23, 111, 229, 0.22);
    }

    .canvas-toolbar {
      top: 12px;
      left: 12px;
      gap: 6px;
      padding: 6px 8px;
      border-radius: 16px;
      background: rgba(255,255,255,0.98);
      box-shadow: 0 10px 28px rgba(26, 42, 62, 0.12);
    }

    .canvas-tool {
      width: 34px;
      height: 34px;
      font-size: 15px;
    }

    .zoom-label {
      min-width: 56px;
      font-size: 12px;
      font-weight: 900;
      color: #42536d;
    }

    .canvas-wrap { top: 82px; }

    @media (max-width: 1400px) {
      .workspace-summary { left: 120px; }
      .workspace-summary strong { font-size: 14px; }
      .capital-badge, .ready-badge { font-size: 9px; padding: 0 10px; }
      .quick-run-button { padding: 0 12px; }
    }

    @media (max-width: 1180px) {
      .workspace-summary {
        left: 12px;
        right: 12px;
        grid-template-columns: 1fr;
        align-items: flex-start;
      }
      .workspace-summary strong {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
      }
      .workspace-summary-actions {
        width: 100%;
        flex-wrap: wrap;
        justify-content: flex-start;
      }
      .canvas-wrap { top: 106px; }
    }

    @media (max-width: 920px) {
      .workspace-summary {
        top: 56px;
        padding: 10px 12px;
        gap: 10px;
      }
      .workspace-summary strong { font-size: 13px; }
      .capital-badge, .ready-badge { min-height: 30px; }
      .quick-run-button { min-height: 32px; }
      .canvas-wrap { top: 132px; }
    }

    @media (max-width: 620px) {
      .workspace-summary {
        top: 54px;
        border-radius: 14px;
      }
      .workspace-kicker { font-size: 7px; }
      .workspace-summary strong { font-size: 12px; }
      .workspace-summary-actions { gap: 6px; }
      .capital-badge, .ready-badge, .quick-run-button {
        font-size: 9px;
      }
      .canvas-wrap { top: 140px; }
    }



    /* Cabecera adaptativa basada en el ancho real del lienzo */
    .workspace {
      container-type: inline-size;
      container-name: simulador-workspace;
    }

    .canvas-toolbar {
      top: 10px !important;
      left: 10px !important;
      z-index: 25;
      min-height: 48px;
      padding: 6px 8px !important;
      gap: 5px !important;
      border-radius: 15px !important;
      background: #ffffff !important;
      border: 1px solid rgba(24, 39, 62, 0.10) !important;
      box-shadow: 0 8px 22px rgba(30, 45, 68, 0.12) !important;
      backdrop-filter: none !important;
    }

    .canvas-tool {
      width: 34px !important;
      height: 34px !important;
      border-radius: 9px !important;
    }

    .zoom-label {
      min-width: 52px !important;
      font-size: 12px !important;
      font-weight: 900 !important;
      color: #30415c !important;
    }

    .workspace-summary {
      top: 10px !important;
      left: 190px !important;
      right: 10px !important;
      min-height: 56px !important;
      display: grid !important;
      grid-template-columns: minmax(150px, 1fr) auto !important;
      align-items: center !important;
      gap: 12px !important;
      padding: 8px 10px 8px 13px !important;
      border-radius: 15px !important;
      border: 1px solid rgba(24, 39, 62, 0.10) !important;
      border-left: 4px solid var(--primary) !important;
      background: #ffffff !important;
      box-shadow: 0 8px 22px rgba(30, 45, 68, 0.10) !important;
      backdrop-filter: none !important;
      overflow: hidden;
    }

    .workspace-summary > div:first-child {
      min-width: 0 !important;
      display: block !important;
    }

    .workspace-kicker {
      display: block;
      margin-bottom: 3px;
      font-size: 7px !important;
      line-height: 1;
      letter-spacing: .15em !important;
      color: #718097 !important;
    }

    .workspace-summary strong {
      display: block;
      margin: 0 !important;
      max-width: none !important;
      color: #18253a !important;
      font-size: 12px !important;
      line-height: 1.25 !important;
      font-weight: 800 !important;
      white-space: nowrap !important;
      overflow: hidden !important;
      text-overflow: ellipsis !important;
    }

    .workspace-summary-actions {
      min-width: 0;
      display: flex !important;
      align-items: center !important;
      justify-content: flex-end !important;
      flex-wrap: nowrap !important;
      gap: 6px !important;
      max-width: none !important;
    }

    .capital-badge,
    .ready-badge {
      min-height: 30px !important;
      padding: 0 10px !important;
      border-radius: 999px !important;
      font-size: 9px !important;
      line-height: 1 !important;
      white-space: nowrap !important;
    }

    #scheduleBadge {
      max-width: 255px;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    #capitalBadge {
      max-width: 210px;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .quick-run-button {
      min-height: 32px !important;
      padding: 0 12px !important;
      border-radius: 10px !important;
      font-size: 9px !important;
      white-space: nowrap !important;
    }

    .canvas-wrap {
      top: 76px !important;
    }

    @container simulador-workspace (max-width: 980px) {
      .workspace-summary {
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 7px !important;
        min-height: 88px !important;
      }

      .workspace-summary-actions {
        justify-content: flex-start !important;
        flex-wrap: wrap !important;
      }

      .workspace-summary strong {
        white-space: nowrap !important;
      }

      .canvas-wrap {
        top: 108px !important;
      }
    }

    @container simulador-workspace (max-width: 700px) {
      .workspace-summary {
        top: 66px !important;
        left: 10px !important;
        right: 10px !important;
        min-height: 92px !important;
        padding: 9px 11px !important;
      }

      .workspace-summary-actions {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        width: 100%;
      }

      .capital-badge,
      .ready-badge,
      .quick-run-button {
        width: 100% !important;
        max-width: none !important;
        justify-content: center !important;
      }

      .canvas-wrap {
        top: 174px !important;
      }
    }

    @container simulador-workspace (max-width: 430px) {
      .workspace-summary-actions {
        grid-template-columns: minmax(0, 1fr) !important;
      }

      .workspace-summary {
        min-height: 158px !important;
      }

      .canvas-wrap {
        top: 240px !important;
      }
    }


    /* El escenario ya se muestra en la cabecera principal: se elimina la franja duplicada */
    .workspace-summary {
      display: none !important;
    }

    .canvas-toolbar {
      top: 10px !important;
      left: 10px !important;
    }

    .canvas-wrap {
      top: 56px !important;
    }

    @media (max-width: 920px) {
      .canvas-wrap {
        top: 54px !important;
      }
    }

    @media (max-width: 620px) {
      .canvas-wrap {
        top: 52px !important;
      }
    }



    /* Vista horizontal automática y lienzo ampliado */
    .workspace {
      background: #eef3f9;
    }

    .canvas-wrap {
      top: 48px !important;
    }

    .canvas-toolbar {
      top: 7px !important;
      left: 9px !important;
      z-index: 25;
    }

    .canvas {
      width: 2400px !important;
      height: 1400px !important;
    }

    body.force-landscape {
      position: fixed;
      inset: 0;
      width: 100vw;
      height: 100vh;
      overflow: hidden !important;
      background: #07101f;
    }

    body.force-landscape .app {
      position: absolute;
      top: 0;
      left: 100vw;
      width: 100vh;
      height: 100vw;
      transform: rotate(90deg);
      transform-origin: top left;
      --topbar-height: 52px;
      --statusbar-height: 30px;
    }

    body.force-landscape .topbar {
      min-height: 52px;
    }

    body.force-landscape .toolbar {
      padding: 0 8px;
    }

    body.force-landscape .statusbar {
      min-height: 30px;
    }

    body.force-landscape .workspace {
      min-width: 0;
      min-height: 0;
    }

    body.force-landscape .canvas-wrap {
      top: 46px !important;
    }

    body.force-landscape .canvas-toolbar {
      top: 6px !important;
      left: 8px !important;
    }

    body.force-landscape .sidebar,
    body.force-landscape .properties {
      top: var(--topbar-height);
      bottom: var(--statusbar-height);
      max-width: min(340px, 72vh);
    }

    @media (max-width: 920px) and (orientation: landscape) {
      .canvas-wrap {
        top: 46px !important;
      }

      .canvas-toolbar {
        top: 6px !important;
      }
    }



    /* ===== CORRECCIÓN MÓVIL INTERACTIVA ===== */
    html,
    body {
      width: 100%;
      height: 100%;
      min-height: 100dvh;
      overflow: hidden;
      overscroll-behavior: none;
    }

    .app {
      width: 100%;
      height: 100dvh;
      min-height: 0;
    }

    /* Neutraliza cualquier rotación automática de versiones anteriores. */
    body.force-landscape,
    body.force-landscape .app {
      position: static !important;
      inset: auto !important;
      top: auto !important;
      left: auto !important;
      width: 100% !important;
      height: 100dvh !important;
      transform: none !important;
      transform-origin: initial !important;
    }

    body.force-landscape .sidebar,
    body.force-landscape .properties {
      top: var(--topbar-height) !important;
      bottom: var(--statusbar-height) !important;
      max-width: none !important;
    }

    .canvas-wrap {
      overflow: auto !important;
      touch-action: pan-x pan-y;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      scrollbar-gutter: stable;
    }

    .canvas,
    .nodes-layer,
    .entity-layer {
      touch-action: pan-x pan-y;
    }

    .node {
      touch-action: none;
      -webkit-tap-highlight-color: transparent;
    }

    .mobile-dock {
      display: none;
    }

    @media (max-width: 1100px) {
      :root {
        --topbar-height: 58px;
        --statusbar-height: 32px;
      }

      .app {
        grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--statusbar-height);
      }

      .topbar {
        grid-template-columns: 116px minmax(0, 1fr) auto !important;
        min-width: 0;
        padding-top: env(safe-area-inset-top, 0px);
      }

      .brand {
        grid-column: 1;
        width: 116px;
        min-width: 116px;
        padding: 5px 7px;
      }

      .brand-logo {
        width: 100px;
        max-height: 40px;
      }

      .toolbar {
        grid-column: 2;
        min-width: 0;
        padding: 0 7px;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
      }

      .toolbar-group,
      .speed-control {
        flex: 0 0 auto;
      }

      .top-actions {
        grid-column: 3 !important;
        padding: 0 7px;
        gap: 4px;
      }

      .sidebar,
      .properties {
        position: fixed;
        top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
        bottom: calc(var(--statusbar-height) + env(safe-area-inset-bottom, 0px));
        width: min(420px, 92vw);
        max-width: 92vw;
        z-index: 90;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
      }

      .sidebar.open,
      .properties.open {
        transform: translateX(0) !important;
      }

      .panel-backdrop.visible {
        z-index: 80;
      }

      .workspace {
        min-width: 0;
        min-height: 0;
      }

      .canvas-wrap {
        top: 48px !important;
        bottom: 0;
      }

      .canvas-toolbar {
        top: 7px !important;
        left: 8px !important;
        z-index: 50;
      }

      .mobile-dock {
        position: fixed;
        left: 50%;
        bottom: calc(var(--statusbar-height) + 8px + env(safe-area-inset-bottom, 0px));
        z-index: 70;
        display: grid;
        grid-template-columns: repeat(5, minmax(48px, 1fr));
        width: min(430px, calc(100vw - 18px));
        padding: 6px;
        gap: 4px;
        border: 1px solid rgba(33, 51, 77, 0.12);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.96);
        box-shadow: 0 12px 34px rgba(20, 36, 58, 0.20);
        backdrop-filter: blur(14px);
        transform: translateX(-50%);
      }

      .mobile-dock button {
        min-width: 0;
        min-height: 46px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        border: 0;
        border-radius: 11px;
        background: transparent;
        color: #263650;
        cursor: pointer;
      }

      .mobile-dock button span {
        font-size: 16px;
        line-height: 1;
        font-weight: 900;
      }

      .mobile-dock button small {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 8px;
        font-weight: 800;
        white-space: nowrap;
      }

      .mobile-dock button.primary {
        background: linear-gradient(145deg, var(--primary), var(--primary-strong));
        color: #ffffff;
        box-shadow: 0 7px 16px rgba(23, 111, 229, 0.24);
      }

      .statusbar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
      }
    }

    @media (max-width: 620px) {
      :root {
        --topbar-height: 56px;
        --statusbar-height: 30px;
      }

      .topbar {
        grid-template-columns: 82px minmax(0, 1fr) !important;
      }

      .brand {
        width: 82px;
        min-width: 82px;
        padding: 5px;
      }

      .brand-logo {
        width: 72px;
        max-height: 36px;
      }

      .toolbar {
        grid-column: 2;
        padding: 0 5px;
        gap: 4px;
      }

      .toolbar .tool-button {
        width: 34px;
        min-width: 34px;
        height: 34px;
        min-height: 34px;
      }

      .speed-control {
        height: 34px;
        padding: 0 7px;
      }

      .top-actions {
        display: none !important;
      }

      .canvas-wrap {
        top: 46px !important;
      }

      .canvas-toolbar {
        top: 6px !important;
        left: 6px !important;
      }

      .sidebar,
      .properties {
        width: 100vw;
        max-width: 100vw;
      }

      .properties .field-row,
      .sidebar .field-row,
      .metrics-grid {
        grid-template-columns: 1fr !important;
      }

      .panel-section {
        padding: 14px;
      }

      .mobile-dock {
        width: calc(100vw - 12px);
        bottom: calc(var(--statusbar-height) + 5px + env(safe-area-inset-bottom, 0px));
        border-radius: 14px;
      }

      .mobile-dock button {
        min-height: 43px;
      }

      .mobile-dock button small {
        font-size: 7.5px;
      }
    }

    @media (max-width: 920px) and (orientation: landscape) {
      :root {
        --topbar-height: 52px;
        --statusbar-height: 28px;
      }

      .topbar {
        grid-template-columns: 100px minmax(0, 1fr) auto !important;
      }

      .brand {
        width: 100px;
        min-width: 100px;
      }

      .brand-logo {
        width: 88px;
        max-height: 34px;
      }

      .canvas-wrap {
        top: 44px !important;
      }

      .mobile-dock {
        left: auto;
        right: 8px;
        bottom: calc(var(--statusbar-height) + 6px + env(safe-area-inset-bottom, 0px));
        width: auto;
        grid-template-columns: repeat(5, 54px);
        transform: none;
      }
    }



    /* =========================================================
       RESPONSIVE FINAL: EXPERIENCIA TIPO COMPUTADOR EN MÓVIL
       ========================================================= */
    html,
    body {
      width: 100%;
      height: 100%;
      min-height: 100dvh;
      overflow: hidden !important;
      overscroll-behavior: none;
      background: #eaf0f7;
    }

    body,
    body.force-landscape,
    body.mobile-portrait,
    body.mobile-landscape {
      position: static !important;
      inset: auto !important;
      width: 100% !important;
      height: 100dvh !important;
      transform: none !important;
      transform-origin: initial !important;
      overflow: hidden !important;
    }

    body.force-landscape .app,
    body.mobile-portrait .app,
    body.mobile-landscape .app {
      position: static !important;
      inset: auto !important;
      width: 100% !important;
      height: 100dvh !important;
      transform: none !important;
      transform-origin: initial !important;
    }

    .app {
      width: 100%;
      height: 100dvh;
      min-height: 0;
      overflow: hidden;
    }

    .canvas-wrap {
      overflow: auto !important;
      touch-action: pan-x pan-y !important;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior: contain;
      scrollbar-width: thin;
      scrollbar-color: rgba(63, 82, 111, .34) transparent;
    }

    .canvas,
    .nodes-layer,
    .entity-layer {
      touch-action: pan-x pan-y;
    }

    .node {
      touch-action: none !important;
      -webkit-tap-highlight-color: transparent;
    }

    /* La navegación móvil duplicada se elimina: se mantienen los controles superiores. */
    .mobile-dock {
      display: none !important;
    }

    @media (max-width: 1100px) {
      :root {
        --topbar-height: 62px;
        --statusbar-height: 30px;
      }

      .app,
      .app.sidebar-collapsed,
      .app.properties-collapsed,
      .app.sidebar-collapsed.properties-collapsed {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        grid-template-rows: var(--topbar-height) minmax(0, 1fr) var(--statusbar-height) !important;
      }

      .topbar {
        grid-column: 1 !important;
        grid-row: 1 !important;
        display: grid !important;
        grid-template-columns: 116px minmax(0, 1fr) auto !important;
        align-items: center;
        min-width: 0;
        min-height: var(--topbar-height);
        padding: env(safe-area-inset-top, 0px) 6px 0;
        border-bottom: 1px solid rgba(255, 255, 255, .10);
        background: linear-gradient(90deg, #0a1830 0%, #0c203b 55%, #0a172a 100%);
        box-shadow: 0 7px 22px rgba(16, 31, 52, .22);
      }

      .brand {
        grid-column: 1 !important;
        display: flex !important;
        width: 116px !important;
        min-width: 116px !important;
        height: 100%;
        padding: 6px 8px !important;
        border-right: 1px solid rgba(255, 255, 255, .10);
      }

      .brand-logo-link {
        display: grid;
        place-items: center;
        width: 100%;
        height: 100%;
      }

      .brand-logo {
        display: block;
        width: 100px !important;
        max-width: 100% !important;
        max-height: 43px !important;
        object-fit: contain;
      }

      .toolbar {
        grid-column: 2 !important;
        display: flex !important;
        align-items: center;
        min-width: 0;
        height: 100%;
        gap: 6px !important;
        padding: 0 7px !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
      }

      .toolbar::-webkit-scrollbar {
        display: none;
      }

      .toolbar-group,
      .speed-control,
      .toolbar-divider {
        flex: 0 0 auto;
      }

      .toolbar .tool-button {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 !important;
        border-radius: 10px;
      }

      .toolbar .tool-button .label {
        display: none !important;
      }

      .toolbar-divider {
        height: 26px;
        margin: 0 1px;
      }

      .speed-control {
        height: 38px !important;
        min-width: 83px;
        padding: 0 8px !important;
        border-radius: 10px;
      }

      .speed-control span {
        display: none !important;
      }

      .speed-control select {
        width: 100%;
        text-align: center;
        font-size: 11px;
      }

      .top-actions {
        grid-column: 3 !important;
        display: flex !important;
        align-items: center;
        gap: 4px !important;
        height: 100%;
        padding: 0 6px !important;
        border-left: 1px solid rgba(255, 255, 255, .10);
      }

      .top-actions .tool-button {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 !important;
      }

      .top-actions .action-label {
        display: none !important;
      }

      .workspace {
        grid-column: 1 !important;
        grid-row: 2 !important;
        min-width: 0;
        min-height: 0;
        background: #edf2f8;
      }

      .canvas-wrap {
        top: 52px !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        padding: 0 0 18px 0;
      }

      .canvas-toolbar {
        top: 8px !important;
        left: 10px !important;
        z-index: 55 !important;
        gap: 5px;
        padding: 5px 7px;
        border: 1px solid rgba(31, 51, 78, .12);
        border-radius: 14px;
        background: rgba(255, 255, 255, .98);
        box-shadow: 0 8px 22px rgba(24, 43, 68, .14);
      }

      .canvas-tool {
        width: 34px !important;
        height: 34px !important;
        border-radius: 9px;
      }

      .zoom-label {
        min-width: 52px !important;
        font-size: 11px !important;
        font-weight: 900;
      }

      .sidebar,
      .properties,
      .app.sidebar-collapsed .sidebar,
      .app.properties-collapsed .properties {
        position: fixed !important;
        top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px)) !important;
        bottom: calc(var(--statusbar-height) + env(safe-area-inset-bottom, 0px)) !important;
        display: block !important;
        width: min(370px, 88vw) !important;
        max-width: 88vw !important;
        height: auto !important;
        z-index: 100 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        box-shadow: 0 22px 55px rgba(15, 29, 49, .30);
        transition: transform .22s ease !important;
      }

      .sidebar {
        left: 0 !important;
        right: auto !important;
        transform: translateX(-105%) !important;
        border-right: 1px solid rgba(255, 255, 255, .10);
      }

      .properties {
        right: 0 !important;
        left: auto !important;
        transform: translateX(105%) !important;
        border-left: 1px solid rgba(24, 39, 62, .10);
      }

      .sidebar.open,
      .properties.open,
      .app.sidebar-collapsed .sidebar.open,
      .app.properties-collapsed .properties.open {
        transform: translateX(0) !important;
      }

      .panel-backdrop {
        position: fixed !important;
        inset: calc(var(--topbar-height) + env(safe-area-inset-top, 0px)) 0 calc(var(--statusbar-height) + env(safe-area-inset-bottom, 0px)) 0 !important;
        z-index: 90 !important;
        background: rgba(8, 20, 36, .26) !important;
        backdrop-filter: blur(2px);
      }

      .panel-head {
        position: sticky;
        top: 0;
        z-index: 5;
      }

      .statusbar,
      .app.sidebar-collapsed .statusbar,
      .app.properties-collapsed .statusbar,
      .app.sidebar-collapsed.properties-collapsed .statusbar {
        grid-column: 1 !important;
        grid-row: 3 !important;
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        min-height: var(--statusbar-height);
        padding-bottom: env(safe-area-inset-bottom, 0px);
      }

      .status-left,
      .status-center,
      .status-right {
        min-width: 0;
        padding: 0 9px !important;
      }

      .status-center {
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }

    @media (max-width: 700px) {
      :root {
        --topbar-height: 58px;
        --statusbar-height: 28px;
      }

      .topbar {
        grid-template-columns: 82px minmax(0, 1fr) !important;
        padding-left: 4px;
        padding-right: 4px;
      }

      .brand {
        width: 82px !important;
        min-width: 82px !important;
        padding: 5px !important;
      }

      .brand-logo {
        width: 72px !important;
        max-height: 36px !important;
      }

      .toolbar {
        grid-column: 2 !important;
        padding: 0 5px !important;
        gap: 4px !important;
      }

      .toolbar .tool-button {
        width: 36px !important;
        min-width: 36px !important;
        height: 36px !important;
        min-height: 36px !important;
      }

      .speed-control {
        height: 36px !important;
        min-width: 72px;
      }

      .top-actions {
        display: none !important;
      }

      .canvas-wrap {
        top: 50px !important;
      }

      .sidebar,
      .properties,
      .app.sidebar-collapsed .sidebar,
      .app.properties-collapsed .properties {
        width: min(350px, 92vw) !important;
        max-width: 92vw !important;
      }

      .properties .field-row,
      .sidebar .field-row {
        grid-template-columns: 1fr !important;
      }

      .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
      }

      .panel-section {
        padding: 14px !important;
      }

      .status-left,
      .status-right {
        display: none !important;
      }

      .statusbar,
      .app.sidebar-collapsed .statusbar,
      .app.properties-collapsed .statusbar,
      .app.sidebar-collapsed.properties-collapsed .statusbar {
        grid-template-columns: minmax(0, 1fr) !important;
      }

      .status-center {
        grid-column: 1 !important;
        justify-content: space-between;
      }
    }

    @media (min-width: 701px) and (max-width: 1100px) {
      .sidebar,
      .properties,
      .app.sidebar-collapsed .sidebar,
      .app.properties-collapsed .properties {
        width: min(390px, 48vw) !important;
        max-width: 48vw !important;
      }
    }

    @media (max-width: 920px) and (orientation: landscape) {
      :root {
        --topbar-height: 56px;
        --statusbar-height: 28px;
      }

      .topbar {
        grid-template-columns: 96px minmax(0, 1fr) auto !important;
      }

      .brand {
        width: 96px !important;
        min-width: 96px !important;
      }

      .brand-logo {
        width: 84px !important;
      }

      .top-actions {
        display: flex !important;
      }

      .canvas-wrap {
        top: 48px !important;
      }

      .sidebar,
      .properties,
      .app.sidebar-collapsed .sidebar,
      .app.properties-collapsed .properties {
        width: min(360px, 44vw) !important;
        max-width: 44vw !important;
      }
    }


    /* Estado de sincronización con Supabase */
    .supabase-status {
      display: inline-flex;
      align-items: center;
      min-height: 22px;
      padding: 0 8px;
      border: 1px solid #d7e0ea;
      border-radius: 999px;
      background: #f7f9fc;
      color: #64748b;
      font-size: 9px;
      font-weight: 900;
      white-space: nowrap;
    }

    .supabase-status.connected {
      border-color: rgba(32, 180, 134, 0.28);
      background: #eefaf5;
      color: #147557;
    }

    .supabase-status.syncing {
      border-color: rgba(58, 139, 253, 0.28);
      background: #eef5ff;
      color: #1764c0;
    }

    .supabase-status.error {
      border-color: rgba(239, 91, 103, 0.30);
      background: #fff4f5;
      color: #bf3c48;
    }

    @media (max-width: 700px) {
      .supabase-status { display: none; }
    }


    /* ===== DATOS DE SUPABASE DENTRO DEL MISMO INDEX.HTML ===== */
    .supabase-live-overlay {
      position: fixed;
      inset: 0;
      z-index: 260;
      display: none;
      align-items: stretch;
      justify-content: flex-end;
      background: rgba(7, 16, 31, .52);
      backdrop-filter: blur(4px);
    }

    .supabase-live-overlay.open {
      display: flex;
    }

    .supabase-live-panel {
      width: min(1120px, 94vw);
      height: 100%;
      display: grid;
      grid-template-rows: auto auto auto minmax(0, 1fr);
      background: #f7f9fc;
      color: #172237;
      box-shadow: -24px 0 70px rgba(0, 0, 0, .28);
      overflow: hidden;
    }

    .supabase-live-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      padding: 16px 18px;
      border-bottom: 1px solid #dde5ef;
      background: #ffffff;
    }

    .supabase-live-title {
      min-width: 0;
    }

    .supabase-live-title h3 {
      margin: 0;
      font-size: 16px;
      color: #172237;
    }

    .supabase-live-title p {
      margin: 4px 0 0;
      color: #6a7890;
      font-size: 10px;
      line-height: 1.45;
    }

    .supabase-live-header-actions {
      display: flex;
      align-items: center;
      gap: 8px;
      flex: 0 0 auto;
    }

    .supabase-live-status {
      display: inline-flex;
      align-items: center;
      gap: 7px;
      min-height: 32px;
      padding: 0 11px;
      border: 1px solid #cfe7dc;
      border-radius: 999px;
      background: #eefaf5;
      color: #147557;
      font-size: 9px;
      font-weight: 900;
      white-space: nowrap;
    }

    .supabase-live-status::before {
      content: "";
      width: 8px;
      height: 8px;
      border-radius: 50%;
      background: #20b486;
      box-shadow: 0 0 0 4px rgba(32, 180, 134, .14);
    }

    .supabase-live-status.error {
      border-color: #f1c7cc;
      background: #fff4f5;
      color: #bf3c48;
    }

    .supabase-live-status.error::before {
      background: #ef5b67;
      box-shadow: 0 0 0 4px rgba(239, 91, 103, .14);
    }

    .supabase-live-close {
      width: 34px;
      height: 34px;
      border: 1px solid #d8e0eb;
      border-radius: 10px;
      background: #ffffff;
      color: #26364d;
      cursor: pointer;
      font-size: 18px;
      font-weight: 900;
    }

    .supabase-live-summary {
      display: grid;
      grid-template-columns: repeat(5, minmax(0, 1fr));
      gap: 10px;
      padding: 12px 18px;
      border-bottom: 1px solid #e1e7ef;
      background: #f7f9fc;
    }

    .supabase-live-kpi {
      min-width: 0;
      padding: 11px 12px;
      border: 1px solid #dfe6ef;
      border-radius: 12px;
      background: #ffffff;
      box-shadow: 0 4px 13px rgba(25, 43, 70, .05);
    }

    .supabase-live-kpi span {
      display: block;
      color: #718096;
      font-size: 9px;
      font-weight: 800;
      text-transform: uppercase;
      letter-spacing: .04em;
    }

    .supabase-live-kpi strong {
      display: block;
      margin-top: 5px;
      overflow: hidden;
      text-overflow: ellipsis;
      color: #172237;
      font-size: 18px;
      white-space: nowrap;
    }

    .supabase-live-toolbar {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      padding: 10px 18px;
      border-bottom: 1px solid #e1e7ef;
      background: #ffffff;
    }

    .supabase-live-tabs {
      display: flex;
      gap: 6px;
      min-width: 0;
      overflow-x: auto;
      scrollbar-width: none;
    }

    .supabase-live-tabs::-webkit-scrollbar {
      display: none;
    }

    .supabase-live-tab {
      flex: 0 0 auto;
      min-height: 32px;
      padding: 0 11px;
      border: 1px solid #d8e0eb;
      border-radius: 9px;
      background: #ffffff;
      color: #526177;
      cursor: pointer;
      font-size: 9px;
      font-weight: 900;
    }

    .supabase-live-tab.active {
      border-color: rgba(58, 139, 253, .42);
      background: #eaf3ff;
      color: #1764c0;
    }

    .supabase-live-meta {
      flex: 0 0 auto;
      color: #6c7a8f;
      font-size: 9px;
      font-weight: 800;
      white-space: nowrap;
    }

    .supabase-live-table-wrap {
      min-height: 0;
      overflow: auto;
      background: #ffffff;
    }

    .supabase-live-table {
      width: 100%;
      min-width: 900px;
      border-collapse: separate;
      border-spacing: 0;
      font-size: 10px;
    }

    .supabase-live-table th,
    .supabase-live-table td {
      padding: 9px 10px;
      border-right: 1px solid #e6ebf2;
      border-bottom: 1px solid #e6ebf2;
      text-align: left;
      vertical-align: top;
      white-space: nowrap;
    }

    .supabase-live-table th {
      position: sticky;
      top: 0;
      z-index: 2;
      background: #f4f7fb;
      color: #43536a;
      font-size: 9px;
      font-weight: 900;
      text-transform: uppercase;
      letter-spacing: .035em;
    }

    .supabase-live-table td {
      color: #26364d;
      background: #ffffff;
    }

    .supabase-live-table tbody tr:hover td {
      background: #f8fbff;
    }

    .supabase-live-empty {
      display: grid;
      place-items: center;
      min-height: 280px;
      padding: 30px;
      color: #718096;
      text-align: center;
      font-size: 11px;
      line-height: 1.6;
    }

    .supabase-live-money {
      color: #0f6f55;
      font-weight: 900;
    }

    @media (max-width: 900px) {
      .supabase-live-panel {
        width: 100vw;
      }

      .supabase-live-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
      }

      .supabase-live-toolbar {
        align-items: flex-start;
        flex-direction: column;
      }

      .supabase-live-meta {
        white-space: normal;
      }
    }


    /* =========================================================
       CABECERA FINAL: CONTROLES ORDENADOS Y SIN SUPERPOSICIONES
       ========================================================= */
    .topbar {
      grid-template-columns: 112px minmax(0, 1fr) auto !important;
      min-width: 0 !important;
      padding: 0 8px 0 0 !important;
      column-gap: 0 !important;
      overflow: hidden !important;
    }

    .brand {
      width: 112px !important;
      min-width: 112px !important;
      padding: 6px 8px !important;
    }

    .brand-logo {
      width: 96px !important;
      max-height: 42px !important;
    }

    .toolbar {
      min-width: 0 !important;
      height: 100% !important;
      gap: 6px !important;
      padding: 0 10px !important;
      overflow-x: auto !important;
      overflow-y: hidden !important;
      scrollbar-width: none !important;
    }

    .toolbar::-webkit-scrollbar {
      display: none !important;
    }

    .toolbar-group {
      gap: 5px !important;
      flex: 0 0 auto !important;
    }

    .toolbar-divider {
      margin: 0 2px !important;
      height: 26px !important;
    }

    .toolbar .tool-button {
      min-width: 38px !important;
      min-height: 38px !important;
      padding: 0 11px !important;
      border-radius: 10px !important;
    }

    .speed-control {
      flex: 0 0 auto !important;
      height: 38px !important;
      min-width: 104px !important;
      padding: 0 10px !important;
    }

    .top-actions {
      grid-column: 3 !important;
      width: auto !important;
      min-width: 0 !important;
      height: 100% !important;
      display: flex !important;
      align-items: center !important;
      justify-content: flex-end !important;
      gap: 7px !important;
      padding: 0 2px 0 8px !important;
      border-left: 1px solid #e1e7ef !important;
      overflow: visible !important;
    }

    .action-cluster {
      display: flex !important;
      align-items: center !important;
      gap: 4px !important;
      flex: 0 0 auto !important;
      padding: 4px !important;
      border: 1px solid #dce4ee !important;
      border-radius: 12px !important;
      background: #f7f9fc !important;
      box-shadow: inset 0 1px 0 rgba(255, 255, 255, .75) !important;
    }

    .action-cluster-data {
      background: #f2f7ff !important;
      border-color: #d4e2f5 !important;
    }

    .top-actions .tool-button {
      width: auto !important;
      min-width: 38px !important;
      min-height: 38px !important;
      padding: 0 10px !important;
      border-radius: 9px !important;
      box-shadow: none !important;
    }

    .top-actions .action-icon {
      display: inline-grid !important;
      place-items: center !important;
      min-width: 15px !important;
      font-size: 13px !important;
    }

    .live-data-button {
      color: #155fae !important;
      background: #ffffff !important;
    }

    .delete-data-button {
      color: #b63845 !important;
      background: #fff8f8 !important;
    }

    @media (max-width: 1500px) {
      .topbar {
        grid-template-columns: 96px minmax(0, 1fr) auto !important;
      }

      .brand {
        width: 96px !important;
        min-width: 96px !important;
      }

      .brand-logo {
        width: 82px !important;
      }

      #connectBtn,
      #deleteBtn {
        width: 38px !important;
        padding: 0 !important;
      }

      #connectBtn .label,
      #deleteBtn .label,
      .top-actions .action-label {
        display: none !important;
      }

      .top-actions .tool-button {
        width: 38px !important;
        padding: 0 !important;
      }

      .speed-control {
        min-width: 88px !important;
      }

      .speed-control span {
        display: none !important;
      }
    }

    @media (max-width: 1180px) {
      .topbar {
        grid-template-columns: 84px minmax(0, 1fr) auto !important;
      }

      .brand {
        width: 84px !important;
        min-width: 84px !important;
        padding: 5px !important;
      }

      .brand-logo {
        width: 72px !important;
      }

      .toolbar {
        padding: 0 6px !important;
        gap: 4px !important;
      }

      .toolbar .tool-button {
        min-width: 36px !important;
        min-height: 36px !important;
        padding: 0 9px !important;
      }

      .toolbar-divider {
        display: none !important;
      }

      .speed-control {
        height: 36px !important;
        min-width: 72px !important;
        padding: 0 6px !important;
      }

      .top-actions {
        gap: 4px !important;
        padding-left: 5px !important;
      }

      .action-cluster {
        gap: 3px !important;
        padding: 3px !important;
        border-radius: 10px !important;
      }

      .top-actions .tool-button {
        width: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
      }
    }

    @media (max-width: 980px) {
      .toolbar .tool-button .label {
        display: none !important;
      }

      .toolbar .tool-button {
        width: 36px !important;
        padding: 0 !important;
      }

      .top-actions {
        display: flex !important;
      }
    }

    @media (max-width: 760px) {
      .topbar {
        grid-template-columns: 72px minmax(0, 1fr) !important;
        padding-right: 4px !important;
      }

      .brand {
        width: 72px !important;
        min-width: 72px !important;
      }

      .brand-logo {
        width: 62px !important;
      }

      .top-actions {
        display: none !important;
      }

      .toolbar {
        grid-column: 2 !important;
      }
    }


    /* ===== HERRAMIENTAS LEGIBLES Y SIN SUPERPOSICIONES ===== */
    .topbar {
      grid-template-columns: 98px minmax(0, 1fr) auto !important;
      overflow: visible !important;
    }

    .toolbar {
      min-width: 0 !important;
      overflow-x: auto !important;
      overflow-y: hidden !important;
      scrollbar-width: none !important;
    }

    .toolbar::-webkit-scrollbar {
      display: none !important;
    }

    .top-actions {
      position: relative !important;
      display: flex !important;
      align-items: center !important;
      justify-content: flex-end !important;
      width: auto !important;
      min-width: 154px !important;
      height: 100% !important;
      padding: 0 8px !important;
      border-left: 1px solid #e1e7ef !important;
      overflow: visible !important;
    }

    .tools-menu-wrap {
      position: relative;
      display: flex;
      align-items: center;
    }

    .tools-menu-trigger {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      min-width: 138px;
      min-height: 40px;
      padding: 0 13px;
      border: 1px solid #cfd9e7;
      border-radius: 11px;
      background: #ffffff;
      color: #22324a;
      box-shadow: 0 4px 14px rgba(31, 49, 75, .08);
      cursor: pointer;
      font: 900 10px/1 system-ui, sans-serif;
    }

    .tools-menu-trigger:hover,
    .tools-menu-trigger[aria-expanded="true"] {
      border-color: #8fb8ee;
      background: #f4f8ff;
      color: #155fae;
    }

    .tools-menu-trigger-icon {
      font-size: 15px;
    }

    .tools-menu-chevron {
      margin-left: auto;
      font-size: 10px;
      transition: transform .18s ease;
    }

    .tools-menu-trigger[aria-expanded="true"] .tools-menu-chevron {
      transform: rotate(180deg);
    }

    .tools-menu {
      position: absolute;
      top: calc(100% + 8px);
      right: 0;
      z-index: 500;
      width: 310px;
      max-height: min(520px, calc(100vh - 90px));
      overflow-y: auto;
      padding: 9px;
      border: 1px solid #d8e1ed;
      border-radius: 14px;
      background: #ffffff;
      box-shadow: 0 22px 60px rgba(19, 34, 57, .24);
      opacity: 0;
      visibility: hidden;
      transform: translateY(-6px);
      pointer-events: none;
      transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
    }

    .tools-menu.open {
      opacity: 1;
      visibility: visible;
      transform: translateY(0);
      pointer-events: auto;
    }

    .tools-menu-heading {
      padding: 7px 9px 5px;
      color: #7b8799;
      font-size: 9px;
      font-weight: 900;
      letter-spacing: .08em;
      text-transform: uppercase;
    }

    .tools-menu-separator {
      height: 1px;
      margin: 7px 4px;
      background: #e6ebf2;
    }

    .tools-menu-item {
      width: 100%;
      display: grid;
      grid-template-columns: 34px minmax(0, 1fr);
      gap: 10px;
      align-items: center;
      padding: 10px;
      border: 0;
      border-radius: 10px;
      background: transparent;
      color: #26364d;
      cursor: pointer;
      text-align: left;
    }

    .tools-menu-item:hover,
    .tools-menu-item:focus-visible {
      outline: none;
      background: #f2f6fb;
    }

    .tools-menu-icon {
      display: grid;
      place-items: center;
      width: 34px;
      height: 34px;
      border: 1px solid #dbe4ef;
      border-radius: 9px;
      background: #ffffff;
      font-size: 15px;
    }

    .tools-menu-item strong,
    .tools-menu-item small {
      display: block;
    }

    .tools-menu-item strong {
      color: #22324a;
      font-size: 11px;
      line-height: 1.3;
    }

    .tools-menu-item small {
      margin-top: 2px;
      color: #758398;
      font-size: 9px;
      line-height: 1.35;
    }

    .tools-menu-item-danger strong {
      color: #b52f3e;
    }

    .tools-menu-item-danger .tools-menu-icon {
      border-color: #f2ccd1;
      background: #fff6f7;
      color: #c23b49;
    }

    /* ===== MODAL DE BORRADO ===== */
    .delete-data-overlay {
      position: fixed;
      inset: 0;
      z-index: 700;
      display: none;
      place-items: center;
      padding: 20px;
      background: rgba(10, 20, 36, .60);
      backdrop-filter: blur(5px);
    }

    .delete-data-overlay.open {
      display: grid;
    }

    .delete-data-dialog {
      width: min(540px, 96vw);
      overflow: hidden;
      border: 1px solid #dce3ed;
      border-radius: 17px;
      background: #ffffff;
      box-shadow: 0 30px 90px rgba(4, 15, 32, .38);
    }

    .delete-data-header {
      display: flex;
      align-items: flex-start;
      justify-content: space-between;
      gap: 16px;
      padding: 20px 20px 16px;
      border-bottom: 1px solid #e7ebf1;
    }

    .delete-data-kicker {
      display: block;
      margin-bottom: 5px;
      color: #be3e4c;
      font-size: 9px;
      font-weight: 900;
      letter-spacing: .08em;
      text-transform: uppercase;
    }

    .delete-data-header h3 {
      margin: 0;
      color: #19283e;
      font-size: 18px;
    }

    .delete-data-header p {
      margin: 6px 0 0;
      color: #69778c;
      font-size: 10px;
      line-height: 1.55;
    }

    .delete-data-close {
      flex: 0 0 auto;
      width: 34px;
      height: 34px;
      border: 1px solid #d9e0ea;
      border-radius: 10px;
      background: #ffffff;
      color: #34445b;
      cursor: pointer;
      font-size: 18px;
    }

    .delete-data-warning {
      margin: 16px 20px 4px;
      padding: 12px 13px;
      border: 1px solid #f0c5ca;
      border-radius: 10px;
      background: #fff5f6;
      color: #8c2d39;
      font-size: 10px;
      line-height: 1.5;
    }

    .delete-data-field {
      display: block;
      margin: 14px 20px 0;
    }

    .delete-data-field > span {
      display: block;
      margin-bottom: 6px;
      color: #33435a;
      font-size: 10px;
      font-weight: 900;
    }

    .delete-data-field input {
      width: 100%;
      height: 40px;
      padding: 0 12px;
      border: 1px solid #cfd8e5;
      border-radius: 10px;
      background: #ffffff;
      color: #18283f;
      font: 600 11px/1 system-ui, sans-serif;
      outline: none;
    }

    .delete-data-field input:focus {
      border-color: #5d9bea;
      box-shadow: 0 0 0 3px rgba(57, 130, 222, .14);
    }

    .delete-data-field small {
      display: block;
      margin-top: 5px;
      color: #78869a;
      font-size: 9px;
    }

    .delete-data-remember {
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 12px 20px 0;
      color: #526177;
      font-size: 9px;
      font-weight: 700;
    }

    .delete-data-error {
      margin: 12px 20px 0;
      padding: 10px 12px;
      border: 1px solid #efc2c7;
      border-radius: 9px;
      background: #fff3f4;
      color: #a52f3b;
      font-size: 10px;
      line-height: 1.5;
      white-space: pre-wrap;
    }

    .delete-data-actions {
      display: flex;
      justify-content: flex-end;
      gap: 9px;
      margin-top: 18px;
      padding: 14px 20px 18px;
      border-top: 1px solid #e7ebf1;
      background: #f8fafc;
    }

    .delete-data-cancel,
    .delete-data-confirm {
      min-height: 38px;
      padding: 0 14px;
      border-radius: 10px;
      cursor: pointer;
      font: 900 10px/1 system-ui, sans-serif;
    }

    .delete-data-cancel {
      border: 1px solid #d3dbe6;
      background: #ffffff;
      color: #34445b;
    }

    .delete-data-confirm {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 8px;
      border: 1px solid #bc3442;
      background: #c93d4b;
      color: #ffffff;
    }

    .delete-data-confirm:disabled {
      cursor: wait;
      opacity: .68;
    }

    .delete-data-spinner {
      display: none;
      width: 13px;
      height: 13px;
      border: 2px solid rgba(255,255,255,.45);
      border-top-color: #ffffff;
      border-radius: 50%;
      animation: delete-spin .7s linear infinite;
    }

    .delete-data-confirm.loading .delete-data-spinner {
      display: inline-block;
    }

    @keyframes delete-spin {
      to { transform: rotate(360deg); }
    }

    @media (max-width: 900px) {
      .topbar {
        grid-template-columns: 78px minmax(0, 1fr) auto !important;
      }

      .top-actions {
        min-width: 50px !important;
        padding: 0 5px !important;
      }

      .tools-menu-trigger {
        min-width: 42px;
        width: 42px;
        padding: 0;
      }

      .tools-menu-trigger > span:nth-child(2),
      .tools-menu-chevron {
        display: none;
      }

      .tools-menu {
        right: -2px;
        width: min(310px, calc(100vw - 20px));
      }
    }
