/* ============================================================
   Sistema de Gestión Documental — Calidad (MKD Soft UI)
   Paleta: fondo principal #F5FCFC, tarjetas/sidebar #FFFFFF,
   Verde Petróleo #125358, Acento Turquesa #14B8A6
   Tipografía: Inter (sistema), JetBrains Mono para códigos
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── RESET Y VARIABLES ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Fondos Luminosos y Frescos */
  --bg-app:           #F5FCFC;
  --bg-sidebar:       #FFFFFF; 
  --bg-sidebar-hover: #EAF5F5;
  --bg-content:       #F5FCFC;
  --bg-surface:       #FFFFFF;
  --bg-surface-2:     #F0F9F9;

  /* Identidad MKD */
  --accent:           #14B8A6; /* Turquesa Brillante */
  --accent-hover:     #0D9488;
  --accent-light:     #CCFBF1;
  --accent-text:      #0F766E;
  
  --brand-dark:       #125358; /* Verde Petróleo Oscuro */
  --brand-color:      #0F4C52;

  /* Estados Semánticos */
  --success:          #10B981;
  --warning:          #F59E0B;
  --danger:           #EF4444;
  --info:             #3B82F6;

  /* Tipografía para fondos claros */
  --text-primary:     #1F2937;
  --text-secondary:   #4B5563;
  --text-muted:       #9CA3AF;
  --text-sidebar:     #374151;
  --text-sidebar-dim: #6B7280;

  /* Bordes sutiles (Soft UI confía más en sombras) */
  --border:           rgba(18, 83, 88, 0.08);
  --border-dark:      rgba(18, 83, 88, 0.12);
  --border-focus:     var(--accent);

  /* Dimensiones */
  --sidebar-width: 260px;
  --topbar-height: 56px; /* Ligeramente más alto para respirar */
  --resizer-width: 4px;

  /* Radios incrementados (Pilar del Soft UI) */
  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Sistema de Sombras Orgánicas (Pigmentadas con la marca) */
  --shadow-sm:    0 2px 8px rgba(18, 83, 88, 0.04);
  --shadow:       0 4px 16px rgba(18, 83, 88, 0.06), 0 2px 4px rgba(18, 83, 88, 0.02);
  --shadow-md:    0 8px 24px rgba(18, 83, 88, 0.08), 0 4px 8px rgba(18, 83, 88, 0.03);
  --shadow-lg:    0 16px 32px rgba(18, 83, 88, 0.1), 0 8px 16px rgba(18, 83, 88, 0.04);
  --shadow-inner: inset 0 2px 4px rgba(18, 83, 88, 0.03);

  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-md: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── PANTALLAS ── */
.screen { display: none; height: 100vh; }
.screen.active { display: flex; }

/* ── LOGIN (Glassmorphism corporativo) ── */
#login-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
  position: relative;
  overflow: hidden;
}
#login-screen::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: url('../img/mkd_sophisticated_login_bg.png');
  background-size: cover;
  background-position: center;
  z-index: 0;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-xl);
  padding: 44px 40px;
  box-shadow: var(--shadow-lg);
  z-index: 1;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.login-logo-icon {
  width: 42px;
  height: 42px;
  background: var(--accent-light);
  color: var(--accent-text);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.login-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-dark);
  line-height: 1.2;
}
.login-logo-text span {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-sidebar-dim);
  margin-top: 2px;
}

.login-card h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}
.login-card p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.form-field { margin-bottom: 16px; }
.form-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.form-field input {
  width: 100%;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid transparent;
  box-shadow: var(--shadow-inner);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
}
.form-field input:focus {
  background: #FFFFFF;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-sm);
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: var(--brand-dark);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(18, 83, 88, 0.25);
  transition: all var(--transition);
  margin-top: 12px;
}
.btn-primary:hover { 
  background: var(--brand-color); 
  box-shadow: 0 6px 16px rgba(18, 83, 88, 0.35);
  transform: translateY(-1px);
}
.btn-primary:active { 
  transform: translateY(1px); 
  box-shadow: 0 2px 8px rgba(18, 83, 88, 0.2);
}

.login-error {
  margin-top: 16px;
  padding: 10px 14px;
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  border-radius: var(--radius);
  font-size: 13px;
  color: #B91C1C;
  display: none;
}
.login-error.show { display: block; }

