/* ============================================================
   Portal BiometricoXpress - Tema Claro estilo Sistema de Biometría / Inngresa
   ============================================================ */

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

:root {
  --primary: #0a6cff;
  --primary-dark: #0856cc;
  --primary-light: #e8f1ff;
  --success: #16a34a;
  --success-light: #e8f7ee;
  --danger: #dc2626;
  --danger-light: #fdecec;
  --warning: #d97706;
  --warning-light: #fdf3e3;
  --info: #0e7490;
  --info-light: #e6f6fa;

  --bg: #f4f6fa;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --border: #e5eaf1;
  --text: #1a2333;
  --text-dim: #61718c;
  --text-muted: #94a3b8;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.12);
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
body { position: relative; overflow-x: hidden; min-height: 100vh; display: flex; flex-direction: column; }
body > main { flex: 1 0 auto; width: 100%; }
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }

/* ---------- Utilidades ---------- */
.hidden { display: none !important; }
.muted { color: var(--text-dim); }
.link { color: var(--primary); cursor: pointer; font-weight: 600; font-size: .86rem; margin-top: .4rem; display: inline-flex; align-items: center; gap: 4px; }
.link:hover { color: var(--primary-dark); text-decoration: underline; }
.mt { margin-top: .6rem; }
.w-30 { width: 30%; }
.flex-1 { flex: 1; min-width: 0; }
.row { display: flex; gap: .6rem; }
.error { color: var(--danger); font-size: .82rem; min-height: 1rem; margin: .35rem 0; }

.fondo-orbes { display: none; }

body > main, body > header, body > footer { position: relative; z-index: 1; }
.overlay { z-index: 100; }
.modal { z-index: 110; }
.toast { z-index: 200; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-dim);
  cursor: pointer; font-size: .86rem; font-weight: 600;
  transition: all .15s ease; font-family: inherit; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary, .btn-lg, .btn-block {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 2px 6px rgba(10, 108, 255, 0.3);
}
.btn-primary:hover, .btn-lg:hover, .btn-block:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-lg { padding: 11px 22px; font-size: .92rem; font-weight: 700; }
.btn-block { width: 100%; margin-top: .4rem; }
.btn-outline { background: transparent; color: var(--text-dim); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sec { background: var(--bg-card); color: var(--text-dim); }
.btn-sec:hover { border-color: var(--primary); color: var(--primary); }
#btn-salir.btn-outline { border-color: var(--border); color: var(--text-dim); }
#btn-salir.btn-outline:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-light); }

.dash-actions .btn:not(.btn-outline) { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 6px rgba(10, 108, 255, 0.3); }
.dash-actions .btn:not(.btn-outline):hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }

