/* Marca CONAI (Manual de Marca v1.0): tema oscuro nativo, Sora para títulos, Inter para el resto.
   Los cuatro colores de marca son fijos; los de estado (ok / warn / bad) son solo semánticos. */

@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/inter-400.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../fonts/inter-500.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/inter-600.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/inter-700.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 600; font-display: swap; src: url("../fonts/sora-600.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 700; font-display: swap; src: url("../fonts/sora-700.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 800; font-display: swap; src: url("../fonts/sora-800.woff2") format("woff2"); }

:root {
  color-scheme: dark;
  /* Superficie */
  --bg: #070B14;
  --surface: #0D1220;
  --surface-2: #131929;
  --surface-3: #1A2235;
  /* Texto */
  --text: #E8ECF8;
  --muted: #94A3B8;
  --faint: #4A5568;
  /* Marca */
  --primary: #1589FF;
  --primary-dim: #4DAAFF;
  --navy: #001A5C;
  --secondary: #7C3AED;
  --secondary-dim: #AF88FF;
  --cyan: #06B6D4;
  --cyan-dim: #22D3EE;
  /* Derivados */
  --border: #1A2235;
  --border-strong: rgba(148, 163, 184, 0.28);
  --accent: var(--primary);
  --accent-text: #FFFFFF;
  --info-bg: rgba(21, 137, 255, 0.14);
  --info: var(--primary-dim);
  --ok: #5FD39A;
  --ok-bg: rgba(95, 211, 154, 0.12);
  --warn: #F0C062;
  --warn-bg: rgba(240, 192, 98, 0.12);
  --bad: #F28B82;
  --bad-bg: rgba(242, 139, 130, 0.12);
  --radius: 10px;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-title: "Sora", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15.5px/1.5 var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary-dim); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font-title); color: var(--text); }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.025em; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.015em; margin: 1.75rem 0 .7rem; }
h3 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 .5rem; }
code { font-size: .9em; background: var(--surface-2); padding: .05rem .3rem; border-radius: 4px; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
  padding: .55rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar .marca { display: flex; align-items: center; gap: .75rem; color: var(--text); text-decoration: none; }
.topbar .marca img { height: 30px; width: auto; display: block; }
.topbar .marca .cliente {
  font: 700 11px/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  padding-left: .75rem; border-left: 1px solid var(--border-strong);
}
.topbar nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.topbar nav a { color: var(--muted); padding: .35rem .6rem; border-radius: 8px; font-weight: 500; }
.topbar nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topbar nav a.activo { color: var(--text); background: var(--surface-3); font-weight: 600; }
.topbar .usuario { color: var(--muted); font-size: .9rem; display: flex; gap: .75rem; align-items: center; }
.badge-alertas {
  background: var(--bad); color: #1A0B0A; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; margin-left: .3rem;
}
@media (max-width: 760px) {
  .topbar { gap: .6rem 1rem; padding: .55rem 16px; justify-content: space-between; }
  .topbar nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px .15rem; }
  .topbar nav a { white-space: nowrap; }
}
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 3rem; }
.pie {
  max-width: 1200px; margin: 0 auto; padding: 1.25rem 16px 2rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: .6rem; color: var(--faint); font-size: 12.5px; font-weight: 500;
}
.pie img { height: 18px; width: auto; }

