/* ERP Motor Geométrico — Estilos */
:root {
  --cp: #1a1a2e;    /* primario */
  --ca: #e94560;    /* acento */
  --cv: #22c55e;    /* éxito */
  --cf: #f0f2f5;    /* fondo */
  --cb: #3b82f6;    /* azul */
  --co: #f59e0b;    /* naranja */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, -apple-system, sans-serif; background: var(--cf); color: #1a1a2e; min-height: 100vh; }

/* HEADER */
.erp-header {
  background: var(--cp);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
.erp-logo { font-weight: 800; font-size: 16px; }
.nit-badge { background: rgba(255,255,255,0.15); border-radius: 6px; padding: 2px 8px; font-size: 12px; margin-left: 8px; font-weight: 400; }
.rol-badge { background: var(--ca); border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 700; }

/* LAYOUT */
.erp-layout { display: flex; height: calc(100vh - 48px); }

/* SIDEBAR */
.erp-sidebar {
  width: 220px;
  background: white;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 12px 0;
}
.sidebar-titulo { padding: 8px 16px; font-size: 11px; font-weight: 700; color: #9ca3af; letter-spacing: 1px; text-transform: uppercase; }
.mod-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #374151;
  text-align: left;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.mod-btn:hover { background: var(--cf); }
.mod-btn.activo { background: #eff6ff; color: var(--cb); border-left-color: var(--cb); font-weight: 700; }
.mod-icono { font-size: 18px; }
.mod-label { flex: 1; }
.mod-count { background: #e5e7eb; border-radius: 10px; padding: 1px 7px; font-size: 11px; }

/* MAIN */
.erp-main { flex: 1; overflow-y: auto; padding: 24px; }

/* BIENVENIDA */
.erp-bienvenida { text-align: center; padding: 60px 20px; }
.erp-bienvenida h2 { font-size: 24px; color: var(--cp); }
.bienvenida-modulos { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-top: 32px; }
.bv-card { background: white; border-radius: 12px; padding: 24px 20px; cursor: pointer; border: 2px solid #e5e7eb; min-width: 130px; transition: all 0.2s; }
.bv-card:hover { border-color: var(--cb); box-shadow: 0 4px 16px rgba(59,130,246,0.15); transform: translateY(-2px); }

/* MÓDULO */
.modulo-header { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.modulo-icono-grande { font-size: 40px; }
.modulo-titulo { font-size: 22px; font-weight: 800; color: var(--cp); }
.modulo-subtitulo { color: #9ca3af; font-size: 13px; }

/* RESUMEN */
.resumen-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.resumen-card { background: white; border-radius: 10px; padding: 16px; border-left: 4px solid var(--cb); }
.rc-label { font-size: 12px; color: #9ca3af; margin-bottom: 4px; }
.rc-valor { font-size: 20px; font-weight: 800; color: var(--cp); }

/* SECCIONES */
.secciones-grid { display: flex; flex-direction: column; gap: 8px; }
.sec-card {
  background: white;
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.15s;
}
.sec-card:hover { border-color: var(--cb); box-shadow: 0 2px 8px rgba(59,130,246,0.1); }
.sec-card.activa { border-color: var(--cb); background: #eff6ff; }
.sec-icono { font-size: 24px; }
.sec-info { flex: 1; }
.sec-label { font-weight: 700; font-size: 14px; }
.sec-count { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.sec-arrow { color: #9ca3af; font-size: 20px; }

/* SECCIÓN DETALLE */
.seccion-header { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.seccion-header h2 { font-size: 20px; font-weight: 800; flex: 1; }
.btn-volver { background: none; border: 1px solid #e5e7eb; border-radius: 8px; padding: 6px 12px; cursor: pointer; font-size: 13px; color: #374151; }
.btn-volver:hover { background: #f9fafb; }
.hojas-count { background: #e5e7eb; border-radius: 10px; padding: 2px 10px; font-size: 12px; }

.seccion-toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.busqueda-input { flex: 1; min-width: 200px; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 12px; font-size: 14px; }
.busqueda-input:focus { outline: none; border-color: var(--cb); }

/* TABLA */
.tabla-wrap { overflow-x: auto; }
.erp-tabla { width: 100%; border-collapse: collapse; font-size: 13px; background: white; border-radius: 10px; overflow: hidden; }
.erp-tabla thead { background: var(--cp); color: white; }
.erp-tabla th { padding: 10px 12px; text-align: left; font-weight: 600; white-space: nowrap; }
.erp-tabla td { padding: 9px 12px; border-bottom: 1px solid #f3f4f6; }
.erp-tabla tbody tr:hover { background: #f9fafb; }
.btn-accion-tabla { background: var(--cp); color: white; border: none; border-radius: 6px; padding: 4px 10px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.btn-accion-tabla:hover { background: var(--ca); }

/* BOTONES */
.btn-nuevo { background: var(--cv); color: white; border: none; border-radius: 8px; padding: 8px 16px; font-weight: 700; cursor: pointer; font-size: 13px; white-space: nowrap; }
.btn-nuevo:hover { opacity: 0.9; }
.btn-guardar { background: var(--cv); color: white; border: none; border-radius: 8px; padding: 10px 20px; font-weight: 700; cursor: pointer; font-size: 14px; }
.btn-cancelar { background: #f3f4f6; color: #374151; border: none; border-radius: 8px; padding: 10px 20px; cursor: pointer; font-size: 14px; }
.btn-agregar-item { background: var(--cf); border: 1px dashed #9ca3af; border-radius: 8px; padding: 8px 16px; cursor: pointer; font-size: 13px; margin-bottom: 8px; }

/* FORMULARIOS */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: #374151; }
.form-grid input, .form-grid select {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
  outline: none;
}
.form-grid input:focus, .form-grid select:focus { border-color: var(--cb); }

.oc-item-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.oc-item-row input, .oc-item-row select { border: 1px solid #e5e7eb; border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.as-linea { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.as-linea input, .as-linea select { border: 1px solid #e5e7eb; border-radius: 6px; padding: 6px 8px; font-size: 13px; }

/* CARGANDO */
.cargando { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 200px; gap: 16px; color: #9ca3af; }
.spinner { width: 32px; height: 32px; border: 3px solid #e5e7eb; border-top-color: var(--cb); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sin-res { text-align: center; padding: 40px; color: #9ca3af; font-size: 14px; }

/* TOAST */
#erp-toast { position: fixed; bottom: 20px; right: 20px; z-index: 600; }
.toast { padding: 12px 20px; border-radius: 10px; font-weight: 600; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,0.15); animation: slideIn 0.2s ease; }
.toast-verde { background: var(--cv); color: white; }
.toast-rojo  { background: var(--ca); color: white; }
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* MÉTRICAS */
.metricas-panel {
  position: fixed;
  bottom: 16px;
  left: 16px;
  background: var(--cp);
  color: white;
  border-radius: 12px;
  font-size: 11px;
  max-width: 220px;
  max-height: 42px;
  overflow: hidden;
  transition: max-height 0.3s;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.metricas-panel.expandido { max-height: 600px; }
.metricas-titulo { padding: 10px 14px; font-weight: 700; cursor: pointer; font-size: 12px; white-space: nowrap; }
.metricas-body { padding: 0 14px 12px; }
.metrica-seccion { font-size: 9px; letter-spacing: 1px; opacity: 0.5; margin: 10px 0 4px; text-transform: uppercase; }
.metrica { display: flex; justify-content: space-between; padding: 2px 0; }
.metrica.verde .metrica-valor { color: var(--cv); }
.metrica.resaltado .metrica-valor { color: var(--co); }
.metrica-label { opacity: 0.7; }
.metrica-valor { font-weight: 700; }

/* LECTOR DOCUMENTO */
#tl-zona-drop.drag-over { border-color: var(--cb); background: #eff6ff; }
#tl-zona-drop:hover { border-color: #9ca3af; background: #f9fafb; }

/* RESPONSIVE */
@media (max-width: 640px) {
  .erp-sidebar { width: 60px; }
  .mod-label, .mod-count, .sidebar-titulo { display: none; }
  .erp-main { padding: 16px; }
  .resumen-grid { grid-template-columns: 1fr 1fr; }
  .metricas-panel { display: none; }
}
