/* Paleta y estilo tomados del portal "DIAN Connect Hub" (Nexo Fiscal): barra lateral oscura,
   amarillo como color de marca, tipografías Figtree (texto) y Outfit (títulos). */
@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&family=Outfit:wght@500;600;700&display=swap");

:root {
  --bg: oklch(0.979 0.002 260); --panel: oklch(1 0 0); --text: oklch(0.22 0.005 260); --muted: oklch(0.52 0.006 260);
  --border: oklch(0.916 0 89.9); --soft: oklch(0.958 0.003 260);
  --accent: oklch(0.916 0.19 102); --accent-text: oklch(0.17 0.004 260); --accent-ink: oklch(0.64 0.14 92); --accent-soft: oklch(0.965 0.06 100);
  --ok: oklch(0.52 0.15 155); --ok-bg: oklch(0.96 0.04 155);
  --warn: oklch(0.42 0.1 70); --warn-bg: oklch(0.97 0.05 85);
  --err: oklch(0.577 0.245 27.325); --err-bg: oklch(0.97 0.025 25);
  --info: oklch(0.52 0.15 245); --info-bg: oklch(0.96 0.025 245); --code-bg: oklch(0.958 0.003 260);
  --side: oklch(0.22 0.005 260); --side-text: oklch(0.944 0.004 260); --side-muted: oklch(0.7 0.006 260);
  --side-hover: oklch(0.32 0.005 260); --side-border: oklch(0.36 0.004 260);
  --serie-emitidos: oklch(0.64 0.14 92); --serie-recibidos: oklch(0.52 0.15 245);
  --radius: 8px; --ancho-lateral: 264px;
  --font-sans: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Outfit", var(--font-sans);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: oklch(0.17 0.004 260); --panel: oklch(0.22 0.005 260); --text: oklch(0.944 0.004 260); --muted: oklch(0.7 0.006 260);
    --border: oklch(1 0 0 / 10%); --soft: oklch(0.3 0.005 260);
    --accent-ink: oklch(0.85 0.17 101); --accent-soft: oklch(0.32 0.005 260);
    --ok: oklch(0.75 0.15 155); --ok-bg: oklch(0.3 0.06 155);
    --warn: oklch(0.85 0.14 85); --warn-bg: oklch(0.32 0.06 85);
    --err: oklch(0.704 0.191 22.216); --err-bg: oklch(0.3 0.08 25);
    --info: oklch(0.75 0.12 245); --info-bg: oklch(0.3 0.06 245); --code-bg: oklch(0.15 0.004 260);
    --side: oklch(0.15 0.004 260); --side-hover: oklch(0.28 0.005 260); --side-border: oklch(1 0 0 / 10%);
    --serie-emitidos: oklch(0.665 0.14 92); --serie-recibidos: oklch(0.63 0.13 245);
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 var(--font-sans); background: var(--bg); color: var(--text); }
a { color: var(--accent-ink); }
button, a, input, select { outline-offset: 2px; }

