/* ============================================================
   Sistema de Afiliaciones — Seguridad Social Colombia
   Tema: Oscuro Profesional
   ============================================================ */

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

:root {
  --bg:       #0d1b2a;
  --surface:  #162032;
  --card:     #1a2744;
  --border:   #253555;
  --primary:  #1d4ed8;
  --ph:       #1e40af;
  --accent:   #3b82f6;
  --success:  #22c55e;
  --danger:   #ef4444;
  --warn:     #f59e0b;
  --purple:   #8b5cf6;
  --text:     #e2e8f0;
  --muted:    #94a3b8;
  --dim:      #4a6080;
  --r:        8px;
  --sh:       0 4px 24px rgba(0,0,0,.4);
  --sidebar-w: 255px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Utilidades ── */
.hidden  { display: none !important; }
.flex    { display: flex; }
.items-c { align-items: center; }
.jus-b   { justify-content: space-between; }
.gap1    { gap: .25rem; }
.gap2    { gap: .5rem; }
.gap3    { gap: .75rem; }
.gap4    { gap: 1rem; }
.text-muted { color: var(--muted); }
.text-danger{ color: var(--danger); }
@keyframes fi { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:none; } }
.fi { animation: fi .22s ease; }

/* ═══════════════════════════════════════════
   BOTONES
═══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .45rem; padding: .6rem 1.2rem; border: none; border-radius: var(--r);
  font-size: .875rem; font-weight: 600; cursor: pointer; transition: all .2s;
  white-space: nowrap; text-decoration: none; font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--ph); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { background: #16a34a; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover   { background: #dc2626; }
.btn-warn     { background: var(--warn);    color: #fff; }
.btn-warn:hover     { background: #d97706; }
.btn-outline  { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover  { background: rgba(255,255,255,.05); }
.btn-sm  { padding: .4rem .85rem; font-size: .8rem; }
.btn-lg  { padding: .85rem 1.8rem; font-size: 1rem; }
.btn-icon{ width: 2rem; height: 2rem; padding: 0; border-radius: 6px; }

/* ═══════════════════════════════════════════
   FORMULARIOS
═══════════════════════════════════════════ */
.ig { margin-bottom: .9rem; }
.ig label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: .35rem; font-weight: 500; }
.ig label .req { color: var(--danger); }

input, select, textarea {
  width: 100%; padding: .65rem .9rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text);
  font-size: .875rem; font-family: inherit; outline: none;
  transition: border-color .2s;
  text-transform: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
input::placeholder, textarea::placeholder { color: var(--dim); }
select option { background: var(--surface); color: var(--text); }
textarea { resize: vertical; min-height: 72px; }

/* Input con símbolo */
.ip { position: relative; }
.ip-sym { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; font-size: .9rem; }
.ip input { padding-left: 2.1rem; }

/* Grids de formulario */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.g3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.span2 { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .g2, .g3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}

.form-actions {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: .75rem; margin-top: 1.25rem;
  padding-top: 1.25rem; border-top: 1px solid var(--border);
}

/* ═══════════════════════════════════════════
   CARDS
═══════════════════════════════════════════ */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r); padding: 1.5rem; box-shadow: var(--sh);
  margin-bottom: 1rem;
}
.card-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; padding-bottom: .875rem; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }

