/* =============================================================================
   UniControl Lab - Estilo compartido de herramientas de ingeniería
   (FSM Designer, Logic Designer)

   Traslada la identidad del sitio institucional (site.css v2.2 "Titanium &
   Control Console") a una interfaz de aplicación de pantalla completa:
   - Lienzo claro "titanio", marca azul #0052cc para acciones.
   - Cian #00c6d7 solo sobre superficies oscuras (consola Insight, editor de
     ecuaciones, preset "Consola SCADA" del lienzo).
   - Inter para lo que se lee, JetBrains Mono para lo que se "mide"
     (tags, IDs, ecuaciones, rótulos técnicos).
   - Sin emojis: iconografía Lucide local.
   Tokens idénticos a :root de site.css; no introducir valores nuevos salvo los
   semánticos de herramienta declarados abajo (--danger, --amber-*).
   ============================================================================= */

:root {
  --bg-titanium: #f8fafc;
  --bg-white: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-panel-light: #e2e8f0;

  --scada-bg: #090e17;
  --scada-surface: #0f172a;
  --scada-surface-elevated: #1e293b;
  --scada-border: rgba(255, 255, 255, 0.1);
  --scada-border-active: rgba(0, 198, 215, 0.4);

  --brand-blue: #0052cc;
  --brand-blue-hover: #0041a8;
  --brand-blue-soft: rgba(0, 82, 204, 0.08);
  --brand-blue-ring: rgba(0, 82, 204, 0.18);

  --brand-cyan: #00c6d7;
  --brand-cyan-soft: rgba(0, 198, 215, 0.12);

  --led-run: #10b981;
  --led-run-soft: rgba(16, 185, 129, 0.15);
  --led-run-glow: 0 0 10px rgba(16, 185, 129, 0.6);
  --led-warning: #f59e0b;

  /* Semánticos propios de herramienta (acciones destructivas y estado ANY) */
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.08);
  --amber-text: #b45309;
  --amber-soft: #fef3c7;
  --amber-border: #fcd34d;

  --text-title: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --text-white: #f8fafc;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --border-light: #e2e8f0;
  --border-card: #cbd5e1;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.08);
  --shadow-scada: 0 20px 50px rgba(9, 14, 23, 0.4);

  --transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);

  --topbar-h: 60px;
}

/* -----------------------------------------------------------------------------
   Base de aplicación (pantalla completa, sin scroll de página)
   ----------------------------------------------------------------------------- */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-titanium);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  /* Sin ligaduras: en ecuaciones y tags ">=", "==", "!=" deben verse tal cual se escriben */
  font-variant-ligatures: none;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; font-variant-ligatures: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }

svg.lucide { flex-shrink: 0; }

::selection { background: var(--brand-blue-ring); }

/* Scrollbars finas y neutras */
* { scrollbar-width: thin; scrollbar-color: var(--border-card) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-card); border-radius: var(--radius-full); border: 2px solid transparent; background-clip: padding-box; }
*::-webkit-scrollbar-track { background: transparent; }

.mono { font-family: var(--font-mono); }

/* -----------------------------------------------------------------------------
   Barra superior
   ----------------------------------------------------------------------------- */
.lab-topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  z-index: 50;
}

.lab-brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  text-decoration: none;
  flex-shrink: 0;
}

.lab-brand img { height: 30px; display: block; }

.lab-tool-id {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 0.9rem;
  border-left: 1px solid var(--border-light);
  line-height: 1.15;
  white-space: nowrap;
}

.lab-tool-id .lab-tool-kicker {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.lab-tool-id .lab-tool-name {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-title);
}

.lab-topbar-spacer { flex: 1; min-width: 0; }

.lab-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.lab-back-link:hover { color: var(--brand-blue); background: var(--brand-blue-soft); }

/* Consola "Co-Pilot Insight": bloque oscuro de identidad (como la consola SCADA del hero) */
.lab-insight {
  flex: 1 1 auto;
  max-width: 780px;
  min-width: 0;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem 0 0.85rem;
  background: var(--scada-bg);
  border: 1px solid var(--scada-border);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(9, 14, 23, 0.18);
  color: var(--text-light);
}

.lab-insight-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-white);
  white-space: nowrap;
}

.led-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--led-run);
  box-shadow: var(--led-run-glow);
  flex-shrink: 0;
}

.led-dot.led-idle { background: var(--text-light); box-shadow: none; }

