/* ================================================================
   ERP VectraSur Consultores — Stylesheet Principal
   Versión: 1.0 | Año Fiscal 2026
   ================================================================ */

/* ── Variables de diseño corporativo ────────────────────────────── */
:root {
  --primary-dark:   #0a345c;  /* Azul profundo corporativo principal  */
  --primary-light:  #428bca;  /* Azul claro: hover y botones de acción*/
  --neutral-dark:   #333333;  /* Gris tipográfico: textos y tablas    */
  --bg-hero:        #ffffff;  /* Blanco puro: fondo del header        */
  --bg-body:        #f4f6f9;  /* Gris claro: fondo de la aplicación   */
  --accent-success: #2ecc71;  /* Verde: utilidades e IVA crédito      */
  --accent-danger:  #e74c3c;  /* Rojo: costos y cuentas por pagar     */
  --accent-warning: #f39c12;  /* Naranja: estados intermedios         */
  --border-color:   #dde3ec;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08);
  --shadow-md:      0 4px 12px rgba(10,52,92,.12);
  --shadow-lg:      0 8px 24px rgba(10,52,92,.18);
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      16px;
  --nav-height:     52px;
  --header-height:  88px;
  --font-base:      'Segoe UI', system-ui, -apple-system, sans-serif;
  --transition:     .18s ease;
}

/* ── Reset y base ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family:      var(--font-base);
  background-color: var(--bg-body);
  color:            var(--neutral-dark);
  line-height:      1.55;
  min-height:       100vh;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { color: var(--primary-light); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ================================================================
   LOGIN
   ================================================================ */
.login-body {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #1565a8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-wrapper {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--bg-hero);
  border-radius: var(--radius-lg);
  padding: 2.8rem 2.4rem 2rem;
  box-shadow: var(--shadow-lg);
}

.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 1.4rem;
}

.login-logo {
  max-height: 72px;
  width: auto;
}

.login-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: .25rem;
}

.login-subtitle {
  text-align: center;
  font-size: .82rem;
  color: #888;
  margin-bottom: 1.8rem;
}

.login-footer {
  text-align: center;
  font-size: .75rem;
  color: #aaa;
  margin-top: 1.6rem;
}

.input-password-wrap { position: relative; }
.input-password-wrap .form-control { padding-right: 2.8rem; }
.btn-toggle-pass {
  position: absolute;
  right: .7rem;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  line-height: 0;
  transition: color var(--transition);
}
.btn-toggle-pass:hover { color: var(--primary-light); }

/* ================================================================
   NAVEGACIÓN SUPERIOR  (queda DEBAJO del header — top: header-height)
   ================================================================ */
#main-nav {
  position: fixed;
  top: var(--header-height);   /* Se ubica debajo del hero header */
  left: 0;
  right: 0;
  z-index: 900;
  height: var(--nav-height);
  background: var(--primary-dark);
  display: flex;
  align-items: center;
  padding: 0 1.2rem;
  gap: 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}

.nav-modules {
  display: flex;
  align-items: center;
  gap: .25rem;
  list-style: none;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-modules::-webkit-scrollbar { display: none; }

.nav-btn {
  height: 34px;
  padding: 0 .9rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 500;
  color: rgba(255,255,255,.82);
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-btn:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
}
.nav-btn.active {
  background: var(--primary-light);
  color: #fff;
}

/* Configuración dropdown */
.nav-config-wrap { position: relative; flex-shrink: 0; }

.nav-btn-config {
  border: 1px solid rgba(255,255,255,.3);
  padding: 0 .9rem;
}

.config-dropdown {
  position: absolute;
  top: calc(100% + .4rem);
  right: 0;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  min-width: 190px;
  list-style: none;
  padding: .4rem 0;
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--transition), transform var(--transition), visibility var(--transition);
}
.config-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: .55rem 1rem;
  font-size: .85rem;
  color: var(--neutral-dark);
  text-align: left;
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg-body); }
.dropdown-item-danger { color: var(--accent-danger); }
.dropdown-sep { height: 1px; background: var(--border-color); margin: .3rem 0; }

/* ================================================================
   HERO HEADER INSTITUCIONAL  (fixed arriba de todo — top: 0)
   ================================================================ */
#hero-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-hero);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.8rem;
  border-bottom: 2px solid var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

