/* ─── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --surface:     #1a1d27;
  --surface2:    #22263a;
  --border:      #2e3350;
  --accent:      #6c63ff;
  --accent-soft: #6c63ff22;
  --success:     #22d3a5;
  --danger:      #ff5f7e;
  --critical:    #ff9f43;
  --text:        #e2e8f0;
  --text-muted:  #7a82a6;
  --edge:        #6b7599;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 4px 24px #00000055;
  --transition:  .2s ease;
}

/* ─── Modo claro ────────────────────────────────────────────── */
body.light {
  --bg:          #f0f2f8;
  --surface:     #ffffff;
  --surface2:    #e8eaf4;
  --border:      #d0d4e8;
  --accent:      #5b52e8;
  --accent-soft: #5b52e822;
  --success:     #0fa87e;
  --danger:      #e03060;
  --critical:    #d97706;
  --text:        #1a1d2e;
  --text-muted:  #6b7280;
  --edge:        #8892b0;
  --shadow:      0 4px 24px #00000018;
}

body.light .node-box          { fill: #ffffff; }
body.light .node-duration-badge { stroke: var(--success); fill: #f0f2f8; }
body.light .aoa-circle        { fill: #ffffff; }
body.light .node-circle       { fill: #ffffff; }
body.light .node-box.critical { fill: #fff7ed; }
body.light .aoa-circle.critical { fill: #fff7ed; }
body.light .node-circle.critical { fill: #fff7ed; }
body.light .proc-step         { background: #ffffff; }
body.light .proc-formula      { background: var(--surface2); }
body.light .proc-section      { background: var(--surface2); }
body.light .proc-critical-list { color: var(--text-muted); }
body.light .import-textarea   { background: var(--surface2); color: var(--text); }
body.light .modal             { background: var(--surface); }
body.light .modal-body input  { background: var(--surface2); color: var(--text); }
body.light .pred-options-list { background: var(--surface2); }
body.light .file-menu-dropdown { background: var(--surface); }
body.light .file-menu-submenu  { background: var(--surface); }
body.light .xlsx-map-select    { background: var(--surface2); color: var(--text); }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  transition: background var(--transition), color var(--transition);
}

/* ─── Header ────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px 14px 16px;
  position: relative;
  z-index: 10;   /* Garantiza que el dropdown flote sobre main en móvil */
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.btn-hamburger {
  font-size: 1.1rem;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  color: var(--text-muted);
  border-color: transparent;
  background: transparent;
  transition: color var(--transition), background var(--transition);
}

.btn-hamburger:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.btn-hamburger.active { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }

/* ─── Undo / Redo ───────────────────────────────────────────── */
.undo-redo-group {
  display: flex;
  gap: 4px;
  align-items: center;
}

.btn-undoredo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: var(--text-muted);
  border-color: var(--border);
  background: transparent;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.btn-undoredo:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.btn-undoredo:disabled { opacity: .35; cursor: not-allowed; }

.btn-theme-toggle {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  color: var(--text-muted);
  border-color: var(--border);
  background: var(--surface2);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
}

.btn-theme-toggle:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-icon { color: var(--accent); font-size: 1.6rem; }
.accent { color: var(--accent); }

.tagline {
  color: var(--text-muted);
  font-size: .82rem;
  border-left: 1px solid var(--border);
  padding-left: 20px;
  flex: 1;
}

/* ─── Menú Archivo ──────────────────────────────────────────── */
.file-menu { position: relative; flex-shrink: 0; }

.file-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.file-menu-btn:hover, .file-menu-btn.open {
  color: var(--text);
  background: var(--surface2);
  border-color: var(--border);
}

.file-menu-arrow { font-size: .65rem; transition: transform var(--transition); }
.file-menu-btn.open .file-menu-arrow { transform: rotate(180deg); }

.file-menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px #00000066, 0 2px 8px #00000044;
  padding: 6px;
  z-index: 200;
  display: none;
  animation: dropdown-in .15s ease;
}

.file-menu-dropdown.open { display: block; }

@keyframes dropdown-in {
  from { opacity: 0; transform: translateY(-6px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.file-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.file-menu-item:hover { background: var(--surface2); }

.fm-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; color: var(--text-muted); }

.fm-text { display: flex; flex-direction: column; gap: 1px; }
.fm-label { font-size: .82rem; font-weight: 600; color: var(--text); line-height: 1.2; }
.fm-hint  { font-size: .7rem; color: var(--text-muted); line-height: 1.2; }

.file-menu-sep { height: 1px; background: var(--border); margin: 4px 0; }

.file-menu-item--danger .fm-label { color: var(--danger); }
.file-menu-item--danger .fm-icon  { color: var(--danger); }
.file-menu-item--danger:hover { background: #ff5f7e14; }

.file-menu-item:disabled { opacity: .38; cursor: not-allowed; pointer-events: none; }

.header-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  margin-left: auto;
  padding-left: 20px;
  border-left: 1px solid var(--border);
}

.brand-by { font-size: .65rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); font-weight: 500; }

.brand-name { font-size: .95rem; font-weight: 800; letter-spacing: -0.3px; color: var(--text); line-height: 1; }

.brand-accent {
  color: var(--accent);
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ─── Layout ────────────────────────────────────────────────── */
/* En escritorio el header mide ~57px; en móvil las media queries lo sobreescriben */
main { display: flex; height: calc(100vh - 57px); overflow: hidden; position: relative; }

/* ─── Panel ─────────────────────────────────────────────────── */
.panel {
  width: 360px;
  min-width: 220px;
  max-width: 600px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  transition: width .3s ease, min-width .3s ease, border-color .3s ease;
}

.panel-resize-handle {
  position: absolute;
  top: 0;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  /* left se ajusta dinámicamente por JS */
}

.panel-resize-handle::after {
  content: '';
  display: none;
}

/* Ensure file menu dropdown is above resize handle */
.file-menu-dropdown { z-index: 60 !important; }

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 1rem; font-weight: 600; }

.panel-header-actions { display: flex; align-items: center; gap: 6px; }

.btn-collapse {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text-muted);
  transition: color var(--transition), background var(--transition), transform var(--transition);
}

.btn-collapse:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }

.panel.collapsed { width: 0 !important; min-width: 0 !important; border-right: none; overflow: hidden; }

/* ─── Table ─────────────────────────────────────────────────── */
.table-wrapper { flex: 1; overflow-y: auto; padding: 12px 16px; }
.table-wrapper::-webkit-scrollbar { width: 5px; }
.table-wrapper::-webkit-scrollbar-track { background: transparent; }
.table-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

table { width: 100%; border-collapse: collapse; }

thead th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}

tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 10px 8px; vertical-align: middle; }

.badge-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: .8rem;
  border: 1.5px solid var(--accent);
  letter-spacing: -.3px;
}

.badge-num.sm { min-width: 20px; height: 20px; font-size: .7rem; border-radius: 4px; padding: 0 4px; }

.cell-name     { color: var(--text); font-weight: 500; }
.cell-name-sm  { color: var(--text); font-size: .78rem; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-duration { color: var(--success); font-weight: 600; }
.cell-pred     { font-size: .82rem; }

.pred-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: .72rem;
  font-weight: 700;
  margin-right: 3px;
}

.btn-row-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.btn-row-delete:hover { color: var(--danger); background: #ff5f7e18; }

.btn-row-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .9rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.btn-row-edit:hover { color: var(--accent); background: var(--accent-soft); }

/* ─── Panel actions ─────────────────────────────────────────── */
.panel-actions { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); }

/* ─── Activities section ────────────────────────────────────── */
.activities-section {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  transition: flex .35s ease, opacity .25s ease, max-height .35s ease;
  max-height: 9999px;
  opacity: 1;
}

.activities-section.collapsed { flex: 0 !important; max-height: 0 !important; opacity: 0; pointer-events: none; }
/* cuando CPM está colapsado, actividades ocupa todo el espacio disponible */
.activities-section.acts-expanded { flex: 99 !important; }
.activities-section .table-wrapper { flex: 1; min-height: 0; }

/* ─── CPM body (colapsable) ─────────────────────────────────── */
.cpm-body {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  max-height: 9999px;
  transition: max-height .35s ease, opacity .25s ease;
  opacity: 1;
}
.cpm-body.collapsed { max-height: 0 !important; opacity: 0; pointer-events: none; }
.cpm-results {
  border-top: 1px solid var(--border);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  transition: flex .35s ease;
}
/* cuando actividades está colapsada, CPM ocupa todo el espacio disponible */
.cpm-results.cpm-expanded { flex: 99 !important; }

/* cuando el body CPM está colapsado, el contenedor se reduce al alto del header */
.cpm-results.body-collapsed {
  flex: 0 0 auto;
  overflow: hidden;
}

.cpm-results::-webkit-scrollbar { width: 5px; }
.cpm-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* header CPM — mismo estilo que .panel-header */
.cpm-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-shrink: 0;
}

/* título CPM — mismo estilo que el h2 de actividades */
.cpm-results h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 0;
}