/* ---------- Barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--bg-card); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1600px; margin: 0 auto; display: flex; align-items: center; gap: 1.5rem; padding: .65rem clamp(1rem, 2.5vw, 1.8rem); flex-wrap: nowrap; }
@media (max-width: 820px) { .topnav { display: none; } .topbar-inner { flex-wrap: wrap; justify-content: space-between; } }
.brand { display: flex; align-items: center; gap: .65rem; }
.brand-logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, #0a6cff, #4f9dff);
  display: grid; place-items: center;
  color: #fff; font-size: 1.15rem; font-weight: 800;
  box-shadow: 0 4px 10px rgba(10, 108, 255, 0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text b { font-size: 1.02rem; letter-spacing: -.02em; color: var(--text); }
.brand-text span { font-size: .66rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .14em; font-weight: 600; }
.topnav { display: flex; gap: 1.3rem; margin-left: auto; }
.topnav a { color: var(--text-dim); font-weight: 600; font-size: .9rem; transition: .15s; }
.topnav a:hover { color: var(--text); }
.top-actions { display: flex; gap: .55rem; }

@media (max-width: 820px) { .topnav { display: none; } .topbar-inner { justify-content: space-between; } }

/* ---------- Hero ---------- */
.hero { text-align: center; padding: 5.5rem 1.5rem 3.5rem; }
.hero-inner { max-width: 860px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.4rem, 7vw, 5rem); font-weight: 800; letter-spacing: -.045em; line-height: 1; text-transform: uppercase; margin-bottom: 1.3rem; color: var(--text); overflow-wrap: break-word; }
.hero h1 .grad { background: linear-gradient(120deg, #0a6cff, #4f9dff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 1.08rem; color: var(--text-dim); line-height: 1.7; max-width: 620px; margin: 0 auto 2.1rem; }
.hero p b { color: var(--text); }
.hero-actions { display: flex; gap: .9rem; justify-content: center; flex-wrap: wrap; }

/* ---------- Features ---------- */
.features { max-width: 1600px; margin: 0 auto; padding: 2.5rem clamp(1rem, 3vw, 2rem) 3.5rem; }
.section-label { text-align: center; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .28em; font-size: .72rem; margin-bottom: .6rem; }
.section-label::before, .section-label::after { content: '·'; color: var(--primary); font-weight: 900; margin: 0 .5rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1.1rem; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.card-icon { font-size: 1.5rem; margin-bottom: .7rem; }
.card h3 { font-size: 1.02rem; margin-bottom: .4rem; letter-spacing: -.01em; }
.card p { color: var(--text-dim); font-size: .9rem; line-height: 1.55; }

/* ---------- Adquisición ---------- */
.adquisicion { max-width: 900px; margin: 0 auto; padding: 0 1.5rem 3.5rem; }
.adquisicion-inner {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 2.2rem 2rem;
  box-shadow: var(--shadow);
}
.adquisicion h2 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: 1.2rem; }
.adquisicion ul { list-style: none; display: grid; gap: .7rem; }
.adquisicion li { color: var(--text-dim); font-size: 1rem; display: flex; align-items: flex-start; gap: .7rem; }
.adquisicion li::before { content: '✓'; color: var(--success); font-weight: 900; flex-shrink: 0; }

/* ---------- Contacto ---------- */
.contacto { text-align: center; padding: 1rem 1.5rem 4rem; }
.contacto h2 { margin-bottom: .4rem; font-weight: 800; }
.contacto p { color: var(--text-dim); margin-bottom: 1.3rem; }
.contacto .btn { text-decoration: none; }

/* ---------- Dashboard ---------- */
#vista-dash { max-width: 1600px; margin: 0 auto; padding: 1.8rem clamp(1rem, 3vw, 2rem) 4rem; }
.dash-layout { display: flex; gap: 1.4rem; align-items: flex-start; }
.dash-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem; }
.dash-head h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.02em; color: var(--text); }
.dash-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Sidebar */
.sidebar {
  width: 248px; flex-shrink: 0;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  position: sticky; top: 78px;
  display: flex; flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.side-head { padding: 16px 20px 14px; border-bottom: 1px solid var(--border); }
.side-head b { color: var(--text); font-size: .95rem; letter-spacing: -.02em; display: block; }
.side-head span { color: var(--text-muted); font-size: .62rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 700; }
.side-nav { padding: 10px 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-dim); font-size: .9rem; font-weight: 500;
  transition: all .15s ease; text-decoration: none;
}
.side-nav a:hover { background: var(--bg); color: var(--text); }
.side-nav a.activo { background: var(--primary-light); color: var(--primary); font-weight: 600; }
.side-nav a.hidden { display: none; }
.pill-count {
  margin-left: auto; background: var(--primary); color: #fff;
  font-size: .68rem; font-weight: 800;
  min-width: 19px; height: 19px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 .35rem;
}

.dash-main { flex: 1; min-width: 0; }
.sec-title { margin: 1.2rem 0 .7rem; color: var(--text-muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.tabla-wrap, #tabla-licencias {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow);
}

/* Stats */
.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.6rem; }
.tarjeta {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem;
  display: flex; flex-direction: column; gap: .2rem;
  border-top: 3px solid var(--primary);
  box-shadow: var(--shadow);
}
.t-num { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; color: var(--text); line-height: 1.1; }
.t-lab { color: var(--text-dim); font-size: .78rem; font-weight: 500; }
.t-num.top-num { font-size: 1rem; letter-spacing: -.01em; }

