@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ig-bg: #F8FAFC;
  --ig-ink: #0F172A;
  --ig-muted: #64748B;
  --ig-border: #E2E8F0;
  --ig-side: #0F172A;
  --ig-side-2: #1E293B;
  --ig-side-text: #F8FAFC;
  --ig-side-muted: #94A3B8;
  --ig-primary: #0D6EFD;
  --ig-accent: #F59E0B;
  --bs-primary: #0D6EFD;
  --bs-body-font-family: 'IBM Plex Sans', system-ui, sans-serif;
  --bs-body-color: #0F172A;
  --bs-body-bg: #F8FAFC;
  --bs-border-color: #E2E8F0;
}

body { font-family: var(--bs-body-font-family); background: var(--ig-bg); color: var(--ig-ink); font-size: .92rem; }
.mono, code { font-family: 'IBM Plex Mono', monospace; }
.tracking-tight { letter-spacing: -.02em; }
.eyebrow { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--ig-muted); font-weight: 600; }
::selection { background: #0D6EFD; color: #fff; }

/* Layout */
.ig-sidebar { position: fixed; inset: 0 auto 0 0; width: 264px; background: var(--ig-side); color: var(--ig-side-text); overflow-y: auto; z-index: 1030; transition: transform .25s ease; }
.ig-brand { padding: 1.25rem 1.25rem 1rem; border-bottom: 1px solid var(--ig-side-2); }
.ig-brand .logo { width: 34px; height: 34px; border-radius: 8px; background: var(--ig-primary); display: grid; place-items: center; font-weight: 700; color: #fff; }
.ig-brand .name { font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; }
.ig-brand .sub { font-size: .68rem; color: var(--ig-side-muted); text-transform: uppercase; letter-spacing: .14em; }
.ig-nav { padding: .75rem .6rem 2rem; }
.ig-nav .mod-btn { width: 100%; background: none; border: 0; color: var(--ig-side-muted); font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; font-weight: 600; padding: .9rem .65rem .4rem; text-align: left; display: flex; align-items: center; gap: .5rem; }
.ig-nav .mod-btn .bi-chevron-down { margin-left: auto; transition: transform .2s ease; }
.ig-nav .mod-btn.collapsed .bi-chevron-down { transform: rotate(-90deg); }
.ig-nav a { display: flex; align-items: center; gap: .65rem; color: #CBD5E1; text-decoration: none; padding: .5rem .75rem; border-radius: 6px; font-size: .88rem; transition: background-color .15s ease, color .15s ease; }
.ig-nav a:hover { background: var(--ig-side-2); color: #fff; }
.ig-nav a.active { background: var(--ig-primary); color: #fff; }
.ig-main { margin-left: 264px; min-height: 100vh; }
.ig-topbar { position: sticky; top: 0; z-index: 1020; background: #fff; border-bottom: 1px solid var(--ig-border); height: 62px; display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem; }
.ig-content { padding: 1.75rem 2rem 3rem; }
@media (max-width: 991px) {
  .ig-sidebar { transform: translateX(-100%); }
  .ig-sidebar.open { transform: none; }
  .ig-main { margin-left: 0; }
  .ig-content { padding: 1.25rem 1rem 2rem; }
}

/* Empresa activa */
.empresa-pill { border: 1px solid var(--ig-border); background: #F1F5F9; border-radius: 8px; padding: .35rem .8rem; display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.empresa-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #10B981; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.empresa-pill:hover { background: #E2E8F0; }

/* Cards */
.card { border: 1px solid var(--ig-border); border-radius: 10px; box-shadow: none; transition: box-shadow .2s ease, transform .2s ease; }
.hover-lift:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(15,23,42,.06); }
.kpi { padding: 1.25rem 1.35rem; position: relative; overflow: hidden; }
.kpi .val { font-size: 2.1rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.kpi .ico { position: absolute; right: 1rem; top: 1rem; font-size: 1.4rem; opacity: .9; width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; }
.kpi .bar { position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.page-head h1 { font-size: 1.55rem; font-weight: 700; letter-spacing: -.025em; margin: 0; }
.list-row { display: flex; gap: .75rem; padding: .7rem 0; border-bottom: 1px solid #F1F5F9; align-items: flex-start; }
.list-row:last-child { border-bottom: 0; }
.empty { color: var(--ig-muted); font-size: .85rem; padding: 1rem 0; text-align: left; }

/* Buttons */
.btn { border-radius: 6px; font-weight: 500; transition: transform .15s ease, background-color .15s ease, box-shadow .15s ease; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-ms { background: #fff; border: 1px solid #CBD5E1; color: var(--ig-ink); }
.btn-ms:hover { background: #F1F5F9; }

/* Tables */
table.dataTable { border-collapse: collapse !important; }
table.dataTable thead th { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ig-muted); font-weight: 600; border-bottom: 1px solid var(--ig-border) !important; background: #fff; }
table.dataTable td { padding: .55rem .75rem !important; vertical-align: middle; border-bottom: 1px solid #F1F5F9; }
table.dataTable tbody tr:hover td { background: #F8FAFC; }
div.dt-container .dt-paging .dt-paging-button, .page-link { border-radius: 999px !important; margin: 0 2px; }
div.dt-container .dt-search input { border-radius: 6px; }
.dt-container { font-size: .86rem; }

/* Modals */
.modal-content { border-radius: 14px; border: 0; }
.modal-backdrop.show { opacity: 1; background: rgba(15,23,42,.55); backdrop-filter: blur(4px); }
.modal-header { border-bottom: 1px solid var(--ig-border); }
.form-label { font-size: .78rem; font-weight: 600; color: #334155; margin-bottom: .25rem; }

/* Badges */
.b-state { font-size: .7rem; font-weight: 600; padding: .3em .6em; border-radius: 5px; letter-spacing: .02em; }
.b-PENDIENTE, .b-ABIERTO, .b-EN_PROCESO, .b-MEDIA { background: #FEF3C7; color: #92400E; }
.b-APROBADO, .b-OK, .b-CUMPLE, .b-SINCRONIZADO, .b-EXPORTADO, .b-COMPLETADA, .b-LOGIN_EXITOSO { background: #D1FAE5; color: #065F46; }
.b-RECHAZADO, .b-ERROR, .b-ALTA, .b-CANCELADO, .b-LOGIN_FALLIDO, .b-USUARIO_BLOQUEADO, .b-PERMISO_DENEGADO { background: #FEE2E2; color: #991B1B; }
.b-NO_CUMPLE, .b-OMITIDO, .b-BAJA, .b-SIMULADO, .b-CERRADO { background: #E2E8F0; color: #334155; }
.b-PARCIAL, .b-REAL { background: #DBEAFE; color: #1E40AF; }

/* Workflow designer & timeline */
.stage-card { border: 1px solid var(--ig-border); border-left: 4px solid var(--ig-primary); border-radius: 10px; padding: 1rem; background: #fff; position: relative; }
.stage-card + .stage-card { margin-top: 1.5rem; }
.stage-card + .stage-card::before { content: ''; position: absolute; left: 28px; top: -1.5rem; height: 1.5rem; border-left: 2px dashed #94A3B8; }
.stage-num { width: 26px; height: 26px; border-radius: 50%; background: var(--ig-primary); color: #fff; display: inline-grid; place-items: center; font-size: .75rem; font-weight: 700; }
.timeline { border-left: 2px solid var(--ig-border); margin-left: .5rem; padding-left: 1.1rem; }
.timeline .tl-item { position: relative; padding-bottom: .9rem; }
.timeline .tl-item::before { content: ''; position: absolute; left: -1.48rem; top: .3rem; width: 10px; height: 10px; border-radius: 50%; background: var(--ig-primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--ig-primary); }
.cond-group { border: 1px dashed #94A3B8; border-radius: 10px; padding: .85rem; background: #FBFDFF; }
.cond-group .cond-group { background: #fff; margin-top: .6rem; }
.diff-old { background: #FEF2F2; color: #991B1B; text-decoration: line-through; }
.diff-new { background: #ECFDF5; color: #065F46; }

/* Tree */
.cc-tree ul { list-style: none; padding-left: 1.1rem; border-left: 1px dashed #CBD5E1; margin: 0; }
.cc-tree > ul { border-left: 0; padding-left: 0; }
.cc-tree li { padding: .2rem 0; }
.cc-node { display: inline-flex; align-items: center; gap: .45rem; padding: .25rem .5rem; border-radius: 6px; cursor: default; }
.cc-node:hover { background: #F1F5F9; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; background-size: cover; background-position: center; color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; }
.login-art::before { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(15,23,42,.55), rgba(15,23,42,.88)); }
.login-art > * { position: relative; }
.login-art h2 { font-size: 2.6rem; font-weight: 700; letter-spacing: -.035em; line-height: 1.05; max-width: 520px; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.login-form .inner { width: 100%; max-width: 400px; }
@media (max-width: 991px) { .login-wrap { grid-template-columns: 1fr; } .login-art { display: none; } }

.fade-up { animation: fadeUp .45s ease both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeUp .45s ease both; }
.stagger > *:nth-child(2) { animation-delay: .05s; } .stagger > *:nth-child(3) { animation-delay: .1s; }
.stagger > *:nth-child(4) { animation-delay: .15s; } .stagger > *:nth-child(5) { animation-delay: .2s; }
.toast-container { z-index: 2000; }
pre.json { background: #0F172A; color: #E2E8F0; border-radius: 8px; padding: .8rem; font-size: .78rem; max-height: 320px; overflow: auto; }
html, body { overflow-x: hidden; }
.kpi .eyebrow { padding-right: 48px; min-height: 2.1em; }
#empresa-actual { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-block; vertical-align: bottom; }
@media (max-width: 575px) {
  .ig-topbar { padding: 0 .6rem; gap: .4rem; }
  #empresa-actual { max-width: 120px; }
  .kpi .val { font-size: 1.6rem; }
  .kpi .ico { width: 32px; height: 32px; font-size: 1.05rem; }
}
.kpi .eyebrow { word-break: normal; overflow-wrap: normal; }
#er-out svg { height: auto; display: block; margin: 0; }

/* CRM */
.b-ACTIVO, .b-ACTIVA, .b-REGISTRADO, .b-RESUELTA { background: #D1FAE5; color: #065F46; }
.b-PROSPECTO, .b-BORRADOR, .b-LLAMADA, .b-CORREO, .b-VISITA, .b-REUNION, .b-TAREA, .b-TICKET, .b-SIMULACION, .b-CONTRATO, .b-PAGARE, .b-CERTIFICADO, .b-FACTURACION, .b-DESPACHO, .b-COMERCIAL, .b-OBRA, .b-INTERNO { background: #DBEAFE; color: #1E40AF; }
.b-BLOQUEADO, .b-ABIERTA { background: #FEE2E2; color: #991B1B; }
.b-INACTIVO, .b-FINALIZADA, .b-NO_CONFIGURADO, .b-OTRO, .b-ADJUNTO_CORREO { background: #E2E8F0; color: #334155; }
.b-PAUSADA, .b-EJECUCION { background: #FEF3C7; color: #92400E; }
.nav-tabs .nav-link { font-size: .84rem; color: var(--ig-muted); border-radius: 8px 8px 0 0; }
.nav-tabs .nav-link.active { color: var(--ig-ink); font-weight: 600; }
.nav-tabs { scrollbar-width: thin; }

.b-SUSPENDIDA, .b-POR_VENCER, .b-EN_GESTION { background: #FEF3C7; color: #92400E; }
.b-CANCELADA { background: #E2E8F0; color: #334155; }
.b-AL_DIA { background: #D1FAE5; color: #065F46; }
.b-MOROSO { background: #FEE2E2; color: #991B1B; }
.b-JUDICIAL { background: #7F1D1D; color: #fff; }
