/* Recuperación de entregas. Tokens del estilo Nexus/LOG; ningún color fijo fuera de :root. */
@font-face { font-family: "Inter"; src: url(fuentes/inter.woff2) format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #F6F7F9; --surface: #FFFFFF; --surface-2: #F1F3F5; --surface-3: #E5E8EB; --border: #DCE0E5; --border-fuerte: #C5CBD3;
  --text: #1C2127; --text-2: #5F6B7C; --text-3: #8F99A8;
  --primary: #2D72D2; --primary-hover: #215DB0; --on-primary: #FFFFFF; --primary-bg: #E5EEFB;
  --ok: #238551; --ok-bg: #E3F0E8; --ok-text: #1B6A40;
  --warn: #C87619; --warn-bg: #F8EBDC; --warn-text: #8A4C08;
  --danger: #CD4246; --danger-bg: #F8E3E3; --danger-text: #A92B33;
  --neutral-bg: #EDEFF2; --neutral-text: #4D5866;
  --sombra: 0 1px 2px rgba(17,20,24,.06), 0 8px 24px rgba(17,20,24,.08);
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111418; --surface: #1C2127; --surface-2: #22272E; --surface-3: #2F343C; --border: #2F343C; --border-fuerte: #404854;
    --text: #F6F7F9; --text-2: #ABB3BF; --text-3: #738091;
    --primary: #4C90F0; --primary-hover: #8ABBFF; --on-primary: #111418; --primary-bg: #1E2B3D;
    --ok: #32A467; --ok-bg: #1D3329; --ok-text: #72CF9C;
    --warn: #EC9A3C; --warn-bg: #3A2D1E; --warn-text: #F5B56B;
    --danger: #E76A6E; --danger-bg: #3D2427; --danger-text: #F79A9D;
    --neutral-bg: #2F343C; --neutral-text: #C5CBD3;
    --sombra: 0 8px 24px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111418; --surface: #1C2127; --surface-2: #22272E; --surface-3: #2F343C; --border: #2F343C; --border-fuerte: #404854;
  --text: #F6F7F9; --text-2: #ABB3BF; --text-3: #738091;
  --primary: #4C90F0; --primary-hover: #8ABBFF; --on-primary: #111418; --primary-bg: #1E2B3D;
  --ok: #32A467; --ok-bg: #1D3329; --ok-text: #72CF9C;
  --warn: #EC9A3C; --warn-bg: #3A2D1E; --warn-text: #F5B56B;
  --danger: #E76A6E; --danger-bg: #3D2427; --danger-text: #F79A9D;
  --neutral-bg: #2F343C; --neutral-text: #C5CBD3;
  --sombra: 0 8px 24px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text); font: 14px/1.45 var(--f-ui);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss03";
}
[hidden] { display: none !important; }
.oculto-svg { position: absolute; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ acceso */
.acceso { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.acceso-caja { max-width: 380px; display: grid; gap: 12px; justify-items: start; }
.acceso-caja h1 { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.acceso-caja p { color: var(--text-2); }

.marca { width: 22px; height: 22px; border-radius: 4px; background: var(--text); position: relative; flex: none; }
.marca::after { content: ""; position: absolute; left: 5px; top: 5px; width: 6px; height: 6px; background: var(--primary); }
.marca::before { content: ""; position: absolute; left: 5px; right: 5px; bottom: 5px; height: 2px; background: var(--bg); }

/* ------------------------------------------------ barra */
.barra {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  height: 56px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.barra-izq, .barra-der { display: flex; align-items: center; gap: 12px; min-width: 0; }
.titulo { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.titulo strong { font-weight: 600; font-size: 14px; white-space: nowrap; }
.titulo span { color: var(--text-3); font-size: 12px; }
.vivo { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.vivo i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.vivo.lento i { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }
.vivo.caido i { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.quien { font-size: 13px; color: var(--text-2); padding-left: 12px; border-left: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.icono { width: 32px; height: 32px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 6px; background: none; cursor: pointer; color: var(--text-2); }
.icono:hover { background: var(--surface-2); color: var(--text); }
.menu { position: relative; }
.menu-lista {
  position: absolute; right: 0; top: 38px; min-width: 220px; padding: 4px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--sombra); display: grid;
}
.menu-lista button { text-align: left; padding: 8px 10px; border: 0; background: none; border-radius: 4px; cursor: pointer; }
.menu-lista button:hover { background: var(--surface-2); }

/* ------------------------------------------------ contenido */
.contenido { max-width: 1440px; margin: 0 auto; padding: 24px; display: grid; gap: 16px; }

.resumen { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.cifra {
  display: grid; gap: 2px; text-align: left; padding: 14px 20px; border: 0; background: none; cursor: pointer;
  border-left: 1px solid var(--border); position: relative;
}
.cifra:first-child { border-left: 0; }
.cifra:hover { background: var(--surface-2); }
.cifra[aria-pressed="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); }
.cifra .n { font-size: 26px; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.cifra .l { font-size: 12px; color: var(--text-2); }
.cifra[data-filtro="vencido"] .n.hay { color: var(--danger-text); }
.cifra[data-filtro="hoy"] .n.hay { color: var(--warn-text); }

.herramientas { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.segmentos { display: inline-flex; padding: 2px; background: var(--surface-3); border-radius: 6px; }
.segmentos button { border: 0; background: none; padding: 5px 12px; border-radius: 4px; cursor: pointer; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.segmentos button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(17,20,24,.12); font-weight: 500; }
.buscar { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; color: var(--text-3); flex: 1 1 200px; max-width: 320px; }
.buscar:focus-within { border-color: var(--primary); }
.buscar input { border: 0; outline: 0; background: none; width: 100%; color: var(--text); }
.filtro-activo { font-size: 12px; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.filtro-activo button { border: 0; background: none; color: var(--primary); cursor: pointer; padding: 0; }
#b-agregar { margin-left: auto; }

.boton {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--border-fuerte); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 500; white-space: nowrap;
}
.boton:hover { background: var(--surface-2); }
.boton.primario { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.boton.primario:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.boton.exito { background: var(--ok); border-color: var(--ok); color: #fff; }
.boton.discreto { border-color: transparent; background: none; color: var(--text-2); }
.boton.discreto:hover { background: var(--surface-2); color: var(--text); }
.boton:disabled { opacity: .55; cursor: default; }

/* ------------------------------------------------ tabla */
.tabla-caja { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; overflow: auto; }
.tabla { width: 100%; border-collapse: collapse; font-size: 13px; }
.tabla th {
  position: sticky; top: 0; z-index: 1; background: var(--surface); text-align: left; font-weight: 500; font-size: 12px; color: var(--text-2);
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.tabla td { padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabla tbody tr.fila { cursor: pointer; }
.tabla tbody tr.fila:hover td { background: var(--surface-2); }
.tabla tbody tr.fila.activa td { background: var(--primary-bg); }
.tabla tr:last-child td { border-bottom: 0; }

/* Encabezado de día: separa la lista como las filas de fecha del Excel. */
.tabla tr.dia td { background: var(--bg); padding: 0; border-bottom: 1px solid var(--border); }
.tabla tr.dia:not(:first-child) td { border-top: 12px solid var(--bg); box-shadow: inset 0 1px 0 var(--border); }
.dia-cab { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px 10px; border-left: 4px solid var(--border-fuerte); }
.dia.pasado .dia-cab { border-left-color: var(--danger); }
.dia.hoy .dia-cab { border-left-color: var(--warn); }
.dia.futuro .dia-cab { border-left-color: var(--primary); }
.dia.entregado .dia-cab { border-left-color: var(--ok); }
.dia-fecha { font-size: 14px; color: var(--text-2); }
.dia-fecha strong { color: var(--text); font-weight: 600; }
.dia-chip { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.dia-chip.pasado { background: var(--danger-bg); color: var(--danger-text); }
.dia-chip.hoy { background: var(--warn-bg); color: var(--warn-text); }
.dia-chip.futuro { background: var(--primary-bg); color: var(--primary); }
.dia-chip.entregado { background: var(--ok-bg); color: var(--ok-text); }
.dia-cuenta { font-size: 12px; color: var(--text-3); margin-left: auto; }

/* Franja de obra dentro del día. */
.tabla tr.obra-fila td { padding: 8px 14px 6px 18px; background: var(--surface); border-bottom: 1px solid var(--border); }
.obra-fila .obra { font-size: 13px; }
.obra-meta { font-size: 12px; color: var(--text-3); margin-left: 10px; }
.tabla tr.fila td.c-desc { padding-left: 32px; }
.c-desc .codigo { display: block; font-family: var(--f-mono); font-size: 11px; color: var(--text-3); margin-top: 1px; }
.comp { display: grid; gap: 1px; }
.comp-cuando { font-size: 12px; color: var(--text-2); padding-left: 14px; font-variant-numeric: tabular-nums; }
.c-cant { width: 64px; }
.c-comp { width: 200px; }
.c-ent { width: 240px; }
.c-msg { width: 52px; }
.mono { font-family: var(--f-mono); font-size: 12px; }
.obra { font-weight: 600; font-variant-numeric: tabular-nums; }
.desc { color: var(--text); }
.tenue { color: var(--text-3); }
.atraso { display: block; font-size: 11px; color: var(--danger-text); white-space: nowrap; }
.atraso.ok { color: var(--text-3); }

.estado { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.estado::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.e-vencido { color: var(--danger-text); }
.e-hoy { color: var(--warn-text); }
.e-proximo { color: var(--primary); }
.e-sin_compromiso { color: var(--text-2); }
.e-sin_compromiso::before { background: none; border: 1.5px dashed currentColor; width: 7px; height: 7px; }
.e-entregado { color: var(--ok-text); }

.entrega { display: grid; line-height: 1.3; }
.entrega .doc { font-family: var(--f-mono); font-size: 11px; color: var(--text-2); }
.recibido { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--ok-text); }
.recibido svg { width: 12px; height: 12px; stroke-width: 2.4; }
.msg { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 12px; position: relative; }
.msg.nuevo { color: var(--primary); font-weight: 600; }
.msg.nuevo::after { content: ""; position: absolute; top: -2px; left: 11px; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); }
.vacio { padding: 48px 16px; text-align: center; color: var(--text-2); }
.pie { font-size: 12px; color: var(--text-3); }

/* ------------------------------------------------ panel lateral */
.velo { position: fixed; inset: 0; background: rgba(17,20,24,.28); z-index: 30; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 31; width: min(520px, 100vw); background: var(--surface);
  border-left: 1px solid var(--border); box-shadow: var(--sombra); display: flex; flex-direction: column;
}
.panel-cabeza { display: flex; justify-content: space-between; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); }
.panel-eyebrow { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.panel-cabeza h2 { font-size: 17px; font-weight: 600; letter-spacing: -.01em; margin-top: 2px; }
.panel-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.panel-cuerpo { overflow: auto; padding: 18px 20px 28px; display: grid; gap: 22px; align-content: start; }

.pasos { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); }
.pasos li { position: relative; padding-top: 18px; padding-right: 8px; font-size: 12px; }
.pasos li::before { content: ""; position: absolute; top: 4px; left: 0; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border-fuerte); background: var(--surface); z-index: 1; }
.pasos li::after { content: ""; position: absolute; top: 8px; left: 12px; right: 2px; height: 2px; background: var(--border); }
.pasos li:last-child::after { display: none; }
.pasos li.hecho::before { background: var(--ok); border-color: var(--ok); }
.pasos li.hecho::after { background: var(--ok); }
.pasos li.actual::before { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.pasos li.alerta::before { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.pasos .t { display: block; color: var(--text-2); }
.pasos .v { display: block; font-weight: 500; font-variant-numeric: tabular-nums; }
.pasos .s { display: block; color: var(--text-3); font-size: 11px; }

.nota { font-size: 13px; padding: 10px 12px; background: var(--warn-bg); color: var(--warn-text); border-radius: 6px; }
.acciones { display: grid; gap: 12px; }
.bloque { display: grid; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 8px; }
.bloque h3, .conversacion h3 { font-size: 12px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.campos { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.campos label, .rejilla label { display: grid; gap: 4px; font-size: 12px; color: var(--text-2); }
input:not([type="search"]):not([type="file"]), select, textarea {
  height: 32px; padding: 0 8px; border: 1px solid var(--border-fuerte); border-radius: 6px; background: var(--surface); color: var(--text); min-width: 0;
}
textarea { height: auto; padding: 8px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.ayuda { font-size: 12px; color: var(--text-2); }

.mensajes { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 14px; }
.mensajes li { display: grid; gap: 2px; padding-left: 10px; border-left: 2px solid var(--border); }
.mensajes li.cliente { border-left-color: var(--primary); }
.mensajes .quien-m { font-size: 12px; display: flex; gap: 6px; align-items: baseline; }
.mensajes .quien-m strong { font-weight: 600; }
.mensajes .lado { font-size: 11px; color: var(--text-3); }
.mensajes .texto { white-space: pre-wrap; overflow-wrap: anywhere; }
.mensajes .sin { color: var(--text-3); border: 0; padding: 0; }
.redactar { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; margin-top: 12px; }

.historial summary { cursor: pointer; font-size: 12px; color: var(--text-2); }
.historial ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; font-size: 12px; }
.historial li { display: grid; grid-template-columns: 92px 1fr; gap: 8px; }
.historial .cuando { color: var(--text-3); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ diálogos */
.dialogo { border: 1px solid var(--border); border-radius: 10px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--sombra); }
.dialogo.ancho { width: min(760px, calc(100vw - 32px)); }
.dialogo::backdrop { background: rgba(17,20,24,.35); }
.dialogo > form, .dialogo > div { padding: 20px; display: grid; gap: 14px; }
.dialogo h2 { font-size: 16px; font-weight: 600; }
.rejilla { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rejilla .ancho { grid-column: 1 / -1; }
.dialogo-pie { display: flex; justify-content: flex-end; gap: 8px; }
.fila-form { display: flex; gap: 8px; flex-wrap: wrap; }
.fila-form input { flex: 1 1 200px; }
.enlace-nuevo { padding: 12px; background: var(--ok-bg); border-radius: 6px; display: grid; gap: 8px; font-size: 13px; }
.enlace-nuevo input { font-family: var(--f-mono); font-size: 12px; }
.tabla.compacta td, .tabla.compacta th { padding: 7px 8px; }
.error { color: var(--danger-text); font-size: 13px; }

.aviso {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 6px; font-size: 13px; box-shadow: var(--sombra);
}
.aviso.mal { background: var(--danger); color: #fff; }

/* ------------------------------------------------ angosto: renglones como lista */
@media (max-width: 860px) {
  .barra { padding: 0 16px; }
  .quien, .titulo span, .vivo span { display: none; }
  .titulo strong { white-space: normal; }
  .contenido { padding: 16px; }
  .resumen { grid-template-columns: repeat(2, 1fr); }
  .cifra:nth-child(3) { border-left: 0; }
  .cifra:nth-child(n+3) { border-top: 1px solid var(--border); }
  .buscar { max-width: none; }
  #b-agregar { margin-left: 0; }
  .tabla thead { display: none; }
  .tabla, .tabla tbody { display: block; }
  .tabla tr.fila {
    display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; padding: 10px 14px 10px 22px; border-bottom: 1px solid var(--border); align-items: start;
    grid-template-areas: "desc msg" "comp ent";
  }
  .tabla tr.fila td { padding: 0 !important; border: 0; background: none !important; }
  .tabla tr.fila.activa { background: var(--primary-bg); }
  .tabla tr.dia, .tabla tr.obra-fila, .tabla tr.dia td, .tabla tr.obra-fila td { display: block; }
  .dia-cuenta { margin-left: 0; width: 100%; }
  .tabla td.c-msg { grid-area: msg; }
  .tabla td.c-desc { grid-area: desc; }
  .tabla td.c-comp { grid-area: comp; font-size: 12px; }
  .tabla td.c-ent { grid-area: ent; font-size: 12px; text-align: right; }
  .tabla td.c-cant { display: none; }
  .pasos { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .pasos li:nth-child(2)::after { display: none; }
  .rejilla { grid-template-columns: 1fr; }
}
.linea-m { display: none; white-space: nowrap; color: var(--text-3); font-weight: 400; margin-left: 6px; }
@media (prefers-reduced-motion: no-preference) {
  .panel:not([hidden]) { animation: entra 180ms ease-out; }
  @keyframes entra { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }
}
