/* ============================================================
   Observatorio de Cursos Moodle — CEV
   Universidad de San Buenaventura · Seccional Cartagena
   Identidad institucional heredada de sitio_cev
   ============================================================ */

:root {
  /* Paleta institucional USB */
  --usb-orange: #EF7D00;
  --usb-orange-dark: #C96A00;
  --usb-orange-light: #FFF3E5;
  --usb-dark: #1F2933;
  --usb-dark-2: #323F4B;
  --usb-gray-text: #52606D;
  --usb-gray-soft: #7B8794;
  --usb-gray-light: #F5F7FA;
  --usb-border: #E2E4E8;
  --usb-white: #FFFFFF;

  /* Estado de los cursos */
  --e-operacion: #1F8A5F;
  --e-vacio: #E08700;
  --e-oculto: #7B8794;
  --e-finalizado: #55677D;

  /* Gravedad de las alertas */
  --g-alta: #C62828;
  --g-media: #E08700;
  --g-baja: #55677D;

  /* Series de los gráficos (orden fijo, para que un mismo dato
     conserve su color entre pantallas) */
  --s1: #EF7D00;
  --s2: #2C7A9E;
  --s3: #4C956C;
  --s4: #7C6BB0;
  --s5: #C1436D;
  --s6: #55677D;

  --font-primary: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-secondary: 'Open Sans', system-ui, -apple-system, sans-serif;

  --barra: 250px;
  --sp-xs: .5rem;
  --sp-sm: 1rem;
  --sp-md: 1.5rem;
  --sp-lg: 2.5rem;

  --r-sm: 6px;
  --r-md: 12px;
  --r-lg: 20px;

  --sh-sm: 0 1px 3px rgba(31, 41, 51, .07);
  --sh-md: 0 6px 18px rgba(31, 41, 51, .09);
  --sh-lg: 0 18px 40px rgba(31, 41, 51, .16);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-secondary);
  color: var(--usb-dark);
  background: var(--usb-gray-light);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-primary); font-weight: 700; line-height: 1.25; }
