/* ─────────────────────────────────────────────
 * Módulo DB Flow
 * ───────────────────────────────────────────── */

/* ── Lista de diagramas ── */
.mod-dbflow .mod-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
}

.mod-dbflow .mod-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.dbf-lista-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
}

/* ── Cards de cliente (nivel 1) ── */
.dbf-client-card {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 18px 20px;
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.dbf-client-card:hover {
    box-shadow: 0 4px 18px rgba(0,0,0,0.09);
    border-color: #6655ff;
}
.dbf-client-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6655ff, #4a8fe0);
    color: #fff;
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.dbf-client-info { flex: 1; min-width: 0; }
.dbf-client-nombre {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dbf-client-count {
    font-size: 12px;
    color: #6b7280;
    margin-top: 3px;
}
.dbf-client-arrow {
    font-size: 22px;
    color: #9ca3af;
    flex-shrink: 0;
}

.dbf-lista-loading,
.dbf-lista-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 24px;
    color: #9ca3af;
    font-size: 0.95rem;
}

.dbf-empty-icon {
    font-size: 3rem;
    margin-bottom: 12px;
}

/* ── Estado vacío de un cliente sin diagramas ── */
.dbf-empty-cliente {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.dbf-empty-texto {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
    margin: 0 0 6px;
}

.dbf-empty-subtexto {
    font-size: 0.875rem;
    color: #9ca3af;
    margin: 0 0 20px;
}

.dbf-empty-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.dbf-card {
    background: #ffffff;
    border: 1px solid var(--color-topbar-border);
    border-radius: 8px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: box-shadow 0.15s;
}

.dbf-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.dbf-card-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.dbf-card-icon { font-size: 1.8rem; }

.dbf-card-nombre {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-text);
}

.dbf-card-proyecto {
    font-size: 0.78rem;
    color: var(--color-accent);
    margin-top: 2px;
}

.dbf-card-desc {
    font-size: 0.85rem;
    color: #6b7280;
    line-height: 1.5;
}

.dbf-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
}

.dbf-card-fecha {
    font-size: 0.75rem;
    color: #9ca3af;
}

.dbf-card-actions {
    display: flex;
    gap: 6px;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.78rem;
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
    border: none;
}