/* Barra lateral (en móvil, barra superior) */
header { background: var(--side); color: var(--side-text); display: flex; gap: 12px 20px; align-items: center; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--side-border); }
header h1 { font: 600 17px/1.25 var(--font-display); margin: 0; display: flex; align-items: center; gap: 12px; }
header h1::before, .login h1::before {
  content: ""; flex: none; width: 36px; height: 36px; border-radius: 6px;
  background: var(--accent) no-repeat center / 20px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23292a2e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z'/%3E%3Cpath d='m9 12 2 2 4-4'/%3E%3C/svg%3E");
}
header nav { display: flex; gap: 4px; flex-wrap: wrap; }
header nav a { color: var(--side-muted); text-decoration: none; font-weight: 500; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border-radius: 6px; }
header nav a::before { content: ""; flex: none; width: 16px; height: 16px; background: currentColor; -webkit-mask: var(--icono) no-repeat center / contain; mask: var(--icono) no-repeat center / contain; }
header nav a[href="dashboard.html"] { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='7' height='9' x='3' y='3' rx='1'/%3E%3Crect width='7' height='5' x='14' y='3' rx='1'/%3E%3Crect width='7' height='9' x='14' y='12' rx='1'/%3E%3Crect width='7' height='5' x='3' y='16' rx='1'/%3E%3C/svg%3E"); }
header nav a[href="index.html"] { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' x2='12' y1='3' y2='15'/%3E%3C/svg%3E"); }
header nav a[href="emitidos.html"] { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z'/%3E%3Cpath d='M14 2v4a2 2 0 0 0 2 2h4'/%3E%3Cpath d='m9 15 2 2 4-4'/%3E%3C/svg%3E"); }
header nav a[href="recibidos.html"] { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='22 12 16 12 14 15 10 15 8 12 2 12'/%3E%3Cpath d='M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z'/%3E%3C/svg%3E"); }
header nav a[href="historial.html"] { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8'/%3E%3Cpath d='M3 3v5h5'/%3E%3Cpath d='M12 7v5l4 2'/%3E%3C/svg%3E"); }
header nav a[href="admin.html"] { --icono: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 7h-9'/%3E%3Cpath d='M14 17H5'/%3E%3Ccircle cx='17' cy='17' r='3'/%3E%3Ccircle cx='7' cy='7' r='3'/%3E%3C/svg%3E"); }
header nav a:hover, header nav a.activo { background: var(--side-hover); color: var(--side-text); }
header nav a.activo::before { background: var(--accent); }
#banner { margin-left: auto; font-size: 13px; color: var(--side-muted); }
#banner b { color: var(--side-text); }
#banner a { color: var(--accent); font-weight: 600; text-decoration: none; }
#banner a:hover { text-decoration: underline; }
@media (min-width: 1024px) {
  header { position: fixed; inset: 0 auto 0 0; width: var(--ancho-lateral); flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 0; padding: 0; border-bottom: 0; border-right: 1px solid var(--side-border); overflow-y: auto; }
  header h1 { height: 64px; padding: 0 16px; border-bottom: 1px solid var(--side-border); }
  header nav { flex-direction: column; padding: 12px; flex: 1; }
  header nav a { height: 40px; padding: 0 12px; }
  #banner { margin: 12px; padding: 12px; border-radius: 6px; background: var(--side-hover); line-height: 1.8; }
  body:has(> header) > main { margin-left: var(--ancho-lateral); }
}

main { max-width: 1300px; margin: 0 auto; padding: 32px 32px 40px; }
section.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; box-shadow: 0 1px 2px oklch(0 0 0 / 5%); }
h2 { font: 600 17px/1.3 var(--font-display); margin: 0 0 12px; }
h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .02em; margin: 22px 0 10px; color: var(--accent-ink); font-weight: 600; }

/* Botones: amarillo de marca, contorno y peligro */
button, .boton { background: var(--accent); color: var(--accent-text); border: 1px solid transparent; border-radius: 6px; padding: 8px 16px; min-height: 36px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 1px 2px oklch(0 0 0 / 8%); transition: filter .15s, background .15s; }
button:hover:not(:disabled), .boton:hover { filter: brightness(.95); }
button.secundario, .boton.secundario { background: var(--panel); color: var(--text); border-color: var(--border); }
button.secundario:hover:not(:disabled), .boton.secundario:hover { background: var(--soft); filter: none; }
button.peligro { background: var(--err); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; min-height: 36px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent-ink); box-shadow: 0 0 0 3px oklch(0.64 0.14 92 / 20%); }
input[type="checkbox"] { min-height: 0; accent-color: var(--accent-ink); }
input[type="file"] { padding: 4px; background: var(--soft); }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; border: 1px solid var(--border); background: var(--panel); color: var(--text); border-radius: 4px; padding: 4px 10px; margin-right: 10px; cursor: pointer; }
textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
label { display: block; font-size: 12px; color: var(--text); margin-bottom: 4px; font-weight: 500; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 16px; }
.ayuda { font-size: 13px; color: var(--muted); margin-top: 4px; }
.fila-botones { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }

/* Tablas */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .02em; position: sticky; top: 0; background: var(--soft); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--accent-soft); }