.encabezado { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.encabezado h1 { margin: 0; }

/* Tarjetas y KPIs */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin-bottom: 1rem;
}
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); }
.kpis { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); margin-bottom: 1rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .85rem 1rem;
  color: var(--text); text-decoration: none; display: block;
}
a.kpi:hover { background: var(--surface-2); text-decoration: none; }
.kpi .valor { font: 800 1.75rem/1.15 var(--font-title); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.kpi .etiqueta { color: var(--muted); font-size: .85rem; margin-top: .15rem; }

/* Tablas */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.tabla-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
th, td { padding: .55rem .7rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font: 700 11px/1.3 var(--font-body); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); background: var(--surface); }
tbody tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Botones */
.btn, button {
  display: inline-block; font: 500 14.5px/1.3 var(--font-body); cursor: pointer; border-radius: 8px;
  padding: .5rem .95rem; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  text-decoration: none;
}
.btn:hover, button:hover { background: var(--surface-3); text-decoration: none; }
.btn-primario, button.btn-primario { background: var(--primary); border-color: var(--primary); color: var(--accent-text); font-weight: 600; }
.btn-primario:hover, button.btn-primario:hover { background: var(--primary-dim); border-color: var(--primary-dim); }
.btn-chico { padding: .2rem .55rem; font-size: .85rem; }
.btn-peligro { color: var(--bad); border-color: rgba(242, 139, 130, 0.45); background: transparent; }
.acciones { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* Estados */
.estado { display: inline-block; padding: .1rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: var(--info-bg); color: var(--info); white-space: nowrap; }
.estado.ok { background: var(--ok-bg); color: var(--ok); }
.estado.warn { background: var(--warn-bg); color: var(--warn); }
.estado.bad { background: var(--bad-bg); color: var(--bad); }
.muted { color: var(--muted); }
.chico { font-size: .85rem; }

.mensajes { list-style: none; padding: 0; margin: 0 0 1rem; }
.mensajes li { padding: .65rem .95rem; border-radius: var(--radius); margin-bottom: .5rem; background: var(--info-bg); color: var(--info); }
.mensajes li.success { background: var(--ok-bg); color: var(--ok); }
.mensajes li.error { background: var(--bad-bg); color: var(--bad); }
.mensajes li.warning { background: var(--warn-bg); color: var(--warn); }

/* Formularios */
.form-grid { display: grid; gap: .8rem 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.campo label { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: .25rem; }
.campo input, .campo select, .campo textarea, td input, td select, input[type="search"], input[type="date"], select {
  width: 100%; font: inherit; padding: .45rem .6rem; border: 1px solid var(--border-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text);
}
.acciones input, .acciones select { width: auto; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 1px;
}
.campo .ayuda { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.errorlist { color: var(--bad); margin: .2rem 0 0; padding: 0; list-style: none; font-size: .85rem; }
.campo-ancho { grid-column: 1 / -1; }
.campo input[type="radio"], .campo input[type="checkbox"], td input[type="checkbox"] { width: auto; padding: 0; accent-color: var(--primary); }

/* Producción */
.maquina h3 { display: flex; justify-content: space-between; align-items: baseline; }
.cola { list-style: none; margin: 0; padding: 0; }
.cola li { padding: .55rem 0; border-top: 1px solid var(--border); }
.cola li:first-child { border-top: 0; }
.barra { height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; margin-top: .35rem; }
.barra > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dim)); }

/* Alertas */
.alerta { border-left: 3px solid var(--warn); }
.alerta.alerta_1, .alerta.falta_mp { border-left-color: var(--bad); }
.alerta.aviso_previo { border-left-color: var(--primary); }
.alerta.tercero, .alerta.facturar, .alerta.entrega_obs { border-left-color: var(--secondary); }
.alerta pre { white-space: pre-wrap; font: inherit; margin: .5rem 0 0; color: var(--muted); }

/* Ingreso */
.login { max-width: 380px; margin: 9vh auto 0; padding: 1.75rem 1.5rem; }
.login .logo { display: block; height: 40px; width: auto; margin-bottom: 1.25rem; }
.login .bajada { color: var(--muted); margin: -.25rem 0 1.25rem; }
.login button { width: 100%; margin-top: .25rem; }

/* Documentos imprimibles (OT, remitos, OCE, notas) */
.ot { max-width: 800px; }
.ot table td:first-child { width: 35%; color: var(--muted); }

