/* Control MIG — hoja unica.
   Paleta de la marca MIG (azul marino, azul electrico, lila): el color se reserva para estados (activo, pendiente,
   bloqueado) y para la marca. El NIT y las claves van en monoespaciada porque
   se leen caracter por caracter. */

:root {
  --bg: #F4F6FB;
  --panel: #FFFFFF;
  --ink: #141C36;
  --ink-2: #48516D;
  --ink-3: #767F99;
  --line: #DCE1EE;
  --line-2: #EBEEF6;
  --brand: #2146E0;
  --brand-hover: #1A37B8;
  --brand-soft: #E6EAFF;
  --on-brand: #FFFFFF;
  --marino: #061847;
  --ok: #1D7443;      --ok-soft: #E3F2E8;
  --warn: #8C5A00;    --warn-soft: #FBEFD5;
  --bad: #B0261E;     --bad-soft: #FBE5E2;
  --muted-soft: #EEF1F8;
  --focus: #7B86FF;
  --shadow: 0 1px 2px rgba(6, 24, 71, .06), 0 8px 24px rgba(6, 24, 71, .09);

  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --r-control: 6px;
  --r-panel: 10px;
  --lateral: 232px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A1024;
    --panel: #111933;
    --ink: #E6EAF7;
    --ink-2: #A7AFCB;
    --ink-3: #7E87A6;
    --line: #253052;
    --line-2: #1A2242;
    --brand: #8C98FF;
    --brand-hover: #A6AFFF;
    --brand-soft: #1D2657;
    --on-brand: #0A1024;
    --ok: #62C98C;    --ok-soft: #14301F;
    --warn: #E8B650;  --warn-soft: #33270C;
    --bad: #F08A80;   --bad-soft: #3A1714;
    --muted-soft: #182043;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14.5px/1.5 var(--sans);
}
/* Cifras alineadas solo donde se comparan numeros: en esta fuente tnum tambien ensancha la puntuacion. */
.resumen b, .num, .ficha-nit, .paginas { font-variant-numeric: tabular-nums; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.05rem; font-weight: 650; }
h3 { font-size: .95rem; font-weight: 600; }
p { margin: 0; }
.mono { font-family: var(--mono); font-size: .92em; letter-spacing: -.01em; }
.tenue { color: var(--ink-3); }
.sec { color: var(--ink-2); }
.oculto, [hidden] { display: none !important; }
.sprite { position: absolute; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 18px; }
.marca-clara, .marca-clara:hover { color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ------------------------------------------------------------ Estructura */
.marco { display: grid; grid-template-columns: var(--lateral) 1fr; min-height: 100vh; }

.lateral {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 12px 14px;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; color: var(--ink); }
.marca:hover { text-decoration: none; }
.marca-sello {
  width: 34px; height: 34px; border-radius: 8px; background: var(--brand); color: var(--on-brand);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; letter-spacing: -.02em;
}
.marca b { display: block; font-size: 15px; line-height: 1.1; }
.marca small { color: var(--ink-3); font-size: 12px; }
.marca-logo { flex-direction: column; align-items: flex-start; gap: 6px; }
.marca-logo img { display: block; width: 150px; height: auto; }
.marca-logo small { padding-left: 2px; font-weight: 600; color: var(--ink-2); }

.menu { display: flex; flex-direction: column; gap: 1px; }
.menu-grupo { margin: 16px 8px 4px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.menu a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-control);
  color: var(--ink-2); font-weight: 500;
}
.menu a:hover { background: var(--muted-soft); color: var(--ink); text-decoration: none; }
.menu a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.menu svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; }
.menu .cuenta-menu {
  margin-left: auto; min-width: 22px; padding: 0 7px; border-radius: 20px; text-align: center;
  background: var(--warn-soft); color: var(--warn); font-size: 12px; font-weight: 700; line-height: 20px;
}
.lateral-pie { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--line-2); font-size: 13px; }
.lateral-pie .quien { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lateral-pie form { margin: 0; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.barra {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 12px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-2);
}
.boton-menu, .logo-barra { display: none; }
.logo-barra img { display: block; width: 96px; height: auto; }
.contenido { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }

.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.encabezado p { margin-top: 4px; color: var(--ink-2); }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------ Buscador de NIT (el elemento central) */
.buscador { position: relative; flex: 1; max-width: 640px; }
.buscador input[type=search] {
  width: 100%; height: 42px; padding: 0 84px 0 42px; border-radius: 21px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: 500 15px var(--sans);
}
.buscador input[type=search]::placeholder { color: var(--ink-3); font-weight: 400; }
.buscador input[type=search]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.buscador > svg { position: absolute; left: 15px; top: 12px; width: 18px; height: 18px; stroke: var(--ink-3); fill: none; stroke-width: 2; }
.buscador kbd {
  position: absolute; right: 12px; top: 10px; font: 500 11.5px var(--sans); color: var(--ink-3);
  border: 1px solid var(--line); border-radius: 5px; padding: 2px 6px; background: var(--bg);
}
.resultados {
  position: absolute; top: 48px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-panel); box-shadow: var(--shadow); padding: 6px; max-height: 70vh; overflow-y: auto;
}
.resultados a {
  display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: baseline;
  padding: 9px 10px; border-radius: var(--r-control); color: var(--ink);
}
.resultados a:hover, .resultados a[aria-selected="true"] { background: var(--brand-soft); text-decoration: none; }
.resultados .nit { font-family: var(--mono); font-weight: 500; }
.resultados .origen { font-size: 12px; color: var(--ink-3); }
.resultados .nada { padding: 12px; color: var(--ink-2); }