/* Gráficos del dashboard */
.graf-caja {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1.2rem 1.3rem;
  box-shadow: var(--shadow); margin-bottom: 1.4rem;
}
.graf-titulo {
  margin: 0 0 .8rem; color: var(--text-muted); font-size: .72rem;
  font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
}
.graf-svg { display: flex; flex-direction: column; align-items: center; gap: .8rem; }
.graf-svg svg { width: 100%; max-width: 230px; height: auto; }
.graf-total { font-size: 34px; font-weight: 800; fill: var(--text); }
.graf-sub { font-size: 11px; fill: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }
.donut-leyenda { display: flex; flex-wrap: wrap; gap: .45rem 1rem; justify-content: center; }
.ley-item { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; color: var(--text-dim); }
.ley-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.graf-vacio { padding: 1.5rem; text-align: center; color: var(--text-muted); font-size: .86rem; }
.graf-barras { display: flex; flex-direction: column; gap: .65rem; }
.bar-fila { display: grid; grid-template-columns: minmax(120px, 1fr) 2.2fr 34px; align-items: center; gap: .7rem; }
.bar-lab { font-size: .82rem; font-weight: 600; color: var(--text-dim); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #0a6cff, #38bdf8);
  min-width: 3px; transition: width .35s ease;
}
.bar-val { font-size: .8rem; font-weight: 800; color: var(--text); text-align: right; }

/* Filtros */
.filtros { display: flex; gap: .6rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.filtros input, .filtros select { padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: inherit; font-size: .9rem; background: var(--bg-card); color: var(--text); }
.filtros input:focus, .filtros select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 108, 255, 0.12); }
.filtros input { flex: 1; min-width: 220px; }
.filtros select option { background: #fff; color: var(--text); }

/* Tablas */
.tabla { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tabla th {
  text-align: left; padding: 11px 14px;
  font-size: .72rem; color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  white-space: nowrap;
}
.tabla td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: .88rem; vertical-align: middle; }
.tabla tbody tr { transition: background .1s; }
.tabla tbody tr:hover td { background: #f8fafc; }
.tabla tbody tr:last-child td { border-bottom: none; }
.serial-cell { font-family: Consolas, monospace; font-weight: 700; font-size: .84rem; color: var(--primary); }

/* Pills / badges */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.pill-activa { background: var(--success-light); color: var(--success); }
.pill-en_uso { background: var(--primary-light); color: var(--primary); }
.pill-cerca { background: var(--warning-light); color: var(--warning); }
.pill-revocada { background: var(--danger-light); color: var(--danger); }
.pill-expirada { background: var(--bg); color: var(--text-muted); }

/* Botones en tablas */
.btn-acc {
  display: inline-flex; align-items: center;
  padding: 5px 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-card);
  color: var(--text-dim); cursor: pointer; font-size: .76rem; font-weight: 600;
  margin-right: .25rem; margin-bottom: .15rem; transition: all .15s; font-family: inherit; white-space: nowrap;
}
.btn-acc:hover { border-color: var(--primary); color: var(--primary); }
.btn-acc.revocar { color: var(--danger); border-color: #f3c6c6; }
.btn-acc.revocar:hover { background: var(--danger-light); border-color: var(--danger); color: var(--danger); }

/* Alerta */
.alerta {
  display: flex; align-items: center; gap: .45rem; flex-wrap: wrap;
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 1.1rem;
  background: var(--warning-light); border: 1px solid #f3d9a4; color: var(--warning);
  font-size: .88rem; font-weight: 500;
}
.alerta .link { margin-top: 0; white-space: nowrap; }
.sin-acceso { padding: 2rem; text-align: center; color: var(--text-muted); }

/* ---------- Configuración ---------- */
.conf-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; width: 100%; }
.panel {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.4rem;
  box-shadow: var(--shadow);
}
.panel h4 { margin-bottom: 1rem; color: var(--text); font-size: 1rem; font-weight: 700; }
.panel label { display: block; margin: .8rem 0 .3rem; font-size: .78rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.panel input { width: 100%; padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .9rem; font-family: inherit; background: var(--bg-card); color: var(--text); }
.panel input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 108, 255, 0.12); }