/* Logística */
.qr svg { display: block; border-radius: 6px; }
.remito-impreso { page-break-after: always; }
.remito-impreso:last-child { page-break-after: auto; }
.cabecera-remito { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.radios ul { list-style: none; padding: 0; margin: 0; display: flex; gap: 1rem; flex-wrap: wrap; }
.radios label { display: flex; gap: .4rem; align-items: center; justify-content: flex-start; color: var(--text); font-size: 1rem; }
.foto-remito { max-width: 100%; max-height: 480px; border: 1px solid var(--border); border-radius: var(--radius); }
.publico { max-width: 520px; margin: 0 auto; }
.publico .cliente-publico { font: 700 11px/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.publico button { width: 100%; padding: .85rem; font-size: 1.05rem; }
.publico input[type="file"] { padding: .7rem .5rem; }
.aviso { padding: .65rem .95rem; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); margin-bottom: 1rem; }

/* Impresión: los documentos salen en blanco y negro, sin la interfaz. */
@media print {
  :root {
    color-scheme: light;
    --bg: #FFFFFF; --surface: #FFFFFF; --surface-2: #FFFFFF; --surface-3: #F1F3F7;
    --text: #000000; --muted: #444B57; --faint: #6B7280;
    --border: #C9CED8; --border-strong: #C9CED8;
  }
  .topbar, .pie, .no-print { display: none !important; }
  body { background: #fff; color: #000; }
  main { padding: 0; }
  .card { border: 0; }
  tbody tr:hover td { background: none; }
  .remito-impreso { border: 0; padding: 0; margin: 0 0 1rem; }
}

/* Dónde está un pedido: pasos en orden, el último es la situación actual */
.pasos { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--surface-3); }
.paso { position: relative; padding: .3rem 0 .3rem .4rem; color: var(--text); }
.paso::before {
  content: ""; position: absolute; left: -1.55rem; top: .7rem; width: 10px; height: 10px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 3px var(--surface);
}
.paso.muted, .paso.muted a { color: var(--muted); }
.paso.muted::before { background: var(--faint); }
.paso.ok::before { background: var(--ok); }
.paso.warn::before { background: var(--warn); }
.paso.bad { color: var(--bad); font-weight: 600; }
.paso.bad::before { background: var(--bad); }
.paso-resumen { color: var(--muted); margin-top: .2rem; max-width: 420px; }
.paso-resumen.bad { color: var(--bad); }
.paso-resumen.warn { color: var(--warn); }

/* Volver */
.volver { display: inline-flex; align-items: center; gap: .3rem; color: var(--muted); font-size: .9rem; font-weight: 500; margin-bottom: .9rem; }
.volver:hover { color: var(--text); text-decoration: none; }
.ayuda-terceros summary { cursor: pointer; }
.ayuda-terceros ol { margin: .75rem 0 .25rem; padding-left: 1.25rem; }
.ayuda-terceros li { margin-bottom: .45rem; }

/* Confirmación dentro de la página (sin ventanitas del navegador) */
.confirmar { display: inline-block; position: relative; }
.confirmar > summary { list-style: none; }
.confirmar > summary::-webkit-details-marker { display: none; }
.confirmar[open] > summary { background: var(--surface-3); }
.confirmar-caja {
  position: absolute; z-index: 5; right: 0; top: calc(100% + .4rem); width: min(320px, 85vw);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: .8rem .9rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); text-align: left;
}
.confirmar-caja p { margin: 0 0 .6rem; color: var(--text); font-size: .9rem; white-space: normal; }
.acciones .confirmar-caja { left: 0; right: auto; }

/* Tablero: etapas de los pedidos. Escala de un solo tono (azul de marca), oscuro → claro = más cerca de la entrega.
   Validada contra el fondo #0D1220: luminosidad OKLab 0,45 · 0,57 · 0,67 · 0,78 · 0,88. */
