/* Consola de Facturas — SentryOpen
   Tema claro, densidad de tabla, un acento. Ver DESIGN.md. */

:root {
  --bg:        oklch(0.985 0.003 265);
  --surface:   oklch(0.997 0.002 265);
  --surface-2: oklch(0.968 0.004 265);
  --line:      oklch(0.905 0.008 265);
  --line-soft: oklch(0.945 0.006 265);
  --ink:       oklch(0.22  0.020 265);
  --ink-2:     oklch(0.47  0.015 265);
  --ink-3:     oklch(0.62  0.012 265);
  --accent:    oklch(0.47  0.155 268);
  --accent-2:  oklch(0.40  0.150 268);
  --accent-bg: oklch(0.955 0.020 268);
  --ok:        oklch(0.52  0.130 155);
  --ok-bg:     oklch(0.960 0.032 155);
  --no:        oklch(0.53  0.190 27);
  --no-bg:     oklch(0.962 0.030 27);
  --warn:      oklch(0.58  0.120 70);
  --warn-bg:   oklch(0.962 0.040 70);

  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --r: 6px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  font-feature-settings: "cv05", "ss01";
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ------------------------------------------------------------ estructura */

.app { display: grid; grid-template-columns: 208px 1fr; min-height: 100vh; }

.lateral {
  background: var(--surface-2);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.marca {
  display: flex; align-items: center; gap: 9px;
  padding: 18px 18px 16px;
  font-size: 15px; font-weight: 650; letter-spacing: -0.01em;
}
.marca .punto {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); flex: none;
}
.marca small {
  display: block; font-size: 11.5px; font-weight: 400;
  color: var(--ink-3); letter-spacing: 0.02em; margin-top: 1px;
}

nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 1px; }
nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: var(--r);
  color: var(--ink-2); font-size: 14px; font-weight: 450;
  transition: background 120ms ease-out, color 120ms ease-out;
}
nav a:hover { background: oklch(0.93 0.006 265); color: var(--ink); text-decoration: none; }
nav a.on { background: var(--accent-bg); color: var(--accent-2); font-weight: 550; }
nav a svg { width: 16px; height: 16px; flex: none; stroke-width: 1.7; }
nav .grupo {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); padding: 16px 9px 5px; font-weight: 600;
}
nav a.pendiente { color: var(--ink-3); cursor: default; }
nav a.pendiente:hover { background: none; color: var(--ink-3); }
nav a.pendiente span:last-child {
  margin-left: auto; font-size: 10.5px; border: 1px solid var(--line);
  padding: 1px 5px; border-radius: 20px; color: var(--ink-3);
}

.sesion {
  margin-top: auto; padding: 14px 18px;
  border-top: 1px solid var(--line);
  font-size: 12.5px; color: var(--ink-2);
}
.sesion b { display: block; color: var(--ink); font-weight: 550; font-size: 13px; }
.sesion a { font-size: 12.5px; color: var(--ink-3); }

.trabajo { min-width: 0; display: flex; flex-direction: column; }