/* ------------------------------------------------------------ Controles */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 34px; padding: 0 14px;
  border-radius: var(--r-control); border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: 500 14px var(--sans); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primario { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primario:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn.peligro { color: var(--bad); }
.btn.peligro.lleno { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.chico { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.fantasma { border-color: transparent; background: transparent; }
.btn.fantasma:hover { background: var(--muted-soft); }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--ink-3); border-top-color: transparent; animation: gira .7s linear infinite;
}
@keyframes gira { to { transform: rotate(360deg); } }

.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.campo > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.campo small { color: var(--ink-3); font-size: 12.5px; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=tel], select, textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border-radius: var(--r-control);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: 400 14px var(--sans);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input[readonly] { background: var(--muted-soft); }
.rejilla { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rejilla .ancho { grid-column: 1 / -1; }
.rejilla-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); margin: 0; }

/* Casillas de dias y horas del bot */
.fichas { display: flex; flex-wrap: wrap; gap: 6px; }
.fichas label { position: relative; }
.fichas input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.fichas span {
  display: inline-block; min-width: 40px; text-align: center; padding: 5px 8px; border-radius: var(--r-control);
  border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); background: var(--panel);
}
.fichas input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }
.fichas input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Filtros como pestanas segmentadas */
.filtros { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--panel); padding: 2px; flex-wrap: wrap; }
.filtros button, .filtros a {
  border: 0; background: transparent; color: var(--ink-2); font: 500 13.5px var(--sans);
  padding: 5px 12px; border-radius: 4px; cursor: pointer;
}
.filtros button:hover, .filtros a:hover { color: var(--ink); text-decoration: none; }
.filtros [aria-pressed="true"], .filtros [aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.filtros .n { margin-left: 5px; color: var(--ink-3); font-weight: 500; }

.herramientas { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.herramientas .buscar-tabla { width: 300px; max-width: 100%; }

/* ------------------------------------------------------------ Paneles y tablas */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-panel); }
.panel-cab { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.panel-cab p { color: var(--ink-3); font-size: 13px; }
.panel-cuerpo { padding: 18px; }
.panel-pie { padding: 10px 18px; border-top: 1px solid var(--line-2); font-size: 13px; }

.tabla-envoltura { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th {
  text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-3); padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel); position: sticky; top: 0;
}
.tabla th button { all: unset; cursor: pointer; }
.tabla th button:hover { color: var(--ink); }
.tabla th button:focus-visible { outline: 2px solid var(--focus); }
.tabla td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.tabla tbody tr:hover { background: color-mix(in srgb, var(--brand-soft) 45%, transparent); }
.tabla tbody tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; }
.tabla .fin { text-align: right; white-space: nowrap; }
.tabla .nombre b { display: block; font-weight: 600; }
.tabla .nombre small { color: var(--ink-3); }
.tabla .vacio { text-align: center; padding: 40px 12px; color: var(--ink-2); }
.corta { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.paginas { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line-2); font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.paginas .acciones { gap: 6px; }

/* Estados */
.estado {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 20px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap; background: var(--muted-soft); color: var(--ink-2);
}
.estado::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.estado.ok { background: var(--ok-soft); color: var(--ok); }
.estado.warn { background: var(--warn-soft); color: var(--warn); }
.estado.bad { background: var(--bad-soft); color: var(--bad); }
.estado.brand { background: var(--brand-soft); color: var(--brand); }

/* Interruptor de fila (mensualidad, activo) */
.interruptor { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.interruptor i { width: 32px; height: 18px; border-radius: 10px; background: var(--line); position: relative; transition: background .15s; }
.interruptor i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.interruptor[aria-checked="true"] i { background: var(--brand); }
.interruptor[aria-checked="true"] i::after { transform: translateX(14px); }
.interruptor:focus-visible i { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ------------------------------------------------------------ Tablero */
.resumen { display: flex; flex-wrap: wrap; gap: 8px 28px; padding: 14px 0 22px; color: var(--ink-2); border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.resumen b { color: var(--ink); font-size: 1.25rem; font-weight: 700; margin-right: 6px; }
.tablero { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.tablero .completo { grid-column: 1 / -1; }
.lista-tarea { list-style: none; margin: 0; padding: 0; }
.lista-tarea li { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); }
.lista-tarea li:last-child { border-bottom: 0; }
.lista-tarea .que { flex: 1; min-width: 0; }
.lista-tarea .que b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-tarea .que small { color: var(--ink-3); }
.limpio { padding: 22px 18px; color: var(--ink-2); display: flex; gap: 10px; align-items: center; }
.limpio svg { width: 20px; height: 20px; stroke: var(--ok); fill: none; stroke-width: 2; }

.franja-wa { display: flex; align-items: center; gap: 14px; padding: 14px 18px; flex-wrap: wrap; }
.punto { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); flex: none; }
.punto.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.punto.bad { background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); }
.punto.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }

/* ------------------------------------------------------------ Ficha por NIT */
.ficha-cab { display: flex; gap: 22px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; padding-bottom: 20px; margin-bottom: 22px; border-bottom: 1px solid var(--line); }
.ficha-nit { font-family: var(--mono); font-size: 2.2rem; font-weight: 500; letter-spacing: -.03em; line-height: 1; }
.ficha-cab h1 { font-size: 1.15rem; font-weight: 600; color: var(--ink-2); margin-top: 8px; }
.ficha-estados { display: flex; gap: 8px; flex-wrap: wrap; }
.ficha { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.ficha .completo { grid-column: 1 / -1; }
dl.datos { display: grid; grid-template-columns: 150px 1fr; gap: 8px 14px; margin: 0; font-size: 14px; }
dl.datos dt { color: var(--ink-3); }
dl.datos dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.clave { font-family: var(--mono); font-size: 12.5px; background: var(--muted-soft); padding: 6px 8px; border-radius: var(--r-control); overflow-wrap: anywhere; display: block; }

/* ------------------------------------------------------------ Dialogos, avisos */
dialog.modal {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--line);
  border-radius: 12px; background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
}
dialog.modal.estrecho { width: min(440px, calc(100vw - 32px)); }
dialog.modal::backdrop { background: rgba(6, 12, 34, .5); }
dialog.modal[open] { animation: aparece .16s ease-out; }
@keyframes aparece { from { opacity: 0; transform: translateY(6px); } }
.modal form { display: flex; flex-direction: column; max-height: calc(100vh - 42px); margin: 0; }
.modal-cab { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-cuerpo { padding: 18px 20px; overflow-y: auto; }
.modal-cuerpo > p { color: var(--ink-2); }
.modal-pie { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line-2); }

.avisos { position: fixed; right: 18px; bottom: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 36px)); }
.aviso {
  display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 8px; background: var(--ink); color: var(--bg);
  box-shadow: var(--shadow); font-size: 14px; animation: aparece .18s ease-out;
}
.aviso.error { background: var(--bad); color: #fff; }
.flash { margin-bottom: 16px; padding: 11px 14px; border-radius: 8px; border: 1px solid; font-size: 14px; }
.flash.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 30%, transparent); color: var(--ok); }
.flash.error { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.flash.aviso { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }

.nota { padding: 12px 14px; border-radius: 8px; background: var(--muted-soft); color: var(--ink-2); font-size: 13.5px; }
.nota.warn { background: var(--warn-soft); color: var(--warn); }

/* ------------------------------------------------------------ Ingreso */
.ingreso { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(360px, .9fr); }
.ingreso-lado {
  background: var(--marino); color: #FFFFFF; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.ingreso-lado img { width: 220px; height: auto; display: block; }
.ingreso-lado h1 { font-size: clamp(2rem, 4vw, 3.1rem); font-weight: 700; letter-spacing: -.03em; max-width: 13ch; line-height: 1.05; }
.ingreso-lado p { max-width: 42ch; opacity: .85; margin-top: 14px; font-size: 15px; }
.nits { font-family: var(--mono); font-size: 13px; opacity: .5; line-height: 1.9; }
.ingreso-form { display: grid; place-items: center; padding: 32px; }
.ingreso-form form { width: min(340px, 100%); display: flex; flex-direction: column; gap: 16px; }
.ingreso-form h2 { font-size: 1.35rem; }
.ingreso-form .btn { height: 40px; }

/* ------------------------------------------------------------ Pantallas chicas */
@media (max-width: 1100px) {
  .tablero, .ficha { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .marco { grid-template-columns: 1fr; }
  .lateral { position: fixed; z-index: 40; left: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .lateral.abierto { transform: none; }
  .boton-menu { display: inline-flex; }
  .logo-barra { display: block; flex: none; }
  .barra, .contenido { padding-left: 16px; padding-right: 16px; }
  .rejilla, .rejilla-3 { grid-template-columns: 1fr; }
  .ingreso { grid-template-columns: 1fr; }
  .ingreso-lado { padding: 28px; min-height: 220px; }
  .nits { display: none; }
  .resultados a { grid-template-columns: 1fr; gap: 2px; }
  .buscador kbd { display: none; }
  dl.datos { grid-template-columns: 1fr; gap: 2px; }
  dl.datos dd { margin-bottom: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.empuja { margin-left: auto; }
.en-linea { display: inline-flex; margin: 0; }
fieldset.campo { border: 0; padding: 0; margin: 0; }
fieldset.campo > span { font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
/* Tablas densas: mejor desplazar de lado que partir NIT y nombres en cuatro lineas. */
table.tabla { min-width: 780px; }
.tabla .mono, .tabla td:first-child { white-space: nowrap; }
.tabla .nombre { min-width: 220px; }
.tabla .nombre b { white-space: normal; }
.herramientas select { width: auto; min-width: 190px; }