/* ---------- Modales ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 20, 35, 0.55); z-index: 100; }
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 14px; padding: 1.8rem;
  width: min(96vw, 460px); z-index: 110; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.modal-lg { width: min(96vw, 640px); }
.modal-sm { width: min(96vw, 420px); }
.modal h2 { font-size: 1.3rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: .3rem; color: var(--text); }
.modal label { display: block; margin: .8rem 0 .3rem; font-size: .78rem; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 9px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: .9rem; font-family: inherit;
  background: var(--bg-card); color: var(--text);
}
.modal select option { background: #fff; color: var(--text); }
.modal input:focus, .modal select:focus, .modal textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(10, 108, 255, 0.12); }
.modal-cerrar { position: absolute; top: 12px; right: 16px; border: none; background: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer; line-height: 1; }
.modal-cerrar:hover { color: var(--text); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.serial-box {
  background: #0f172a; border: 1px solid #3b82f6; color: #93c5fd;
  padding: 1.1rem; border-radius: 10px;
  font-family: Consolas, monospace; font-size: 1rem; text-align: center; letter-spacing: 1px;
  margin: .9rem 0; word-break: break-all;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--bg-card); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  color: var(--text); padding: .8rem 1.4rem; border-radius: var(--radius-sm);
  z-index: 200; font-weight: 600; font-size: .88rem;
  box-shadow: var(--shadow-lg);
}

/* ---------- Pie de página ---------- */
.footer {
  background: var(--bg-card);
  color: var(--text-dim); font-size: .85rem;
  padding: 1.6rem 1.5rem 1.1rem;
  border-top: 1px solid var(--border);
  margin-top: 2.5rem;
}
.footer-cols {
  max-width: 1600px; margin: 0 auto;
  display: flex; flex-wrap: wrap; gap: 2rem;
  justify-content: space-between; align-items: flex-start;
}
.footer-col { display: flex; flex-direction: column; gap: .35rem; min-width: 170px; }
.footer-col b { color: var(--text); font-size: .78rem; text-transform: uppercase; letter-spacing: .12em; margin-bottom: .4rem; }
.footer-marca b { font-size: 1.02rem; text-transform: none; letter-spacing: -.02em; }
.footer-col span { color: var(--text-muted); line-height: 1.5; }
.footer a { color: var(--text-dim); }
.footer a:hover { color: var(--primary); }
.social { display: flex; gap: .55rem; }
.social a {
  width: 34px; height: 34px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--bg); color: var(--text-dim);
  transition: all .15s ease;
}
.social a:hover { background: var(--primary-light); color: var(--primary); transform: translateY(-2px); }
.footer-bar {
  max-width: 1600px; margin: 1.2rem auto 0;
  padding-top: .9rem; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .4rem;
  color: var(--text-muted); font-size: .8rem;
}
.footer-bar b { color: var(--text); font-weight: 700; }

/* ---------- Presentes en ---------- */
.presentes { text-align: center; padding: 1rem 1.5rem 4.5rem; }
.presentes h2 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin-bottom: .3rem; }
.presentes p { color: var(--text-dim); margin-bottom: 1.5rem; }
.paises { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; }
.pais {
  background: var(--bg-card); border: 1px solid var(--border);
  padding: .55rem 1.15rem; border-radius: 999px;
  font-weight: 600; color: var(--text-dim); font-size: .88rem;
  box-shadow: var(--shadow); transition: all .15s ease;
}
.pais:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .dash-layout { flex-direction: column; align-items: stretch; }
  .dash-main { width: 100%; max-width: 100%; }
  .sidebar { width: 100%; position: static; flex-direction: row; align-items: center; overflow-x: auto; box-shadow: none; }
  .side-head { display: none; }
  .side-nav { flex-direction: row; gap: .3rem; flex-wrap: wrap; padding: 10px 12px; }
  .side-nav a { white-space: nowrap; padding: 8px 12px; margin-bottom: 0; }
  #vista-dash { padding-top: 1.2rem; }
  .footer-cols { gap: 1.4rem; }
}

@media (max-width: 480px) {
  .grid-2 { grid-template-columns: 1fr; }
  .dash-head { align-items: stretch; }
  .dash-actions { width: 100%; }
  .dash-actions .btn { flex: 1; }
  .tarjetas { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 400px) {
  .tarjetas { grid-template-columns: 1fr; }
  .dash-actions .btn { flex: none; width: 100%; }
  .modal { padding: 1.4rem; }
  .hero { padding: 3.5rem 1rem 2.5rem; }
  .adquisicion-inner { padding: 1.6rem 1.2rem; }
  .card { padding: 1.2rem 1.1rem; }
}