.lab-insight-auto {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  color: var(--led-run);
  background: var(--led-run-soft);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.lab-insight-text {
  flex: 1;
  min-width: 0;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #cbd5e1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  cursor: help;
}

.lab-insight-text .insight-note { color: var(--text-light); font-style: italic; }
.lab-insight-text .insight-error { color: #fca5a5; font-style: italic; }

.lab-insight-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.lab-insight-nav {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  padding: 0.1rem 0.2rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--scada-border);
  background: var(--scada-surface);
}

.lab-insight-nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-light);
  transition: var(--transition);
}

.lab-insight-nav button:hover { color: var(--brand-cyan); background: var(--scada-surface-elevated); }

.lab-insight-nav span {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  min-width: 38px;
  text-align: center;
  color: var(--brand-cyan);
}

.lab-insight-tip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  height: 28px;
  padding: 0 0.6rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--scada-border-active);
  background: var(--brand-cyan-soft);
  color: var(--brand-cyan);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  transition: var(--transition);
}

.lab-insight-tip:hover:not(:disabled) { background: rgba(0, 198, 215, 0.22); }
.lab-insight-tip:disabled { opacity: 0.5; }

.lab-insight-auto-chk {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-light);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.lab-insight-auto-chk input { accent-color: var(--brand-cyan); margin: 0; cursor: pointer; }

/* -----------------------------------------------------------------------------
   Contenedor principal, barra lateral y separadores
   ----------------------------------------------------------------------------- */
#app-container {
  display: flex;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

#sidebar {
  width: 360px;
  min-width: 280px;
  max-width: 600px;
  background: var(--bg-white);
  padding: 1rem 1rem 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-light);
  z-index: 20;
}

#resizer {
  width: 5px;
  margin-left: -3px;
  background: transparent;
  cursor: col-resize;
  flex-shrink: 0;
  z-index: 25;
  position: relative;
  transition: background 0.2s;
}

#resizer:hover, #resizer:active { background: var(--brand-blue); }

#workspace {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
  background: var(--bg-titanium);
  z-index: 10;
  display: flex;
  min-width: 0;
}

/* Bloques de la barra lateral */
.lab-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.lab-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.35rem 0 0.55rem;
}

#sidebar h3, .lab-section-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-title);
}

#sidebar h3 svg.lucide, .lab-section-title svg.lucide { color: var(--brand-blue); }

.lab-section + .lab-section { margin-top: 1.1rem; }

.lab-grid { display: grid; gap: 0.4rem; }
.lab-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.lab-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.lab-row { display: flex; gap: 0.4rem; align-items: center; }
.lab-row > .grow { flex: 1; min-width: 0; }
.span-all { grid-column: 1 / -1; }

/* -----------------------------------------------------------------------------
   Botones de herramienta
   ----------------------------------------------------------------------------- */
.tbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 32px;
  padding: 0 0.7rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-body);
  font-size: 0.78rem;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1;
  transition: var(--transition);
}

.tbtn svg.lucide { width: 15px; height: 15px; color: var(--brand-blue); transition: var(--transition); }

.tbtn:hover:not(:disabled) {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  background: var(--brand-blue-soft);
}

.tbtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--brand-blue-ring); }
.tbtn:disabled { opacity: 0.4; }

