/* ============================================================
   Sistema de diseño — Sistema Contable
   Paleta: navy (marca/sidebar), naranja (acciones principales),
   colores de categoría para encabezados de tarjeta (azul, morado,
   verde azulado, oliva) — inspirado en el estilo de referencia que
   pidió el cliente: sidebar con iconos, tarjetas de color sólido,
   tablas con cabecera oscura, badges consistentes.
   ============================================================ */

:root {
  --navy:        #16324a;
  --navy-2:      #1f4566;
  --azul:        #3468e0;
  --morado:      #6a4fd1;
  --verde-az:    #0f8f83;
  --oliva:       #a9790a;
  --naranja:     #f0873a;
  --naranja-2:   #e07425;
  --verde:       #1aa179;
  --rojo:        #d9534f;
  --gris-fondo:  #f2f4f7;
  --gris-borde:  #e5e9ef;
  --texto:       #22303f;
  --texto-suave: #64748b;

  /* Reasignar las variables de Bootstrap 5 -> reskin instantáneo de
     btn-primary, badge bg-primary/success/danger, alert-*, etc. en
     TODA la app sin tocar cada página una por una. */
  --bs-primary: var(--naranja);
  --bs-primary-rgb: 240, 135, 58;
  --bs-success: var(--verde);
  --bs-success-rgb: 26, 161, 121;
  --bs-danger: var(--rojo);
  --bs-danger-rgb: 217, 83, 79;
  --bs-body-color: var(--texto);
  --bs-body-bg: var(--gris-fondo);
  --bs-border-color: var(--gris-borde);
  --bs-link-color: var(--azul);
  --bs-link-hover-color: var(--navy-2);
}

body {
  background: var(--gris-fondo);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--texto);
}

/* ---------- Barra superior ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--gris-borde);
  padding: .65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1030;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--navy);
  text-decoration: none;
}
.topbar-brand .logo-badge {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--azul), var(--navy));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: .9rem;
}
.rol-badge {
  background: #fdeee0;
  color: var(--naranja-2);
  font-weight: 700;
  font-size: .72rem;
  letter-spacing: .03em;
  padding: .3rem .7rem;
  border-radius: 999px;
}
.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #e7e4fb;
  color: #5d4bb8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
}
.salir-link {
  color: var(--rojo);
  text-decoration: none;
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  align-items: center;
  gap: .3rem;
}
.salir-link:hover { color: #a33; }

/* ---------- Layout: sidebar + contenido ---------- */
.app-shell {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - 60px);
}
.sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: #fff;
  border-right: 1px solid var(--gris-borde);
  min-height: calc(100vh - 60px);
  padding: 1rem 0;
  position: sticky;
  top: 60px;
  overflow-y: auto;
  max-height: calc(100vh - 60px);
}
.sidebar-section-label {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: #9aa5b1;
  text-transform: uppercase;
  padding: .9rem 1.25rem .35rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .5rem 1.25rem;
  color: var(--texto);
  text-decoration: none;
  font-size: .92rem;
  border-left: 3px solid transparent;
}
.sidebar-link i { font-size: 1rem; width: 18px; text-align: center; color: var(--texto-suave); }
.sidebar-link:hover { background: #f5f7fa; }
.sidebar-link.active {
  background: #eaf1fd;
  border-left-color: var(--azul);
  color: var(--azul);
  font-weight: 600;
}
.sidebar-link.active i { color: var(--azul); }

.content {
  flex: 1 1 auto;
  padding: 1.5rem 1.75rem;
  min-width: 0;
}

/* ---------- Tarjetas de módulo (dashboard) ---------- */
.modulo-card {
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(16,40,60,.08);
  background: #fff;
  height: 100%;
  text-decoration: none;
  display: block;
  color: inherit;
  transition: transform .12s ease, box-shadow .12s ease;
}
.modulo-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16,40,60,.12);
  color: inherit;
}
.modulo-card-header {
  padding: .85rem 1.1rem;
  color: #fff;
  font-weight: 700;
  font-size: 1.02rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.modulo-card-header i { font-size: 1.15rem; }
.modulo-card-body {
  padding: .95rem 1.1rem;
  color: var(--texto-suave);
  font-size: .87rem;
}
.bg-navy   { background: var(--navy); }
.bg-azul   { background: var(--azul); }
.bg-morado { background: var(--morado); }
.bg-verde-az { background: var(--verde-az); }
.bg-oliva  { background: var(--oliva); }

/* ---------- Tarjetas de estadística ---------- */
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 1rem 1.2rem;
  box-shadow: 0 1px 3px rgba(16,40,60,.06);
}
.stat-card .stat-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--texto-suave);
  text-transform: uppercase;
}
.stat-card .stat-valor {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
}

/* ---------- Tarjetas normales ---------- */
.card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(16,40,60,.07);
}

/* ---------- Tablas ---------- */
table.table {
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
table.table thead {
  background: var(--navy);
}
table.table thead th {
  color: #fff;
  font-weight: 600;
  font-size: .82rem;
  border: none;
  vertical-align: middle;
}
table.table tbody td {
  font-size: .89rem;
  vertical-align: middle;
}

/* ---------- Badges ---------- */
.badge {
  font-weight: 600;
  letter-spacing: .01em;
  padding: .4em .65em;
  border-radius: 6px;
}

/* ---------- Botones ---------- */
.btn {
  border-radius: 7px;
  font-weight: 600;
  font-size: .9rem;
}
.btn-primary {
  border-color: var(--naranja-2);
}
.btn-primary:hover, .btn-primary:active {
  background-color: var(--naranja-2) !important;
  border-color: var(--naranja-2) !important;
}

/* ---------- Alertas ---------- */
.alert {
  border: none;
  border-radius: 8px;
}

/* ---------- Pestañas (nav-tabs) ---------- */
.nav-tabs {
  border-bottom: 1px solid var(--gris-borde);
}
.nav-tabs .nav-link {
  border: none;
  color: var(--texto-suave);
  font-weight: 600;
  font-size: .9rem;
  padding: .55rem .2rem;
  margin-right: 1.4rem;
  border-bottom: 2px solid transparent;
}
.nav-tabs .nav-link.active {
  color: var(--naranja-2);
  border-bottom-color: var(--naranja-2);
  background: transparent;
}

/* ---------- Responsive: sidebar se colapsa en pantallas chicas ---------- */
@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-basis: auto;
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--gris-borde);
  }
  .content { padding: 1.1rem; }
}