/* ═══════════════════════════════════════════
   TABLA
═══════════════════════════════════════════ */
.tbl-wrap { overflow-x: auto; border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; }
th {
  padding: .7rem 1rem; text-align: left; font-size: .75rem; font-weight: 600;
  color: var(--muted); background: rgba(0,0,0,.2);
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
td { padding: .7rem 1rem; font-size: .85rem; border-top: 1px solid rgba(255,255,255,.04); }
tr:hover td { background: rgba(59,130,246,.04); }

/* ═══════════════════════════════════════════
   BADGES
═══════════════════════════════════════════ */
.badge {
  display: inline-flex; align-items: center; padding: .18rem .6rem;
  border-radius: 999px; font-size: .72rem; font-weight: 600; white-space: nowrap;
}
.b-blue   { background: rgba(59,130,246,.15);  color: #60a5fa; }
.b-green  { background: rgba(34,197,94,.15);   color: #4ade80; }
.b-red    { background: rgba(239,68,68,.15);   color: #f87171; }
.b-warn   { background: rgba(245,158,11,.15);  color: #fbbf24; }
.b-purple { background: rgba(139,92,246,.15);  color: #a78bfa; }

.dot { width: .45rem; height: .45rem; border-radius: 50%; display: inline-block; margin-right: .35rem; flex-shrink: 0; }
.dot-g { background: var(--success); }
.dot-r { background: var(--danger); }
.dot-w { background: var(--warn); }

/* ═══════════════════════════════════════════
   DASHBOARD EXTRAS
═══════════════════════════════════════════ */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem;
}
@media (max-width: 1200px) { .stats-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px)  { .stats-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px)  { .stats-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r);
  padding: 1.25rem; display: flex; align-items: center; gap: .875rem; box-shadow: var(--sh);
}
.stat-icon {
  width: 2.75rem; height: 2.75rem; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; flex-shrink: 0;
}
.stat-info h3 { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.stat-info p  { font-size: .75rem; color: var(--muted); margin-top: .2rem; }

.dash-grid2 {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1.5rem;
}
@media (max-width: 900px) { .dash-grid2 { grid-template-columns: 1fr; } }

/* Bar charts */
.bar-row { display: flex; align-items: center; gap: .75rem; padding: .45rem 0; }
.bar-label { font-size: .78rem; width: 200px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-wrap { flex: 1; height: .55rem; background: rgba(255,255,255,.06); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 4px; transition: width .5s; }
.bar-eps  { background: linear-gradient(90deg, #22c55e, #4ade80); }
.bar-val  { font-size: .8rem; font-weight: 700; color: var(--accent); width: 30px; text-align: right; }

/* ═══════════════════════════════════════════
   SECCIONES DEL FORMULARIO
═══════════════════════════════════════════ */
.fsec { margin-bottom: 1.5rem; }
.fsec-title {
  font-size: .78rem; font-weight: 700; color: var(--accent);
  text-transform: uppercase; letter-spacing: .08em;
  padding-bottom: .5rem;
  border-bottom: 1px solid rgba(59,130,246,.2);
  margin-bottom: .875rem;
  display: flex; align-items: center; gap: .4rem;
}
.sec-hd {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: .75rem;
}
.sec-title { font-size: 1.05rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }

.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .ei { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }

/* ═══════════════════════════════════════════
   PAGINACIÓN
═══════════════════════════════════════════ */
.pagination { display: flex; gap: .35rem; margin-top: 1rem; flex-wrap: wrap; }
.page-btn {
  padding: .4rem .75rem; border-radius: var(--r); font-size: .82rem; font-weight: 600;
  text-decoration: none; color: var(--muted); background: var(--card);
  border: 1px solid var(--border); transition: all .2s;
}
.page-btn:hover, .page-btn.active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}

/* ═══════════════════════════════════════════
   LOGIN
═══════════════════════════════════════════ */
#loginPage {
  min-height: 100vh; display: flex;
  background: linear-gradient(135deg, #090f1a 0%, #0d1b2a 50%, #0f2040 100%);
}
.login-left {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 3rem; position: relative; overflow: hidden; gap: 2rem;
}
.login-left::before {
  content: ''; position: absolute; inset: 0;
  background-image:
    radial-gradient(circle at 25% 25%, rgba(29,78,216,.08) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, rgba(139,92,246,.06) 0%, transparent 50%);
}
.lg-brand {
  display: flex; align-items: center; gap: 1rem;
  position: relative; z-index: 1;
}
.lg-brand-icon {
  width: 3.5rem; height: 3.5rem; border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  display: flex; align-items: center; justify-content: center; font-size: 1.75rem;
  box-shadow: 0 0 30px rgba(29,78,216,.4);
}
.lg-brand-name { font-size: 1.1rem; font-weight: 800; letter-spacing: .04em; }
.lg-brand-sub  { font-size: .72rem; color: var(--muted); letter-spacing: .06em; }

.lg-bubbles {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 1.25rem; max-width: 480px;
}
.lg-bub {
  background: rgba(22,32,50,.85); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.4rem; backdrop-filter: blur(10px);
  flex: 1; min-width: 150px;
}
.lg-bub h4 { font-size: 1.5rem; font-weight: 800; margin-bottom: .1rem; }
.lg-bub p  { font-size: .75rem; color: var(--muted); }
.lg-bub.c-g h4 { color: var(--success); }
.lg-bub.c-b h4 { color: var(--accent); }
.lg-bub.c-w h4 { color: var(--warn); }
.lg-bub.c-p h4 { color: var(--purple); }

.lg-info {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: .5rem; max-width: 380px;
}
.lg-info p { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: .5rem; }

.login-right {
  width: 420px; min-height: 100vh;
  background: rgba(15,26,48,.97); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 3rem 2.5rem;
}
@media (max-width: 700px) {
  .login-left  { display: none; }
  .login-right { width: 100%; }
}

.lg-logo {
  width: 5rem; height: 5rem; border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; margin-bottom: 1.5rem;
  box-shadow: 0 0 40px rgba(29,78,216,.35);
}
.lg-title  { font-size: 1.55rem; font-weight: 800; letter-spacing: .06em; margin-bottom: .25rem; text-align: center; }
.lg-sub    { font-size: .75rem; color: var(--muted); letter-spacing: .12em; margin-bottom: 2.5rem; text-align: center; }

.lg-wrap { position: relative; margin-bottom: 1.1rem; width: 100%; }
.lg-wrap label { display: block; font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-bottom: .35rem; }
.lg-wrap .ico  { position: absolute; left: .9rem; top: calc(1.55rem + .4rem); color: var(--muted); font-size: .95rem; }
.lg-wrap .eye  { position: absolute; right: .9rem; top: calc(1.55rem + .35rem); background: none; border: none; color: var(--muted); cursor: pointer; font-size: .95rem; padding: .1rem; }
.lg-wrap input { padding: .8rem 1rem .8rem 2.6rem; background: rgba(10,20,36,.8); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); font-size: .925rem; width: 100%; outline: none; transition: all .2s; }
.lg-wrap input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }

.lg-btn {
  width: 100%; padding: .875rem; margin-top: .25rem;
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  border: none; border-radius: var(--r); color: #fff;
  font-size: .975rem; font-weight: 700; cursor: pointer; transition: all .2s; letter-spacing: .03em;
}
.lg-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 8px 24px rgba(29,78,216,.45); }

.lg-err {
  background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3);
  color: #f87171; padding: .7rem .9rem; border-radius: var(--r);
  font-size: .82rem; margin-bottom: .875rem; width: 100%; text-align: center;
}
.lg-footer {
  margin-top: 2rem; font-size: .74rem; color: var(--dim);
  text-align: center; line-height: 1.7;
}

/* ═══════════════════════════════════════════
   APP LAYOUT
═══════════════════════════════════════════ */
#appPage { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0; bottom: 0; z-index: 100;
  transition: transform .25s;
}
.sb-brand {
  padding: 1.25rem 1rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: .75rem; flex-shrink: 0;
}
.sb-ico {
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex; align-items: center; justify-content: center; font-size: 1.15rem; flex-shrink: 0;
}
.sb-name { font-weight: 800; font-size: .9rem; line-height: 1.2; }
.sb-sub  { font-size: .67rem; color: var(--muted); }
.sb-nav  { padding: .875rem .75rem; flex: 1; display: flex; flex-direction: column; gap: .2rem; overflow-y: auto; }
.nav-it {
  display: flex; align-items: center; gap: .7rem; padding: .7rem .875rem;
  border-radius: var(--r); cursor: pointer; transition: all .2s;
  color: var(--muted); font-size: .875rem; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left; text-decoration: none;
}
.nav-it:hover { background: var(--card); color: var(--text); }
.nav-it.active { background: rgba(29,78,216,.18); color: var(--accent); border-left: 3px solid var(--accent); padding-left: calc(.875rem - 3px); }
.nav-it .ni { font-size: 1rem; width: 1.2rem; text-align: center; }
.nav-sep { height: 1px; background: var(--border); margin: .5rem 0; }

.sb-user {
  padding: .875rem 1rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .7rem; flex-shrink: 0;
}
.u-av {
  width: 2.1rem; height: 2.1rem; border-radius: 50%;
  background: linear-gradient(135deg, #7c3aed, #4f46e5);
  display: flex; align-items: center; justify-content: center; font-size: .85rem; flex-shrink: 0;
  font-weight: 800; color: #fff;
}
.u-info { flex: 1; min-width: 0; }
.u-info p    { font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.u-info span { font-size: .7rem; color: var(--muted); }
.u-logout { text-decoration: none; font-size: 1rem; opacity: .6; transition: opacity .2s; }
.u-logout:hover { opacity: 1; }

/* Main content */
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar {
  padding: .875rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); position: sticky; top: 0; z-index: 50; gap: 1rem;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-title { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.tb-right { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }

.sb-toggle { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1.2rem; padding: .2rem; display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .sb-toggle { display: block; }
}

.srch { position: relative; }
.srch span { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: .8rem; pointer-events: none; }
.srch input { padding: .5rem .875rem .5rem 2.25rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); font-size: .825rem; outline: none; width: 220px; transition: border-color .2s; }
.srch input:focus { border-color: var(--accent); }
.content { padding: 1.5rem; flex: 1; }

/* ═══════════════════════════════════════════
   MODAL
═══════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.75);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem; backdrop-filter: blur(4px);
}
.modal {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  max-height: 92vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6);
  width: 100%;
}
.modal-hd {
  padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--card); z-index: 1;
}
.modal-title { font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: .5rem; }
.modal-x {
  width: 1.875rem; height: 1.875rem; border-radius: 6px; border: none;
  background: var(--surface); color: var(--text); cursor: pointer; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
.modal-body { padding: 1.4rem; }
.modal-ft {
  padding: .875rem 1.4rem; border-top: 1px solid var(--border);
  display: flex; justify-content: center; gap: .75rem; flex-wrap: wrap;
}

/* ═══════════════════════════════════════════
   RECIBO (preview + print)
═══════════════════════════════════════════ */
.rcpt-preview {
  background: #fff; color: #000; border-radius: var(--r);
  padding: 14px 12px; font-family: 'Courier New', monospace;
  font-size: .78rem; max-width: 320px; margin: 0 auto;
  line-height: 1.55; box-shadow: 0 2px 12px rgba(0,0,0,.3);
}
.rcpt-preview * { color: #000 !important; }
.rp-center   { text-align: center; }
.rp-bold     { font-weight: 700; }
.rp-big      { font-size: .92rem; }
.rp-sm       { font-size: .68rem; }
.rp-hr       { border: none; border-top: 1px dashed #aaa; margin: 6px 0; }
.rp-row      { display: flex; justify-content: space-between; font-size: .76rem; margin: 2px 0; }
.rp-total    { display: flex; justify-content: space-between; font-size: .92rem; font-weight: 700; margin: 5px 0; padding: 4px 0; border-top: 2px solid #000; border-bottom: 2px solid #000; }
.rp-foot     { text-align: center; margin-top: 8px; font-size: .68rem; }
.rp-logo-txt { font-size: .9rem; font-weight: 900; letter-spacing: .04em; }
.rp-sub-txt  { font-size: .72rem; }

/* Estilos de impresión térmica 80mm */
#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea {
    display: block !important; width: 80mm; margin: 0; padding: 3mm 4mm;
    font-family: 'Courier New', monospace; font-size: 9pt; line-height: 1.45;
    color: #000; background: #fff;
  }
  #printArea * { color: #000 !important; background: transparent !important; }
  .pr-c     { text-align: center; }
  .pr-b     { font-weight: bold; }
  .pr-big   { font-size: 11pt; }
  .pr-sm    { font-size: 7.5pt; }
  .pr-hr    { display: block; border: none; border-top: 1px dashed #000; margin: 2.5mm 0; }
  .pr-row   { display: flex; justify-content: space-between; }
  .pr-total { display: flex; justify-content: space-between; font-weight: bold; font-size: 12pt; padding: 1mm 0; border-top: 1px solid #000; border-bottom: 1px solid #000; margin: 2mm 0; }
}

/* ═══════════════════════════════════════════
   TOAST
═══════════════════════════════════════════ */
.toast {
  position: fixed; top: 1.25rem; right: 1.25rem; z-index: 9999;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r);
  padding: .8rem 1.1rem; box-shadow: var(--sh);
  display: flex; align-items: center; gap: .6rem; font-size: .85rem;
  opacity: 0; transform: translateY(-8px); transition: all .3s;
  pointer-events: none; min-width: 220px; max-width: 340px;
}
.toast.show  { opacity: 1; transform: none; }
.toast.t-ok  { border-left: 3px solid var(--success); }
.toast.t-err { border-left: 3px solid var(--danger); }
.toast.t-info{ border-left: 3px solid var(--accent); }

/* ═══════════════════════════════════════════
   FLASH messages (PHP)
═══════════════════════════════════════════ */
.flash {
  padding: .8rem 1rem; border-radius: var(--r); margin-bottom: 1rem;
  font-size: .875rem; display: flex; align-items: center; gap: .6rem;
}
.flash-ok  { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.3);  color: #4ade80; }
.flash-err { background: rgba(239,68,68,.12);  border: 1px solid rgba(239,68,68,.3);  color: #f87171; }