.tbtn-primary { background: var(--brand-blue); border-color: var(--brand-blue); color: #fff; font-weight: 600; }
.tbtn-primary svg.lucide { color: #fff; }
.tbtn-primary:hover:not(:disabled) { background: var(--brand-blue-hover); border-color: var(--brand-blue-hover); color: #fff; }

.tbtn-dark { background: var(--scada-surface); border-color: var(--scada-surface); color: var(--text-white); font-weight: 600; }
.tbtn-dark svg.lucide { color: var(--brand-cyan); }
.tbtn-dark:hover:not(:disabled) { background: var(--scada-surface-elevated); border-color: var(--scada-surface-elevated); color: #fff; }

.tbtn-danger svg.lucide { color: var(--danger); }
.tbtn-danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.tbtn-danger:hover:not(:disabled) svg.lucide { color: var(--danger); }

.tbtn-run { background: var(--led-run); border-color: var(--led-run); color: #fff; font-weight: 600; }
.tbtn-run svg.lucide { color: #fff; }
.tbtn-run:hover:not(:disabled) { background: #059669; border-color: #059669; color: #fff; }

.tbtn-stop { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.tbtn-stop svg.lucide { color: #fff; }
.tbtn-stop:hover:not(:disabled) { background: #991b1b; border-color: #991b1b; color: #fff; }

.tbtn-on { background: var(--brand-blue-soft); border-color: var(--brand-blue); color: var(--brand-blue); font-weight: 600; }

.tbtn-sm { height: 26px; padding: 0 0.5rem; font-size: 0.72rem; }
.tbtn-sm svg.lucide { width: 13px; height: 13px; }

.tbtn-icon { width: 32px; padding: 0; flex-shrink: 0; }
.tbtn-icon.tbtn-sm { width: 26px; }

.tbtn-mono { font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; }

/* Botones de fila (tablas) */
.row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin-left: 2px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  transition: var(--transition);
  vertical-align: middle;
}

.row-btn svg.lucide { width: 14px; height: 14px; }
.row-btn:hover:not(:disabled) { color: var(--brand-blue); background: var(--brand-blue-soft); border-color: rgba(0, 82, 204, 0.25); }
.row-btn.danger:hover:not(:disabled) { color: var(--danger); background: var(--danger-soft); border-color: rgba(185, 28, 28, 0.25); }
.row-btn:disabled { opacity: 0.3; }

.row-btn-text { width: auto; padding: 0 0.55rem; gap: 0.3rem; font-size: 0.72rem; font-weight: 600; color: var(--brand-blue); border-color: var(--border-light); background: var(--bg-white); }

/* -----------------------------------------------------------------------------
   Campos
   ----------------------------------------------------------------------------- */
.lab-input,
#sidebar input[type="text"],
#sidebar input[type="number"],
.modal input[type="text"],
.modal input[type="number"],
.modal input[type="password"],
.modal select,
.form-group input,
.form-group select {
  height: 32px;
  min-width: 0;
  padding: 0 0.6rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-title);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lab-input::placeholder, #sidebar input::placeholder, .modal input::placeholder, textarea::placeholder {
  color: var(--text-light);
  font-family: var(--font-mono);
}

.lab-input:focus, #sidebar input:focus, .modal input:focus, .modal select:focus, .form-group input:focus, .form-group select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-blue-ring);
}

.project-title-input {
  flex: 1;
  height: 36px !important;
  font-family: var(--font-sans) !important;
  font-size: 0.9rem !important;
  font-weight: 600;
  color: var(--text-title) !important;
}

.project-title-input::placeholder { font-family: var(--font-sans) !important; font-weight: 400; }

.input-group { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; align-items: center; }
.input-group input { flex: 1; }

.chk-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-body);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

input[type="checkbox"] { accent-color: var(--brand-blue); }
input[type="range"] { accent-color: var(--brand-blue); margin: 0; padding: 0; height: 12px; }

/* -----------------------------------------------------------------------------
   Tablas
   ----------------------------------------------------------------------------- */
.lab-table,
#sidebar table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 0.5rem;
  text-align: left;
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.lab-table th, #sidebar th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border-light);
}

.lab-table td, #sidebar td {
  padding: 0.4rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-body);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.lab-table tr:last-child td, #sidebar tr:last-child td { border-bottom: none; }

.lab-table tbody tr, #sidebar tbody tr { transition: background 0.15s; }
.lab-table tbody tr:hover, #sidebar tbody tr:hover { background: var(--bg-titanium); }

#sidebar td:first-child { font-family: var(--font-mono); font-weight: 600; color: var(--text-title); }

tr.selected-row, tr.selected-row:hover {
  background: var(--brand-blue-soft) !important;
  box-shadow: inset 3px 0 0 var(--brand-blue);
}

tr.selected-row td { color: var(--text-title) !important; }

.cell-sub { font-size: 0.68rem; color: var(--text-muted); font-weight: 400; margin-top: 2px; }

.tag-any {
  display: inline-block;
  margin-left: 4px;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  background: var(--amber-soft);
  color: var(--amber-text);
  border: 1px solid var(--amber-border);
  font-family: var(--font-mono);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.tbtn-any { color: var(--amber-text); font-family: var(--font-mono); font-weight: 700; font-size: 0.68rem; }
.tbtn-any:hover:not(:disabled) { border-color: var(--amber-text); color: var(--amber-text); background: var(--amber-soft); }

/* Sliders de transición (FSM) */
.slider-group {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 3px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-muted);
}

/* -----------------------------------------------------------------------------
   Modales
   ----------------------------------------------------------------------------- */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 1999;
}

.modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-white);
  padding: 1.4rem 1.5rem 1.25rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 2px 6px rgba(15, 23, 42, 0.06);
  z-index: 2000;
  color: var(--text-body);
  max-height: 88vh;
  overflow-y: auto;
}

.modal h3 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0 0 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-title);
}