a { color: var(--usb-orange-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; }

.muted { color: var(--usb-gray-text); }
.small { font-size: .8125rem; }
.tiny  { font-size: .75rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.numero { font-variant-numeric: tabular-nums; }
.oculto { display: none !important; }

/* ============================================================
   1. Acceso
   ============================================================ */

.acceso {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--usb-white);
}

.acceso__marca {
  background: linear-gradient(160deg, var(--usb-dark) 0%, #2B3947 60%, #3A2A18 100%);
  color: var(--usb-white);
  padding: var(--sp-lg);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--sp-md);
}

.acceso__marca img { width: 190px; height: auto; }
.acceso__marca h1 { font-size: 2.1rem; }
.acceso__marca .lema { color: #CBD2D9; max-width: 42ch; }

.acceso__pasos { list-style: none; display: grid; gap: var(--sp-sm); margin-top: var(--sp-sm); }
.acceso__pasos li { display: flex; gap: var(--sp-sm); align-items: flex-start; color: #E4E7EB; }
.acceso__pasos b { display: grid; place-items: center; flex: 0 0 28px; height: 28px;
  background: var(--usb-orange); color: var(--usb-white); border-radius: 50%; font-size: .875rem; }

.acceso__form { display: grid; place-items: center; padding: var(--sp-lg); }
.acceso__caja { width: min(380px, 100%); }
.acceso__caja h2 { font-size: 1.5rem; margin-bottom: var(--sp-xs); }

@media (max-width: 860px) {
  .acceso { grid-template-columns: 1fr; }
  .acceso__marca { padding: var(--sp-md); }
}

/* ============================================================
   2. Estructura de la aplicación
   ============================================================ */

.app { display: grid; grid-template-columns: var(--barra) 1fr; min-height: 100vh; }

.lateral {
  background: var(--usb-dark);
  color: #CBD2D9;
  padding: var(--sp-md) var(--sp-sm);
  display: flex;
  flex-direction: column;
  gap: var(--sp-md);
  position: sticky;
  top: 0;
  height: 100vh;
}

.lateral__marca { display: grid; gap: 4px; padding-inline: var(--sp-xs); }
.lateral__marca img { width: 150px; height: auto; }
.lateral__marca span { font-size: .6875rem; letter-spacing: .06em; text-transform: uppercase; color: #9AA5B1; }

.lateral nav { display: grid; gap: 2px; }
.lateral nav a {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .75rem; border-radius: var(--r-sm);
  color: #CBD2D9; font-weight: 600; font-size: .9375rem;
  transition: background .15s, color .15s;
}
.lateral nav a:hover { background: rgba(255, 255, 255, .07); color: var(--usb-white); text-decoration: none; }
.lateral nav a[aria-current="page"] { background: var(--usb-orange); color: var(--usb-white); }
.lateral nav a svg { flex: 0 0 18px; }

.lateral__pie { margin-top: auto; display: grid; gap: var(--sp-xs); font-size: .75rem; color: #9AA5B1; }
.lateral__pie strong { color: #E4E7EB; display: block; }

.principal { display: flex; flex-direction: column; min-width: 0; }

.cabecera {
  background: var(--usb-white);
  border-bottom: 1px solid var(--usb-border);
  padding: var(--sp-sm) var(--sp-md);
  display: flex; align-items: center; gap: var(--sp-sm); flex-wrap: wrap;
  position: sticky; top: 0; z-index: 20;
}
.cabecera h1 { font-size: 1.35rem; }
.cabecera__sub { color: var(--usb-gray-text); font-size: .8125rem; }
.cabecera__acciones { margin-left: auto; display: flex; gap: var(--sp-xs); align-items: center; flex-wrap: wrap; }

.contenido { padding: var(--sp-md); display: grid; gap: var(--sp-md); align-content: start; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; }
  .lateral nav { grid-auto-flow: column; overflow-x: auto; }
}

/* ============================================================
   3. Controles
   ============================================================ */

.btn {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .95rem; border: 1px solid transparent; border-radius: var(--r-sm);
  font-family: var(--font-primary); font-weight: 600; font-size: .875rem;
  cursor: pointer; background: var(--usb-orange); color: var(--usb-white);
  transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:hover { background: var(--usb-orange-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--claro { background: var(--usb-white); color: var(--usb-dark); border-color: var(--usb-border); }
.btn--claro:hover { background: var(--usb-gray-light); }
.btn--oscuro { background: var(--usb-dark); }
.btn--oscuro:hover { background: var(--usb-dark-2); }
.btn--fantasma { background: transparent; color: var(--usb-gray-text); }
.btn--fantasma:hover { background: var(--usb-gray-light); }
.btn--sm { padding: .3rem .6rem; font-size: .8125rem; }

label.campo { display: grid; gap: .25rem; font-size: .8125rem; font-weight: 600; color: var(--usb-gray-text); }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="search"], select {
  width: 100%; padding: .5rem .7rem;
  border: 1px solid var(--usb-border); border-radius: var(--r-sm);
  font-family: var(--font-secondary); font-size: .9375rem; font-weight: 400;
  color: var(--usb-dark); background: var(--usb-white);
}
input:focus, select:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--usb-orange); outline-offset: 1px;
}

.tarjeta {
  background: var(--usb-white); border: 1px solid var(--usb-border);
  border-radius: var(--r-md); box-shadow: var(--sh-sm); padding: var(--sp-md);
}
.tarjeta > header { display: flex; align-items: baseline; gap: var(--sp-xs); margin-bottom: var(--sp-sm); flex-wrap: wrap; }
.tarjeta > header h2, .tarjeta > header h3 { font-size: 1rem; }
.tarjeta > header .muted { font-size: .8125rem; }
.tarjeta > header .acciones { margin-left: auto; display: flex; gap: .35rem; }

/* ============================================================
   4. Barra de filtros
   ============================================================ */

.filtros { display: grid; gap: var(--sp-sm); }
.filtros__fila { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.filtros__pie { display: flex; align-items: center; gap: var(--sp-xs); flex-wrap: wrap; }
.filtros__resumen { color: var(--usb-gray-text); font-size: .8125rem; margin-right: auto; }

.interruptor { display: flex; align-items: center; gap: .45rem; font-size: .8125rem; font-weight: 600; color: var(--usb-gray-text); cursor: pointer; }
.interruptor input { width: 16px; height: 16px; accent-color: var(--usb-orange); }

/* ============================================================
   5. Indicadores (KPI)
   ============================================================ */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--sp-sm); }

.kpi {
  background: var(--usb-white); border: 1px solid var(--usb-border);
  border-radius: var(--r-md); padding: var(--sp-sm) var(--sp-md);
  box-shadow: var(--sh-sm); display: grid; gap: .15rem;
  border-left: 4px solid var(--usb-orange);
}
.kpi__valor { font-family: var(--font-primary); font-size: 2rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi__titulo { font-size: .8125rem; font-weight: 600; color: var(--usb-gray-text); }
.kpi__nota { font-size: .75rem; color: var(--usb-gray-soft); }
.kpi--exito { border-left-color: var(--e-operacion); }
.kpi--aviso { border-left-color: var(--e-vacio); }
.kpi--neutro { border-left-color: var(--usb-dark); }
.kpi--riesgo { border-left-color: var(--g-alta); }

.kpi--boton { cursor: pointer; text-align: left; font: inherit; }
.kpi--boton:hover { box-shadow: var(--sh-md); }

/* Barra de proporción bajo un KPI */
.medidor { height: 6px; border-radius: 999px; background: var(--usb-gray-light); overflow: hidden; margin-top: .3rem; }
.medidor > span { display: block; height: 100%; background: var(--usb-orange); border-radius: 999px; }
.medidor--exito > span { background: var(--e-operacion); }
.medidor--aviso > span { background: var(--e-vacio); }

/* ============================================================
   6. Distintivos
   ============================================================ */

.pin {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .5rem; border-radius: 999px;
  font-size: .6875rem; font-weight: 700; letter-spacing: .02em;
  text-transform: uppercase; white-space: nowrap;
  background: var(--usb-gray-light); color: var(--usb-gray-text);
}
.pin::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pin--operacion  { background: #E4F5ED; color: var(--e-operacion); }
.pin--vacio      { background: #FFF3E0; color: #A65E00; }
.pin--oculto     { background: #EEF1F4; color: var(--e-oculto); }
.pin--finalizado { background: #ECF0F5; color: var(--e-finalizado); }
.pin--llano::before { display: none; }
.pin--nivel { background: var(--usb-orange-light); color: #A65E00; text-transform: none; letter-spacing: 0; font-weight: 600; }

/* ============================================================
   7. Tablas
   ============================================================ */

.tabla-envoltura { overflow-x: auto; border: 1px solid var(--usb-border); border-radius: var(--r-md); background: var(--usb-white); }

table.datos { width: 100%; border-collapse: collapse; font-size: .875rem; }
table.datos th, table.datos td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--usb-border); }
table.datos thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--usb-gray-light); font-family: var(--font-primary);
  font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--usb-gray-text);
  border-bottom: 2px solid var(--usb-border); white-space: nowrap;
}
table.datos tbody tr:hover { background: #FAFBFC; }
table.datos tbody tr:last-child td { border-bottom: none; }
table.datos td.num, table.datos th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.datos tfoot td { font-weight: 700; background: var(--usb-gray-light); border-top: 2px solid var(--usb-border); }

th.ordenable { cursor: pointer; user-select: none; }
th.ordenable:hover { color: var(--usb-dark); }
th.ordenable[data-dir]::after { content: " ▲"; font-size: .7em; }
th.ordenable[data-dir="desc"]::after { content: " ▼"; }

.enlace-curso { font-weight: 600; color: var(--usb-dark); cursor: pointer; background: none; border: none; padding: 0; text-align: left; }
.enlace-curso:hover { color: var(--usb-orange-dark); text-decoration: underline; }

/* Barra proporcional dentro de una celda */
.barra-celda { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .5rem; min-width: 120px; }
.barra-celda__pista { height: 8px; background: var(--usb-gray-light); border-radius: 999px; overflow: hidden; }
.barra-celda__pista > span { display: block; height: 100%; background: var(--usb-orange); }

/* ============================================================
   8. Alertas
   ============================================================ */

.alertas { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: var(--sp-sm); }

.alerta {
  display: grid; grid-template-columns: auto 1fr; gap: .75rem;
  padding: var(--sp-sm); border: 1px solid var(--usb-border); border-radius: var(--r-md);
  background: var(--usb-white); text-align: left; cursor: pointer; font: inherit;
  transition: box-shadow .15s, border-color .15s;
}
.alerta:hover { box-shadow: var(--sh-md); border-color: var(--usb-gray-soft); }
.alerta__cifra { font-family: var(--font-primary); font-size: 1.75rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.alerta__titulo { font-weight: 700; font-size: .9375rem; }
.alerta__texto { font-size: .8125rem; color: var(--usb-gray-text); }
.alerta--alta  .alerta__cifra { color: var(--g-alta); }
.alerta--media .alerta__cifra { color: var(--g-media); }
.alerta--baja  .alerta__cifra { color: var(--g-baja); }
.alerta--cero  { opacity: .6; }
.alerta--cero .alerta__cifra { color: var(--e-operacion); }

/* ============================================================
   9. Gráficos
   ============================================================ */

.graficos { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: var(--sp-md); }
.grafico svg { width: 100%; height: auto; display: block; overflow: visible; }
.grafico text { font-family: var(--font-secondary); fill: var(--usb-gray-text); }
.grafico .valor { font-weight: 700; fill: var(--usb-dark); font-variant-numeric: tabular-nums; }
.grafico .eje { stroke: var(--usb-border); stroke-width: 1; }
.grafico rect, .grafico path.sector { transition: opacity .15s; }
.grafico rect:hover, .grafico path.sector:hover { opacity: .82; }

.leyenda { display: flex; flex-wrap: wrap; gap: .4rem .9rem; margin-top: var(--sp-sm); font-size: .8125rem; }
.leyenda span { display: inline-flex; align-items: center; gap: .4rem; color: var(--usb-gray-text); }
.leyenda i { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }

/* ============================================================
   10. Panel lateral de detalle
   ============================================================ */

.velo {
  position: fixed; inset: 0; background: rgba(31, 41, 51, .45);
  display: grid; justify-items: end; z-index: 60;
}
.panel {
  width: min(560px, 100%); height: 100%; background: var(--usb-white);
  box-shadow: var(--sh-lg); overflow-y: auto;
  display: grid; grid-template-rows: auto 1fr; animation: entra .18s ease-out;
}
@keyframes entra { from { transform: translateX(24px); opacity: .4; } to { transform: none; opacity: 1; } }

.panel__cabecera {
  padding: var(--sp-md); border-bottom: 1px solid var(--usb-border);
  position: sticky; top: 0; background: var(--usb-white); z-index: 2;
}
.panel__cabecera h2 { font-size: 1.15rem; padding-right: 2.5rem; }
.panel__cerrar {
  position: absolute; top: var(--sp-sm); right: var(--sp-sm);
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--usb-border);
  background: var(--usb-white); cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--usb-gray-text);
}
.panel__cerrar:hover { background: var(--usb-gray-light); }
.panel__cuerpo { padding: var(--sp-md); display: grid; gap: var(--sp-md); align-content: start; }

.ficha { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: var(--sp-sm); }
.ficha > div { background: var(--usb-gray-light); border-radius: var(--r-sm); padding: .6rem .75rem; }
.ficha dt { font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; color: var(--usb-gray-soft); font-weight: 700; }
.ficha dd { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.lista-datos { display: grid; gap: .5rem; }
.lista-datos > div { display: grid; grid-template-columns: 40% 1fr; gap: var(--sp-xs); font-size: .875rem; padding-bottom: .5rem; border-bottom: 1px dashed var(--usb-border); }
.lista-datos dt { color: var(--usb-gray-text); font-weight: 600; }

/* ============================================================
   11. Estados y avisos
   ============================================================ */

.aviso {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .7rem .9rem; border-radius: var(--r-sm); font-size: .875rem;
  border: 1px solid; background: var(--usb-orange-light); border-color: #F4C88E; color: #7A4A00;
}
.aviso--error { background: #FDECEC; border-color: #F3B7B7; color: #8C1D1D; }
.aviso--ok    { background: #E4F5ED; border-color: #A9DCC5; color: #14603F; }
.aviso--info  { background: #ECF3F7; border-color: #B8D4E3; color: #1D4E63; }

.vacio-estado { display: grid; gap: .5rem; justify-items: center; padding: var(--sp-lg); text-align: center; color: var(--usb-gray-text); }
.vacio-estado strong { font-family: var(--font-primary); color: var(--usb-dark); }

.cargando { display: grid; place-items: center; padding: var(--sp-lg); color: var(--usb-gray-soft); font-size: .875rem; gap: .75rem; }
.girador { width: 26px; height: 26px; border: 3px solid var(--usb-border); border-top-color: var(--usb-orange); border-radius: 50%; animation: gira .8s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* Franja de estado de sincronización en la cabecera */
.sinc { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--usb-gray-text); padding: .25rem .6rem; border-radius: 999px; background: var(--usb-gray-light); }
.sinc::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--e-operacion); }
.sinc--viejo::before { background: var(--e-vacio); }
.sinc--nunca::before { background: var(--g-alta); }

/* Ayuda contextual sobre una definición */
.ayuda { border-bottom: 1px dotted var(--usb-gray-soft); cursor: help; }

/* ============================================================
   12. Paginación
   ============================================================ */

.paginacion { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.paginacion .info { margin-right: auto; font-size: .8125rem; color: var(--usb-gray-text); }

/* ============================================================
   13. Impresión — los informes deben salir limpios en papel/PDF
   ============================================================ */

@media print {
  .lateral, .cabecera__acciones, .filtros, .btn, .paginacion { display: none !important; }
  .app { grid-template-columns: 1fr; }
  body { background: var(--usb-white); }
  .tarjeta { box-shadow: none; border-color: #CCC; break-inside: avoid; }
  .contenido { padding: 0; }
  a[href]::after { content: ""; }
}