.encabezado {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.encabezado h1 { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.encabezado .sub { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.encabezado .der { margin-left: auto; display: flex; gap: 8px; align-items: center; }

main { padding: 22px 28px 48px; }

/* --------------------------------------------------------------- botones */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
  font: 500 13.5px var(--sans); cursor: pointer;
  transition: background 120ms ease-out, border-color 120ms ease-out;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primario {
  background: var(--accent); border-color: var(--accent); color: oklch(0.99 0 0);
}
.btn.primario:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.peligro:hover { border-color: var(--no); color: var(--no); }
.btn svg { width: 15px; height: 15px; stroke-width: 1.8; }

/* ------------------------------------------------------------ indicadores
   Franja de cifras separadas por divisiones. No son tarjetas. */

.franja {
  display: flex; flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 24px;
}
.cifra { padding: 16px 22px; flex: 1 1 150px; border-right: 1px solid var(--line-soft); }
.cifra:last-child { border-right: 0; }
.cifra .et {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); font-weight: 600; margin-bottom: 6px;
}
.cifra .v { font-size: 25px; font-weight: 600; letter-spacing: -0.025em; line-height: 1.1; }
.cifra .v small { font-size: 14px; font-weight: 500; color: var(--ink-3); }
.cifra .pie { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.cifra.ok .v { color: var(--ok); }
.cifra.no .v { color: var(--no); }

/* --------------------------------------------------------------- secciones */

.seccion { margin-bottom: 28px; }
.seccion > h2 {
  font-size: 13px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-2); margin-bottom: 10px;
}
.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; overflow: hidden;
}
.panel .cabeza {
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px; font-weight: 600;
}
.panel .cabeza .der { margin-left: auto; font-weight: 400; color: var(--ink-2); font-size: 12.5px; }
.panel .cuerpo { padding: 16px; }

/* ----------------------------------------------------------------- tablas */

table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--surface-2);
  text-align: left; font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-2);
  padding: 9px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td {
  padding: 9px 14px; border-bottom: 1px solid var(--line-soft);
  font-size: 13.5px; height: 34px; vertical-align: middle;
}
/* aire contra los bordes del panel y entre columnas */
thead th:first-child, tbody td:first-child { padding-left: 16px; }
thead th:last-child,  tbody td:last-child  { padding-right: 16px; }
/* la descripción es la única columna que crece: necesita separarse de las cifras */
td.desc, th.desc { padding-right: 28px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background 120ms ease-out; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.alerta { background: var(--no-bg); }
tbody tr.alerta:hover { background: oklch(0.945 0.038 27); }
td.der, th.der { text-align: right; }
.tabla-scroll { overflow-x: auto; }

.prov { font-weight: 500; }
.prov small { display: block; color: var(--ink-3); font-size: 11.5px; font-weight: 400; }

/* ---------------------------------------------------------------- estados */

.estado {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.estado::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: currentColor;
}
.estado.ok { color: var(--ok); }
.estado.no { color: var(--no); }
.estado.warn { color: var(--warn); }

.marbete {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; border: 1px solid var(--line);
  color: var(--ink-2); background: var(--surface);
}
.marbete.ok { color: var(--ok); border-color: oklch(0.85 0.06 155); background: var(--ok-bg); }
.marbete.no { color: var(--no); border-color: oklch(0.86 0.07 27); background: var(--no-bg); }
.marbete.warn { color: var(--warn); border-color: oklch(0.86 0.07 70); background: var(--warn-bg); }

/* ------------------------------------------------------------------ aviso */

.aviso {
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 11px 14px; font-size: 13.5px; margin-bottom: 14px;
  background: var(--surface); color: var(--ink-2);
}
.aviso.ok   { background: var(--ok-bg);   border-color: oklch(0.87 0.05 155); color: oklch(0.36 0.10 155); }
.aviso.no   { background: var(--no-bg);   border-color: oklch(0.87 0.06 27);  color: oklch(0.40 0.15 27); }
.aviso.warn { background: var(--warn-bg); border-color: oklch(0.87 0.06 70);  color: oklch(0.40 0.10 70); }
.aviso b { font-weight: 600; }

/* ------------------------------------------------------------ formularios */

label.campo { display: block; margin-bottom: 14px; }
label.campo span {
  display: block; font-size: 12.5px; font-weight: 550;
  color: var(--ink-2); margin-bottom: 5px;
}
input[type=text], input[type=password], input[type=search], select {
  width: 100%; padding: 8px 11px; font: 400 14px var(--sans);
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r);
  transition: border-color 120ms ease-out;
}
input:hover, select:hover { border-color: oklch(0.85 0.01 265); }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-bg); }