/* ── APP LAYOUT ── */
#app-screen {
  flex-direction: column;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  padding: 0;
  flex-shrink: 0;
  z-index: 100;
}

.topbar-brand {
  width: var(--sidebar-width);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px;
  border-right: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-icon {
  width: 30px;
  height: 30px;
  background: var(--accent-light);
  color: var(--accent-text);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--brand-dark);
  white-space: nowrap;
}

.topbar-search {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 24px;
}
.search-wrap {
  position: relative;
  width: 100%;
  max-width: 600px;
}
.search-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
  pointer-events: none;
}
.search-wrap input {
  width: 100%;
  height: 38px;
  background: var(--bg-surface-2);
  border: 1px solid transparent;
  box-shadow: var(--shadow-inner);
  border-radius: var(--radius-lg);
  padding: 0 16px 0 38px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
}
.search-wrap input::placeholder { color: var(--text-muted); }
.search-wrap input:focus {
  background: #FFFFFF;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-sm);
}
.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-muted);
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  box-shadow: var(--shadow-sm);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
}

.view-toggle {
  display: flex;
  background: var(--bg-surface-2);
  border-radius: var(--radius);
  padding: 3px;
  margin-right: 12px;
}
.view-toggle button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.view-toggle button:hover { color: var(--brand-dark); }
.view-toggle button.active {
  background: #FFFFFF;
  color: var(--brand-dark);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
}
.icon-btn:hover {
  color: var(--brand-dark);
  background: var(--bg-surface-2);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--accent-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-text);
  cursor: pointer;
  margin-left: 8px;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}
.user-avatar:hover {
  transform: scale(1.05);
}

/* ── BODY WRAPPER ── */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-resizer {
  width: var(--resizer-width);
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 20;
  transition: background 0.15s, width 0.1s;
}
.sidebar-resizer:hover,
.sidebar-resizer.is-dragging {
  background: var(--accent-light);
  width: 4px;
}

.sidebar-section {
  padding: 16px 12px;
}
.sidebar-section:not(:last-child) {
  border-bottom: 1px solid var(--border);
}
.sidebar-section:last-child { flex: 1; overflow-y: auto; padding-top: 12px; }

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 12px;
}
.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.sidebar-section-action {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: all var(--transition);
}
.sidebar-section-action:hover {
  color: var(--brand-dark);
  background: var(--bg-surface-2);
}

/* Árbol de carpetas (Estilo Píldora Soft UI) */
.tree-node {
  display: flex;
  align-items: center;
  gap: 0;
  height: 32px;
  padding-right: 8px;
  margin: 2px 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  user-select: none;
  position: relative;
}
.tree-node:hover { background: var(--bg-sidebar-hover); }
.tree-node.selected {
  background: var(--accent-light);
}
.tree-node.selected::before {
  content: '';
  position: absolute;
  left: -12px; /* Alineado fuera del padding si es necesario, o en el borde */
  top: 6px;
  bottom: 6px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--accent);
}

.tree-indent { flex-shrink: 0; }
.tree-arrow {
  width: 24px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 10px;
  transition: transform var(--transition);
}
.tree-arrow.expanded { transform: rotate(90deg); color: var(--brand-dark); }
.tree-arrow.leaf { pointer-events: none; color: transparent; }

.tree-icon {
  font-size: 14px;
  flex-shrink: 0;
  margin-right: 8px;
}
.tree-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sidebar);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.tree-node.selected .tree-label { color: var(--brand-dark); font-weight: 600; }
.tree-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-surface-2);
  padding: 2px 6px;
  border-radius: 12px;
  flex-shrink: 0;
}
.tree-node.selected .tree-badge {
  background: #FFFFFF;
  color: var(--accent-text);
}

.tree-actions {
  opacity: 0;
  pointer-events: none;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-muted);
  transition: all var(--transition);
  cursor: pointer;
  background: none;
  border: none;
  margin-left: 4px;
}
.tree-node:hover .tree-actions,
.tree-node.selected .tree-actions {
  opacity: 1;
  pointer-events: all;
}
.tree-actions:hover { background: var(--bg-surface); color: var(--brand-dark); box-shadow: var(--shadow-sm); }

/* Scrollbar sidebar suave */
.sidebar *::-webkit-scrollbar { width: 5px; }
.sidebar *::-webkit-scrollbar-track { background: transparent; }
.sidebar *::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 10px; }

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-app);
}