.header-identity {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-logo {
  max-height: 56px;
  width: auto;
  object-fit: contain;
}

.header-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
}
.header-user-name {
  font-size: .95rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.header-user-cargo {
  font-size: .78rem;
  color: #777;
}

.header-actions { display: flex; align-items: center; gap: .75rem; }

.btn-save-global {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
  font-weight: 600;
  padding: .55rem 1.2rem;
}

/* ================================================================
   MAIN VIEWPORT
   ================================================================ */
#app-viewport {
  /* Empuja el contenido por debajo del header fijo + nav fija */
  padding-top: calc(var(--header-height) + var(--nav-height) + 1.8rem);
  padding-right: 1.8rem;
  padding-bottom: 1.8rem;
  padding-left: 1.8rem;
  min-height: 100vh;
}

/* Pantalla de carga inicial */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: 60vh;
  color: #888;
}

/* ================================================================
   COMPONENTES REUTILIZABLES
   ================================================================ */

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  height: 38px;
  padding: 0 1.2rem;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  font-weight: 600;
  transition: background var(--transition), opacity var(--transition), box-shadow var(--transition);
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; height: 44px; font-size: .95rem; }

.btn-primary  { background: var(--primary-light); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: #3278b5; box-shadow: 0 2px 8px rgba(66,139,202,.35); }

.btn-secondary { background: var(--bg-body); color: var(--neutral-dark); border: 1px solid var(--border-color); }
.btn-secondary:hover:not(:disabled) { background: var(--border-color); }

.btn-success { background: var(--accent-success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #27ae60; }

.btn-danger  { background: var(--accent-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c0392b; }

.btn-outline {
  background: transparent;
  color: var(--primary-light);
  border: 1px solid var(--primary-light);
}
.btn-outline:hover:not(:disabled) { background: rgba(66,139,202,.1); }

.btn-sm { height: 30px; padding: 0 .8rem; font-size: .79rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: var(--radius-sm); }

/* Formularios */
.form-group { margin-bottom: 1.1rem; }
.form-group label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--neutral-dark);
  margin-bottom: .35rem;
}

.form-control {
  width: 100%;
  height: 40px;
  padding: 0 .85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: .87rem;
  font-family: inherit;
  color: var(--neutral-dark);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(66,139,202,.2);
}
.form-control:disabled { background: var(--bg-body); color: #999; }

textarea.form-control {
  height: auto;
  min-height: 80px;
  padding: .65rem .85rem;
  resize: vertical;
}
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23888' d='M6 8L0 0h12z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .85rem center; padding-right: 2.2rem; }

.form-row { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.form-check { display: flex; align-items: center; gap: .5rem; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary-light); cursor: pointer; }
.form-check label { font-size: .87rem; cursor: pointer; margin: 0; }

/* Alertas */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  border: 1px solid transparent;
  margin-bottom: 1rem;
}
.alert-danger  { background: #fdf0f0; border-color: #f5c6c6; color: #c0392b; }
.alert-success { background: #edfaf3; border-color: #b2e4c9; color: #1e7e48; }
.alert-warning { background: #fef9ec; border-color: #fde68a; color: #92640c; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
.spinner-lg { width: 38px; height: 38px; border-width: 3.5px; border-color: var(--border-color); border-top-color: var(--primary-light); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Tarjetas (Cards) */
.card {
  background: #fff;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.card-body   { padding: 1.4rem; }
.card-footer { padding: .9rem 1.4rem; border-top: 1px solid var(--border-color); background: var(--bg-body); border-radius: 0 0 var(--radius-md) var(--radius-md); }

/* Tablas */
.table-wrap { overflow-x: auto; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
.table th {
  background: var(--bg-body);
  color: var(--primary-dark);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: .65rem 1rem;
  text-align: left;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
}
.table td {
  padding: .7rem 1rem;
  border-bottom: 1px solid #eef1f6;
  vertical-align: middle;
  color: var(--neutral-dark);
}
.table tbody tr:hover td { background: #f7f9fc; }
.table tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: .4rem; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .65rem;
  border-radius: 100px;
  font-size: .73rem;
  font-weight: 600;
  line-height: 1.4;
}
.badge-success { background: #d4f5e4; color: #1a6b3a; }
.badge-danger  { background: #fde8e8; color: #b71c1c; }
.badge-warning { background: #fef3cd; color: #856404; }
.badge-info    { background: #dbeafe; color: #1e40af; }
.badge-neutral { background: var(--bg-body); color: #666; border: 1px solid var(--border-color); }

/* Métricas del Dashboard */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 1.3rem 1.5rem;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-light);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition);
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.metric-card.success { border-left-color: var(--accent-success); }
.metric-card.danger  { border-left-color: var(--accent-danger); }
.metric-card.warning { border-left-color: var(--accent-warning); }

.metric-label {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #888;
  margin-bottom: .4rem;
}
.metric-value {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--primary-dark);
  line-height: 1;
}
.metric-value.success { color: var(--accent-success); }
.metric-value.danger  { color: var(--accent-danger); }
.metric-sub {
  font-size: .75rem;
  color: #aaa;
  margin-top: .3rem;
}

/* Gráficos */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.2rem;
}
.chart-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  box-shadow: var(--shadow-sm);
}
.chart-card canvas { max-height: 260px; }

/* Barra de herramientas / filtros */
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.2rem;
}
.toolbar-left  { display: flex; align-items: center; gap: .6rem; flex: 1; flex-wrap: wrap; }
.toolbar-right { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }

.search-wrap { position: relative; min-width: 220px; flex: 1; max-width: 360px; }
.search-wrap svg {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #aaa;
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 38px;
  padding: 0 .85rem 0 2.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: .86rem;
  outline: none;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--primary-light); }

/* Selector de período */
.period-select { min-width: 170px; height: 38px; }

/* Modales */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,52,92,.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn .18s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-sm  { max-width: 440px; }
.modal-md  { max-width: 660px; }
.modal-lg  { max-width: 900px; }
.modal-xl  { max-width: 1100px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary-dark);
}
.modal-close {
  font-size: 1.3rem;
  color: #aaa;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--accent-danger); }

.modal-body   { padding: 1.4rem 1.5rem; }
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-body);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Perfil CRM */
.crm-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.4rem;
}
@media (max-width: 640px) { .crm-profile-grid { grid-template-columns: 1fr; } }

.crm-data-group { margin-bottom: .7rem; }
.crm-data-label { font-size: .73rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: #999; }
.crm-data-value { font-size: .9rem; color: var(--neutral-dark); font-weight: 500; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border-color); margin-bottom: 1.2rem; }
.tab-btn {
  height: 38px;
  padding: 0 1.2rem;
  font-size: .84rem;
  font-weight: 600;
  color: #888;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-btn:hover { color: var(--primary-light); }
.tab-btn.active { color: var(--primary-dark); border-bottom-color: var(--primary-dark); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Cálculo automático de montos */
.calc-result {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: .6rem;
  margin-top: .8rem;
}
.calc-item label { font-size: .73rem; font-weight: 700; text-transform: uppercase; color: #888; }
.calc-item .value { font-size: 1rem; font-weight: 700; color: var(--primary-dark); }
.calc-item.total .value { font-size: 1.15rem; color: var(--accent-success); }

/* Páginator */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .35rem;
  margin-top: 1rem;
}
.page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 .5rem;
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 600;
  color: var(--neutral-dark);
  border: 1px solid var(--border-color);
  background: #fff;
  transition: background var(--transition), color var(--transition);
}
.page-btn:hover { background: var(--primary-light); color: #fff; border-color: var(--primary-light); }
.page-btn.active { background: var(--primary-dark); color: #fff; border-color: var(--primary-dark); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* Estado vacío */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #aaa;
}
.empty-state svg { margin: 0 auto 1rem; opacity: .4; }
.empty-state p { font-size: .9rem; }

/* Sección de título de módulo */
.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.4rem;
}
.module-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary-dark);
}
.module-subtitle {
  font-size: .83rem;
  color: #888;
  margin-top: .15rem;
}

/* Divider */
.divider { height: 1px; background: var(--border-color); margin: 1.2rem 0; }

/* Responsive ajustes */
@media (max-width: 768px) {
  #app-viewport {
    padding-top: calc(var(--header-height) + var(--nav-height) + 1rem);
    padding-right: 1rem;
    padding-bottom: 1rem;
    padding-left: 1rem;
  }
  #hero-header { padding: 0 1rem; }
  .header-logo { max-height: 40px; }
  .module-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 520px) {
  .nav-modules { gap: .1rem; }
  .nav-btn { padding: 0 .6rem; font-size: .76rem; }
}