:root {
  --etapa-0: #2B5592; --etapa-1: #1D74D8; --etapa-2: #3A97FF; --etapa-3: #79BCFF; --etapa-4: #BBDDFF;
}
.etapa-0 { background: var(--etapa-0); } .etapa-1 { background: var(--etapa-1); } .etapa-2 { background: var(--etapa-2); }
.etapa-3 { background: var(--etapa-3); } .etapa-4 { background: var(--etapa-4); }
.etapas-barra { display: flex; gap: 2px; height: 40px; border-radius: 8px; overflow: hidden; }
.etapa-seg { display: flex; align-items: center; justify-content: center; min-width: 30px; text-decoration: none; transition: filter .15s; }
.etapa-seg:hover { filter: brightness(1.15); text-decoration: none; }
.etapa-seg.elegida { outline: 2px solid var(--text); outline-offset: -2px; }
.etapa-seg-n { font: 700 14px/1 var(--font-body); font-variant-numeric: tabular-nums; }
.etapa-seg.etapa-0 .etapa-seg-n, .etapa-seg.etapa-1 .etapa-seg-n { color: #FFFFFF; }
.etapa-seg.etapa-2 .etapa-seg-n, .etapa-seg.etapa-3 .etapa-seg-n, .etapa-seg.etapa-4 .etapa-seg-n { color: #070B14; }
.etapas-leyenda { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; margin: .7rem 0 0; padding: 0; color: var(--muted); font-size: .88rem; }
.etapas-leyenda li { display: flex; align-items: center; gap: .4rem; }
.etapas-leyenda li strong { color: var(--text); }
.etapas-leyenda li.vacia, .etapas-leyenda li.vacia strong { color: var(--faint); }
.etapas-leyenda .sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.stepper { display: flex; gap: 2px; width: 110px; margin-bottom: .25rem; }
.paso-e { flex: 1; height: 8px; border-radius: 2px; background: var(--surface-3); }
.paso-e.actual { box-shadow: 0 0 0 1px var(--text); }
.meter { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-bottom: .25rem; }
.meter > span { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.txt-bad { color: var(--bad); } .txt-warn { color: var(--warn); }
table.seguimiento td { vertical-align: middle; }
.paso-e.etapa-0 { background: var(--etapa-0); } .paso-e.etapa-1 { background: var(--etapa-1); }
.paso-e.etapa-2 { background: var(--etapa-2); } .paso-e.etapa-3 { background: var(--etapa-3); }
.paso-e.etapa-4 { background: var(--etapa-4); }

/* Filas clicables */
[data-href] { cursor: pointer; }
tbody tr[data-href]:hover td { background: var(--surface-3); }
.cola li[data-href] { border-radius: 6px; margin: 0 -.4rem; padding-left: .4rem; padding-right: .4rem; }
.cola li[data-href]:hover { background: var(--surface-2); }

/* Lista lateral en las pantallas de detalle */
main:has(.lateral) { max-width: 1440px; }
.layout:has(> .lateral) { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.principal { min-width: 0; }
.lateral { position: sticky; top: 1rem; }
.lateral-caja { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; }
.lateral-titulo { font: 700 .95rem/1.2 var(--font-title); cursor: pointer; list-style: none; margin-bottom: .6rem; }
.lateral-titulo::-webkit-details-marker { display: none; }
.lateral-buscar { width: 100%; font: inherit; font-size: .9rem; padding: .4rem .55rem; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); color: var(--text); margin-bottom: .5rem; }
.lateral-lista { max-height: calc(100vh - 11rem); overflow-y: auto; margin: 0 -.25rem; padding: 0 .25rem; }
.lateral-grupo + .lateral-grupo { margin-top: .75rem; }
.lateral-grupo-nombre { font: 700 11px/1 var(--font-body); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: .35rem 0 .35rem .35rem; }
.lateral-grupo-nombre span { color: var(--faint); }
.lateral ul { list-style: none; margin: 0; padding: 0; }
.lateral li a { display: block; padding: .45rem .5rem; border-radius: 8px; color: var(--text); text-decoration: none; }
.lateral li a:hover { background: var(--surface-2); }
.lateral li a.activo { background: var(--surface-3); box-shadow: inset 3px 0 0 var(--primary); }
.lateral-fila { display: flex; justify-content: space-between; align-items: center; gap: .5rem; font-size: .9rem; }
.lateral-fila .estado { font-size: .7rem; padding: 0 .45rem; }
.lateral-sub { display: block; color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 900px) {
  .layout:has(> .lateral) { grid-template-columns: 1fr; gap: 1rem; }
  .lateral { position: static; }
  .lateral-caja:not([open]) .lateral-titulo { margin-bottom: 0; }
  .lateral-lista { max-height: 50vh; }
}
.layout > *, .lateral, .lateral-caja, .lateral-lista, .lateral li a { min-width: 0; }
.lateral-fila strong { white-space: nowrap; }
@media (max-width: 760px) { .topbar { overflow-x: clip; } }

/* Tesorería */
.subnav { display: flex; gap: .25rem; flex-wrap: wrap; margin: -.25rem 0 1.1rem; padding-bottom: .6rem; border-bottom: 1px solid var(--border); }
.subnav a { color: var(--muted); padding: .3rem .6rem; border-radius: 8px; font-size: .9rem; font-weight: 500; }
.subnav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.subnav a.activo { background: var(--surface-3); color: var(--text); font-weight: 600; }
.check-fila { display: flex; gap: .5rem; align-items: center; padding: .25rem 0; color: var(--text); font-size: .92rem; }
.check-fila input { width: auto; }
.txt-entra { color: var(--primary-dim); } .txt-sale { color: #F0A060; }
/* Gráfico de cash flow: entra / sale validados contra el fondo oscuro (ΔE 32,5; contraste ≥ 3:1). */
:root { --g-entra: #2F86F0; --g-sale: #D9772A; }
svg.grafico { width: 100%; height: auto; display: block; font-family: var(--font-body); }
.g-titulo { fill: var(--muted); font-size: 12px; font-weight: 600; }
.g-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.g-valor { fill: var(--text); font-size: 12px; font-weight: 600; }
.g-eje { stroke: var(--border-strong); stroke-width: 1; }
.g-cero { stroke: var(--border-strong); stroke-dasharray: 4 4; }
.g-linea { fill: none; stroke: var(--text); stroke-width: 2; }
.g-punto { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.g-punto.neg { fill: var(--bad); }
.g-entra { fill: var(--g-entra); } .g-sale { fill: var(--g-sale); }
.g-hit { fill: transparent; }
.g-semana:hover .g-hit { fill: var(--surface-2); }
.etapas-leyenda .sw-linea { height: 2px; width: 14px; border-radius: 0; background: var(--text); }
.grid > *, .kpis > * { min-width: 0; }

/* Compras */
.aprobar-total { font: 800 1.3rem/1 var(--font-title); }
.btn-grande { padding: .7rem 1.4rem; font-size: 1rem; }
table.comparativo th.num { white-space: normal; }
input.falta { border-color: var(--warn); }
