/* GEM·PRO — estilos (paleta GEMSES) */
:root {
  --azul-950: #0a2e5c; --azul-800: #0d3b73; --azul-600: #124a8f; --azul-400: #2b76d1;
  --teal: #12a5a5; --teal-claro: #12c2a0; --oro: #e0a80d; --oro-oscuro: #8a6d0b;
  --tinta: #12233d; --gris: #5b6b7f; --linea: #e2e8f0; --fondo: #f4f7fb; --card: #ffffff;
  --rojo: #c0392b; --rojo-suave: #f6e4e0; --verde: #0f766e; --verde-suave: #e2f3ec;
  --azul-suave: #eef4fb; --oro-suave: #fdf6e3;
  --sombra: 0 6px 22px rgba(13, 59, 115, .08);
  --radio: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: "Segoe UI", system-ui, Arial, sans-serif; background: var(--fondo); color: var(--tinta); min-height: 100vh; }
a { color: var(--azul-600); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem;
  background: linear-gradient(160deg, var(--azul-950) 0%, var(--azul-800) 55%, #0f4a6e 100%); }
.login-card { background: var(--card); border-radius: 18px; box-shadow: 0 18px 60px rgba(0,0,0,.35); padding: 2.2rem; width: 100%; max-width: 400px; }
.login-card img { display: block; margin: 0 auto 1.2rem; max-width: 260px; }
.login-card h1 { font-size: 1.05rem; text-align: center; color: var(--gris); font-weight: 600; margin-bottom: 1.4rem; }

/* ---------- app shell ---------- */
.topbar { background: var(--azul-950); color: #fff; display: flex; align-items: center; gap: .9rem; padding: .55rem 1rem;
  position: sticky; top: 0; z-index: 40; border-bottom: 3px solid var(--teal); }
.topbar .brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; letter-spacing: .5px; }
.topbar .brand img { height: 40px; }
.topbar .brand .dot { color: var(--oro); }
.topbar .brand .pro { color: var(--teal-claro); }
.topbar .org { font-size: .78rem; color: #c5d6ee; line-height: 1.2; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sel-area { background: rgba(255,255,255,.1); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 8px;
  padding: .3rem .5rem; font-size: .82rem; max-width: 340px; width: auto; }
.sel-area optgroup, .sel-area option { color: var(--tinta); background: #fff; }
.topbar .user { font-size: .78rem; text-align: right; color: #c5d6ee; }
.topbar .user b { color: #fff; display: block; }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,.35); color: #fff; border-radius: 8px; padding: .35rem .7rem; font-size: .78rem; }
.btn-ghost:hover { background: rgba(255,255,255,.12); }

.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar { width: 210px; background: var(--card); border-right: 1px solid var(--linea); padding: 1rem .6rem; flex-shrink: 0; }
.sidebar nav a { display: flex; align-items: center; gap: .55rem; padding: .55rem .7rem; border-radius: 9px; color: var(--tinta);
  font-size: .88rem; font-weight: 600; margin-bottom: .15rem; }
.sidebar nav a:hover { background: var(--azul-suave); }
.sidebar nav a.active { background: var(--azul-800); color: #fff; }
.sidebar nav a .ico { width: 20px; text-align: center; }
.main { flex: 1; padding: 1.3rem 1.5rem 3rem; min-width: 0; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: 0; border-bottom: 1px solid var(--linea); padding: .4rem; }
  .sidebar nav { display: flex; overflow-x: auto; gap: .2rem; }
  .sidebar nav a { white-space: nowrap; font-size: .8rem; }
  .topbar .org { display: none; }
  .main { padding: 1rem .8rem 3rem; }
}

/* ---------- componentes ---------- */
h2.page-title { font-size: 1.35rem; color: var(--azul-800); margin-bottom: .2rem; }
p.page-sub { color: var(--gris); font-size: .86rem; margin-bottom: 1.2rem; }
.card { background: var(--card); border-radius: var(--radio); box-shadow: var(--sombra); padding: 1.1rem 1.2rem; margin-bottom: 1.1rem; }
.card h3 { font-size: .98rem; color: var(--azul-800); margin-bottom: .7rem; display: flex; align-items: center; gap: .5rem; }
.grid { display: grid; gap: 1rem; }
.grid.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1.1rem; }
.kpi { background: var(--card); border-radius: var(--radio); box-shadow: var(--sombra); padding: .9rem 1rem; border-top: 4px solid var(--teal); }
.kpi.alt { border-top-color: var(--oro); }
.kpi.warn { border-top-color: var(--rojo); }
.kpi .val { font-size: 1.75rem; font-weight: 800; color: var(--azul-800); line-height: 1.1; }
.kpi .lbl { font-size: .74rem; color: var(--gris); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-top: .15rem; }
.kpi .sub { font-size: .74rem; color: var(--teal); font-weight: 600; margin-top: .2rem; }

.tres { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

table.tabla { width: 100%; border-collapse: collapse; font-size: .84rem; }
table.tabla th { background: var(--azul-800); color: #fff; text-align: left; padding: .5rem .6rem; font-size: .76rem;
  text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; }
table.tabla td { padding: .48rem .6rem; border-bottom: 1px solid var(--linea); vertical-align: top; }
table.tabla tr:hover td { background: var(--azul-suave); }
.tabla-scroll { overflow-x: auto; max-height: 65vh; overflow-y: auto; border-radius: 8px; border: 1px solid var(--linea); }

.badge { display: inline-block; padding: .13rem .55rem; border-radius: 99px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.badge.si { background: var(--verde-suave); color: var(--verde); }
.badge.no { background: var(--rojo-suave); color: var(--rojo); }
.badge.na { background: var(--linea); color: var(--gris); }
.badge.sin { background: var(--oro-suave); color: var(--oro-oscuro); }
.badge.tipo-E { background: var(--oro-suave); color: var(--oro-oscuro); }
.badge.tipo-M { background: var(--azul-suave); color: var(--azul-600); }
.badge.tipo-S { background: var(--verde-suave); color: var(--verde); }
.badge.kpi-t { background: var(--azul-suave); color: var(--azul-600); }
.badge.kri-t { background: var(--rojo-suave); color: var(--rojo); }
.badge.kci-t { background: var(--verde-suave); color: var(--verde); }
.badge.p75 { background: var(--rojo-suave); color: var(--rojo); }
.badge.p50 { background: var(--oro-suave); color: var(--oro-oscuro); }
.badge.p25 { background: var(--verde-suave); color: var(--verde); }

.prog { background: var(--linea); border-radius: 99px; height: 9px; overflow: hidden; }
.prog > span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--teal), var(--teal-claro)); }
.prog.rojo > span { background: linear-gradient(90deg, #e05a4a, var(--rojo)); }
.prog.oro > span { background: linear-gradient(90deg, var(--oro), #f0c040); }

input, select, textarea { font-family: inherit; font-size: .86rem; padding: .5rem .6rem; border: 1px solid var(--linea);
  border-radius: 8px; background: #fff; color: var(--tinta); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--teal); border-color: var(--teal); }
label.fld { display: block; font-size: .76rem; font-weight: 700; color: var(--gris); margin: .6rem 0 .25rem; text-transform: uppercase; letter-spacing: .4px; }
.btn { background: var(--azul-800); color: #fff; border: 0; border-radius: 9px; padding: .55rem 1rem; font-size: .85rem; font-weight: 700; }
.btn:hover { background: var(--azul-600); }
.btn.teal { background: var(--teal); }
.btn.teal:hover { background: #0f8f8f; }
.btn.oro { background: var(--oro); color: var(--tinta); }
.btn.sm { padding: .3rem .6rem; font-size: .75rem; border-radius: 7px; }
.btn.rojo { background: var(--rojo); }
.btn.gris { background: var(--linea); color: var(--tinta); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.tabs { display: flex; gap: .3rem; border-bottom: 2px solid var(--linea); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: .55rem .9rem; font-size: .86rem; font-weight: 700; color: var(--gris);
  border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs button.active { color: var(--azul-800); border-bottom-color: var(--teal); }

.mapa-banda { border-radius: var(--radio); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.mapa-banda.E { background: linear-gradient(135deg, #fdf6e3, #fbf0d0); border-left: 6px solid var(--oro); }
.mapa-banda.M { background: linear-gradient(135deg, #eef4fb, #e1ecf7); border-left: 6px solid var(--azul-600); }
.mapa-banda.S { background: linear-gradient(135deg, #e2f3ec, #d5ece2); border-left: 6px solid var(--verde); }
.mapa-banda h3 { font-size: 1rem; margin-bottom: .6rem; color: var(--tinta); }
.mapa-banda .macros { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.macro-card { background: rgba(255,255,255,.85); border-radius: 10px; padding: .7rem .8rem; box-shadow: 0 2px 8px rgba(13,59,115,.06); }
.macro-card h4 { font-size: .8rem; color: var(--azul-800); margin-bottom: .45rem; text-transform: uppercase; letter-spacing: .3px; }
.proc-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .3rem .45rem;
  border-radius: 7px; font-size: .82rem; color: var(--tinta); }
.proc-item:hover { background: var(--azul-suave); }
.proc-item .cod { font-weight: 800; color: var(--teal); font-size: .72rem; margin-right: .3rem; }
.proc-item .pct { font-size: .72rem; font-weight: 700; }

.donut-row { display: flex; gap: 1.2rem; flex-wrap: wrap; justify-content: space-around; }
.donut-box { text-align: center; }
.donut-box .nombre { font-weight: 700; font-size: .85rem; margin-top: .3rem; }
.donut-box .nivel { font-size: .74rem; color: var(--gris); }

.semaforo { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }
.semaforo.v { background: var(--verde); } .semaforo.r { background: var(--rojo); } .semaforo.g { background: #b9c3d0; }

.lista-editable li { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px dashed var(--linea); font-size: .85rem; list-style: none; }
.lista-editable li .del { color: var(--rojo); background: none; border: 0; font-weight: 800; font-size: .9rem; }
.add-row { display: flex; gap: .5rem; margin-top: .55rem; flex-wrap: wrap; }
.add-row input, .add-row select { flex: 1; min-width: 130px; }

.toast { position: fixed; bottom: 1.2rem; right: 1.2rem; background: var(--tinta); color: #fff; padding: .7rem 1.1rem;
  border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.3); font-size: .85rem; z-index: 99; opacity: 0; transition: opacity .25s; }
.toast.show { opacity: 1; }
.toast.err { background: var(--rojo); }

.error-msg { background: var(--rojo-suave); color: var(--rojo); border-radius: 8px; padding: .5rem .8rem; font-size: .82rem; margin-top: .7rem; }
.muted { color: var(--gris); font-size: .82rem; }
.flujo-img { max-width: 100%; border: 1px solid var(--linea); border-radius: 10px; }
.pill-filtros { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .8rem; }
.pill-filtros select, .pill-filtros input { width: auto; }
.metodo h4 { color: var(--azul-800); margin: 1rem 0 .35rem; font-size: .95rem; }
.metodo p, .metodo li { font-size: .88rem; line-height: 1.55; color: var(--tinta); }
.metodo ul { padding-left: 1.2rem; margin: .4rem 0; }
.impacto-sel { width: auto; display: inline-block; }
footer.pie { text-align: center; color: var(--gris); font-size: .74rem; padding: 1rem; }

/* aterrizaje de hipervínculos profundos */
.resaltado { outline: 3px solid var(--oro); outline-offset: 2px; border-radius: 8px;
  animation: resplandor 2.4s ease-out; }
tr.resaltado td { background: var(--oro-suave) !important; }
@keyframes resplandor { 0% { box-shadow: 0 0 0 6px rgba(224,168,13,.45); } 100% { box-shadow: 0 0 0 0 rgba(224,168,13,0); } }

/* ---------- Logo institucional ---------- */
.logo-inst { height: 34px; max-width: 150px; object-fit: contain; background: #fff;
  border-radius: 6px; padding: 3px 6px; margin-right: .6rem; }
.inst-bloque { border: 1px solid var(--linea); border-radius: 10px; padding: .8rem; margin-bottom: .9rem; }
.inst-cab { display: flex; align-items: center; gap: .9rem; margin-bottom: .5rem; flex-wrap: wrap; }
.inst-logo { width: 110px; height: 54px; border: 1px dashed var(--linea); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; background: var(--fondo); flex: none; }
.inst-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sin-logo { color: var(--gris); font-size: .72rem; }

/* ---------- Biblioteca documental ---------- */
.bib-head { display: flex; align-items: flex-start; gap: 1rem; }
.bib-fecha { margin-left: auto; color: var(--gris); font-size: .8rem; white-space: nowrap; padding-top: .4rem; }
.bib-layout { display: grid; grid-template-columns: 232px 1fr; gap: 1rem; align-items: start; }
.bib-facetas { background: var(--card); border: 1px solid var(--linea); border-radius: 12px;
  padding: .7rem; position: sticky; top: 72px; }
.faceta { margin-bottom: .9rem; }
.faceta h4 { margin: 0 0 .35rem; font-size: .74rem; letter-spacing: .04em; text-transform: uppercase;
  color: #fff; background: var(--azul-800); padding: .35rem .5rem; border-radius: 6px; }
.faceta-item { display: block; padding: .25rem .5rem; font-size: .82rem; color: var(--azul-600);
  text-decoration: none; border-radius: 5px; }
.faceta-item:hover { background: var(--oro-suave); }
.faceta-item.activo { background: var(--azul-600); color: #fff; font-weight: 600; }
.faceta-item .n { color: var(--gris); font-size: .74rem; }
.faceta-item.activo .n { color: #dbe7f7; }
.faceta-limpiar { display: block; font-size: .72rem; color: var(--rojo); padding: .25rem .5rem; text-decoration: none; }
.bib-barra { display: flex; align-items: center; gap: .7rem; margin-bottom: .8rem; flex-wrap: wrap; }
.bib-barra input { max-width: 340px; }
.bib-grupo { margin-bottom: 1rem; border: 1px solid var(--linea); border-radius: 12px; overflow: hidden; background: var(--card); }
.bib-grupo-head { background: var(--fondo); border-bottom: 1px solid var(--linea);
  padding: .5rem .75rem; font-size: .8rem; color: var(--gris); }
.bib-tabla td { vertical-align: top; }
.doc-link { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; text-decoration: none; }
.doc-ico { background: #c0392b; color: #fff; font-size: .6rem; font-weight: 700; padding: .12rem .3rem;
  border-radius: 3px; letter-spacing: .03em; flex: none; }
.doc-file { font-size: .72rem; margin-top: .15rem; }
.estado { display: inline-block; padding: .28rem .55rem; border-radius: 6px; font-size: .74rem;
  font-weight: 700; color: #fff; text-align: center; }
/* contrastes verificados contra blanco (WCAG AA, >= 4.5:1) */
.estado.verde { background: #14663a; }
.estado.amarillo { background: #8a6100; }
.estado.naranja { background: #9a5b00; }
.estado.gris { background: #5b6b7f; }

/* ---------- Modal de edición ---------- */
.modal-fondo { position: fixed; inset: 0; background: rgba(10,25,47,.55); display: flex;
  align-items: center; justify-content: center; padding: 1rem; z-index: 60; }
.modal { background: var(--card); border-radius: 14px; padding: 1.2rem; width: min(760px, 100%);
  max-height: 88vh; overflow-y: auto; box-shadow: 0 18px 50px rgba(0,0,0,.3); }
.modal h3 { margin-top: 0; color: var(--azul-950); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: .8rem 0; }
.form-grid .ancho { grid-column: 1 / -1; }
.fld-grp { display: flex; flex-direction: column; gap: .2rem; }
.fld-grp label { font-size: .74rem; font-weight: 600; color: var(--gris); text-transform: uppercase; letter-spacing: .03em; }
.modal-pie { display: flex; gap: .5rem; flex-wrap: wrap; border-top: 1px solid var(--linea); padding-top: .8rem; }

@media (max-width: 860px) {
  .bib-layout { grid-template-columns: 1fr; }
  .bib-facetas { position: static; }
  .form-grid { grid-template-columns: 1fr; }
}
