* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --accent: #e67e22;
  --bg: #f8f9fa;
  --border: #dee2e6;
  --text: #333;
  --field-bg: #fff;
  --field-border: #5dade2;
  --section-visible: #27ae60;
  --section-hidden: #e74c3c;
}
body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: var(--text); height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: #e8ecef; }

/* ===== CABECERA ===== */
#app-header { background: white; border-bottom: 2px solid #eee; padding: 8px 20px; display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
#app-header .logo { height: 32px; }
#app-header h1 { font-size: 18px; font-weight: 700; color: #555; letter-spacing: -0.3px; }
#app-header h1 span { color: var(--accent); }

/* ===== BARRA DE HERRAMIENTAS ===== */
#toolbar { background: var(--primary); color: white; padding: 6px 16px; display: flex; align-items: center; gap: 10px; flex-shrink: 0; z-index: 100; flex-wrap: wrap; }
.file-btn { background: rgba(255,255,255,0.12); border: 1px dashed rgba(255,255,255,0.4); color: white; padding: 4px 11px; border-radius: 4px; cursor: pointer; font-size: 12px; display: flex; align-items: center; gap: 5px; transition: background 0.2s; position: relative; }
.file-btn:hover { background: rgba(255,255,255,0.22); }
/* El input va oculto: si cubriera el botón, el navegador mostraría su cursor por
   defecto y su tooltip nativo ("No se ha seleccionado ningún fichero"). Al clicar el
   label se dispara igualmente el diálogo de archivo. */
.file-btn input[type="file"] { display: none; }
.file-btn.loaded { background: rgba(39,174,96,0.35); border-color: rgba(39,174,96,0.7); border-style: solid; }
.file-btn.disabled { opacity: 0.4; cursor: not-allowed; }
.file-btn.disabled:hover { background: rgba(255,255,255,0.12); }
.toolbar-sep { width: 1px; height: 20px; background: rgba(255,255,255,0.25); }
.toggle-btn { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); color: white; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; transition: all 0.2s; }
.toggle-btn:hover { background: rgba(255,255,255,0.18); }
.toggle-btn.active { background: rgba(255,255,255,0.3); border-color: white; font-weight: 600; }
a.toggle-btn, a.dl-link { text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.toolbar-search { display: flex; align-items: center; gap: 4px; margin-left: 6px; }
.toolbar-search input { padding: 3px 8px; border: 1px solid rgba(255,255,255,0.3); border-radius: 3px; font-size: 12px; background: rgba(255,255,255,0.12); color: white; width: 140px; }
.toolbar-search input::placeholder { color: rgba(255,255,255,0.5); }
.toolbar-search input:focus { outline: none; background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.6); }
.toolbar-search .search-info { font-size: 11px; color: rgba(255,255,255,0.6); }

/* ===== DISEÑO PRINCIPAL ===== */
#main-area { display: flex; flex: 1; overflow: hidden; }