.filtros { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filtros input[type=search] { width: 260px; }
.filtros select { width: auto; }

/* ------------------------------------------------------------ zona de carga */

.soltar {
  border: 1.5px dashed oklch(0.85 0.012 265);
  border-radius: 8px; padding: 26px 20px; text-align: center;
  cursor: pointer; background: var(--surface);
  transition: border-color 120ms ease-out, background 120ms ease-out;
}
.soltar:hover, .soltar.activa { border-color: var(--accent); background: var(--accent-bg); }
.soltar svg { width: 26px; height: 26px; stroke: var(--accent); stroke-width: 1.6; }
.soltar p { color: var(--ink-2); font-size: 13.5px; margin-top: 7px; }
.soltar .archivos { color: var(--accent-2); font-weight: 550; font-size: 13px; margin-top: 7px; }
input[type=file] { display: none; }

.carga { display: grid; grid-template-columns: 1fr 220px; gap: 14px; align-items: end; }
@media (max-width: 760px) { .carga { grid-template-columns: 1fr; } }

/* ----------------------------------------------------------------- detalle */

.detalle { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
@media (max-width: 1080px) { .detalle { grid-template-columns: 1fr; } }

.datos { width: 100%; }
.datos tr td { padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.datos tr:last-child td { border-bottom: 0; }
.datos td:first-child { color: var(--ink-2); width: 38%; padding-right: 10px; }
.datos td:last-child {
  text-align: right; font-weight: 550;
  padding-left: 14px; word-break: break-word; hyphens: auto;
}

.veredicto { padding: 18px 16px; border-bottom: 1px solid var(--line); }
.veredicto .grande { font-size: 25px; font-weight: 650; letter-spacing: -0.02em; }
.veredicto.ok   { background: var(--ok-bg); }
.veredicto.no   { background: var(--no-bg); }
.veredicto.warn { background: var(--warn-bg); }
.veredicto.ok   .grande { color: var(--ok); }
.veredicto.no   .grande { color: var(--no); }
.veredicto.warn .grande { color: var(--warn); }
.veredicto .fuente { font-size: 12px; color: var(--ink-2); margin-top: 5px; }

.asiento td { font-size: 13px; }
.asiento .cuenta { font-family: var(--mono); font-weight: 600; }
.asiento tfoot td {
  font-weight: 650; border-top: 1.5px solid var(--line); border-bottom: 0;
  background: var(--surface-2);
}

details.crudo { margin-top: 14px; }
details.crudo summary {
  cursor: pointer; font-size: 12.5px; color: var(--ink-2);
  padding: 7px 0; user-select: none;
}
details.crudo summary:hover { color: var(--ink); }
details.crudo pre {
  font-family: var(--mono); font-size: 12px; line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px; overflow-x: auto;
  color: var(--ink-2); max-height: 320px;
}

/* ------------------------------------------------------------------ vacío */

.vacio { padding: 44px 20px; text-align: center; color: var(--ink-2); }
.vacio h3 { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.vacio p { font-size: 13.5px; max-width: 46ch; margin: 0 auto; }

/* ------------------------------------------------------------------ login */

.acceso {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--surface-2);
}
.acceso .caja {
  width: 100%; max-width: 348px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 28px;
}
.acceso h1 { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; margin-bottom: 4px; }
.acceso .sub { font-size: 13px; color: var(--ink-2); margin-bottom: 22px; }
.acceso .btn { width: 100%; justify-content: center; padding: 9px; margin-top: 4px; }
.acceso .pie { text-align: center; font-size: 12px; color: var(--ink-3); margin-top: 18px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .lateral { position: static; height: auto; flex-direction: row; align-items: center;
             overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .lateral nav { flex-direction: row; padding: 8px; }
  .lateral .marca { padding: 12px 14px; }
  .lateral .marca small, .sesion { display: none; }
  main, .encabezado { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------------------------------------------------------------- pestañas */

.pestanas {
  display: flex; gap: 2px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.pestanas a {
  padding: 8px 16px; font-size: 13.5px; font-weight: 500;
  color: var(--ink-2); border-bottom: 2px solid transparent;
  margin-bottom: -1px; transition: color 120ms ease-out, border-color 120ms ease-out;
}
.pestanas a:hover { color: var(--ink); text-decoration: none; }
.pestanas a.on { color: var(--accent-2); border-bottom-color: var(--accent); font-weight: 600; }

.dos-columnas { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .dos-columnas { grid-template-columns: 1fr; } }

.btn.mini { padding: 4px 10px; font-size: 12.5px; }
.sesion .rol { display: block; color: var(--ink-3); font-size: 11.5px; margin-top: 1px; }

/* --------------------------------------------------------------- alarma
   Aviso permanente mientras el buzón no esté entrando. No es un mensaje
   que se descarta: se queda hasta que el problema se resuelve. */

.alarma {
  display: flex; align-items: center; gap: 14px;
  padding: 13px 16px; margin-bottom: 18px;
  border: 1px solid oklch(0.86 0.07 70);
  background: var(--warn-bg); color: oklch(0.38 0.10 70);
  border-radius: var(--r); font-size: 14px;
}
.alarma.grave {
  border-color: oklch(0.84 0.09 27);
  background: var(--no-bg); color: oklch(0.40 0.16 27);
}
.alarma svg { width: 22px; height: 22px; flex: none; }
.alarma b { display: block; font-weight: 650; margin-bottom: 2px; }
.alarma span { opacity: 0.92; }
.alarma .btn { margin-left: auto; flex: none; }
.alarma.grave svg { animation: latido 2s ease-in-out infinite; }

@keyframes latido {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}
@media (prefers-reduced-motion: reduce) {
  .alarma.grave svg { animation: none; }
}

/* --------------------------------------------------------------- portal
   Acceso externo: una sola columna, sin barra lateral. El proveedor entra,
   deja su comprobante y ve el estado. Nada más. */

body.portal { background: var(--surface-2); }

.portal-cabecera {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 28px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.portal-cabecera .marca { padding: 0; }
.portal-cabecera .btn { margin-left: auto; }

.portal-cuerpo { max-width: 940px; margin: 0 auto; padding: 26px 20px 60px; }

.portal-pie {
  text-align: center; font-size: 12.5px; color: var(--ink-3);
  padding: 0 20px 34px;
}

.chincheta {
  margin-left: auto; background: var(--accent); color: oklch(0.99 0 0);
  font: 600 11px var(--mono); min-width: 18px; height: 18px;
  border-radius: 20px; display: inline-flex; align-items: center;
  justify-content: center; padding: 0 5px;
}
