/* Facturas entrantes: diagrama, modos, bandeja y detalle paso a paso. */
.inv { container: inv / inline-size; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.inv .page-head { margin-bottom: 0; flex-wrap: wrap; }
.inv-sim { flex: none; }
.inv-sim .i { color: var(--accent); }
.demo-tag { padding: 1px 6px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 600; }
@media (max-width: 759px) { .inv-sim { width: 100%; height: 42px; } }

.gr-proceso { --c: var(--slate); }
.gr-lista { --c: var(--accent); }
.gr-enviada { --c: var(--blue); }
.gr-revision { --c: var(--red); }

/* ---------- Modo de envío ---------- */
.mode { display: grid; gap: 8px; align-items: center; }
.mode-sw { position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border-radius: 10px; background: var(--n2); box-shadow: inset 0 0 0 1px var(--line-2); }
.mode-sw input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.mode-sw label {
  position: relative; z-index: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 4px 8px; border-radius: 8px; cursor: pointer; text-align: center; line-height: 1.2;
  font-size: 13px; font-weight: 600; color: var(--fg2); transition: color .18s;
}
.mode-sw label .i { width: 15px; height: 15px; }
.mode-sw label:hover { color: var(--fg1); }
.mode-sw input:checked + label { color: var(--accent-ink); }
.mode-sw input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }
.mode-thumb { position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc(50% - 3px); border-radius: 8px; background: var(--accent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); transition: transform .26s var(--ease-drawer); }
.mode[data-mode="auto"] .mode-thumb { transform: translateX(100%); }
.mode-line { color: var(--fg2); font-size: 13px; max-width: 72ch; }
@container inv (min-width: 760px) {
  .mode { grid-template-columns: 390px minmax(0, 1fr); gap: 16px; }
  .mode-sw label { white-space: nowrap; }
}