/* Panel lateral de variables */
#var-panel { width: 280px; min-width: 200px; background: var(--bg); border-right: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0; }
#var-panel .panel-title { padding: 7px 12px; background: #34495e; color: white; font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
#var-panel .panel-title .count { font-weight: 400; opacity: 0.7; }
.var-panel-actions { padding: 6px; display: flex; gap: 4px; flex-shrink: 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.var-panel-actions button { flex: 1 0 30%; padding: 4px 6px; font-size: 11px; border: 1px solid #ccc; border-radius: 3px; cursor: pointer; background: white; color: var(--text); }
.var-panel-actions button:hover { background: #eee; }
.var-panel-actions button.accent { background: var(--accent); color: white; border-color: var(--accent); }
.var-panel-actions button.accent:hover { background: #d35400; }
#var-tables { flex: 1; overflow-y: auto; padding: 6px; }
.vartable { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: 11px; table-layout: fixed; }
.vartable caption { text-align: left; font-weight: 700; font-size: 11px; padding: 4px 6px; background: #eaf2f8; color: var(--primary); border-radius: 3px 3px 0 0; }
.vartable th { background: #f0f0f0; padding: 3px 6px; text-align: left; font-weight: 600; border: 1px solid #ddd; }
.vartable td { padding: 3px 6px; border: 1px solid #ddd; vertical-align: middle; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vartable td.vname { font-family: 'Consolas', monospace; font-size: 10px; color: #555; }
.vartable td.vval { font-size: 10px; }
.vartable tr.has-value td { background: #fef9e7; }
.vartable tr.highlight td { background: #d5f5e3 !important; font-weight: 700; }
.vartable .th-name { width: 55%; }
.vartable .th-val { width: 45%; }

/* Ruta de decisión */
#decision-path { padding: 6px; border-bottom: 1px solid var(--border); font-size: 11px; background: #f0f0f0; flex-shrink: 0; }
#decision-path .path-title { font-weight: 700; color: var(--primary); margin-bottom: 3px; }
#decision-path .path-stat { color: #555; }
#decision-path .path-stat .vis { color: var(--section-visible); font-weight: 700; }
#decision-path .path-stat .hid { color: var(--section-hidden); font-weight: 700; }

/* Campos obligatorios */
.g-field.required:not(.filled) input, .g-field.required:not(.filled) select, .g-field.required:not(.filled) textarea { border-color: #e74c3c; }
.g-field.required.filled input, .g-field.required.filled select, .g-field.required.filled textarea { border-color: var(--field-border); }
.g-field.required::after { content: '*'; color: #e74c3c; font-weight: 700; font-size: 14px; margin-left: 1px; }
.g-field.g-field-missing input, .g-field.g-field-missing textarea, .g-field.g-field-missing select { border: 2px solid #c0392b; background: #fdecea; }
.g-field.g-field-missing::before { content: '⚠'; color: #c0392b; font-weight: 700; margin-right: 3px; }
.g-toggle.required::after { content: '*'; color: #e74c3c; font-weight: 700; font-size: 14px; margin-left: 1px; }
.g-toggle.required.filled::after { color: #27ae60; }

/* ===== ÁREA DEL DOCUMENTO ===== */
#doc-area { flex: 1; overflow-y: auto; padding: 16px; }
#doc-container { max-width: 860px; margin: 0 auto; background: white; border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 2px 12px rgba(0,0,0,0.08); padding: 28px 36px; min-height: 80vh; height: fit-content; width: 100%; }

/* Pantalla de bienvenida */
#welcome { text-align: center; padding: 50px 20px; color: #888; }
#welcome h2 { color: #555; margin-bottom: 10px; font-size: 20px; }
#welcome p { font-size: 13px; line-height: 1.8; }
#welcome .drop-zone { margin-top: 20px; padding: 35px; border: 2px dashed #ccc; border-radius: 10px; }
body.drag-over #welcome .drop-zone { border-color: var(--primary-light); background: rgba(41,128,185,0.05); }

#doc-content { display: none; line-height: 1.7; font-size: 14px; }
#doc-content h1 { font-size: 20px; margin: 18px 0 8px; color: var(--primary); }
#doc-content h2 { font-size: 17px; margin: 16px 0 6px; color: #2c3e50; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; }
#doc-content h3 { font-size: 15px; margin: 14px 0 4px; color: #34495e; text-transform: uppercase; }
#doc-content p { margin: 5px 0; }
#doc-content ul, #doc-content ol { margin: 5px 0 5px 22px; }
#doc-content li { margin: 3px 0; }
#doc-content hr { border: none; border-top: 1px solid #ccc; margin: 14px 0; }
#doc-content strong { font-weight: 700; }
#doc-content em { font-style: italic; }
#doc-content blockquote { border-left: 3px solid var(--primary-light); padding: 4px 12px; margin: 8px 0; background: #f7fbff; }
#doc-content img { max-width: 48px; height: auto; vertical-align: middle; }
#doc-content .g-var { font-weight: 600; color: #6c3483; }
#doc-content .g-var.g-var-empty { color: #999; font-style: italic; font-weight: 400; }
#doc-content .g-invisible { display: none; }
.debug-on #doc-content .g-invisible { display: revert; outline: 2px dashed #d68910; outline-offset: 1px; background: #fef9e7; color: #7d6608; opacity: 0.9; padding: 4px 8px; margin: 4px 0; }
.debug-on #doc-content table.g-invisible { display: block; border: none; }
.debug-on #doc-content table.g-invisible tbody,
.debug-on #doc-content table.g-invisible thead,
.debug-on #doc-content table.g-invisible tr { display: contents; }
.debug-on #doc-content table.g-invisible th,
.debug-on #doc-content table.g-invisible td { display: inline; border: none !important; padding: 0 2px; background: transparent !important; font-weight: normal; }
.debug-on #doc-content table.g-invisible .g-field { display: inline-flex !important; width: auto !important; min-width: 80px; vertical-align: middle; margin: 0 2px; }
.debug-on #doc-content table.g-invisible .g-field > input,
.debug-on #doc-content table.g-invisible .g-field > textarea,
.debug-on #doc-content table.g-invisible .g-field > select { width: auto; min-width: 80px; }
.debug-on #doc-content tr.g-invisible td,
.debug-on #doc-content tr.g-invisible th { background: #fef9e7 !important; color: #7d6608; }

#doc-content table { border-collapse: collapse; width: 100%; margin: 8px 0; table-layout: fixed; }
#doc-content th, #doc-content td { border: 1px solid #bbb; padding: 7px 12px; font-size: 13px; vertical-align: middle; overflow: hidden; word-wrap: break-word; }
#doc-content th { background: #eaf2f8; font-weight: 600; }
#doc-content td:first-child { font-weight: 500; background: #fafafa; }

/* Controles de formulario */
.g-field { display: inline-block; vertical-align: middle; margin: 1px 2px; }
.g-field input[type="text"] { border: 1px solid var(--field-border); border-radius: 3px; padding: 3px 8px; font-size: 13px; font-family: inherit; background: var(--field-bg); color: var(--text); min-width: 160px; }
.g-field textarea { border: 1px solid var(--field-border); border-radius: 3px; padding: 3px 8px; font-size: 13px; font-family: inherit; background: var(--field-bg); color: var(--text); min-width: 200px; width: 300px; min-height: 28px; height: 28px; max-height: 200px; resize: both; overflow: auto; vertical-align: middle; line-height: 1.4; }
.g-field input[type="date"] { border: 1px solid var(--field-border); border-radius: 3px; padding: 3px 8px; font-size: 13px; font-family: inherit; background: var(--field-bg); color: var(--text); min-width: 140px; }
.g-field select { border: 1px solid var(--field-border); border-radius: 3px; padding: 3px 8px; font-size: 13px; font-family: inherit; background: var(--field-bg); color: var(--text); min-width: 160px; cursor: pointer; }
.g-field input:focus, .g-field select:focus, .g-field textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(26,82,118,0.15); }
.g-field input:disabled, .g-field select:disabled, .g-field textarea:disabled { background: #f0f0f0; color: #666; border-color: #ccc; cursor: default; resize: none; }
.g-field .g-suffix { font-size: 12px; color: #777; }
.g-field.readonly input, .g-field.readonly select, .g-field.readonly textarea { background: #fef9e7; border-color: #f0b429; font-weight: 600; }
/* Layout flex en celdas: el input crece y el sufijo €/% y el * van al lado, NO encima.
   Importante: el textarea base tiene width:300px + min-width:200px + resize:both;
   en celda lo forzamos a width:auto + min-width:0 + resize:none para que SI se encoja. */
#doc-content td .g-field { display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0; margin: 0; }
#doc-content td .g-field > input,
#doc-content td .g-field > select,
#doc-content td .g-field > textarea {
  flex: 1 1 0%;
  width: auto;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
#doc-content td .g-field > textarea { resize: none; }
#doc-content td .g-field .g-suffix { flex-shrink: 0; margin: 0; line-height: 1; }
#doc-content td .g-field.required::after { flex-shrink: 0; line-height: 1; margin-left: 2px; }
#doc-content td .g-toggle { display: inline-flex; align-items: center; }
#doc-content td .g-toggle.required::after { line-height: 1; margin-left: 4px; }

/* Wrapper para .g-field + texto sufijo literal del markdown del usuario
   (ej: "{{personalized | reference: X}} €"). El cliente lo crea autom&aacute;ticamente
   al cargar el doc. Inline-flex para que el conjunto ocupe una sola l&iacute;nea. */
#doc-content td .g-cell-row { display: flex; align-items: center; gap: 4px; width: 100%; min-width: 0; }
#doc-content td .g-cell-row > .g-field { flex: 1 1 0%; width: auto; }
#doc-content td .g-cell-row > .g-cell-suffix { flex-shrink: 0; font-size: 13px; color: #555; white-space: nowrap; }

/* Toggle */
.g-toggle { display: inline-flex; align-items: center; gap: 6px; vertical-align: middle; margin: 1px 2px; cursor: pointer; }
.g-toggle input[type="checkbox"] { display: none; }
.g-toggle .toggle-track { width: 40px; height: 22px; border-radius: 11px; background: #ccc; position: relative; transition: background 0.25s; border: 1px solid #bbb; flex-shrink: 0; }
.g-toggle .toggle-track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: white; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.25s; }
.g-toggle input:checked + .toggle-track { background: #27ae60; border-color: #1e8449; }
.g-toggle input:checked + .toggle-track::after { transform: translateX(18px); }
.g-toggle .toggle-label { font-size: 12px; font-weight: 600; color: #999; min-width: 20px; }
.g-toggle input:checked ~ .toggle-label { color: #27ae60; }
.g-toggle.is-false .toggle-track { background: #e74c3c; border-color: #c0392b; }
.g-toggle.is-false .toggle-label { color: #e74c3c; }
.g-toggle.is-unset .toggle-track { background: #ccc; }
.g-toggle.is-unset .toggle-label { color: #999; }

/* Secciones */
.g-section { transition: all 0.15s ease; }
.g-section.hidden { display: none; }
.debug-on .g-section { display: block !important; }
.debug-on .g-section.visible { border-left: 3px solid var(--section-visible); padding-left: 8px; margin: 4px 0; }
.debug-on .g-section.hidden { border-left: 3px dashed var(--section-hidden); padding-left: 8px; margin: 4px 0; opacity: 0.75; }
.debug-badge { display: none; font-size: 10px; padding: 1px 6px; border-radius: 3px; font-weight: 600; margin-bottom: 2px; }
.debug-on .debug-badge { display: inline-block; }
.debug-badge.true { background: var(--section-visible); color: white; }
.debug-badge.false { background: var(--section-hidden); color: white; }
.debug-comment { display: none; background: #f5f5f5; border-left: 3px solid #999; padding: 3px 8px; margin: 3px 0; font-style: italic; color: #888; font-size: 11px; }
.debug-on .debug-comment { display: block; }
.debug-let { display: none; background: #f5eef8; border-left: 3px solid #8e44ad; padding: 3px 8px; margin: 3px 0; font-size: 11px; color: #6c3483; }
.debug-on .debug-let { display: block; }
.debug-cond { display: none; font-size: 11px; color: #555; font-family: 'Consolas', monospace; margin-left: 6px; vertical-align: middle; }
.debug-on .debug-cond { display: inline; }
.debug-cond-ref { cursor: pointer; padding: 0 3px; border-radius: 3px; background: #e8f4f8; color: #2874a6; }
.debug-cond-ref:hover { background: #d4eaf2; text-decoration: underline; }

.align-center { text-align: center; }
.align-right { text-align: right; }

/* Función / Unknown */
.g-function { display: inline-block; background: #eaf2f8; border: 1px solid #aed6f1; border-radius: 3px; padding: 3px 8px; font-size: 12px; color: var(--primary); font-style: italic; vertical-align: middle; }
.g-unknown { background: #ffeaa7; padding: 1px 4px; border-radius: 2px; font-size: 11px; }

/* Barra de estado */
#statusbar { background: #2c3e50; color: #bdc3c7; padding: 3px 16px; font-size: 11px; display: flex; gap: 18px; flex-shrink: 0; }
#statusbar .s { display: flex; align-items: center; gap: 3px; }
#statusbar .sv { color: #ecf0f1; font-weight: 600; }
#statusbar .err { color: #e74c3c; }

/* Diálogo de error / mensajes */
#toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #2c3e50; color: white; padding: 10px 18px; border-radius: 6px; font-size: 13px; box-shadow: 0 4px 18px rgba(0,0,0,0.3); z-index: 2000; display: none; max-width: 600px; }
#toast.error { background: #c0392b; }

@media print {
  @page { size: A4; margin: 12mm 10mm; }
  body { height: auto; overflow: visible; background: white; }
  #app-header, #toolbar, #statusbar, #var-panel { display: none !important; }
  #main-area { display: block; overflow: visible; }
  #doc-area { overflow: visible !important; padding: 0; display: block !important; }
  #doc-container { box-shadow: none; border: none; border-radius: 0; max-width: 100%; width: 100%; padding: 0; margin: 0; }
  #doc-content { font-size: 11px; line-height: 1.5; }
  #doc-content table { width: 100%; table-layout: fixed; font-size: 10px; page-break-inside: auto; }
  #doc-content tr { page-break-inside: avoid; }
  #doc-content th, #doc-content td { padding: 4px 6px; word-wrap: break-word; overflow-wrap: break-word; }
  #doc-content img { max-width: 36px; }
  .g-field input, .g-field select, .g-field textarea { border: none !important; background: transparent !important; box-shadow: none !important; outline: none !important; -webkit-appearance: none !important; appearance: none !important; resize: none !important; overflow: hidden !important; padding: 0 2px !important; margin: 0 !important; min-width: 20px !important; max-width: none !important; width: auto !important; height: auto !important; font-size: 10px; font-family: inherit; color: #000; }
  .g-field textarea { display: inline; white-space: pre-wrap; }
  .g-field.required::after, .g-toggle.required::after, .g-toggle.required.filled::after { display: none !important; content: none !important; }
  .g-toggle .toggle-track { display: none !important; }
  .g-toggle .toggle-label { font-size: 10px !important; font-weight: 700 !important; color: #000 !important; }
  .g-function { display: none !important; }
  .g-section.hidden { display: none !important; }
  .debug-badge, .debug-comment, .debug-let { display: none !important; }
}
/* ===== VISTA DEL CÓDIGO FUENTE ===== */
#source-view { display: none; flex: 1; overflow: hidden; background: #1e1e1e; flex-direction: column; }
.source-mode #source-view { display: flex; }
.source-mode #doc-area { display: none; }

/* Toolbar nueva del editor markdown (sustituye a la antigua barra de b&uacute;squeda inline). */
#md-toolbar { padding: 4px 8px; background: #252526; border-bottom: 1px solid #333; display: flex; align-items: center; gap: 2px; flex-shrink: 0; flex-wrap: wrap; color: #d4d4d4; }
.md-btn { background: #3c3c3c; color: #d4d4d4; border: 1px solid #555; padding: 4px 8px; border-radius: 3px; font-size: 12px; cursor: pointer; min-width: 28px; height: 26px; display: inline-flex; align-items: center; justify-content: center; transition: background 0.15s; font-family: inherit; }
.md-btn:hover:not(:disabled) { background: #505050; }
.md-btn:active:not(:disabled) { background: #264f78; }
.md-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.md-btn.active { background: #264f78; border-color: #0078d4; }
.md-btn b, .md-btn i, .md-btn s { display: inline-block; font-size: 13px; line-height: 1; }
.md-btn-text { padding: 4px 10px; font-weight: 500; color: #4ea1d3; min-width: auto; }
.md-btn-text:hover:not(:disabled) { color: #fff; background: #0078d4; }
.md-select { background: #3c3c3c; color: #d4d4d4; border: 1px solid #555; padding: 3px 6px; border-radius: 3px; font-size: 12px; cursor: pointer; height: 26px; font-family: inherit; }
.md-sep { width: 1px; height: 18px; background: #555; flex-shrink: 0; margin: 0 4px; }
.md-grow { flex: 1; }
/* Botones de acci&oacute;n del editor (Editar/Guardar/Descartar/.md/dirty) */
#md-toolbar #btn-src-edit, #md-toolbar #btn-src-download { background: #3c3c3c; color: #d4d4d4; border: 1px solid #555; padding: 4px 10px; border-radius: 3px; font-size: 12px; cursor: pointer; height: 26px; }
#md-toolbar #btn-src-edit:hover, #md-toolbar #btn-src-download:hover { background: #505050; }
#md-toolbar #btn-src-save { background: #1e7e34; color: white; border: 1px solid #155724; padding: 4px 10px; border-radius: 3px; font-size: 12px; cursor: pointer; height: 26px; }
#md-toolbar #btn-src-save:hover { background: #155724; }
#md-toolbar #btn-src-discard { background: #c0392b; color: white; border: 1px solid #96281b; padding: 4px 10px; border-radius: 3px; font-size: 12px; cursor: pointer; height: 26px; }
#md-toolbar #btn-src-discard:hover { background: #96281b; }
#src-dirty-indicator { font-size: 11px; color: #f0b429; font-style: italic; margin-left: 4px; }
/* En modo s&oacute;lo-lectura (no edit), los botones de formato/insert quedan deshabilitados visualmente */
.source-mode:not(.edit-mode) #md-toolbar .md-btn:not(#md-tool-find),
.source-mode:not(.edit-mode) #md-toolbar .md-select { opacity: 0.45; pointer-events: none; }
#source-scroll { flex: 1; overflow-y: auto; }
.edit-mode #source-scroll { display: none; }
#source-edit-wrap { display: none; flex: 1; overflow: hidden; flex-direction: row; }
.edit-mode #source-edit-wrap { display: flex; }
#src-line-nums { background: #1e1e1e; color: #e67e22; font-family: 'Consolas', monospace; font-size: 13px; line-height: 1.6; padding: 12px 10px 12px 8px; text-align: right; min-width: 50px; border-right: 1px solid #333; overflow: hidden; user-select: none; flex-shrink: 0; white-space: pre; }
#source-editor { flex: 1; background: #1e1e1e; color: #d4d4d4; font-family: 'Consolas', monospace; font-size: 13px; line-height: 1.6; border: none; outline: none; padding: 12px 20px; resize: none; tab-size: 2; overflow: auto; box-sizing: border-box; white-space: pre; }
#source-content { font-family: 'Consolas', monospace; font-size: 13px; line-height: 1.6; color: #d4d4d4; max-width: 960px; margin: 0 auto; padding: 12px 0; }
.src-line { display: flex; padding: 0 12px; }
.src-line:hover { background: rgba(255,255,255,0.04); }
.src-linenum { color: #e67e22; min-width: 42px; text-align: right; padding-right: 14px; user-select: none; border-right: 1px solid #333; margin-right: 14px; flex-shrink: 0; }
.src-linetext { white-space: pre-wrap; word-break: break-word; flex: 1; }
.src-line.src-line-highlight { background: rgba(255, 204, 0, 0.35); animation: srcLineFade 2s ease-out; }
@keyframes srcLineFade { 0% { background: rgba(255, 204, 0, 0.7); } 100% { background: rgba(255, 204, 0, 0.0); } }
.src-error-mark { text-decoration: underline wavy #e74c3c; text-decoration-thickness: 2px; background: rgba(231, 76, 60, 0.2); border-radius: 2px; padding: 0 1px; cursor: pointer; }
.src-error-mark:hover { background: rgba(231, 76, 60, 0.4); }
.src-comment { color: #6a9955; font-style: italic; }
.src-section-open { color: #569cd6; font-weight: 600; }
.src-section-close { color: #569cd6; }
.src-let { color: #c586c0; font-weight: 600; }
.src-personalized { color: #ce9178; }
.src-definition { color: #dcdcaa; }
.src-variable { color: #9cdcfe; }
.src-function { color: #4ec9b0; }

/* ===== DIÁLOGO NUEVO TESAUROS ===== */
#errors-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1001; }
#errors-overlay.active, #errors-dialog.active { display: block; }
#errors-dialog { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: white; border: 2px solid var(--primary); border-radius: 8px; padding: 16px 20px; width: 580px; max-width: 90vw; z-index: 1002; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
#errors-dialog h3 { margin: 0 0 10px; color: var(--primary); font-size: 15px; }
#errors-dialog .err-list { overflow-y: auto; max-height: 55vh; border: 1px solid #ddd; border-radius: 4px; }
.err-list .err-empty { padding: 20px; text-align: center; color: #999; font-style: italic; }
.err-list .err-item { padding: 6px 10px; border-bottom: 1px solid #f0f0f0; cursor: pointer; font-size: 12px; display: flex; gap: 8px; align-items: center; }
.err-list .err-item:last-child { border-bottom: none; }
.err-list .err-item:hover { background: #fff8e1; }
.err-list .err-item.active { background: #fdebd0; }
.err-list .err-item .err-sev { font-size: 14px; line-height: 1; flex-shrink: 0; width: 16px; text-align: center; }
.err-list .err-item .err-sev.sev-error { color: #c0392b; }
.err-list .err-item .err-sev.sev-warning { color: #d68910; }
.err-list .err-item .err-sev.sev-info { color: #2874a6; }
.err-list .err-item .err-type { font-size: 10px; padding: 2px 6px; border-radius: 3px; font-weight: 600; flex-shrink: 0; }
.err-list .err-item .err-type.cat-syntax { background: #fadbd8; color: #922b21; }
.err-list .err-item .err-type.cat-structure { background: #d6eaf8; color: #1b4f72; }
.err-list .err-item .err-type.cat-thesaurus { background: #fef9e7; color: #7d6608; }
.err-list .err-item .err-type.cat-directive { background: #e8daef; color: #5b2c6f; }
.err-list .err-item .err-type.cat-condition { background: #fdebd0; color: #784212; }
.err-list .err-item .err-type.cat-let { background: #d5f5e3; color: #196f3d; }
.err-list .err-item .err-type.cat-other { background: #f0f0f0; color: #555; }
.err-list .err-item .err-text { flex: 1; overflow: hidden; }
.err-list .err-item .err-text > * { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.err-list .err-item .err-sugg { font-size: 11px; color: #888; font-style: italic; margin-top: 2px; }
.err-list .err-item .err-action { flex-shrink: 0; padding: 2px 8px; font-size: 11px; font-weight: 600; border: 1px solid #2874a6; background: white; color: #2874a6; border-radius: 3px; cursor: pointer; }
.err-list .err-item .err-action:hover { background: #2874a6; color: white; }
.err-list .err-item .err-action.err-fix { border-color: #27ae60; color: #1e8449; }
.err-list .err-item .err-action.err-fix:hover { background: #27ae60; color: white; }
.err-list .err-item .err-text .err-bad { color: #c0392b; font-weight: 600; font-family: 'Consolas', monospace; background: #fdecea; padding: 0 3px; border-radius: 2px; }
.err-list .err-item .err-line { color: #888; font-family: 'Consolas', monospace; font-size: 11px; flex-shrink: 0; }

#st-err.clickable { cursor: pointer; }
#st-err.clickable:hover { background: #fadbd8; padding: 0 4px; border-radius: 3px; }

/* ===== Botón llave inglesa en statusbar y panel #err-panel ===== */
.err-stat { display: flex; align-items: center; gap: 6px; }
.err-toggle-btn { background: transparent; border: 1px solid #888; color: inherit; padding: 0 6px; font-size: 13px; line-height: 1; height: 18px; border-radius: 3px; cursor: pointer; }
.err-toggle-btn:hover { background: #fadbd8; border-color: #c0392b; color: #c0392b; }
.err-toggle-btn.active { background: #c0392b; border-color: #c0392b; color: white; font-weight: 700; }

#err-panel { display: none; width: 360px; min-width: 240px; background: var(--bg); border-right: 1px solid var(--border); flex-direction: column; overflow: hidden; flex-shrink: 0; }
#err-panel .panel-title { padding: 7px 12px; background: #c0392b; color: white; font-size: 12px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
#err-panel .panel-title .count { font-weight: 400; opacity: 0.85; }
.err-panel-actions { padding: 6px; display: flex; gap: 4px; flex-shrink: 0; border-bottom: 1px solid var(--border); }
.err-panel-actions button { flex: 1 0 auto; padding: 4px 8px; font-size: 11px; border: 1px solid #ccc; border-radius: 3px; cursor: pointer; background: white; color: var(--text); }
.err-panel-actions button:hover { background: #eee; }
#err-panel-list { flex: 1; overflow-y: auto; }
#err-panel-list .err-item { padding: 8px 10px; align-items: flex-start; }
#err-panel-list .err-item.active { background: #fdebd0; border-left: 3px solid #c0392b; padding-left: 7px; }
/* En el panel hay espacio vertical: dejar que mensaje y sugerencia hagan wrap
   en vez de recortarse con ellipsis. */
#err-panel-list .err-item .err-text { white-space: normal; }
#err-panel-list .err-item .err-text > * { white-space: normal; overflow: visible; text-overflow: clip; }

body.err-mode #var-panel { display: none; }
body.err-mode #err-panel { display: flex; }

#edit-val-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1001; }
#edit-val-overlay.active, #edit-val-dialog.active { display: block; }
#edit-val-dialog { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: white; border: 2px solid var(--primary); border-radius: 8px; padding: 20px 24px; min-width: 380px; max-width: 520px; z-index: 1002; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
#edit-val-dialog h3 { margin: 0 0 10px; color: var(--primary); font-size: 15px; }
#edit-val-dialog .ev-meta { font-size: 12px; color: #555; margin-bottom: 10px; }
#edit-val-dialog .ev-meta .ev-label { font-weight: 600; color: #2c3e50; }
#edit-val-dialog .ev-meta .ev-ref { color: #888; margin-left: 6px; font-family: 'Consolas', monospace; }
#edit-val-dialog .ev-input { margin-bottom: 8px; }
#edit-val-dialog .ev-input input[type=text],
#edit-val-dialog .ev-input input[type=date],
#edit-val-dialog .ev-input select,
#edit-val-dialog .ev-input textarea { width: 100%; padding: 6px 10px; font-size: 13px; border: 1px solid #ccc; border-radius: 4px; box-sizing: border-box; font-family: inherit; }
#edit-val-dialog .ev-input textarea { resize: vertical; min-height: 80px; }
#edit-val-dialog .ev-input .ev-yesno { display: flex; gap: 14px; }
#edit-val-dialog .ev-input .ev-yesno label { display: flex; align-items: center; gap: 4px; font-size: 13px; cursor: pointer; }

#thesaurus-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1001; }
#thesaurus-overlay.active, #thesaurus-dialog.active { display: block; }
#thesaurus-dialog { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: white; border: 2px solid var(--primary); border-radius: 8px; padding: 20px 24px; min-width: 360px; max-width: 460px; z-index: 1002; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
#thesaurus-dialog h3 { margin: 0 0 14px; color: var(--primary); font-size: 15px; }
#thesaurus-dialog .ts-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#thesaurus-dialog .ts-row label { font-size: 13px; color: #444; min-width: 90px; }
#thesaurus-dialog .ts-row input, #thesaurus-dialog .ts-row select { flex: 1; padding: 4px 8px; font-size: 13px; border: 1px solid #ccc; border-radius: 4px; }
#thesaurus-dialog .ts-row input:focus, #thesaurus-dialog .ts-row select:focus { outline: none; border-color: var(--primary); }
#thesaurus-dialog .ts-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; border-top: 1px solid #eee; padding-top: 12px; }
#thesaurus-dialog .ts-actions button { padding: 5px 14px; font-size: 12px; border-radius: 4px; cursor: pointer; border: 1px solid #ccc; background: white; }
#thesaurus-dialog .ts-actions button.primary { background: var(--primary); color: white; border-color: var(--primary); }
#thesaurus-dialog .ts-actions button.primary:hover { background: var(--primary-light); }
#thesaurus-dialog .ts-close { position: absolute; top: 8px; right: 12px; background: none; border: none; font-size: 18px; cursor: pointer; color: #999; }
#thesaurus-dialog .ts-error { color: #e74c3c; font-size: 12px; margin-top: 4px; min-height: 16px; }

/* ===== Autocompletado propio (sustituye <datalist> que Edge rompe con "Datos guardados") ===== */
#thesaurus-dialog .ts-row .ac-wrap { flex: 1; position: relative; display: flex; align-items: stretch; }
#thesaurus-dialog .ts-row .ac-wrap input { flex: 1; padding-right: 26px !important; }
.ac-toggle { position: absolute; right: 1px; top: 1px; bottom: 1px; width: 24px; border: none; background: transparent; color: #888; cursor: pointer; font-size: 11px; padding: 0; border-left: 1px solid #eee; }
.ac-toggle:hover { color: var(--primary); background: #f0f0f0; }
.ac-popup { display: none; position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #ccc; border-radius: 0 0 4px 4px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); max-height: 240px; overflow-y: auto; z-index: 1010; margin-top: 1px; }
.ac-popup.open { display: block; }
.ac-popup .ac-item { padding: 5px 10px; font-size: 12px; cursor: pointer; border-bottom: 1px solid #f5f5f5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ac-popup .ac-item:last-child { border-bottom: none; }
.ac-popup .ac-item:hover, .ac-popup .ac-item.ac-active { background: #eaf2f8; color: var(--primary); }
.ac-popup .ac-empty { padding: 8px 10px; color: #999; font-size: 12px; font-style: italic; }
#ts-i18n-section { display: none; border: 1px solid #ddd; border-radius: 4px; padding: 8px; margin-top: 6px; background: #f9f9f9; }
#ts-i18n-section.active { display: block; }
#ts-i18n-section .ts-i18n-title { font-size: 12px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }
#ts-i18n-list { max-height: 180px; overflow-y: auto; margin-bottom: 6px; padding: 2px; position: relative; }
#ts-i18n-list .ts-i18n-item { display: flex; gap: 4px; align-items: center; margin-bottom: 4px; font-size: 12px; padding: 2px 4px; border-radius: 3px; background: white; border: 1px solid #e6e6e6; transition: opacity 0.12s; }
#ts-i18n-list .ts-i18n-item.dragging { opacity: 0.35; }
#ts-i18n-list .ts-i18n-item.drop-target-above { box-shadow: 0 -2px 0 0 var(--accent); }
#ts-i18n-list .ts-i18n-item.drop-target-below { box-shadow: 0 2px 0 0 var(--accent); }
#ts-i18n-list .ts-i18n-item .drag-handle { cursor: grab; color: #999; padding: 0 3px; user-select: none; font-size: 14px; line-height: 1; }
#ts-i18n-list .ts-i18n-item.dragging .drag-handle { cursor: grabbing; }
#ts-i18n-list .ts-i18n-item .i18n-id, #ts-i18n-list .ts-i18n-item .i18n-label { flex: 1 1 0; min-width: 0; padding: 2px 6px; border: 1px solid #ddd; border-radius: 3px; font-size: 12px; background: #fafafa; }
#ts-i18n-list .ts-i18n-item .i18n-id:focus, #ts-i18n-list .ts-i18n-item .i18n-label:focus { outline: none; border-color: var(--primary); background: white; }
#ts-i18n-list .ts-i18n-item .i18n-arrow { color: #999; font-size: 11px; flex-shrink: 0; }
#ts-i18n-list .ts-i18n-item button[data-remove-idx] { background: none; border: none; color: #e74c3c; cursor: pointer; font-size: 14px; padding: 0 4px; flex-shrink: 0; }
#ts-i18n-list .ts-i18n-item button[data-remove-idx]:hover { color: #c0392b; }
.ts-i18n-hint { font-weight: 400; font-size: 10px; color: #888; font-style: italic; margin-left: 4px; }
.drag-handle-hint { font-style: normal; font-weight: 700; color: #aaa; }
#ts-i18n-add-row { display: flex; gap: 4px; align-items: center; }
#ts-i18n-add-row input { flex: 1; padding: 3px 6px; font-size: 12px; border: 1px solid #ccc; border-radius: 3px; }
#ts-i18n-add-row button { padding: 3px 10px; font-size: 11px; background: var(--primary); color: white; border: none; border-radius: 3px; cursor: pointer; }

.vartable .badge-new { display: inline-block; background: #e67e22; color: white; font-size: 9px; padding: 1px 5px; border-radius: 3px; margin-left: 4px; font-weight: 600; vertical-align: middle; }

/* Caption actions del sidebar (sort/group/expand) */
.vartable caption .caption-actions { display: flex; gap: 2px; align-items: center; justify-content: flex-end; margin-bottom: 3px; }
.vartable caption .caption-title { display: block; }
.vartable caption .caption-btn { font-size: 11px; line-height: 1; padding: 2px 6px; border: 1px solid transparent; border-radius: 3px; background: transparent; color: var(--primary); cursor: pointer; font-weight: 600; }
.vartable caption .caption-btn:hover { background: rgba(41,128,185,0.12); }
.vartable caption .caption-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.vartable caption .caption-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.vartable caption .caption-btn:disabled:hover { background: transparent; }

/* Group headers + collapsable rows */
.vartable tr.group-header td { background: #dfe9f3; font-weight: 600; color: var(--primary); cursor: pointer; user-select: none; padding: 4px 6px; }
.vartable tr.group-header td:hover { background: #c8d8e8; }
.vartable tr.group-header.has-changes td { border-left: 3px solid var(--accent); }
.vartable tr.group-header .group-caret { display: inline-block; width: 10px; font-size: 9px; color: var(--primary); }
.vartable tr.group-header .group-count { font-weight: 400; opacity: 0.7; font-size: 10px; margin-left: 4px; }
.vartable tr.group-row.collapsed { display: none; }

/* Drag & drop variables */
.vartable tr[draggable="true"] { cursor: grab; }
.vartable tr[draggable="true"]:active { cursor: grabbing; }
.vartable tr.drag-selected td { background: #d5f5e3 !important; }
.vartable tr.drag-selected td::before { content: '✓ '; color: #27ae60; font-weight: 700; }
#source-editor.drag-over-editor { outline: 3px dashed #e67e22 !important; outline-offset: -3px; background: rgba(230,126,34,0.05) !important; }
.drag-ghost { position: absolute; top: -1000px; left: -1000px; background: #34495e; color: white; padding: 4px 10px; border-radius: 4px; font-size: 11px; font-family: 'Consolas', monospace; white-space: nowrap; z-index: 9999; }

/* Popup valor largo */
#val-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 999; }
#val-overlay.active { display: block; }
#val-popup { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: white; border: 2px solid var(--primary); border-radius: 6px; padding: 16px; max-width: 500px; min-width: 280px; max-height: 60vh; overflow-y: auto; z-index: 1000; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
#val-popup.active { display: block; }
#val-popup .popup-title { font-weight: 700; font-size: 13px; color: var(--primary); margin-bottom: 8px; font-family: 'Consolas', monospace; }
#val-popup .popup-value { font-size: 13px; line-height: 1.5; word-break: break-all; background: #f8f9fa; padding: 10px; border-radius: 4px; border: 1px solid #eee; max-height: 40vh; overflow: auto; white-space: pre-wrap; }
#val-popup .popup-close { position: absolute; top: 8px; right: 12px; background: none; border: none; font-size: 18px; cursor: pointer; color: #999; }
.vartable td.vval .expand-btn { cursor: pointer; color: var(--primary-light); font-size: 13px; font-weight: 700; margin-left: 2px; vertical-align: middle; border: none; background: none; padding: 0 3px; line-height: 1; }
.vartable td.vval .expand-btn:hover { color: var(--accent); }

/* Diálogo de Configuración */
#config-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1001; }
#config-overlay.active, #config-dialog.active { display: block; }
#config-dialog { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: white; border: 2px solid var(--primary); border-radius: 8px; padding: 20px 24px; min-width: 340px; max-width: 440px; z-index: 1002; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
#config-dialog h3 { margin: 0 0 14px; color: var(--primary); font-size: 15px; }
#config-dialog .cfg-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
#config-dialog .cfg-row label { font-size: 13px; color: #444; }
#config-dialog .cfg-row input[type="color"] { width: 44px; height: 28px; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; padding: 1px; }
#config-dialog .cfg-row select { padding: 3px 8px; font-size: 13px; border: 1px solid #ccc; border-radius: 4px; }
#config-dialog .cfg-presets { display: flex; gap: 6px; margin-bottom: 14px; }
#config-dialog .cfg-presets button { flex: 1; padding: 5px 8px; font-size: 11px; border: 1px solid #ccc; border-radius: 4px; cursor: pointer; background: white; }
#config-dialog .cfg-presets button:hover { background: #eee; }
#config-dialog .cfg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; border-top: 1px solid #eee; padding-top: 12px; }
#config-dialog .cfg-actions button { padding: 5px 14px; font-size: 12px; border-radius: 4px; cursor: pointer; border: 1px solid #ccc; background: white; }
#config-dialog .cfg-actions button.primary { background: var(--primary); color: white; border-color: var(--primary); }
#config-dialog .cfg-close { position: absolute; top: 8px; right: 12px; background: none; border: none; font-size: 18px; cursor: pointer; color: #999; }
#config-dialog .cfg-preview-wrap { margin: 6px 0 12px; }
#config-dialog .cfg-preview-wrap label { display: block; font-size: 11px; color: #888; margin-bottom: 4px; }
#config-dialog .cfg-preview { font-family: 'Consolas', monospace; line-height: 1.5; border: 1px solid #ccc; border-radius: 4px; padding: 10px; white-space: pre; overflow: hidden; }
#config-dialog .cfg-hint { font-size: 11px; color: #888; font-style: italic; margin: 0 0 10px; line-height: 1.4; }

/* Botón colapsar/expandir el sidebar */
body.sidebar-collapsed #var-panel { display: none; }

/* ===== Modales gen&eacute;ricos del editor markdown (Find / Replace / Link / Insert) ===== */
.md-modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1001; }
.md-modal-overlay.active { display: block; }
.md-modal-dialog { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); background: white; border: 2px solid var(--primary); border-radius: 8px; padding: 20px 24px; min-width: 380px; max-width: 480px; z-index: 1002; box-shadow: 0 8px 30px rgba(0,0,0,0.3); }
.md-modal-dialog.active { display: block; }
.md-modal-dialog h3 { margin: 0 0 12px; color: var(--primary); font-size: 15px; }
.md-modal-dialog .md-close { position: absolute; top: 8px; right: 12px; background: none; border: none; font-size: 18px; cursor: pointer; color: #999; }
.md-modal-dialog .md-close:hover { color: var(--primary); }
.md-modal-dialog .md-label { display: block; font-size: 12px; color: #555; margin: 8px 0 4px; }
.md-modal-dialog input[type="text"] { width: 100%; padding: 6px 10px; border: 1px solid #ccc; border-radius: 4px; font-size: 13px; box-sizing: border-box; }
.md-modal-dialog input[type="text"]:focus { outline: none; border-color: var(--primary); }
.md-modal-dialog .md-check { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #555; margin-top: 6px; }
.md-modal-dialog .md-check input[type="checkbox"] { margin: 0; }
.md-modal-dialog .md-find-info { font-size: 12px; color: #888; margin-top: 8px; min-height: 16px; }
.md-modal-dialog .md-find-info.error { color: #e74c3c; }
.md-modal-dialog .md-find-info.ok { color: #27ae60; }
.md-modal-dialog .md-dialog-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; border-top: 1px solid #eee; padding-top: 12px; flex-wrap: wrap; }
.md-modal-dialog .md-dialog-actions button { padding: 6px 14px; font-size: 12px; border-radius: 4px; cursor: pointer; border: 1px solid #ccc; background: white; }
.md-modal-dialog .md-dialog-actions button:hover { background: #eee; }
.md-modal-dialog .md-dialog-actions button.primary { background: var(--primary); color: white; border-color: var(--primary); }
.md-modal-dialog .md-dialog-actions button.primary:hover { background: var(--primary-light); }
.md-modal-dialog .md-dialog-actions button:disabled { opacity: 0.4; cursor: not-allowed; }
.md-modal-dialog .md-dialog-actions button:disabled:hover { background: white; }

/* Picker tabla */
#md-table-popup { display: none; position: fixed; z-index: 1003; background: white; border: 1px solid #888; border-radius: 6px; padding: 10px; box-shadow: 0 4px 18px rgba(0,0,0,0.25); }
#md-table-popup.active { display: block; }
#md-table-grid { display: grid; grid-template-columns: repeat(10, 18px); grid-template-rows: repeat(10, 18px); gap: 2px; }
#md-table-grid .md-table-cell { width: 18px; height: 18px; border: 1px solid #ccc; background: #f5f5f5; cursor: pointer; }
#md-table-grid .md-table-cell.selected { background: #aed6f1; border-color: var(--primary); }
#md-table-info { font-size: 11px; color: #555; text-align: center; margin-top: 6px; min-height: 14px; }

/* Modal insertar tesauro / funci&oacute;n (m&aacute;s ancho y con scroll interno) */
.md-insert-wide { min-width: 460px !important; max-width: 560px !important; }
#md-insert-toolbar { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; padding: 6px; background: #f4f7fa; border: 1px solid #e0e6ec; border-radius: 4px; }
#md-insert-toolbar #md-insert-filter { flex: 1; padding: 4px 8px; border: 1px solid #ccc; border-radius: 3px; font-size: 12px; }
#md-insert-toolbar #md-insert-filter:focus { outline: none; border-color: var(--primary); }
#md-insert-toolbar #md-insert-count { font-size: 11px; color: #888; }
#md-insert-hint { font-size: 11px; color: #888; margin: 2px 4px 6px; line-height: 1.4; }
#md-insert-hint b { color: #555; font-weight: 600; }
#md-insert-hint code { background: #f4f7fa; border: 1px solid #e0e6ec; border-radius: 3px; padding: 0 4px; font-family: 'Consolas', monospace; color: #555; }
#md-insert-list { max-height: 320px; overflow-y: auto; border: 1px solid #e0e6ec; border-radius: 4px; padding: 4px; background: white; }
#md-insert-list .md-insert-row { display: flex; align-items: center; gap: 6px; padding: 3px 6px; border-radius: 3px; cursor: pointer; font-size: 12px; user-select: none; }
#md-insert-list .md-insert-row:hover { background: #f0f6fb; }
#md-insert-list .md-insert-row.selected { background: #d5f5e3; }
#md-insert-list .md-insert-row .ref { font-family: 'Consolas', monospace; color: #333; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#md-insert-list .md-insert-row .label { color: #888; font-size: 11px; margin-left: 8px; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#md-insert-list .md-insert-row .ns-badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; font-weight: 700; }
#md-insert-list .md-insert-row .ns-pers { background: #aed6f1; color: #154360; }
#md-insert-list .md-insert-row .ns-var { background: #d6c2e8; color: #4a235a; }
#md-insert-list .md-insert-row .ns-func { background: #d4efdf; color: #196f3d; }
#md-insert-list .md-insert-group-header { font-weight: 700; color: var(--primary); padding: 4px 6px; background: #eaf2f8; border-radius: 3px; margin-top: 4px; font-size: 11px; cursor: pointer; user-select: none; }
#md-insert-list .md-insert-group-header.collapsed .md-insert-group-caret::before { content: '\25B6'; }
#md-insert-list .md-insert-group-header .md-insert-group-caret::before { content: '\25BC'; margin-right: 4px; color: var(--primary); font-size: 9px; }
#md-insert-list .md-insert-group-header.collapsed + .md-insert-group-rows { display: none; }

@media (max-width: 600px) { #var-panel { display: none; } }