.btn-danger:hover:not(:disabled) { background-color: #dc2626; }

/* ── Acciones del encabezado de lista (botones alineados) ── */
.dbf-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* ── Lista de diagramas en modal de copia (checkboxes) ── */
.dbf-copiar-diags-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 4px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dbf-copiar-diag-item {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.12s;
    flex-wrap: wrap;
}

.dbf-copiar-diag-item:hover { background: #f3f4f6; }

.dbf-copiar-diag-item input[type="checkbox"] {
    flex-shrink: 0;
    margin-top: 2px;
    accent-color: var(--color-accent);
    cursor: pointer;
}

.dbf-copiar-diag-nombre {
    font-size: 0.875rem;
    font-weight: 600;
    color: #111827;
}

.dbf-copiar-diag-desc {
    font-size: 0.76rem;
    color: #6b7280;
    flex-basis: 100%;
    padding-left: 20px;
    line-height: 1.3;
}

.dbf-copiar-loading {
    padding: 12px;
    text-align: center;
    color: #9ca3af;
    font-size: 0.85rem;
}

/* ── Descripción informativa en modal de nuevo Schema ── */
.dbf-schema-desc {
    font-size: 0.875rem;
    color: #6b7280;
    line-height: 1.5;
    margin: 0 0 16px;
}

/* ── Destino fijo en modal de copia (cuando hay Schema activo) ── */
.dbf-copiar-destino-fijo {
    padding: 8px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

/* ═══════════════════════════════════════════
 * EDITOR DE DIAGRAMA
 * ═══════════════════════════════════════════ */

.dbf-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #0a0a14;
    color: #d8d8f0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    position: relative;
    overflow: hidden;
}

/* ── Toolbar del editor ── */
.dbf-toolbar {
    background: #13131f;
    border-bottom: 1px solid #252540;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    flex-wrap: wrap;
    z-index: 50;
}

.dbf-diag-nombre {
    font-weight: 700;
    font-size: 13px;
    color: #c0c0e0;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.dbf-nombre-input {
    width: 180px;
    max-width: 220px;
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    color: #1a1a3a;
    background: #ffffff;
    border: 1.5px solid #6366f1;
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

.dbf-toolbar-sep {
    width: 1px;
    height: 20px;
    background: #252540;
    margin: 0 3px;
    flex-shrink: 0;
}

.dbf-save-status {
    font-size: 11px;
    color: #40b870;
    margin-left: 4px;
}

/* ── Botones del toolbar del editor ── */
.dbf-btn {
    padding: 4px 10px;
    border: 1px solid #252540;
    background: #1a1a2c;
    color: #d8d8f0;
    border-radius: 5px;
    cursor: pointer;
    font-size: 11px;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.12s;
    white-space: nowrap;
    flex-shrink: 0;
}

.dbf-btn:hover          { background: #22223a; border-color: #303055; }
.dbf-btn-active         { background: #1e1a3a !important; border-color: #6655ff !important; color: #9988ff !important; }
.dbf-btn-back           { border-left: 3px solid #6655ff; }
.dbf-btn-conn           { border-left: 3px solid #e05555; }
.dbf-btn-db             { border-left: 3px solid #4a8fe0; }
.dbf-btn-tbl            { border-left: 3px solid #40b870; }
.dbf-btn-chn            { border-left: 3px solid #d4800a; }
.dbf-btn-link           { border-left: 3px solid #e0a030; }
.dbf-btn-del            { border-left: 3px solid #e74c3c; }
.dbf-btn-save           { border-left: 3px solid #40b870; }
.dbf-btn-sql            { border-left: 3px solid #4a8fe0; }
.dbf-btn-audit          { border-left: 3px solid #a060d0; }
.dbf-btn-full           { width: 100%; justify-content: center; }
.dbf-btn-zoom           { padding: 4px 8px; font-size: 14px; font-weight: 700; line-height: 1; }
.dbf-zoom-label         { font-size: 11px; color: #9898b8; min-width: 36px; text-align: center; flex-shrink: 0; }

.dbf-badge {
    background: #e74c3c;
    color: #fff;
    border-radius: 10px;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 700;
}

/* ── Navegador de árbol ── */
.dbf-nav {
    width: 210px;
    min-width: 210px;
    background: #0b0b1a;
    border-right: 1px solid #1e1e38;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.dbf-nav-head {
    padding: 10px 12px 8px;
    border-bottom: 1px solid #1e1e38;
    font-weight: 700;
    font-size: 11px;
    color: #6060a8;
    letter-spacing: 0.5px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.dbf-nav-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0 8px;
}

.dbf-nav-empty {
    color: #4040708;
    font-size: 11px;
    text-align: center;
    padding: 18px 10px;
    color: #404070;
}

.dbf-nav-group { margin-bottom: 2px; }

.dbf-nav-sec-hd {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px 4px;
    font-size: 10px;
    font-weight: 700;
    color: #5050a0;
    cursor: pointer;
    user-select: none;
    letter-spacing: 0.5px;
}
.dbf-nav-sec-hd:hover { color: #8080cc; }

.dbf-nav-chev {
    font-size: 9px;
    transition: transform 0.15s;
    flex-shrink: 0;
}

.dbf-nav-cnt {
    margin-left: auto;
    background: #1a1a34;
    border-radius: 8px;
    padding: 1px 6px;
    font-size: 10px;
    color: #6060a0;
}

.dbf-nav-sec-body.dbf-nav-closed,
.dbf-nav-sub.dbf-nav-closed { display: none; }

.dbf-nav-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 0;
    font-size: 11px;
    color: #9090c8;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    border-radius: 3px;
    margin: 0 4px;
}
.dbf-nav-item:hover { background: #181830; color: #c0c0ee; }

.dbf-nav-item[data-d="0"] { padding-left: 10px; }
.dbf-nav-item[data-d="1"] { padding-left: 22px; }
.dbf-nav-item[data-d="2"] { padding-left: 36px; }

.dbf-nav-tog {
    width: 12px;
    text-align: center;
    font-size: 8px;
    color: #505090;
    flex-shrink: 0;
    cursor: pointer;
    transition: color 0.1s;
}
.dbf-nav-tog:hover { color: #9090cc; }
.dbf-nav-tog-leaf  { pointer-events: none; }

.dbf-nav-lbl {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.dbf-btn-active {
    background: #2a2a50 !important;
    color: #c0c0ff !important;
    border-color: #4040a0 !important;
}

/* ── Divisor entre árbol y scripts ── */
.dbf-nav-div {
    height: 1px;
    background: #2a2a4a;
    flex-shrink: 0;
}

/* ── Sección Scripts ── */
.dbf-nav-scripts-wrap {
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 160px;
    max-height: 42%;
    border-top: none;
    overflow: hidden;
}

.dbf-nav-scripts-hd {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px 4px;
    font-size: 11px;
    font-weight: 700;
    color: #6060a8;
    flex-shrink: 0;
    letter-spacing: 0.4px;
}

.dbf-nav-scripts-hd span { flex: 1; }

.dbf-nav-hd-btn {
    background: none;
    border: 1px solid #2a2a48;
    border-radius: 3px;
    color: #6060a0;
    font-size: 11px;
    padding: 1px 5px;
    cursor: pointer;
    line-height: 1.4;
}
.dbf-nav-hd-btn:hover { background: #1e1e38; color: #a0a0d0; }

.dbf-nav-filter-wrap {
    padding: 0 6px 4px;
    flex-shrink: 0;
}

.dbf-nav-filter-inp {
    width: 100%;
    background: #0f0f22;
    border: 1px solid #2a2a48;
    border-radius: 4px;
    color: #9090c8;
    font-size: 11px;
    padding: 4px 7px;
    box-sizing: border-box;
    outline: none;
}
.dbf-nav-filter-inp:focus { border-color: #4040a0; }
.dbf-nav-filter-inp::placeholder { color: #404070; }

.dbf-nav-scripts-body {
    flex: 1;
    overflow-y: auto;
    padding: 2px 0 6px;
}

.dbf-nav-folder-hd {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px 3px 8px;
    font-size: 11px;
    color: #8080b8;
    cursor: pointer;
    user-select: none;
}
.dbf-nav-folder-hd:hover { color: #b0b0d8; }

.dbf-nav-folder-lbl { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dbf-nav-icon-btn {
    background: none;
    border: none;
    color: #404070;
    font-size: 11px;
    cursor: pointer;
    padding: 0 3px;
    line-height: 1;
    flex-shrink: 0;
}
.dbf-nav-icon-btn:hover     { color: #8080c0; }
.dbf-nav-icon-del:hover     { color: #e05555; }

.dbf-nav-rename-inp {
    background: #0f0f22;
    border: 1px solid #4040a0;
    border-radius: 3px;
    color: #c0c0ff;
    font-size: 11px;
    padding: 1px 5px;
    width: 100%;
    outline: none;
}

.dbf-nav-item-active { background: #1e1e40 !important; color: #d0d0ff !important; }

.dbf-code {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 11.5px;
    line-height: 1.5;
    resize: vertical;
}

/* ── Imágenes de navegación ── */
.dbf-img-upload-zone {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 6px 0 4px;
    flex-wrap: wrap;
}

.dbf-img-upload-lbl {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #1a1a34;
    border: 1px solid #2a2a50;
    border-radius: 4px;
    color: #8080c0;
    font-size: 11px;
    padding: 4px 10px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
}
.dbf-img-upload-lbl:hover { background: #252548; color: #c0c0ff; }

.dbf-img-paste-hint {
    font-size: 10px;
    color: #404070;
    margin-left: 2px;
}

.dbf-img-empty {
    font-size: 11px;
    color: #404070;
    padding: 4px 0 8px;
}

.dbf-img-thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.dbf-img-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 90px;
    flex-shrink: 0;
}

.dbf-img-thumb-wrap {
    position: relative;
    width: 90px;
    height: 72px;
    border-radius: 5px;
    overflow: visible;
    flex-shrink: 0;
}

.dbf-img-obs-ta {
    width: 100%;
    background: #0f0f22;
    border: 1px solid #252540;
    border-radius: 4px;
    color: #9090c0;
    font-size: 10px;
    padding: 4px 6px;
    resize: none;
    outline: none;
    font-family: inherit;
    line-height: 1.4;
    box-sizing: border-box;
}
.dbf-img-obs-ta:focus     { border-color: #4040a0; }
.dbf-img-obs-ta::placeholder { color: #303055; }

.dbf-img-thumb {
    width: 90px;
    height: 72px;
    object-fit: cover;
    border-radius: 5px;
    border: 1px solid #2a2a50;
    cursor: pointer;
    display: block;
    transition: opacity 0.15s;
}
.dbf-img-thumb:hover { opacity: 0.85; border-color: #6060b0; }

.dbf-img-del-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #c0202080;
    border: none;
    color: #fff;
    font-size: 9px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    padding: 0;
    display: none;
}
.dbf-img-thumb-wrap:hover .dbf-img-del-btn { display: block; }
.dbf-img-del-btn:hover { background: #e03030; }

.dbf-img-obs-badge {
    position: absolute;
    bottom: -5px;
    right: -5px;
    font-size: 11px;
    pointer-events: none;
}

/* ── Modal de cámara ── */
.dbf-cam-modal {
    position: absolute;
    inset: 0;
    z-index: 410;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dbf-cam-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.82);
}

.dbf-cam-box {
    position: relative;
    z-index: 1;
    background: #0e0e1e;
    border: 1px solid #2a2a50;
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: min(560px, 92vw);
    width: 100%;
}

.dbf-cam-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #8080b0;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.dbf-cam-close:hover { color: #e05555; }

.dbf-cam-video {
    width: 100%;
    border-radius: 6px;
    background: #000;
    max-height: 50vh;
    object-fit: cover;
}

.dbf-cam-controls {
    display: flex;
    justify-content: center;
}

/* ── Lightbox ── */
.dbf-img-modal {
    position: absolute;
    inset: 0;
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dbf-img-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
}

.dbf-img-modal-box {
    position: relative;
    z-index: 1;
    background: #12121f;
    border: 1px solid #2a2a50;
    border-radius: 10px;
    padding: 16px;
    max-width: min(700px, 90vw);
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dbf-img-modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #8080b0;
    font-size: 18px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}
.dbf-img-modal-close:hover { color: #e05555; }

.dbf-img-modal-img {
    width: 100%;
    max-height: 55vh;
    object-fit: contain;
    border-radius: 6px;
    background: #0a0a18;
}

.dbf-img-modal-obs-wrap { display: flex; flex-direction: column; gap: 4px; }
.dbf-img-modal-obs-lbl  { font-size: 10px; color: #5050a0; text-transform: uppercase; letter-spacing: 0.8px; }

.dbf-img-modal-obs-inp {
    background: #0f0f22;
    border: 1px solid #2a2a48;
    border-radius: 5px;
    color: #b0b0d8;
    font-size: 12px;
    padding: 7px 10px;
    resize: vertical;
    outline: none;
    font-family: inherit;
}
.dbf-img-modal-obs-inp:focus { border-color: #4040a0; }

/* Overrides tema claro para imágenes */
.dbf-editor--light .dbf-img-upload-lbl      { background: #eeeef8; border-color: #c0c0d8; color: #6060a0; }
.dbf-editor--light .dbf-img-upload-lbl:hover { background: #e0e0f4; color: #3030a0; }
.dbf-editor--light .dbf-img-thumb           { border-color: #c0c0d8; }
.dbf-editor--light .dbf-img-modal-box       { background: #f4f4fc; border-color: #c0c0d8; }
.dbf-editor--light .dbf-img-modal-img       { background: #e8e8f4; }
.dbf-editor--light .dbf-img-modal-obs-inp   { background: #eeeef8; border-color: #c0c0d8; color: #303060; }
.dbf-editor--light .dbf-img-modal-obs-lbl   { color: #8080b0; }
.dbf-editor--light .dbf-img-paste-hint      { color: #a0a0c0; }
.dbf-editor--light .dbf-img-obs-ta          { background: #eeeef8; border-color: #c0c0d8; color: #404060; }
.dbf-editor--light .dbf-img-obs-ta::placeholder { color: #b0b0c8; }

/* ── Workspace: panel + canvas ── */
.dbf-workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Panel de propiedades ── */
.dbf-panel {
    width: 300px;
    min-width: 300px;
    background: #111120;
    border-right: 1px solid #252540;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

.dbf-panel-head {
    padding: 10px 14px 8px;
    border-bottom: 1px solid #252540;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.dbf-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 12px 16px;
}

.dbf-panel-foot {
    padding: 10px 12px;
    border-top: 1px solid #252540;
    flex-shrink: 0;
}

.dbf-panel-empty {
    color: #5050a0;
    font-size: 12px;
    text-align: center;
    padding: 20px 10px;
    line-height: 1.6;
}

/* ── Formulario del panel ── */
.dbf-sec {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #5050a0;
    font-weight: 700;
    margin: 14px 0 6px;
    padding-bottom: 4px;
    border-bottom: 1px solid #1e1e38;
}

.dbf-fg { margin-bottom: 8px; }

.dbf-fl {
    display: block;
    font-size: 11px;
    color: #7070a0;
    margin-bottom: 3px;
}

.dbf-fc {
    width: 100%;
    background: #0d0d1c;
    border: 1px solid #252540;
    color: #d8d8f0;
    border-radius: 4px;
    padding: 5px 8px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.12s;
    resize: vertical;
}

.dbf-fc:focus { border-color: #6655ff; }

.dbf-dup-warn {
    color: #ff4d4d;
    font-size: 11px;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Campo: fila de campo en tabla ── */
.dbf-field-block { margin-bottom: 6px; }

.dbf-field-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}

.dbf-fc-name { flex: 1; min-width: 0; font-family: monospace; }
.dbf-fc-type { width: 92px; flex-shrink: 0; }

.dbf-fc-pk {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #e0a030;
    flex-shrink: 0;
    cursor: pointer;
    white-space: nowrap;
}

.dbf-btn-xs {
    padding: 3px 7px;
    border-radius: 4px;
    border: 1px solid #252540;
    background: #1a1a2c;
    color: #d8d8f0;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
}

.dbf-btn-xs:hover    { background: #22223a; }
.dbf-btn-xs.dbf-btn-rel    { color: #9988ff; border-color: #4433aa; }
.dbf-btn-xs.dbf-btn-del    { color: #e74c3c; border-color: #6a2020; }
.dbf-btn-xs.dbf-btn-create { color: #40b870; border-color: #1f5035; }
.dbf-btn-xs.dbf-btn-add    { color: #40b870; margin-top: 4px; }
.dbf-btn-xs.dbf-active     { background: #1a1040; border-color: #6655ff; color: #9988ff; }

/* ── Formulario de relación de campo ── */
.dbf-field-rel {
    background: #0d0d20;
    border: 1px solid #252545;
    border-radius: 4px;
    padding: 7px 8px;
    margin-top: 4px;
}

.dbf-frf-row {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 5px;
}

.dbf-frf-lbl { font-size: 10px; color: #7070a0; flex-shrink: 0; width: 44px; }

.dbf-frf-quick {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

/* ── Canvas ── */
.dbf-canvas-wrap {
    flex: 1;
    overflow: hidden;   /* pan gestionado por transform translate en #dbfWorld */
    position: relative;
    background: #0a0a14;
    cursor: default;
}

.dbf-mode-connect { cursor: crosshair; }

/* ── Modo pan (doble clic en área libre del diagrama) ── */
.dbf-pan-mode    { cursor: grab !important; }
.dbf-is-dragging { cursor: grabbing !important; }

.dbf-world {
    position: relative;
    width: 5000px;
    height: 4000px;
    background-image:
        linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px);
    background-size: 40px 40px;
}

.dbf-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

/* ── Nodos ── */
.dbf-node {
    position: absolute;
    border-radius: 9px;
    min-width: 190px;
    max-width: 250px;
    cursor: move;
    user-select: none;
    touch-action: none;
    box-shadow: 0 5px 18px rgba(0,0,0,0.55);
    border: 2px solid transparent;
    transition: border-color 0.12s, box-shadow 0.12s;
    z-index: 10;
}

.dbf-node:hover         { box-shadow: 0 8px 28px rgba(0,0,0,0.7); }

.dbf-selected {
    border-color: rgba(255,255,255,0.85) !important;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.15), 0 8px 28px rgba(0,0,0,0.7) !important;
    z-index: 20;
}

.dbf-connecting-src { outline: 2px dashed #e0a030; outline-offset: 3px; }

.dbf-node-conn .dbf-node-head { background: #b83030; }
.dbf-node-db   .dbf-node-head { background: #2965b8; }
.dbf-node-tbl  .dbf-node-head { background: #1f8a50; }
.dbf-node-chn  .dbf-node-head { background: #9a4f0a; }

.dbf-node-head {
    padding: 10px 13px 9px;
    border-radius: 7px 7px 0 0;
    display: flex;
    align-items: flex-start;
    gap: 9px;
}

.dbf-node-icon { font-size: 17px; flex-shrink: 0; margin-top: 1px; }

.dbf-node-tag {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.9px;
    opacity: 0.75;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 3px;
}

.dbf-node-name {
    font-weight: 700;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #fff;
}

.dbf-node-body {
    padding: 8px 13px 10px;
    background: rgba(0,0,0,0.35);
    border-radius: 0 0 7px 7px;
}

.dbf-node-line {
    font-size: 11px;
    color: rgba(255,255,255,0.6);
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dbf-node-empty { color: rgba(255,255,255,0.25); font-style: italic; }

.dbf-node-breadcrumb {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    letter-spacing: 0.02em;
}

.dbf-chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }

.dbf-chip {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: monospace;
    color: rgba(255,255,255,0.7);
}

.dbf-chip.pk   { background: rgba(224,160,48,0.15); border-color: rgba(224,160,48,0.3); color: #e0a030; }
.dbf-chip.rel  { background: rgba(160,96,208,0.15); border-color: rgba(160,96,208,0.3); color: #b060e0; }
.dbf-chip.more { color: #6655ff; border-color: #6655ff; }

/* ── Hint bar ── */
.dbf-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a0a;
    border: 1px solid #3a3020;
    color: #e0a030;
    font-size: 12px;
    padding: 5px 14px;
    border-radius: 6px;
    z-index: 200;
}

/* ── Toast ── */
.dbf-toast {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: #22223a;
    color: #d8d8f0;
    border: 1px solid #303055;
    border-radius: 7px;
    padding: 8px 16px;
    font-size: 13px;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.dbf-toast-show { opacity: 1; pointer-events: auto; }

/* ── Modales ── */
.dbf-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 400;
}

/* ── SQL Modal ── */
.dbf-sql-panel {
    background: #111120;
    border: 1px solid #252540;
    border-radius: 10px;
    width: 780px;
    max-width: 96vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.dbf-sql-head {
    padding: 12px 16px;
    border-bottom: 1px solid #252540;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.dbf-sql-body { flex: 1; overflow-y: auto; padding: 12px 16px; }

.dbf-sql-body pre {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    color: #c8e0f0;
    white-space: pre;
    line-height: 1.6;
}

.dbf-sql-foot {
    padding: 10px 16px;
    border-top: 1px solid #252540;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dbf-sql-info { flex: 1; font-size: 11px; color: #7070a0; }

/* ── Search Modal ── */
.dbf-search-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    z-index: 400;
}

.dbf-search-box {
    background: #111120;
    border: 1px solid #252540;
    border-radius: 10px;
    width: 560px;
    max-width: 96vw;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dbf-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid #252540;
}

.dbf-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #d8d8f0;
    font-size: 15px;
    font-family: inherit;
}

.dbf-search-results { flex: 1; overflow-y: auto; }

.dbf-search-empty {
    padding: 24px 16px;
    color: #5050a0;
    font-size: 12px;
    text-align: center;
}

.dbf-search-item {
    padding: 10px 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid #1a1a30;
    transition: background 0.1s;
}

.dbf-search-item:hover,
.dbf-search-focused { background: #1a1a30; }

.dbf-search-footer {
    padding: 8px 16px;
    border-top: 1px solid #252540;
    display: flex;
    gap: 14px;
    font-size: 11px;
    color: #5050a0;
}

.dbf-search-footer kbd {
    background: #1a1a2c;
    border: 1px solid #303055;
    border-radius: 3px;
    padding: 1px 5px;
    font-size: 10px;
    font-family: monospace;
    color: #a0a0c0;
}

/* ── Papelera Modal ── */
/* ── Auditoría modal ── */
.dbf-audit-panel {
    background: #111120;
    border: 1px solid #252540;
    border-radius: 10px;
    width: 560px;
    max-width: 96vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.dbf-audit-head {
    padding: 12px 16px;
    border-bottom: 1px solid #252540;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    font-size: 14px;
    font-weight: 600;
    color: #c0b0f0;
}

.dbf-audit-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dbf-audit-loading,
.dbf-audit-empty {
    text-align: center;
    padding: 32px 0;
    color: #555570;
    font-size: 13px;
}

.dbf-audit-row {
    background: #16162a;
    border: 1px solid #222240;
    border-radius: 6px;
    padding: 9px 12px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 3px 12px;
    font-size: 12px;
}

.dbf-audit-action {
    font-size: 13px;
    font-weight: 600;
    color: #c8c0f0;
    grid-column: 1;
}

.dbf-audit-who {
    color: #80a0e0;
    grid-column: 2;
    grid-row: 1;
    text-align: right;
    font-size: 12px;
}

.dbf-audit-when {
    color: #606080;
    grid-column: 2;
    grid-row: 2;
    text-align: right;
    font-size: 11px;
}

.dbf-audit-det {
    color: #808098;
    font-size: 11px;
    grid-column: 1 / -1;
    margin-top: 2px;
}

.dbf-editor--light .dbf-audit-panel  { background: #f8f8fd; border-color: #d8d8ea; }
.dbf-editor--light .dbf-audit-head   { border-color: #d8d8ea; color: #5040a0; }
.dbf-editor--light .dbf-audit-row    { background: #f0f0fb; border-color: #d8d8ea; }
.dbf-editor--light .dbf-audit-action { color: #4030a0; }
.dbf-editor--light .dbf-audit-who    { color: #4060b0; }
.dbf-editor--light .dbf-audit-when   { color: #9090b0; }
.dbf-editor--light .dbf-audit-det    { color: #8080a0; }

/* ── Incidencias (nav + panel) ── */
.dbf-inc-dept {
    font-size: 10px;
    background: rgba(220,80,80,0.15);
    border: 1px solid rgba(220,80,80,0.3);
    color: #e07070;
    border-radius: 3px;
    padding: 1px 6px;
}

.dbf-inc-cnt {
    font-size: 10px;
    background: rgba(100,100,200,0.15);
    border: 1px solid rgba(100,100,200,0.25);
    color: #9090d0;
    border-radius: 3px;
    padding: 1px 6px;
}

.dbf-inc-nodos-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dbf-inc-nodo-row {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    padding: 9px 11px;
}

.dbf-inc-ruta {
    font-size: 12px;
    color: #a0c0f0;
    line-height: 1.5;
    word-break: break-word;
}

.dbf-editor--light .dbf-inc-dept    { background: rgba(200,50,50,0.08); border-color: rgba(200,50,50,0.25); color: #b03030; }
.dbf-editor--light .dbf-inc-cnt     { background: rgba(60,60,180,0.08); border-color: rgba(60,60,180,0.2);  color: #5050b0; }
.dbf-editor--light .dbf-inc-nodo-row{ background: rgba(0,0,0,0.03); border-color: #d8d8ea; }
.dbf-editor--light .dbf-inc-ruta    { color: #3060a0; }

.dbf-trash-panel {
    background: #111120;
    border: 1px solid #252540;
    border-radius: 10px;
    width: 500px;
    max-width: 96vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.dbf-trash-head {
    padding: 12px 16px;
    border-bottom: 1px solid #252540;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.dbf-trash-body { flex: 1; overflow-y: auto; padding: 10px 14px; }

.dbf-trash-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #1a1a30;
    font-size: 13px;
}

.dbf-trash-foot {
    padding: 10px 14px;
    border-top: 1px solid #252540;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ── Dialecto SQL select ── */
.dbf-sql-head select {
    background: #0d0d1c;
    border: 1px solid #252540;
    color: #d8d8f0;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
}

/* ══════════════════════════════════════════════════
 * TEMA CLARO — overrides sobre el tema oscuro
 * ══════════════════════════════════════════════════ */

.dbf-editor--light { background: #f0f0f6; color: #1a1a3a; }

/* Toolbar */
.dbf-editor--light .dbf-toolbar       { background: #ffffff; border-color: #d8d8ea; }
.dbf-editor--light .dbf-toolbar-sep   { background: #d8d8ea; }
.dbf-editor--light .dbf-diag-nombre   { color: #1a1a3a; }
.dbf-editor--light .dbf-zoom-label    { color: #4a4a6a; }
.dbf-editor--light .dbf-save-status   { color: #16a34a; }

/* Botones del toolbar */
.dbf-editor--light .dbf-btn                    { background: #eeeef8; color: #1a1a3a; border-color: #d0d0e8; }
.dbf-editor--light .dbf-btn:hover              { background: #e4e4f2; border-color: #b8b8d8; }
.dbf-editor--light .dbf-btn-active             { background: #ede9fe !important; border-color: #7c3aed !important; color: #5b21b6 !important; }
.dbf-editor--light .dbf-badge                  { background: #dc2626; }

/* Botones pequeños (xs) */
.dbf-editor--light .dbf-btn-xs                 { background: #eeeef8; color: #1a1a3a; border-color: #d0d0e8; }
.dbf-editor--light .dbf-btn-xs:hover           { background: #e4e4f2; }
.dbf-editor--light .dbf-btn-xs.dbf-btn-rel     { color: #5b21b6; border-color: #a78bfa; }
.dbf-editor--light .dbf-btn-xs.dbf-btn-del     { color: #dc2626; border-color: #fca5a5; }
.dbf-editor--light .dbf-btn-xs.dbf-btn-create  { color: #15803d; border-color: #86efac; }
.dbf-editor--light .dbf-btn-xs.dbf-btn-add     { color: #15803d; }
.dbf-editor--light .dbf-btn-xs.dbf-active      { background: #ede9fe; border-color: #7c3aed; color: #5b21b6; }

/* Panel */
.dbf-editor--light .dbf-panel           { background: #f8f8fd; border-color: #d8d8ea; }
.dbf-editor--light .dbf-panel-head      { border-color: #d8d8ea; }
.dbf-editor--light .dbf-panel-foot      { border-color: #d8d8ea; }
.dbf-editor--light .dbf-panel-empty     { color: #8080b0; }
.dbf-editor--light .dbf-nav             { background: #f0f0fa; border-color: #d0d0ea; }
.dbf-editor--light .dbf-nav-head        { border-color: #d0d0ea; color: #7070b0; }
.dbf-editor--light .dbf-nav-sec-hd      { color: #8080c0; }
.dbf-editor--light .dbf-nav-sec-hd:hover { color: #5050a0; }
.dbf-editor--light .dbf-nav-item        { color: #5050a0; }
.dbf-editor--light .dbf-nav-item:hover  { background: #e0e0f4; color: #3030a0; }
.dbf-editor--light .dbf-nav-cnt         { background: #e0e0f0; color: #8080b0; }
.dbf-editor--light .dbf-nav-empty       { color: #a0a0c0; }
.dbf-editor--light .dbf-btn-active        { background: #e8e8ff !important; color: #4040b0 !important; border-color: #a0a0d0 !important; }
.dbf-editor--light .dbf-nav-div           { background: #d0d0e8; }
.dbf-editor--light .dbf-nav-scripts-hd   { color: #7070b0; }
.dbf-editor--light .dbf-nav-folder-hd    { color: #6060a0; }
.dbf-editor--light .dbf-nav-folder-hd:hover { color: #3030a0; }
.dbf-editor--light .dbf-nav-filter-inp   { background: #eeeef8; border-color: #c0c0da; color: #4040a0; }
.dbf-editor--light .dbf-nav-filter-inp::placeholder { color: #a0a0c0; }
.dbf-editor--light .dbf-nav-hd-btn       { border-color: #c0c0d8; color: #7070a0; }
.dbf-editor--light .dbf-nav-hd-btn:hover { background: #e0e0f4; color: #3030a0; }
.dbf-editor--light .dbf-nav-item-active  { background: #dcdcf8 !important; color: #2020a0 !important; }
.dbf-editor--light .dbf-sec             { color: #6060a0; border-color: #d8d8ea; }
.dbf-editor--light .dbf-fl              { color: #6060a0; }
.dbf-editor--light .dbf-fc              { background: #ffffff; border-color: #d0d0e8; color: #1a1a3a; }
.dbf-editor--light .dbf-fc:focus        { border-color: #7c3aed; }
.dbf-editor--light .dbf-field-rel       { background: #f0f0fa; border-color: #d8d8ea; }
.dbf-editor--light .dbf-frf-lbl         { color: #6060a0; }
.dbf-editor--light .dbf-fc-pk           { color: #b45309; }

/* Canvas */
.dbf-editor--light .dbf-canvas-wrap { background: #f0f0f6; }
.dbf-editor--light .dbf-world {
    background-image:
        linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
}

/* Nodos */
.dbf-editor--light .dbf-node            { box-shadow: 0 4px 14px rgba(0,0,0,0.15); }
.dbf-editor--light .dbf-node:hover      { box-shadow: 0 8px 24px rgba(0,0,0,0.22); }
.dbf-editor--light .dbf-selected        { border-color: rgba(0,0,0,0.5) !important; box-shadow: 0 0 0 3px rgba(0,0,0,0.12), 0 8px 24px rgba(0,0,0,0.22) !important; }
.dbf-editor--light .dbf-node-body       { background: rgba(255,255,255,0.92); }
.dbf-editor--light .dbf-node-line       { color: #374151; }
.dbf-editor--light .dbf-node-empty      { color: rgba(0,0,0,0.3); }
.dbf-editor--light .dbf-node-breadcrumb { color: rgba(0,0,0,0.4); }
.dbf-editor--light .dbf-chip            { background: rgba(0,0,0,0.06); border-color: rgba(0,0,0,0.12); color: #374151; }
.dbf-editor--light .dbf-chip.pk         { background: rgba(180,83,9,0.1);  border-color: rgba(180,83,9,0.3);  color: #b45309; }
.dbf-editor--light .dbf-chip.rel        { background: rgba(109,40,217,0.1); border-color: rgba(109,40,217,0.3); color: #6d28d9; }
.dbf-editor--light .dbf-chip.more       { color: #5b21b6; border-color: #7c3aed; }

/* SQL y Search modales */
.dbf-editor--light .dbf-sql-panel       { background: #f8f8fd; border-color: #d8d8ea; }
.dbf-editor--light .dbf-sql-head        { border-color: #d8d8ea; }
.dbf-editor--light .dbf-sql-body pre    { color: #1a2a4a; }
.dbf-editor--light .dbf-sql-foot        { border-color: #d8d8ea; }
.dbf-editor--light .dbf-sql-info        { color: #6060a0; }
.dbf-editor--light .dbf-search-box      { background: #f8f8fd; border-color: #d8d8ea; }
.dbf-editor--light .dbf-search-row      { border-color: #d8d8ea; }
.dbf-editor--light .dbf-search-input    { color: #1a1a3a; }
.dbf-editor--light .dbf-search-empty    { color: #8080b0; }
.dbf-editor--light .dbf-search-item:hover { background: #eeeef8; }

/* Papelera */
.dbf-editor--light .dbf-trash-panel     { background: #f8f8fd; border-color: #d8d8ea; }
.dbf-editor--light .dbf-trash-head      { border-color: #d8d8ea; }
.dbf-editor--light .dbf-trash-foot      { border-color: #d8d8ea; }
.dbf-editor--light .dbf-trash-item      { border-color: #d8d8ea; }
.dbf-editor--light .dbf-trash-item:hover { background: #eeeef8; }

/* Toast y hint */
.dbf-editor--light .dbf-toast   { background: #ffffff; color: #1a1a3a; border-color: #d8d8ea; }
.dbf-editor--light .dbf-hint    { background: #fffbeb; border-color: #fcd34d; color: #92400e; }

/* Search footer kbd */
.dbf-editor--light .dbf-search-footer kbd { background: #e0e0f0; color: #1a1a3a; border-color: #c0c0d8; }