/* Estados */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border: 1px solid transparent; border-radius: 6px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.pendiente, .chip.en_proceso { background: var(--info-bg); color: var(--info); border-color: color-mix(in oklch, var(--info) 25%, transparent); }
.chip.con_errores, .chip.rechazado, .chip.error_envio { background: var(--err-bg); color: var(--err); border-color: color-mix(in oklch, var(--err) 25%, transparent); }
.chip.aceptado { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in oklch, var(--ok) 25%, transparent); }
.chip.simulado { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in oklch, var(--warn) 30%, transparent); }
.chip.real { background: var(--err-bg); color: var(--err); border-color: color-mix(in oklch, var(--err) 25%, transparent); }
.lista-msg { margin: 0; padding-left: 16px; font-size: 12px; }
.lista-msg.err { color: var(--err); }
.lista-msg.adv { color: var(--warn); }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 12px; overflow: auto; max-height: 460px; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.aviso { border: 1px solid transparent; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.aviso.err { background: var(--err-bg); color: var(--err); border-color: color-mix(in oklch, var(--err) 30%, transparent); }
.aviso.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in oklch, var(--ok) 30%, transparent); }
.aviso.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in oklch, var(--warn) 30%, transparent); }
.resumen { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.resumen > * { background: var(--soft); border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; }
.resumen b { color: var(--text); font: 600 14px var(--font-display); margin-left: 4px; }
dialog { border: 1px solid var(--border); border-radius: 10px; background: var(--panel); color: var(--text); width: min(1000px, 95vw); padding: 0; box-shadow: 0 20px 50px oklch(0 0 0 / 25%); }
dialog::backdrop { background: oklch(0.12 0.004 260 / 72%); }
dialog .cabeza { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-family: var(--font-display); font-size: 16px; }
dialog .cuerpo { padding: 14px 18px; max-height: 75vh; overflow: auto; }
.columnas-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 800px) { .columnas-2 { grid-template-columns: 1fr; } main { padding: 16px; } }
.tabla-scroll { overflow-x: auto; max-height: 65vh; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.tabla-scroll tr:last-child td { border-bottom: 0; }
.oculto { display: none !important; }

/* Encabezado de página, tarjetas de métricas y detalle (Emitidos) */
.encabezado { display: flex; flex-wrap: wrap; gap: 16px; justify-content: space-between; align-items: flex-end; border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 24px; }
.encabezado .antetitulo { margin: 0 0 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; color: var(--accent-ink); }
.encabezado h1 { font: 600 28px/1.2 var(--font-display); margin: 0; }
.encabezado p.ayuda { margin: 6px 0 0; max-width: 760px; }
.metricas { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 20px; }
.metrica { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: 0 1px 2px oklch(0 0 0 / 5%); }
.metrica .etiqueta { margin: 0; font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.metrica .valor { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 6px 0 0; font: 600 24px/1.2 var(--font-display); }
.metrica .valor.ok { color: var(--ok); }
.metrica .valor.err { color: var(--err); }
.metrica .nota { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.filtros { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.paginacion { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; font-size: 12px; color: var(--muted); }
.enlace-doc { font-weight: 600; color: var(--accent-ink); text-decoration: none; }
.enlace-doc:hover { text-decoration: underline; }
.codigo { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }
.detalle { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.detalle .visor { width: 100%; height: 78vh; border: 1px solid var(--border); border-radius: var(--radius); background: var(--soft); }
.datos { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; font-size: 13px; }
.datos dt { color: var(--muted); }
.datos dd { margin: 0; font-weight: 500; word-break: break-word; }
@media (max-width: 1100px) { .detalle { grid-template-columns: 1fr; } .detalle .visor { height: 60vh; } }

/* Tablero */
.metricas.tablero-kpi { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.tablero { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); margin-bottom: 20px; }
.tablero > section.panel { margin-bottom: 0; }
@media (min-width: 1200px) { .tablero { grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr); } }
.panel .cabeza-panel { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.panel .cabeza-panel h2 { margin: 0; }
.panel .cabeza-panel p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.leyenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.leyenda span::before { content: ""; display: inline-block; width: 12px; height: 2px; vertical-align: middle; margin-right: 6px; background: var(--c); }
.grafica { position: relative; }
.grafica svg { display: block; width: 100%; height: 260px; overflow: visible; }
.grafica .eje { font-size: 11px; fill: var(--muted); }
.grafica .rejilla { stroke: var(--border); stroke-width: 1; }
.grafica .linea { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.grafica .punto { stroke: var(--panel); stroke-width: 2; }
.grafica .etiqueta-serie { font-size: 11px; fill: var(--text); font-weight: 600; }
.grafica .guia { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.tooltip-grafica { position: absolute; pointer-events: none; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 12px; box-shadow: 0 4px 12px oklch(0 0 0 / 12%); white-space: nowrap; transform: translate(-50%, -100%); }
.tooltip-grafica b { display: block; margin-bottom: 2px; }
.tooltip-grafica i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--c); }
.barras { display: grid; gap: 12px; }
.barra .fila { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.barra .fila b { font-variant-numeric: tabular-nums; }
.barra .pista { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.barra .relleno { height: 100%; border-radius: 4px; background: var(--c); min-width: 2px; }
.atencion { display: grid; gap: 12px; }
.atencion .item { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.atencion .item.err { border-color: color-mix(in oklch, var(--err) 35%, transparent); background: var(--err-bg); }
.atencion .item.warn { background: var(--warn-bg); }
.atencion .item h3 { margin: 0; font: 600 14px/1.4 var(--font-sans); text-transform: none; letter-spacing: 0; color: var(--text); }
.atencion .item p { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.atencion .item a { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 600; }
.actividad { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; font-size: 13px; }
.actividad small { display: block; color: var(--muted); }