/* Breadcrumb */
.breadcrumb-bar {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  background: var(--bg-app);
  gap: 0;
  flex-shrink: 0;
}
.breadcrumb-item {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color var(--transition);
}
.breadcrumb-item:hover { color: var(--accent-hover); }
.breadcrumb-item.active {
  color: var(--brand-dark);
  font-weight: 600;
  cursor: default;
}
.breadcrumb-sep {
  margin: 0 8px;
  color: var(--text-muted);
  font-size: 12px;
}

/* Toolbar de contenido */
.content-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 28px 16px;
  background: var(--bg-app);
  flex-shrink: 0;
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sm {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.btn-sm-primary {
  background: var(--brand-dark);
  color: #fff;
  box-shadow: 0 2px 8px rgba(18, 83, 88, 0.15);
}
.btn-sm-primary:hover { 
  background: var(--brand-color); 
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(18, 83, 88, 0.2);
}
.btn-sm-ghost {
  background: #FFFFFF;
  color: var(--text-primary);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-sm-ghost:hover {
  background: var(--bg-surface-2);
  color: var(--brand-dark);
  border-color: var(--border-dark);
}

/* Filtros de estado */
.status-filter {
  display: flex;
  gap: 4px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px;
  box-shadow: var(--shadow-sm);
}
.status-filter button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.status-filter button:hover { color: var(--brand-dark); }
.status-filter button.active {
  background: var(--bg-surface-2);
  color: var(--brand-dark);
}

.layout-btns {
  display: flex;
  background: #FFFFFF;
  border-radius: var(--radius-sm);
  padding: 4px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.layout-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 15px;
  transition: all var(--transition);
}
.layout-btn.active {
  background: var(--bg-surface-2);
  color: var(--brand-dark);
}

/* ── VISTA EXPLORER ── */
#explorer-view {
  flex: 1;
  overflow-y: auto;
  padding: 0 28px 28px;
}

/* Lista de archivos */
.file-list-header {
  display: grid;
  grid-template-columns: minmax(200px,3fr) 120px 120px 80px 80px 100px;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-surface-2);
  border-radius: var(--radius-lg);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  user-select: none;
  margin-bottom: 8px;
}
.file-list-header .col-sortable {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition);
}
.file-list-header .col-sortable:hover { color: var(--brand-dark); }

.file-list { display: flex; flex-direction: column; gap: 6px; }

.file-row {
  display: grid;
  grid-template-columns: minmax(200px,3fr) 120px 120px 80px 80px 100px;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.file-row:hover { 
  border-color: var(--accent-light);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.file-row.selected { 
  background: var(--bg-surface-2); 
  border-color: var(--accent);
}

.file-row-name {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.file-icon { font-size: 20px; flex-shrink: 0; }
.file-name-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}
.file-code {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

.file-row-cell {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Badges de estado (Colores pastel vibrantes) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.badge-approved  { background: #D1FAE5; color: #065F46; }
.badge-approved::before { background: #10B981; }
.badge-draft     { background: #F3F4F6; color: #374151; }
.badge-draft::before { background: #6B7280; }
.badge-review    { background: #FEF3C7; color: #92400E; }
.badge-review::before { background: #F59E0B; }
.badge-obsolete  { background: #FEE2E2; color: #991B1B; }
.badge-obsolete::before { background: #EF4444; }
.badge-archived  { background: #E2E8F0; color: #475569; }
.badge-archived::before { background: #94A3B8; }

/* Vista Grid */
.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.file-card {
  background: #FFFFFF;
  border: 1px solid #FFFFFF;
  border-radius: var(--radius-xl);
  padding: 20px 18px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: all var(--transition);
}
.file-card:hover {
  border-color: var(--accent-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
}
.file-card-icon { font-size: 36px; margin-bottom: 16px; }
.file-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 6px;
}
.file-card-meta { font-size: 12px; color: var(--text-muted); }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 100px 20px;
  text-align: center;
}
.empty-state-icon { font-size: 56px; margin-bottom: 24px; opacity: .8; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--brand-dark); margin-bottom: 12px; }
.empty-state p { font-size: 14px; color: var(--text-secondary); max-width: 320px; line-height: 1.6; }
.empty-state .btn-sm { margin-top: 24px; }

/* ── VISTA GRAPH (Soft/Light theme) ── */
#graph-view {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
  background-image: radial-gradient(var(--border-dark) 1.5px, transparent 1.5px);
  background-size: 32px 32px;
}
#graph-view.active { display: flex; }

.graph-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 10;
}
.graph-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.graph-filter-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font);
  border-radius: 20px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: #FFFFFF;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.graph-filter-btn::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.graph-filter-btn.active {
  background: var(--bg-surface-2);
  color: var(--brand-dark);
  border-color: var(--border-dark);
}
.graph-controls {
  display: flex;
  gap: 6px;
}
.graph-ctrl-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
}
.graph-ctrl-btn:hover {
  background: var(--bg-surface-2);
  color: var(--brand-dark);
}

#cytoscape-container { position: absolute; inset: 0; }

.graph-legend {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-lg);
}
.graph-legend-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 12px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── PANEL DETALLE (slide-in flotante) ── */
.detail-panel {
  width: 360px;
  background: #FFFFFF;
  border-left: none;
  box-shadow: -8px 0 32px rgba(18, 83, 88, 0.08);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-md);
  flex-shrink: 0;
  z-index: 50;
}
.detail-panel.open { transform: translateX(0); }

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: #FFFFFF;
}
.detail-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-dark);
}
.detail-body { padding: 24px; overflow-y: auto; flex: 1; }

.detail-field { margin-bottom: 20px; }
.detail-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 6px;
}
.detail-field-value {
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
  line-height: 1.5;
}
.detail-field-value.mono {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--brand-dark);
  background: var(--bg-surface-2);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
}