/* body CPM: ocupa el espacio restante y scroll solo aquí */
#cpm-body {
  padding: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#cpm-body::-webkit-scrollbar { width: 5px; }
#cpm-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.btn-collapse-acts {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-color: var(--border);
  transition: color var(--transition), background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.btn-collapse-acts svg { transition: transform .3s ease; }
.btn-collapse-acts:hover { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.btn-collapse-acts.expanded svg { transform: rotate(180deg); }

.cpm-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.proc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 0 0;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.btn-copy-cpm { flex: none !important; font-size: .72rem; padding: 5px 10px; }

/* ─── Toggle switch ─────────────────────────────────────────── */
.toggle-switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.toggle-switch input { display: none; }

.toggle-track {
  position: relative;
  width: 34px;
  height: 18px;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  transition: background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--transition), background var(--transition);
}

.toggle-switch input:checked + .toggle-track { background: var(--accent-soft); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-track .toggle-thumb { transform: translateX(16px); background: var(--accent); }

.toggle-label { font-size: .7rem; font-weight: 600; color: var(--text-muted); transition: color var(--transition); white-space: nowrap; }
.toggle-switch:has(input:checked) .toggle-label { color: var(--accent); }

/* ─── Procedimiento matemático ──────────────────────────────── */
.cpm-procedure { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 14px; }

.proc-section { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }

.proc-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

.proc-section-title .proc-icon { font-size: .9rem; }
.proc-section-title.forward  { color: #60a5fa; border-left: 3px solid #60a5fa; }
.proc-section-title.backward { color: #f472b6; border-left: 3px solid #f472b6; }
.proc-section-title.slack    { color: var(--success); border-left: 3px solid var(--success); }
.proc-section-title.critical { color: var(--critical); border-left: 3px solid var(--critical); }

.btn-copy-step {
  margin-left: auto;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: inherit;
  opacity: .55;
  cursor: pointer;
  font-size: .8rem;
  padding: 2px 7px;
  line-height: 1;
  transition: opacity var(--transition), background var(--transition), border-color var(--transition);
  flex-shrink: 0;
}
.btn-copy-step:hover { opacity: 1; background: #ffffff18; border-color: currentColor; }

.proc-steps { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }

.proc-step {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color var(--transition);
}

.proc-step.is-critical { border-color: #ff9f4344; background: #ff9f4308; }
.proc-step-header { display: flex; align-items: center; gap: 8px; }

.proc-act-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 800;
  font-size: .7rem;
  border: 1.5px solid var(--accent);
  flex-shrink: 0;
}

.proc-act-badge.critical { background: #ff9f4318; color: var(--critical); border-color: var(--critical); }
.proc-act-name { font-size: .78rem; font-weight: 600; color: var(--text); }

.proc-formula {
  font-size: .75rem;
  color: var(--text-muted);
  font-family: 'Consolas', 'Courier New', monospace;
  padding: 4px 8px;
  background: var(--surface2);
  border-radius: 4px;
  border-left: 2px solid var(--border);
  line-height: 1.6;
}

.proc-formula .val-es  { color: #60a5fa; font-weight: 700; }
.proc-formula .val-ef  { color: #34d399; font-weight: 700; }
.proc-formula .val-ls  { color: #f472b6; font-weight: 700; }
.proc-formula .val-lf  { color: #fb923c; font-weight: 700; }
.proc-formula .val-sl  { color: var(--success); font-weight: 700; }
.proc-formula .val-dur { color: var(--text); font-weight: 700; }
.proc-formula .val-crit { color: var(--critical); font-weight: 700; }
.proc-formula .op      { color: var(--text-muted); }

.proc-result { font-size: .73rem; color: var(--text-muted); padding-left: 4px; }
.proc-result strong { color: var(--text); }

.proc-legend { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); background: var(--surface2); }
.proc-legend-item { display: flex; align-items: center; gap: 4px; font-size: .68rem; color: var(--text-muted); }
.proc-legend-dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

.proc-critical-list { padding: 10px 12px; font-size: .78rem; color: var(--text-muted); line-height: 1.8; }
.proc-critical-list .crit-path-arrow { color: var(--critical); font-weight: 700; }
.proc-critical-list .crit-act {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: 4px;
  background: #ff9f4318;
  border: 1px solid #ff9f4344;
  color: var(--critical);
  font-weight: 700;
  font-size: .72rem;
  margin: 0 2px;
}

.cpm-results table { font-size: .78rem; }
.cpm-results thead th { font-size: .7rem; padding: 4px 6px; }
.cpm-results tbody td { padding: 6px 6px; }
.cpm-results .critical-row td { color: var(--critical); font-weight: 600; }

.critical-path-label { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: .82rem; color: var(--text-muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot.critical { background: var(--critical); }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), background var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-success { background: var(--success); color: #0f1117; flex: 1; }
.btn-success:hover { opacity: .88; }
.btn-ghost { background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--border); }
.btn-icon { background: var(--surface2); color: var(--text); border: 1px solid var(--border); width: 32px; height: 32px; padding: 0; font-size: 1.1rem; border-radius: var(--radius-sm); }
.btn-icon:hover { background: var(--border); }
.btn-user { background: transparent; border: none; width: auto; height: auto; border-radius: 50%; }
.btn-user:hover { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .88; }

/* ─── Canvas section ────────────────────────────────────────── */
.canvas-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--bg); }

.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  gap: 8px;
}

.toolbar-hint { font-size: .78rem; color: var(--text-muted); }
.toolbar-right { display: flex; align-items: center; gap: 6px; }

/* ── Grupo de zoom (zoom-out | reset | zoom-in agrupados) ── */
.toolbar-zoom-group {
  display: flex;
  align-items: center;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

/* Botón base del toolbar */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.toolbar-btn:hover { background: var(--accent-soft); color: var(--accent); }
.toolbar-btn:active { background: var(--border); }

/* Separadores internos del grupo zoom */
.toolbar-zoom-group .toolbar-btn + .toolbar-btn {
  border-left: 1px solid var(--border);
}

/* Candado — separado del grupo, con borde propio */
.toolbar-btn--lock {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  width: 30px;
  height: 30px;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.toolbar-btn--lock:hover { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }

/* Cuando el candado está activo (nodos bloqueados) */
.toolbar-btn--lock.locked {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.toolbar-btn--lock.locked:hover { background: var(--accent-hover, #4840d4); border-color: var(--accent-hover, #4840d4); }

.canvas-container { flex: 1; position: relative; overflow: hidden; cursor: grab; }
.canvas-container:active { cursor: grabbing; }
/* Cuando los nodos están bloqueados, cursor normal en el canvas */
.canvas-container.nodes-locked { cursor: grab; }
#diagram-svg { width: 100%; height: 100%; display: block; }

/* ─── Empty state ───────────────────────────────────────────── */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  pointer-events: none;
}

.empty-icon { font-size: 4rem; color: var(--border); line-height: 1; }
.empty-state p { text-align: center; color: var(--text-muted); font-size: .9rem; line-height: 1.7; }

/* ─── SVG nodes ─────────────────────────────────────────────── */
.node-group { cursor: grab; touch-action: none; }
.node-group:active { cursor: grabbing; }
.aoa-node-group { touch-action: none; }

.node-circle { fill: var(--surface2); stroke: var(--accent); stroke-width: 2; transition: filter .15s; }
.node-circle.critical { stroke: var(--critical); fill: #ff9f4318; }
.node-group:hover .node-circle { filter: drop-shadow(0 0 8px var(--accent)); }
.node-group:hover .node-circle.critical { filter: drop-shadow(0 0 8px var(--critical)); }

.node-label { fill: var(--text); font-size: 11px; font-weight: 600; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }
.node-num { fill: var(--accent); font-size: 13px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }

.node-duration-badge {
  fill: var(--surface);
  font-size: 10px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
  pointer-events: none;
  font-family: 'Segoe UI', system-ui, sans-serif;
  paint-order: stroke;
  stroke: var(--success);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.node-es, .node-ef, .node-ls, .node-lf { font-size: 9px; font-weight: 600; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }
.node-es { fill: #60a5fa; }
.node-ef { fill: #34d399; }
.node-ls { fill: #f472b6; }
.node-lf { fill: #fb923c; }

.node-box { fill: var(--surface2); stroke: var(--accent); stroke-width: 1.5; rx: 8; }
.node-box.critical { stroke: var(--critical); fill: #ff9f4310; }

/* ─── SVG edges ─────────────────────────────────────────────── */
.edge-line { fill: none; stroke: var(--edge); stroke-width: 2; marker-end: url(#arrow); }
.edge-line.critical { stroke: var(--critical); stroke-width: 2.5; marker-end: url(#arrow-critical); }
.edge-label { fill: var(--text-muted); font-size: 10px; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }
.arrow-head          { fill: var(--edge); }
.arrow-head-critical { fill: var(--critical); }

/* ─── Modal ─────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: #00000088; backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 100; }

.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); width: 420px; max-width: 95vw; box-shadow: var(--shadow); animation: modal-in .18s ease; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1rem; font-weight: 600; }

.btn-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 4px 8px; border-radius: var(--radius-sm); transition: color var(--transition), background var(--transition); }
.btn-close:hover { color: var(--danger); background: #ff5f7e18; }

.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.modal-num-badge-wrap { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.modal-num-label { font-size: .78rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.modal-num-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; height: 32px; padding: 0 10px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-weight: 800; font-size: 1rem; border: 2px solid var(--accent); letter-spacing: -.3px; }

.modal-body label { display: flex; flex-direction: column; gap: 6px; font-size: .82rem; font-weight: 600; color: var(--text-muted); }
.hint { font-weight: 400; font-size: .75rem; color: var(--text-muted); }

.modal-body input { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; font-size: .9rem; outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.modal-body input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px 18px; border-top: 1px solid var(--border); }

/* ─── Selector de predecesores ──────────────────────────────── */
.pred-selected-wrap {
  min-height: 38px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}

.pred-selected-wrap:empty::before { content: 'Ningún predecesor seleccionado'; color: var(--text-muted); font-size: .8rem; font-style: italic; }

.pred-chip-selected {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  color: var(--text);
  font-size: .78rem;
  font-weight: 600;
  animation: chip-in .15s ease;
}

@keyframes chip-in { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }

.pred-chip-selected .chip-num { color: var(--accent); font-weight: 800; font-size: .8rem; }
.pred-chip-selected .chip-name { color: var(--text-muted); font-size: .74rem; }
.pred-chip-remove { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: .75rem; padding: 0 1px; line-height: 1; border-radius: 3px; transition: color var(--transition); display: flex; align-items: center; }
.pred-chip-remove:hover { color: var(--danger); }

.pred-options-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); padding: 4px; }
.pred-options-list::-webkit-scrollbar { width: 4px; }
.pred-options-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

.pred-option-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; cursor: pointer; transition: background var(--transition); user-select: none; }
.pred-option-row:hover { background: var(--surface2); }
.pred-option-row.selected { background: var(--accent-soft); border: 1px solid var(--accent); }
.pred-option-row.selected:hover { background: #6c63ff33; }

.pred-opt-num { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 24px; padding: 0 5px; border-radius: 5px; background: var(--surface2); border: 1.5px solid var(--border); color: var(--accent); font-weight: 800; font-size: .78rem; flex-shrink: 0; transition: background var(--transition), border-color var(--transition); }
.pred-option-row.selected .pred-opt-num { background: var(--accent); border-color: var(--accent); color: #fff; }

.pred-opt-name { flex: 1; font-size: .82rem; color: var(--text); font-weight: 500; }
.pred-opt-check { font-size: .85rem; color: var(--accent); opacity: 0; transition: opacity var(--transition); }
.pred-option-row.selected .pred-opt-check { opacity: 1; }
.pred-empty-msg { text-align: center; color: var(--text-muted); font-size: .78rem; padding: 14px 8px; font-style: italic; }

/* ─── Panel IO ──────────────────────────────────────────────── */
.panel-io { display: flex; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); }

.btn-io { flex: 1; background: var(--surface2); color: var(--text-muted); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 7px 10px; font-size: .78rem; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; transition: color var(--transition), border-color var(--transition), background var(--transition); }
.btn-io:hover { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.io-icon { font-size: 1rem; font-weight: 700; }

/* ─── Diagram type toggle ───────────────────────────────────── */
.diagram-type-toggle { display: flex; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.type-btn { background: none; border: none; color: var(--text-muted); font-size: .78rem; font-weight: 700; padding: 5px 12px; cursor: pointer; transition: background var(--transition), color var(--transition); letter-spacing: .04em; }
.type-btn:hover { color: var(--text); background: var(--border); }
.type-btn.active { background: var(--accent); color: #fff; }
.toolbar-sep { width: 1px; background: var(--border); margin: 4px 4px; }

/* ─── Modal wide ────────────────────────────────────────────── */
.modal-wide { width: 520px; }
.import-hint { font-size: .82rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 4px; }
.import-hint code { background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: .78rem; color: var(--accent); font-family: 'Consolas', monospace; }
.import-textarea { width: 100%; min-height: 160px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); padding: 12px; font-size: .82rem; font-family: 'Consolas', 'Courier New', monospace; line-height: 1.6; resize: vertical; outline: none; transition: border-color var(--transition); }
.import-textarea:focus { border-color: var(--accent); }
.import-error { font-size: .8rem; color: var(--danger); background: #ff5f7e14; border: 1px solid #ff5f7e44; border-radius: var(--radius-sm); padding: 8px 12px; margin-top: 4px; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE — móvil primero
   ══════════════════════════════════════════════════════════════ */

/* ─── Header compacto en móvil ──────────────────────────────── */
@media (max-width: 640px) {
  header {
    padding: 0;
  }

  /* El header-inner se convierte en dos filas */
  .header-inner {
    flex-wrap: wrap;
    gap: 0;
    align-items: stretch;
  }

  /* ── Fila 1: hamburger | logo | (spacer) | theme ── */
  .btn-hamburger {
    order: 1;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 0;
    border-right: 1px solid var(--border);
  }

  .logo {
    order: 2;
    font-size: 1rem;
    gap: 6px;
    padding: 0 10px;
    flex: 1;                   /* empuja el resto hacia la derecha */
    height: 44px;
    align-items: center;
  }
  .logo-icon { font-size: 1.1rem; }

  /* tagline y brand: completamente fuera en móvil */
  .tagline      { display: none; }
  .header-brand { display: none; }

  .btn-theme-toggle {
    order: 3;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 0;
    border-left: 1px solid var(--border);
    border-top: none;
    border-right: none;
    border-bottom: none;
    background: transparent;
  }

  /* ── Fila 2: ocupa todo el ancho, contiene archivo + undo/redo ── */
  .file-menu {
    order: 4;
    flex: 1;                   /* se expande */
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
  }

  .file-menu-btn {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--border);
    font-size: .8rem;
    justify-content: flex-start;
  }

  .undo-redo-group {
    order: 5;
    border-top: 1px solid var(--border);
    gap: 0;
    height: 38px;
    align-items: center;
    flex-shrink: 0;
  }

  .btn-undoredo {
    width: 38px;
    height: 38px;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--border);
    background: transparent;
  }
}

/* ─── Layout principal: columna en móvil ────────────────────── */
@media (max-width: 768px) {
  /* html/body: layout fijo en móvil, sin scroll de página */
  html, body { height: 100%; overflow: hidden; }

  main {
    flex-direction: column;
    height: calc(100dvh - 82px);  /* llena toda la pantalla menos el header */
    min-height: 0;
    overflow: hidden;
  }

  /* Panel ocupa zona superior — altura fija con scroll interno */
  .panel {
    width: 100% !important;
    min-width: unset !important;
    max-width: unset !important;
    height: auto;
    max-height: 52vh;
    border-right: none;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    transition: max-height .3s ease, border-color .3s ease;
  }

  /* Ocultar manija de redimensionado */
  .panel-resize-handle { display: none; }

  /* Panel colapsado en móvil */
  .panel.collapsed {
    width: 100% !important;
    height: 0 !important;
    min-height: 0 !important;
    max-height: 0 !important;
    border-bottom: none;
    overflow: hidden;
  }

  /* Canvas ocupa todo el espacio restante */
  .canvas-section {
    flex: 1;
    min-height: 40vh;   /* piso mínimo por si el panel está muy expandido */
    height: 0;          /* flex: 1 necesita height:0 para calcular correctamente */
  }

  /* Toolbar del canvas: solo controles, sin hint */
  .toolbar-hint { display: none; }
  .canvas-toolbar { justify-content: flex-end; padding: 6px 10px; }

  /* Tabla con scroll horizontal */
  .table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* CPM table con scroll */
  #cpm-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #cpm-table-wrapper table { min-width: 420px; }

  /* Procedimiento: fórmulas con scroll */
  .proc-formula { overflow-x: auto; white-space: nowrap; }

  /* proc-toolbar apilado en columna */
  .proc-toolbar { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* Touch: desactivar gestos del navegador en el canvas para que
     nuestros handlers de Pointer Events reciban todos los eventos */
  .canvas-container { touch-action: none; }

  /* ── Dropdown: fixed para que siempre flote sobre el panel y canvas ── */
  .file-menu-dropdown {
    position: fixed;
    top: 82px;           /* justo debajo del header de dos filas */
    left: 0;
    right: auto;
    min-width: min(280px, 94vw);
    z-index: 300;
  }
}

/* ─── Ajuste fino 480px ─────────────────────────────────────── */
@media (max-width: 480px) {
  .panel { max-height: 58vh; }

  /* File menu: dropdown pantalla completa en móvil pequeño */
  .file-menu-dropdown {
    position: fixed;
    top: 82px;   /* justo debajo del header de dos filas */
    left: 0;
    right: 0;
    width: 100%;
    min-width: unset;
    border-radius: 0 0 var(--radius) var(--radius);
    border-left: none;
    border-right: none;
    border-top: none;
  }

  /* Modal: pantalla casi completa */
  .modal       { width: 96vw; margin: 0 2vw; max-height: 92vh; overflow-y: auto; }
  .modal-body  { padding: 14px; gap: 12px; }
  .modal-footer { padding: 10px 14px 14px; }

  /* Modal de importar/exportar */
  .modal-wide { width: 96vw; }
  .import-textarea { min-height: 110px; font-size: .78rem; }

  /* Panel header más compacto */
  .panel-header { padding: 10px 12px 8px; }
  .panel-header h2 { font-size: .88rem; }
  .panel-header-actions { gap: 4px; }

  /* Botón "Generar Diagrama" */
  .panel-actions { padding: 10px 12px; }
  .panel-actions .btn-success { font-size: .78rem; padding: 8px 10px; }

  /* AOA values toggle: ocultar label */
  #aoa-values-wrap .toggle-label { display: none; }

  /* CPM results más compacto */
  #cpm-body { padding: 10px; }
  .cpm-results-header { padding: 14px 16px 12px; }
  .cpm-results thead th { font-size: .65rem; padding: 3px 4px; }
  .cpm-results tbody td { padding: 5px 4px; }

  /* Splash en móvil pequeño */
  .splash-logo { font-size: 1.8rem !important; }
  .splash-logo-icon { font-size: 2rem !important; }
}

/* ─── Tabla de actividades en móvil ─────────────────────────── */
@media (max-width: 768px) {
  /* La tabla de actividades no usa scroll horizontal,
     se adapta al ancho disponible con columnas compactas */
  #activity-table { min-width: unset; width: 100%; table-layout: fixed; }

  /* Anchos de columna fijos para que todo quepa */
  #activity-table th:nth-child(1),
  #activity-table td:nth-child(1) { width: 36px; padding-left: 8px; padding-right: 4px; }   /* # */

  #activity-table th:nth-child(2),
  #activity-table td:nth-child(2) { width: auto; }                                            /* Nombre */

  #activity-table th:nth-child(3),
  #activity-table td:nth-child(3) { width: 44px; text-align: center; }                       /* Dur. */

  #activity-table th:nth-child(4),
  #activity-table td:nth-child(4) { width: 60px; }                                            /* Predecesores */

  #activity-table th:nth-child(5),
  #activity-table td:nth-child(5) { width: 58px; text-align: right; padding-right: 8px; }   /* Acciones */

  /* Nombre: truncar si es largo */
  #activity-table .cell-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 0;  /* table-layout: fixed requiere esto para que text-overflow funcione */
    font-size: .8rem;
  }

  /* Duración */
  #activity-table .cell-duration { font-size: .8rem; }

  /* Chips de predecesores: mostrar solo el número */
  #activity-table .cell-pred { font-size: .72rem; }
  #activity-table .pred-chip { font-size: .68rem; min-width: 18px; height: 18px; padding: 0 3px; margin-right: 2px; }

  /* Botones de acción: compactos */
  .btn-row-edit   { font-size: .78rem; padding: 3px 5px; }
  .btn-row-delete { font-size: .88rem; padding: 3px 5px; }

  /* Badges de número */
  .badge-num { min-width: 22px; height: 22px; font-size: .72rem; padding: 0 4px; }

  /* Padding de celdas */
  tbody td { padding: 8px 4px; }
  thead th { padding: 5px 4px; }
}

/* ─── AOA diagram styles ────────────────────────────────────── */
.aoa-circle { fill: var(--surface2); stroke: var(--accent); stroke-width: 2; transition: filter .15s; }
.aoa-circle.critical { stroke: var(--critical); fill: #ff9f4318; }
.aoa-node-group:hover .aoa-circle { filter: drop-shadow(0 0 8px var(--accent)); }
.aoa-node-group:hover .aoa-circle.critical { filter: drop-shadow(0 0 8px var(--critical)); }

.aoa-node-label { fill: var(--text); font-size: 13px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }
.aoa-edge-label { fill: var(--text); font-size: 10px; font-weight: 600; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }
.aoa-edge-dur { fill: var(--success); font-size: 9px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }
.aoa-edge-dur.critical-text { fill: var(--critical); }

.aoa-val-key { fill: var(--text-muted); font-size: 8px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; text-transform: uppercase; letter-spacing: .04em; }
.aoa-val-num { font-size: 11px; font-weight: 800; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }
.aoa-val-es  { fill: #60a5fa; }
.aoa-val-ef  { fill: #34d399; }
.aoa-val-ls  { fill: #f472b6; }
.aoa-val-lf  { fill: #fb923c; }
.aoa-val-slack { font-size: 9px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; font-family: 'Segoe UI', system-ui, sans-serif; }

body.light .aoa-val-es  { fill: #2563eb; }
body.light .aoa-val-ef  { fill: #059669; }
body.light .aoa-val-ls  { fill: #db2777; }
body.light .aoa-val-lf  { fill: #d97706; }

.aoa-values-toggle { margin: 0; cursor: pointer; }

.edge-dummy { stroke-dasharray: 6 4; opacity: .5; }
.edge-dummy.critical { stroke: var(--critical); stroke-width: 2.5; marker-end: url(#arrow-critical); opacity: .85; }

/* ─── Modal pequeño ─────────────────────────────────────────── */
.modal-sm { width: 360px; }
.confirm-icon { font-size: 2.4rem; text-align: center; margin-bottom: 10px; }
.confirm-msg { font-size: .88rem; color: var(--text-muted); text-align: center; line-height: 1.7; }
.confirm-msg strong { color: var(--text); }

/* ─── Utilities ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── fin de style.css ──────────────────────────────────────── */

/* ══════════════════════════════════════════════════════════════
   SUBMENÚS DEL MENÚ ARCHIVO
   ══════════════════════════════════════════════════════════════ */

/* ─── Submenús Importar / Exportar (inline, despliegan hacia abajo) ── */

/* Ítem padre — actúa como botón trigger */
.file-menu-item--sub {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  user-select: none;
  transition: background var(--transition);
}
.file-menu-item--sub:hover,
.file-menu-item--sub.open { background: var(--surface2); }

/* Flecha SVG del trigger */
.fm-sub-arrow {
  margin-left: auto;
  display: flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform .2s ease, color .2s ease;
}
.file-menu-item--sub.open .fm-sub-arrow { transform: rotate(180deg); color: var(--accent); }

/* Panel de submenu — inline, debajo del trigger */
.file-menu-submenu {
  display: none;
  flex-direction: column;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin: 2px 0 4px 0;
  overflow: hidden;
  animation: dropdown-in .15s ease;
}
.file-menu-submenu.open { display: flex; }

/* Items dentro del submenu con indentación */
.file-menu-subitem {
  padding-left: 32px !important;
}
.file-menu-subitem:hover { background: var(--surface) !important; }

/* ── Modal extra-ancho para el mapeador Excel ── */
.modal-xl { width: 680px; max-width: 96vw; }

/* ── Vista previa de columnas Excel ── */
.xlsx-preview-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 160px;
  overflow-y: auto;
}
.xlsx-preview-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: .72rem;
  font-family: 'Consolas', monospace;
}
.xlsx-preview-wrap th {
  background: var(--surface2);
  padding: 5px 10px;
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: left;
}
.xlsx-preview-wrap td {
  padding: 4px 10px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.xlsx-preview-wrap tr:last-child td { border-bottom: none; }

/* ── Campo de mapeo ── */
.xlsx-map-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 4px;
}
@media (max-width: 560px) { .xlsx-map-fields { grid-template-columns: 1fr; } }

.xlsx-map-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.xlsx-map-label {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.xlsx-map-label span { color: var(--accent); }
.xlsx-map-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 10px;
  font-size: .82rem;
  outline: none;
  transition: border-color var(--transition);
  cursor: pointer;
}
.xlsx-map-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Radio buttons para selector JPG ── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.radio-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.radio-option:hover { border-color: var(--accent); background: var(--accent-soft); }
.radio-option input[type="radio"] { display: none; }
.radio-mark {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition);
}
.radio-option:has(input:checked) .radio-mark {
  border-color: var(--accent);
}
.radio-option:has(input:checked) .radio-mark::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--accent);
}
.radio-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.radio-label { font-size: .85rem; font-weight: 600; color: var(--text); }
.radio-hint  { font-size: .72rem; font-weight: 400; color: var(--text-muted); }


/* ═══════════════════════════════════════════════════════════════
   NEW FEATURES — User Menu, Panel Tabs, PERT Analysis, Cloud
   ═══════════════════════════════════════════════════════════════ */

/* ── User Menu (header) ───────────────────────────────── */
.header-user-menu { position: relative; display: flex; align-items: center; }
.btn-user { position: relative; }
.user-avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft, rgba(108,99,255,0.15));
  color: var(--accent, #6c63ff);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; letter-spacing: 0;
}
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--panel-bg, #1a1d2e); border: 1px solid var(--border, #2e3350);
  border-radius: 8px; padding: 6px; min-width: 180px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4); z-index: 200;
  display: flex; flex-direction: column;
}
.user-dropdown.hidden { display: none; }
.user-dropdown-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 6px;
  font-size: 13px; color: var(--text-muted, #9ca3af);
  text-decoration: none; transition: all 0.15s;
}
.user-dropdown-item:hover { background: var(--accent-soft, rgba(108,99,255,0.12)); color: var(--text, #e2e8f0); }
.user-dropdown-item--danger { color: #ef4444; }
.user-dropdown-item--danger:hover { background: rgba(239,68,68,0.1); }

/* ── Panel Tabs ───────────────────────────────────────── */
.panel-tabs {
  display: flex; gap: 2px; padding: 6px 12px;
  background: var(--panel-header-bg, #161822);
  border-bottom: 1px solid var(--border, #2e3350);
  overflow: hidden; flex-shrink: 0;
}
.panel-tab {
  padding: 6px 12px; border-radius: 6px;
  font-size: 11px; font-weight: 600;
  color: var(--text-muted, #7a82a6);
  background: transparent; border: none; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.panel-tab:hover { color: var(--text, #e2e8f0); background: var(--hover-bg, rgba(255,255,255,0.05)); }
.panel-tab.active {
  color: var(--accent, #6c63ff); background: var(--accent-soft, rgba(108,99,255,0.15));
}

/* ── PERT Analysis Panel ──────────────────────────────── */
.pert-analysis-panel { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-height: 0; border-top: 1px solid var(--border); }
.pert-analysis-panel.hidden { display: none; }
.pert-panel-header { flex-shrink: 0; }
.pert-panel-header h3 { font-size: 1rem; font-weight: 600; color: var(--text); text-transform: none; letter-spacing: normal; margin-bottom: 0; }
.pert-body { display: flex; flex-direction: column; flex: 1; min-height: 0; padding: 16px; overflow-y: auto; }
.pert-body::-webkit-scrollbar { width: 5px; }
.pert-body::-webkit-scrollbar-track { background: transparent; }
.pert-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.pert-body .table-wrapper { flex: none; overflow-x: auto; padding: 0; margin-bottom: 12px; font-size: 10.92px; }
.pert-body .table-wrapper tbody td { padding: 6px 6px; font-size: 10.92px; }
.pert-body .table-wrapper::-webkit-scrollbar { width: 5px; height: 5px; }
.pert-body .table-wrapper::-webkit-scrollbar-track { background: transparent; }
.pert-body .table-wrapper::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.pert-instructions { text-align: center; padding: 32px 16px; color: var(--text-muted, #7a82a6); font-size: .78rem; line-height: 1.6; }
.pert-instructions p { margin-bottom: 12px; }

/* PERT te column (orange like critical) */
.pert-te { color: var(--warning, #ff9f43) !important; font-weight: 700 !important; }

/* PERT critical path label */
#pert-critical-label { margin: 14px 0 16px; font-size: .78rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
#pert-critical-label strong { color: var(--warning, #ff9f43); }

.pert-stats { padding: 14px 0 0; border-top: 1px solid var(--border, #2e3350); margin-top: 4px; }
.pert-stats.hidden { display: none; }
.pert-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.pert-stat-item { text-align: center; padding: 10px 4px; background: var(--surface2, rgba(255,255,255,0.03)); border: 1px solid var(--border, #2e3350); border-radius: 6px; }
.pert-stat-label { display: block; font-size: .65rem; font-weight: 600; color: var(--text-muted, #7a82a6); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.pert-stat-value { display: block; font-size: .9rem; font-weight: 800; color: var(--warning, #ff9f43); font-family: var(--mono, 'JetBrains Mono', monospace); }
.pert-prob-header { font-size: .65rem; font-weight: 600; color: var(--text-muted, #7a82a6); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }

.pert-probabilities { display: flex; flex-direction: column; gap: 4px; }
.pert-prob-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 10px; background: var(--surface2, rgba(255,255,255,0.03)); border: 1px solid var(--border, #2e3350); border-radius: 5px; font-size: .78rem;
}
.pert-prob-days { color: var(--text, #e2e8f0); font-weight: 600; font-family: var(--mono, monospace); }
.pert-prob-percent { color: var(--accent, #6c63ff); font-weight: 700; font-family: var(--mono, monospace); }

/* ── PERT Estimate Table (in modal) ───────────────────── */
.pert-estimate-table { max-height: 300px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border, #2e3350) transparent; }
.pert-estimate-table::-webkit-scrollbar { width: 5px; }
.pert-estimate-table::-webkit-scrollbar-track { background: transparent; }
.pert-estimate-table::-webkit-scrollbar-thumb { background: var(--border, #2e3350); border-radius: 99px; }
body.light .pert-estimate-table::-webkit-scrollbar-thumb { background: #d1d5db; }
.pert-estimate-table table { width: 100%; border-collapse: collapse; font-size: 12px; }
.pert-estimate-table th { text-align: left; padding: 6px 8px; color: var(--text-muted, #7a82a6); font-size: 10px; text-transform: uppercase; border-bottom: 1px solid var(--border, #2e3350); }
.pert-estimate-table td { padding: 6px 8px; border-bottom: 1px solid var(--border, #2e3350); }
.pert-estimate-table input {
  width: 60px; padding: 4px 6px; background: var(--panel-bg, #1a1d2e);
  border: 1px solid var(--border, #2e3350); border-radius: 4px;
  color: var(--text, #e2e8f0); font-size: 12px; text-align: center;
  font-family: var(--mono, monospace);
}
.pert-estimate-table input:focus { border-color: var(--accent, #6c63ff); outline: none; }

/* ── Cloud Projects List ──────────────────────────────── */
.cloud-projects-list { max-height: 400px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.cloud-project-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; background: var(--panel-header-bg, #161822);
  border: 1px solid var(--border, #2e3350); border-radius: 6px;
  cursor: pointer; transition: all 0.15s;
}
.cloud-project-item:hover { border-color: var(--accent, #6c63ff); background: var(--accent-soft, rgba(108,99,255,0.08)); }
.cloud-project-info { display: flex; flex-direction: column; gap: 2px; }
.cloud-project-name { font-size: 13px; font-weight: 600; color: var(--text, #e2e8f0); }
.cloud-project-date { font-size: 10px; color: var(--text-muted, #7a82a6); }
.cloud-project-actions { display: flex; gap: 4px; }
.cloud-project-btn {
  padding: 4px 8px; border-radius: 4px; font-size: 10px; cursor: pointer;
  border: 1px solid var(--border, #2e3350); background: transparent;
  color: var(--text-muted, #7a82a6); transition: all 0.15s;
}
.cloud-project-btn:hover { border-color: var(--accent, #6c63ff); color: var(--accent, #6c63ff); }
.cloud-project-btn--danger:hover { border-color: #ef4444; color: #ef4444; }


/* ── Panel Tabs — Light mode fix ──────────────────────── */
body.light .panel-tabs {
  background: #f3f4f8;
  border-bottom-color: #e2e5ee;
}
body.light .panel-tab {
  color: #6b7280;
}
body.light .panel-tab:hover {
  color: #1f2937;
  background: rgba(0,0,0,0.05);
}
body.light .panel-tab.active {
  color: #6c63ff;
  background: rgba(108,99,255,0.1);
}

/* ── User dropdown — Light mode ───────────────────────── */
body.light .user-dropdown {
  background: #fff;
  border-color: #e2e5ee;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}
body.light .user-dropdown-item {
  color: #4b5563;
}
body.light .user-dropdown-item:hover {
  background: rgba(108,99,255,0.08);
  color: #1f2937;
}

/* ── PERT Panel — Light mode ──────────────────────────── */
body.light .pert-analysis-panel { color: #1f2937; border-top-color: #e2e5ee; }
body.light .pert-panel-header h3 { color: #1f2937; }
body.light .pert-stats { border-top-color: #e2e5ee; }
body.light .pert-stat-item { background: #f9fafb; border-color: #e2e5ee; }
body.light .pert-stat-label { color: #6b7280; }
body.light .pert-prob-header { color: #6b7280; }
body.light .pert-prob-row { background: #f9fafb; border-color: #e2e5ee; }
body.light .pert-prob-days { color: #1f2937; }
body.light #pert-critical-label { color: #6b7280; }
body.light .pert-body::-webkit-scrollbar-thumb { background: #d1d5db; }
body.light .pert-body .table-wrapper::-webkit-scrollbar-thumb { background: #d1d5db; }
body.light .pert-estimate-table th { color: #6b7280; border-bottom-color: #e2e5ee; }
body.light .pert-estimate-table td { border-bottom-color: #e2e5ee; }
body.light .pert-estimate-table input { background: #fff; border-color: #e2e5ee; color: #1f2937; }

/* ── Cloud projects — Light mode ──────────────────────── */
body.light .cloud-project-item { background: #f9fafb; border-color: #e2e5ee; }
body.light .cloud-project-item:hover { border-color: #6c63ff; background: rgba(108,99,255,0.04); }
body.light .cloud-project-name { color: #1f2937; }
body.light .cloud-project-date { color: #6b7280; }
body.light .cloud-project-btn { border-color: #e2e5ee; color: #6b7280; }
body.light .cloud-project-btn:hover { border-color: #6c63ff; color: #6c63ff; }

/* ── Pagination buttons ───────────────────────────────── */
.cloud-pagination {
  display: flex; justify-content: center; gap: 4px;
  padding: 12px 0 4px; margin-top: 8px;
  border-top: 1px solid var(--border, #2e3350);
}
.cloud-page-btn {
  padding: 6px 12px; border-radius: 4px; font-size: 11px; font-weight: 600;
  cursor: pointer; border: 1px solid var(--border, #2e3350);
  background: transparent; color: var(--text-muted, #7a82a6); transition: all 0.15s;
}
.cloud-page-btn:hover { border-color: var(--accent, #6c63ff); color: var(--accent, #6c63ff); }
.cloud-page-btn.active { background: var(--accent, #6c63ff); color: #fff; border-color: var(--accent, #6c63ff); }
.cloud-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

body.light .cloud-pagination { border-top-color: #e2e5ee; }
body.light .cloud-page-btn { border-color: #e2e5ee; color: #6b7280; }
body.light .cloud-page-btn:hover { border-color: #6c63ff; color: #6c63ff; }
body.light .cloud-page-btn.active { background: #6c63ff; color: #fff; }

/* ── Panel minimum width: show all 3 tabs ──────────────── */
.panel { min-width: 407px !important; }


/* ═══════════════════════════════════════════════════════════════
   TUTORIAL / ONBOARDING
   ═══════════════════════════════════════════════════════════════ */
.tutorial-overlay {
  position: fixed; inset: 0; z-index: 9000;
  pointer-events: none;
}
.tutorial-overlay.is-active { pointer-events: all; }

.tutorial-highlight {
  position: fixed; z-index: 9001;
  border-radius: 8px;
  box-shadow: 0 0 0 4000px rgba(0,0,0,0.45), 0 0 0 3px var(--accent, #6c63ff), 0 0 20px rgba(108,99,255,0.4);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.tutorial-tooltip {
  position: absolute; z-index: 9002;
  background: var(--surface, #1a1d2e);
  border: 1px solid var(--accent, #6c63ff);
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 320px; width: max-content;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 0 20px rgba(108,99,255,0.15);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0; transform: translateY(8px);
}
.tutorial-tooltip.is-visible { opacity: 1; transform: translateY(0); }

.tutorial-tooltip__step {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  background: var(--accent, #6c63ff); color: #fff;
  font-size: 10px; font-weight: 700; margin-bottom: 8px;
}
.tutorial-tooltip__title {
  font-size: 15px; font-weight: 700; color: var(--text, #e2e8f0);
  margin-bottom: 6px;
}
.tutorial-tooltip__desc {
  font-size: 12.5px; color: var(--text-muted, #9ca3af); line-height: 1.6;
  margin-bottom: 16px;
}
.tutorial-tooltip__actions {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.tutorial-tooltip__skip {
  font-size: 11px; color: var(--text-muted, #7a82a6); cursor: pointer;
  background: none; border: none; padding: 4px 8px;
}
.tutorial-tooltip__skip:hover { color: var(--text, #e2e8f0); }
.tutorial-tooltip__nav { display: flex; gap: 6px; }
.tutorial-tooltip__btn {
  padding: 6px 14px; border-radius: 6px; font-size: 12px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.15s;
}
.tutorial-tooltip__btn--next { background: var(--accent, #6c63ff); color: #fff; }
.tutorial-tooltip__btn--next:hover { filter: brightness(1.1); }
.tutorial-tooltip__btn--prev { background: var(--surface2, rgba(255,255,255,0.05)); color: var(--text-muted); border: 1px solid var(--border); }
.tutorial-tooltip__btn--prev:hover { color: var(--text, #e2e8f0); border-color: var(--text-muted); }

.tutorial-dots {
  display: flex; gap: 4px; justify-content: center; margin-top: 12px;
}
.tutorial-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--border, #2e3350); transition: all 0.2s;
}
.tutorial-dot.is-active { background: var(--accent, #6c63ff); width: 16px; border-radius: 3px; }

/* Light mode */
body.light .tutorial-tooltip { background: #fff; border-color: #6c63ff; box-shadow: 0 12px 40px rgba(0,0,0,0.15), 0 0 20px rgba(108,99,255,0.1); }
body.light .tutorial-tooltip__title { color: #1f2937; }
body.light .tutorial-tooltip__desc { color: #6b7280; }
body.light .tutorial-tooltip__skip { color: #9ca3af; }
body.light .tutorial-tooltip__skip:hover { color: #1f2937; }
body.light .tutorial-tooltip__btn--prev { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }
body.light .tutorial-dot { background: #e5e7eb; }


/* ── LANGUAGE SWITCHER (tool header) ──────────────────────── */
.lang-switcher {
  position: relative;
}

.btn-lang-toggle,
.lang-switcher__btn.btn-lang-toggle {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all .18s ease;
  cursor: pointer;
}

.btn-lang-toggle:hover,
.lang-switcher__btn.btn-lang-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.btn-lang-toggle svg {
  width: 16px;
  height: 16px;
}

.lang-switcher__dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.35);
  padding: 6px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
  z-index: 200;
}

.lang-switcher__dropdown.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.lang-switcher__option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 16px;
  background: none;
  border: none;
  font-size: 13px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--text-muted);
  cursor: pointer;
  transition: all .15s ease;
  text-align: left;
}

.lang-switcher__option:hover {
  background: var(--accent-soft);
  color: var(--text);
}

.lang-switcher__option.is-active {
  color: var(--accent);
  font-weight: 600;
}

.lang-switcher__option-flag--removed {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.lang-switcher__option-label {
  flex: 1;
}

.lang-switcher__option-check {
  width: 14px;
  height: 14px;
  color: var(--accent);
  opacity: 0;
  flex-shrink: 0;
}

.lang-switcher__option.is-active .lang-switcher__option-check {
  opacity: 1;
}

/* Responsive: on small screens */
@media (max-width: 768px) {
  .lang-switcher {
    order: 2;
  }
  .btn-lang-toggle,
  .lang-switcher__btn.btn-lang-toggle {
    width: 40px;
    height: 40px;
  }
}