/* ---------- Diagrama: en móvil, en vertical ---------- */
.inv-diagram { padding: 14px; }
.pl { display: grid; grid-template-columns: minmax(0, 1fr); }
.pl-node {
  position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 0 11px;
  padding: 10px 12px; border-radius: 10px; background: var(--n3); box-shadow: inset 0 0 0 1px var(--line);
}
.pl-node::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1.5px var(--accent); opacity: 0; transition: opacity .25s; pointer-events: none; }
.pl-node.on::after { opacity: 1; }
.pl-ic { grid-row: span 2; display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-m); background: var(--n4); color: var(--fg2); transition: color .2s; }
.pl-node.on .pl-ic { color: var(--accent); }
.pl-ic .i { width: 18px; height: 18px; }
.pl-name { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.pl-count { grid-column: 3; grid-row: 1 / span 2; display: inline-flex; align-items: baseline; gap: 5px; white-space: nowrap; }
.pl-count > b { font: 850 22px/1 var(--display); font-stretch: 106%; font-variant-numeric: tabular-nums; }
.pl-count small { font-size: 12px; color: var(--fg3); }
.pl-node.on .pl-count > b { color: var(--accent); }
.pl-node.own { background: #edf2fa; box-shadow: none; color: var(--ink); }
.pl-node.own .pl-ic { background: #021634; color: #2E9BFF; }
.pl-node.own .pl-count small { color: var(--ink-2); }
.pl-node.own.on .pl-count > b { color: var(--ink); }
.pl-tag { grid-column: 2; grid-row: 2; margin-top: 1px; font-size: 12px; font-weight: 500; color: var(--ink-2); }
.pl-ic { grid-column: 1; }
.pl-name { grid-column: 2; grid-row: 1; }
.pl-node:not(.own) .pl-name { grid-row: 1 / span 2; }
.pl-node.own .pl-count { grid-row: 1 / span 2; }

.pl-link { position: relative; height: 20px; }
.pl-line { position: absolute; left: 26px; top: 0; bottom: 0; width: 6px; overflow: hidden; }
.pl-line::before { content: ""; position: absolute; left: 2px; top: 0; bottom: 0; width: 2px; background: var(--line-2); }
.pl-pulse { position: absolute; left: 1px; top: 0; width: 4px; height: 26px; border-radius: 2px; background: linear-gradient(to bottom, rgba(46, 155, 255, 0), var(--accent) 55%, var(--accent-hi)); opacity: 0; will-change: transform; }
.pl-link.gate { height: 40px; display: flex; align-items: center; padding-left: 40px; }
.pl-gate { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--n4); color: var(--fg1); box-shadow: inset 0 0 0 1px var(--line-2); }
.pl-gate .i { width: 13px; height: 13px; color: var(--accent); }
.pl-gate.auto { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.pl-gate.auto .i { color: inherit; }

@container inv (min-width: 860px) {
  .pl { grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1.28fr) 40px minmax(0, 1fr) 136px minmax(0, 1fr) 40px minmax(0, 1fr); align-items: stretch; }
  .pl-node { display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 12px 13px; min-height: 132px; border-radius: var(--r-m); }
  .pl-tag { margin-top: -5px; }
  .pl-count, .pl-node.own .pl-count { order: 3; margin-top: auto; }
  .pl-count > b { font-size: 28px; }
  .pl-link { height: auto; }
  .pl-tag { margin-top: -5px; }
  .pl-line { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 6px; margin-top: -3px; }
  .pl-line::before { left: 0; right: 0; top: 2px; bottom: auto; width: auto; height: 2px; }
  .pl-pulse { left: 0; top: 1px; width: 26px; height: 4px; background: linear-gradient(to right, rgba(46, 155, 255, 0), var(--accent) 55%, var(--accent-hi)); }
  .pl-link.gate { height: auto; padding: 0; justify-content: center; }
  .pl-gate { position: relative; }
}
.pl-off {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 12px; padding: 9px 11px; border-radius: var(--r-m); text-align: left;
  background: rgba(240, 113, 122, .09); box-shadow: inset 0 0 0 1px rgba(240, 113, 122, .22); color: var(--fg1); font-size: 13px; transition: background-color .15s;
}
.pl-off:hover { background: rgba(240, 113, 122, .14); }
.pl-off b { font-weight: 600; }
.pl-off .i:first-child { color: var(--red); }
.pl-off .i:last-child { margin-left: auto; width: 14px; height: 14px; color: var(--fg3); }

/* Puntos de espera: solo mientras se espera de verdad */
.wait-dots { display: inline-flex; gap: 3px; align-self: center; }
.wait-dots i { width: 4px; height: 4px; border-radius: 50%; background: currentColor; animation: wait-dot 1.1s ease-in-out infinite; }
.wait-dots i:nth-child(2) { animation-delay: .16s; }
.wait-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes wait-dot { 0%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

/* ---------- Bandeja ---------- */
.inv-tabs { padding: 0 2px; }
.ics { display: grid; gap: 6px; margin-top: 10px; }
.ic {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 14px; padding: 12px 14px;
  border-radius: var(--r-l); background: var(--n2); box-shadow: inset 0 0 0 1px var(--line), inset 0 1px 0 rgba(255, 255, 255, .03);
  transition: background-color .15s, box-shadow .15s;
}
.ic:hover { background: #0e2342; box-shadow: inset 0 0 0 1px var(--line-2); }
.ic.is-fresh, .ic.is-live { box-shadow: inset 0 0 0 1.5px var(--accent); }
.ic-open { position: absolute; inset: 0; border-radius: inherit; z-index: 0; }
.ic-open:focus-visible { outline-offset: -2px; border-radius: var(--r-l); }
.ic > *:not(.ic-open) { pointer-events: none; }
.ic-act .btn { pointer-events: auto; position: relative; z-index: 1; }
.ic-who { min-width: 0; }
.ic-who h3 { font-size: 14px; font-weight: 600; line-height: 1.3; }
.ic-who p { color: var(--fg3); font-size: 12.5px; margin-top: 1px; }
.ic-who .num { font-size: 12px; }
.ic-step { grid-column: 1 / -1; grid-row: 2; min-width: 0; display: grid; gap: 5px; }
.ic-label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: color-mix(in srgb, var(--c) 82%, #fff); }
.ic-label .i { width: 14px; height: 14px; color: var(--c); }
.segs { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
.segs i { position: relative; display: block; height: 4px; border-radius: 2px; background: var(--n4); overflow: hidden; }
.segs i::after { content: ""; position: absolute; inset: 0; background: var(--c); transform: scaleX(0); transform-origin: left; transition: transform .5s var(--ease-out); }
.segs i.on::after { transform: scaleX(1); }
.ic-note { color: var(--fg3); font-size: 12.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ic-time { grid-column: 2; grid-row: 1; text-align: right; }
.ic-time small { display: block; font-size: 12px; color: var(--fg3); white-space: nowrap; }
.ic-time b { font-size: 13px; white-space: nowrap; }
.ic-act { grid-column: 1 / -1; display: flex; }
.ic-act:has(.ic-more) { display: none; }
.ic-act .btn { flex: 1; height: 40px; }
.ic-more { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; color: var(--fg3); white-space: nowrap; transition: color .15s; }
.ic-more .i { width: 12px; height: 12px; transition: transform .16s var(--ease-out); }
.ic:hover .ic-more { color: var(--fg1); }
.ic:hover .ic-more .i { transform: translateX(2px); }
@container inv (min-width: 860px) and (max-width: 1040px) {
  .pl { grid-template-columns: minmax(0, 1fr) 26px minmax(0, 1.4fr) 26px minmax(0, 1fr) 124px minmax(0, 1fr) 26px minmax(0, 1fr); }
}
@container inv (min-width: 860px) {
  .ic { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1.25fr) 104px 134px; gap: 22px; align-items: center; padding: 12px 16px; }
  .ic-step { grid-column: 2; grid-row: 1; }
  .ic-time { grid-column: 3; grid-row: 1; text-align: left; }
  .ic-act, .ic-act:has(.ic-more) { grid-column: 4; display: flex; justify-content: flex-end; }
  .ic-act .btn { flex: none; height: 30px; }
}
.inv-empty { padding: 40px 20px; border-radius: var(--r-l); margin-top: 10px; background: var(--n2); box-shadow: inset 0 0 0 1px var(--line); }

/* ---------- Pastilla de paso ---------- */
.inv-step {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  color: color-mix(in srgb, var(--c) 82%, #fff); background: color-mix(in srgb, var(--c) 12%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent);
}
.chip .num { color: var(--fg1); font-size: 11.5px; }

/* ---------- Detalle ---------- */
.in-body { display: block; padding-top: 16px; padding-bottom: 96px; }
.invoice .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 1160px) { .invoice .toast { left: calc((100vw - 640px) / 2); bottom: 22px; } }
.flow { display: grid; }
.fl { position: relative; display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 12px; padding-bottom: 20px; scroll-margin-top: 12px; }
.fl:last-child { padding-bottom: 4px; }
.fl:not(:last-child)::before { content: ""; position: absolute; left: 12px; top: 28px; bottom: 2px; width: 2px; background: var(--line-2); border-radius: 1px; }
.fl-done:not(:last-child)::before { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.fl-mark { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--n3); box-shadow: inset 0 0 0 1px var(--line-2); color: var(--fg3); font-size: 12px; }
.fl-mark .i { width: 14px; height: 14px; }
.fl-done .fl-mark { background: var(--accent); box-shadow: none; color: var(--accent-ink); }
.fl-cur .fl-mark { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--accent); }
.fl-alert .fl-mark { background: rgba(240, 113, 122, .16); box-shadow: inset 0 0 0 1.5px var(--red); color: var(--red); }
.fl-body { min-width: 0; display: grid; gap: 9px; align-content: start; padding-top: 3px; }
.fl-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 10px; }
.fl-h h3 { font-size: 14px; font-weight: 600; }
.fl-todo .fl-h h3 { color: var(--fg3); font-weight: 500; }
.fl-time { font-size: 12px; color: var(--fg3); }
.tag-own, .tag-ai { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag-own .i, .tag-ai .i { width: 13px; height: 13px; }
.tag-own { background: #edf2fa; color: var(--ink); }
.tag-ai { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(46, 155, 255, .25); }
.fl-note { display: flex; gap: 7px; align-items: baseline; color: var(--fg2); font-size: 13px; }
.fl-note .i { width: 14px; height: 14px; flex: none; align-self: center; }
.fl-note .num { font-size: 12.5px; color: var(--fg1); }
.in-gap { margin-top: 2px; }
.in-reason { padding: 10px 12px; border-radius: var(--r-m); background: rgba(240, 113, 122, .09); box-shadow: inset 0 0 0 1px rgba(240, 113, 122, .22); color: var(--fg1); font-size: 13px; }
.wait { display: flex; align-items: center; gap: 9px; color: var(--fg2); font-size: 13px; }
.wait .num { color: var(--fg1); font-size: 12.5px; }
.wait-dots { color: var(--accent); }
.pl-node.own .wait-dots { color: #021634; }

/* Miniatura de la factura */
.in-recv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 16px; align-items: start; }
.bill { display: grid; gap: 5px; align-content: start; text-align: left; }
.bill-page { display: grid; gap: 3px; align-content: start; height: 128px; padding: 9px 8px; border-radius: 3px; overflow: hidden; background: var(--paper); color: var(--ink); box-shadow: 0 10px 22px -12px rgba(0, 0, 0, .7); transition: transform .18s var(--ease-out); }
.bill:hover .bill-page { transform: translateY(-2px); }
.bill-page b { font-size: 9px; line-height: 1.2; font-weight: 700; }
.bill-page small { font-size: 8px; line-height: 1.25; color: var(--ink-2); }
.bill-page i { display: block; height: 3px; margin-top: 5px; border-radius: 1px; background: var(--rule-paper); }
.bill-page i.short { width: 55%; }
.bill.blurred .bill-page > * { filter: blur(1.6px); }
.bill.blurred .bill-page { transform: rotate(-1.5deg); }
.bill-name { display: flex; gap: 3px; align-items: center; font: 500 10.5px/1.25 var(--mono); letter-spacing: -.02em; color: var(--fg2); white-space: nowrap; }
.bill-name .i { width: 12px; height: 12px; }
.in-facts { margin-top: 0; gap: 6px; align-content: start; }
.in-facts > div { grid-template-columns: 84px minmax(0, 1fr); gap: 8px; }
.in-facts dd { font-size: 13px; }

.in-body .study { margin-top: 0; }
.in-body .study-total { margin-top: 2px; }

/* Correo */
.seg-tabs { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--r-m); background: var(--n2); box-shadow: inset 0 0 0 1px var(--line); justify-self: start; }
.seg-tabs button { display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px; border-radius: 6px; font-size: 12.5px; font-weight: 600; color: var(--fg3); transition: background-color .15s, color .15s; }
.seg-tabs .i { width: 14px; height: 14px; }
.seg-tabs button:hover { color: var(--fg1); }
.seg-tabs button[aria-selected="true"] { background: var(--n4); color: var(--fg1); }
.mail { border-radius: var(--r-m); background: var(--paper); color: var(--ink); font-size: 13px; line-height: 1.5; overflow: hidden; box-shadow: 0 14px 30px -18px rgba(0, 0, 0, .75); }
.mail-h { display: grid; gap: 3px; padding: 11px 14px; border-bottom: 1px solid var(--rule-paper); }
.mail-h > div { display: grid; grid-template-columns: 50px minmax(0, 1fr); gap: 6px; }
.mail-h dt { color: var(--ink-2); font-size: 12px; }
.mail-h dd { font-size: 12.5px; overflow-wrap: anywhere; }
.mail-h b { font-weight: 700; font-size: 13.5px; }
.mail-b { display: grid; gap: 8px; padding: 12px 14px; }
.mail-b ul { padding-left: 16px; list-style: disc; }
.mail-b li::marker { color: #1B6FC4; }
.mail::before { content: ""; display: block; height: 4px; background: linear-gradient(90deg, #2E9BFF, #1B6FC4); }
.mail-sign { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mail-sign .logo { height: 40px; }
.mail-b b { font-weight: 600; }
.mail-b .num { font-size: 12.5px; }
.mail-att { display: flex; align-items: center; gap: 7px; width: calc(100% - 28px); margin: 0 14px 12px; padding: 8px 10px; border-radius: 6px; background: #eaf3fc; color: var(--ink); text-align: left; font: 500 11.5px/1.3 var(--mono); transition: background-color .15s; }
.mail-att:hover { background: var(--rule-paper); }
.mail-att .i { color: #1B6FC4; }
.mail-att span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.in-pdf .pdf { max-width: none; margin: 0; padding: 20px 18px; }

/* Esqueleto mientras se redacta */
.skel { display: grid; gap: 9px; padding: 14px; border-radius: var(--r-m); background: var(--n2); box-shadow: inset 0 0 0 1px var(--line); }
.skel i { display: block; height: 10px; border-radius: 3px; background: var(--n4); animation: skel 1.5s ease-in-out infinite; }
.skel i:nth-child(2) { animation-delay: .1s; }
.skel i:nth-child(3) { animation-delay: .2s; }
.skel i:nth-child(4) { animation-delay: .3s; }
.skel i:nth-child(5) { animation-delay: .4s; }
@keyframes skel { 0%, 100% { opacity: .45; } 50% { opacity: 1; } }

/* Envío */
.in-sent { display: grid; gap: 7px; justify-items: start; font-size: 13.5px; }
.in-sent b { font-weight: 600; }
.auto-tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12.5px; font-weight: 700; }
.auto-tag .i { width: 14px; height: 14px; }
.in-after { display: grid; gap: 5px; }
.in-after li { display: flex; gap: 7px; align-items: flex-start; color: var(--fg2); font-size: 13px; }
.in-after .i { width: 14px; height: 14px; margin-top: 2px; color: var(--green); }
.in-send { position: relative; overflow: hidden; }
.in-send-bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--accent-ink); opacity: .55; transform: scaleX(0); transform-origin: left; }
@media (max-width: 479px) {
  .in-recv { grid-template-columns: 104px minmax(0, 1fr); gap: 12px; }
  .bill-page { height: 104px; padding: 7px 6px; }
  .in-facts > div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .in-facts dt { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .wait-dots i, .skel i { animation: none; opacity: 1; transform: none; }
}