.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.detail-relationships { margin-top: 8px; }
.rel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.rel-item:last-child { border-bottom: none; }
.rel-type {
  font-size: 11px;
  padding: 4px 8px;
  background: var(--accent-light);
  color: var(--accent-text);
  border-radius: 6px;
  font-weight: 600;
  white-space: nowrap;
}
.rel-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }

/* ── MODALES (Soft UI Elevations) ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 83, 88, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-md);
}
.modal-backdrop.show {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: #FFFFFF;
  border: 1px solid #FFFFFF;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 32px 64px rgba(18, 83, 88, 0.15);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.95) translateY(10px);
  transition: transform var(--transition-md);
}
.modal-backdrop.show .modal { transform: scale(1) translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--brand-dark); }
.modal-body { padding: 28px; }
.modal-footer {
  padding: 16px 28px;
  background: var(--bg-app);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ── MODAL VISOR DE DOCUMENTOS ── */
.viewer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(18, 83, 88, 0.9);
  backdrop-filter: blur(12px);
  z-index: 1200;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-md);
}
.viewer-backdrop.show { opacity: 1; pointer-events: all; }
.viewer-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(255, 255, 255, 0.1);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  flex-shrink: 0;
}
.viewer-title {
  font-size: 16px;
  font-weight: 600;
  color: #FFFFFF;
}
.viewer-actions button { color: #FFFFFF; border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.1); }
.viewer-actions button:hover { background: rgba(255,255,255,0.2); color: #fff; }

.viewer-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.viewer-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: #FFF;
}
.viewer-body img {
  max-width: 95%;
  max-height: 95%;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.viewer-body pre {
  background: #FFFFFF;
  color: var(--text-primary);
  padding: 32px;
  border-radius: var(--radius-xl);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
  max-width: 900px;
  width: 90%;
  overflow: auto;
  max-height: 80vh;
  box-shadow: var(--shadow-lg);
}

/* Campos de formulario estándar */
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-app);
  border: 1px solid transparent;
  box-shadow: var(--shadow-inner);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  background: #FFFFFF;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light), var(--shadow-sm);
}
.field textarea { resize: vertical; min-height: 100px; }

/* Upload zone */
.upload-zone {
  border: 2px dashed var(--border-dark);
  border-radius: var(--radius-xl);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-app);
  transition: all var(--transition);
}
.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-light);
  transform: scale(1.02);
}
.upload-zone-icon { font-size: 40px; margin-bottom: 12px; }
.upload-zone p { font-size: 14px; font-weight: 600; color: var(--brand-dark); }
.upload-zone span { font-size: 12px; color: var(--text-muted); margin-top: 6px; display: block; }