.modal h3 svg.lucide { width: 18px; height: 18px; color: var(--brand-blue); }

.modal h4 {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-title);
}

.modal h4 svg.lucide { width: 14px; height: 14px; color: var(--brand-blue); }

.modal p { line-height: 1.55; }

.modal-note {
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--text-body);
  background: var(--bg-titanium);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
}

.modal-note strong { color: var(--text-title); }

.modal-group-title {
  grid-column: 1 / -1;
  margin-top: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--brand-blue);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.modal-divider { border: 0; border-top: 1px solid var(--border-light); margin: 0.9rem 0; }

.form-group { margin-bottom: 0.9rem; }
.form-group.compact { margin-bottom: 0.5rem; }

.form-group label, .field-label {
  display: block;
  margin-bottom: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.form-group input, .form-group select { width: 100%; }

.color-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0;
  font-size: 0.8rem;
  color: var(--text-body);
}

.color-row input[type="color"] {
  width: 34px;
  height: 24px;
  padding: 2px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  cursor: pointer;
}

.preset-list { display: grid; gap: 0.4rem; margin-top: 0.4rem; }

.preset-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  text-align: left;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-body);
  transition: var(--transition);
}

.preset-btn:hover { border-color: var(--brand-blue); background: var(--brand-blue-soft); color: var(--brand-blue); }

.preset-swatch {
  display: inline-flex;
  width: 34px;
  height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border-card);
  overflow: hidden;
  flex-shrink: 0;
}

.preset-swatch i { flex: 1; }

.warning-text {
  font-size: 0.74rem;
  line-height: 1.55;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  margin-top: 1rem;
}

.warning-text strong { color: var(--amber-text); }

.settings-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.65rem 0.8rem;
  margin-bottom: 1rem;
  background: var(--bg-titanium);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
}

.settings-strip .inline-num { width: 64px !important; text-align: center; }

.inline-field { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--text-muted); font-size: 0.76rem; }

/* Lista de versiones */
.version-list {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  max-height: 260px;
  overflow-y: auto;
  background: var(--bg-white);
  margin-bottom: 0.5rem;
}

.version-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.8rem;
  border-bottom: 1px solid var(--border-light);
}

.version-item:last-child { border-bottom: none; }
.version-item:hover { background: var(--bg-titanium); }
.version-meta { flex: 1; min-width: 0; }
.version-title { font-weight: 600; font-size: 0.8rem; color: var(--text-title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-date { font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-muted); margin-top: 2px; }
.version-diff { font-family: var(--font-mono); font-size: 0.66rem; color: var(--brand-blue); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.version-actions { display: flex; gap: 0.35rem; flex-shrink: 0; }

.empty-note { padding: 1.1rem; color: var(--text-muted); text-align: center; font-size: 0.78rem; }

/* -----------------------------------------------------------------------------
   Panel UniCo-Pilot (chat lateral)
   ----------------------------------------------------------------------------- */
#copilot-panel {
  width: 360px;
  min-width: 300px;
  background: var(--bg-white);
  border-left: 1px solid var(--border-light);
  display: none;
  flex-direction: column;
  z-index: 15;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.05);
}

.cp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 0.9rem;
  background: var(--scada-bg);
  border-bottom: 1px solid var(--scada-border);
}

.cp-header h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-white);
}

.cp-header-btns { display: flex; gap: 0.15rem; }

.cp-header-btns button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-light);
  transition: var(--transition);
}

.cp-header-btns button svg.lucide { width: 15px; height: 15px; }
.cp-header-btns button:hover { color: var(--brand-cyan); background: var(--scada-surface-elevated); }

.cp-recommendation-box {
  margin: 0.75rem 0.75rem 0;
  padding: 0.75rem 0.85rem;
  background: var(--brand-blue-soft);
  border: 1px dashed rgba(0, 82, 204, 0.35);
  border-radius: var(--radius-md);
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-body);
}

.cp-recommendation-box strong { color: var(--text-title); }

.cp-recommendation-box button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.55rem;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--brand-blue);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  transition: var(--transition);
}

.cp-recommendation-box button svg.lucide { width: 14px; height: 14px; }
.cp-recommendation-box button:hover { background: var(--brand-blue-hover); }

.cp-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem;
  border-bottom: 1px solid var(--border-light);
}

.cp-quick-actions button {
  flex: 1 1 45%;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 30px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-body);
  font-size: 0.7rem;
  font-weight: 500;
  text-align: left;
  line-height: 1.2;
  transition: var(--transition);
}

.cp-quick-actions button svg.lucide { width: 13px; height: 13px; color: var(--brand-blue); }
.cp-quick-actions button:hover { border-color: var(--brand-blue); background: var(--brand-blue-soft); color: var(--brand-blue); }

.cp-chat {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  background: var(--bg-titanium);
}

.cp-msg {
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  line-height: 1.55;
  word-wrap: break-word;
  position: relative;
}

.cp-msg-user {
  background: var(--brand-blue);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  max-width: 85%;
}

.cp-msg-bot {
  background: var(--bg-white);
  color: var(--text-body);
  align-self: flex-start;
  border: 1px solid var(--border-light);
  border-bottom-left-radius: 3px;
  box-shadow: var(--shadow-sm);
  width: 100%;
}

.cp-msg p { margin: 0 0 0.5rem; }
.cp-msg p:last-child { margin: 0; }
.cp-msg strong { color: inherit; }

.cp-msg pre {
  background: var(--scada-surface);
  color: #e2e8f0;
  padding: 0.6rem 0.7rem;
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--scada-surface-elevated);
  font-size: 0.7rem;
}

.cp-msg code { font-family: var(--font-mono); font-size: 0.92em; color: var(--brand-blue-hover); background: var(--bg-subtle); padding: 0.05rem 0.25rem; border-radius: 4px; }
.cp-msg pre code { color: var(--brand-cyan); background: none; padding: 0; }
.cp-msg-user code { color: #fff; background: rgba(255, 255, 255, 0.18); }

.cp-apply-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.6rem;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--brand-blue);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  transition: var(--transition);
}

.cp-apply-btn svg.lucide { width: 15px; height: 15px; }
.cp-apply-btn:hover:not(:disabled) { background: var(--brand-blue-hover); }
.cp-apply-btn:disabled { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border-light); }
.cp-apply-btn.is-applied { background: var(--led-run-soft); color: #047857; border: 1px solid rgba(16, 185, 129, 0.35); }
.cp-apply-btn.cp-retry { width: auto; padding: 0 0.9rem; background: var(--bg-white); color: var(--brand-blue); border: 1px solid var(--border-card); }
.cp-apply-btn.cp-retry:hover { border-color: var(--brand-blue); background: var(--brand-blue-soft); }

.cp-error-title { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--danger); font-weight: 600; }

.cp-input-area {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.75rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-white);
}

.cp-input-area textarea {
  flex: 1;
  resize: none;
  height: 42px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-white);
  color: var(--text-title);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.4;
}

.cp-input-area button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--brand-blue);
  color: #fff;
  transition: var(--transition);
}

.cp-input-area button svg.lucide { width: 17px; height: 17px; }
.cp-input-area button:hover:not(:disabled) { background: var(--brand-blue-hover); }
.cp-input-area button:disabled { background: var(--bg-panel-light); color: var(--text-light); }

.typing-indicator {
  display: none;
  align-self: flex-start;
  margin: 0 0.9rem 0.6rem;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-full);
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--text-muted);
}

/* -----------------------------------------------------------------------------
   Utilidades de giro (estado "procesando")
   ----------------------------------------------------------------------------- */
@keyframes lab-spin { to { transform: rotate(360deg); } }
.spin { animation: lab-spin 1s linear infinite; }

/* -----------------------------------------------------------------------------
   Responsive: las herramientas son de escritorio; en pantallas chicas se
   simplifica la barra superior.
   ----------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .lab-insight-label .lab-insight-label-text, .lab-insight-auto-chk { display: none; }
  .lab-back-link span { display: none; }
}

@media (max-width: 700px) {
  .lab-insight { display: none !important; }
}

@media (max-width: 860px) {
  .lab-tool-id .lab-tool-kicker { display: none; }
  #sidebar { width: 300px; min-width: 240px; }
}