/* ── SEARCH DROPDOWN ── */
.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #FFFFFF;
  border: 1px solid #FFFFFF;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  display: none;
  padding: 8px;
}
.search-results.show { display: block; }
.search-result-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition);
}
.search-result-item:hover { background: var(--bg-surface-2); }
.search-result-icon { font-size: 18px; margin-top: 2px; }
.search-result-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.search-result-path { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: var(--brand-dark);
  color: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  min-width: 280px;
  animation: toastIn .3s cubic-bezier(0.4, 0, 0.2, 1);
}
.toast.success { background: #0F766E; } /* Tono MKD más profundo */
.toast.error   { background: #B91C1C; }
.toast.info    { background: var(--brand-dark); }
@keyframes toastIn { from { opacity:0; transform:translateY(16px) scale(0.95); } to { opacity:1; transform:translateY(0) scale(1); } }

/* Menús Contextuales Dropdown */
.status-dropdown, .folder-ctx-menu {
  position: fixed;
  background: #FFFFFF;
  border: 1px solid #FFFFFF;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  z-index: 600;
  min-width: 180px;
  padding: 6px;
  animation: toastIn .2s ease;
}
.status-opt, .folder-ctx-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text-primary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}
.status-opt:hover, .folder-ctx-menu button:hover { background: var(--bg-surface-2); color: var(--brand-dark); }
.status-opt.active { background: var(--accent-light); }

/* ════════════════════════════════════════════════════════
   MÓDULO: CONFIGURACIÓN
   ════════════════════════════════════════════════════════ */

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 83, 88, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-md);
}
.settings-overlay.show { opacity: 1; pointer-events: all; }

.settings-layout {
  width: min(1000px, 94vw);
  height: min(760px, 92vh);
  background: #FFFFFF;
  border: 1px solid #FFFFFF;
  border-radius: var(--radius-xl);
  box-shadow: 0 32px 80px rgba(18, 83, 88, 0.2);
  display: flex;
  overflow: hidden;
  transform: scale(.96) translateY(14px);
  transition: transform var(--transition-md);
}
.settings-overlay.show .settings-layout { transform: scale(1) translateY(0); }

/* Nav lateral de configuración */
.settings-nav {
  width: 240px;
  background: var(--bg-app);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}
.settings-nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 20px;
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-dark);
}
.settings-nav-list {
  padding: 12px;
  flex: 1;
  overflow-y: auto;
}
.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
}
.settings-nav-item:hover {
  color: var(--brand-dark);
  background: var(--bg-surface);
  box-shadow: var(--shadow-sm);
}
.settings-nav-item.active {
  color: var(--brand-dark);
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}
.settings-nav-icon { font-size: 16px; width: 24px; text-align: center; }
.settings-nav-divider {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 20px 14px 8px;
}

/* Área de contenido */
.settings-content {
  flex: 1;
  overflow-y: auto;
  background: #FFFFFF;
}
.settings-section { padding: 40px; }
.settings-section h2 {
  font-size: 22px;
  font-weight: 800;
  color: var(--brand-dark);
  margin-bottom: 28px;
}
.settings-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
}
.settings-title-row h2 { margin-bottom: 4px; }
.settings-subtitle { font-size: 14px; color: var(--text-secondary); }

/* Cards de configuración */
.settings-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.settings-card h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-dark);
  margin-bottom: 20px;
}
.settings-card-table { padding: 0; overflow-x: auto; }

/* Tabla interna */
.settings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.settings-table th {
  padding: 16px 24px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  text-align: left;
  background: var(--bg-app);
  border-bottom: 1px solid var(--border);
}
.settings-table td {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .sidebar { width: 220px; }
  .topbar-brand { width: 220px; }
  .file-list-header,
  .file-row {
    grid-template-columns: minmax(140px,3fr) 100px 100px 80px;
  }
  .file-list-header :nth-child(n+5),
  .file-row :nth-child(n+5) { display: none; }
  .settings-layout { flex-direction: column; }
  .settings-nav { width: 100%; border-right: none; border-bottom: 1px solid var(--border); flex-direction: row; overflow-x: auto; padding: 12px; }
  .settings-nav-header { display: none; }
  .settings-nav-list { display: flex; padding: 0; }
  .settings-nav-divider { display: none; }
}
@media (max-width: 640px) {
  .sidebar { display: none; }
  .topbar-brand { display: none; }
  .topbar-search { padding: 0 12px; }
  .content-toolbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .toolbar-left, .toolbar-right { justify-content: space-between; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}