/* Nava Pedidos — sigue el sistema visual de NAVA (barberia/docs/03-desarrollo/estandar-diseno-visual.md):
   papel marfil, tinta para el texto, filetes de latón, voz editorial serif + voz funcional sans,
   radios pequeños y profundidad contenida. Modo claro cálido: fondo pergamino y fichas marfil
   (nunca blanco puro, para que no encandile). Movimiento: solo transform/opacity/clip-path. */

@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/instrument-serif-latin-400.woff2") format("woff2");
}
@font-face {
  font-family: "Instrument Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/fonts/instrument-sans-latin-400-700.woff2") format("woff2");
}

:root {
  /* Firma cromática NAVA */
  --ink: #101b2b;
  --ink-hover: #18283d;
  --ink-active: #0a1420;
  --ivory: #f4f0e7;
  --parchment: #e8e2d8;
  --white: #ffffff;
  --graphite: #2a2d32;
  --graphite-2: #5e625f;
  --stone: #c9c0b2;
  --stone-soft: #ddd5c8;
  --sage: #748477;
  /* Acento: latón por omisión; Ajustes lo cambia (y con él los correos) */
  --accent: #b8955a;
  --accent-light: #c9a86f;
  --accent-dark: #765c2f;

  /* Superficies del panel (modo claro cálido) */
  --bg: #ece6db;
  --surface: #f8f5ef;
  --surface-hover: #f3eee5;
  --surface-sunken: #efe9de;
  --line: rgb(16 27 43 / 10%);
  --line-2: rgb(16 27 43 / 18%);
  --edge: #dfd6c8;
  --fg: #142032;
  --fg-soft: #343a43;
  --fg-muted: #5c6068;
  --accent-text: var(--accent-dark);
  --primary-bg: var(--ink);
  --primary-fg: var(--ivory);
  --primary-hover: var(--ink-hover);
  --field: #fdfbf7;
  --field-fg: var(--fg);
  --field-line: var(--stone-soft);
  --field-placeholder: #8b8f8a;
  --bar-bg: rgb(236 230 219 / 92%);
  --viewer-bg: var(--parchment);
  --knob-on: var(--accent);

  /* Estados sobre marfil (AA) */
  --s-pending: #8f5c0c;
  --s-process: #2c5a85;
  --s-done: #2d6a47;
  --s-reject: #a43a3a;

  /* Estados sobre superficies claras (acceso) */
  --bad-bg: #f8edec; --bad-ink: #8a2c2c; --bad-line: #a43a3a;

  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 2px;
  --shadow-raised: 0 1px 2px rgb(16 27 43 / 6%), 0 4px 14px rgb(16 27 43 / 6%);
  --shadow-lift: 0 2px 4px rgb(16 27 43 / 8%), 0 14px 30px rgb(16 27 43 / 11%);
  --shadow-dialog: 0 24px 60px rgb(16 27 43 / 24%);

  --fast: 120ms;
  --base: 200ms;
  --enter: 520ms;
  --ease-out: cubic-bezier(0.22, 0.8, 0.24, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --stagger: 55ms;

  --focus: var(--accent);
}

/* Modo noche: tinta de fondo, fichas de tinta levantadas, texto marfil, acento claro */
:root[data-mode="dark"] {
  color-scheme: dark;
  --bg: #101b2b;
  --surface: #172338;
  --surface-hover: #1d2b42;
  --surface-sunken: #111c2d;
  --line: rgb(244 240 231 / 10%);
  --line-2: rgb(244 240 231 / 18%);
  --edge: rgb(244 240 231 / 8%);
  --fg: #f4f0e7;
  --fg-soft: #cbd0d8;
  --fg-muted: #a8b0bd;
  --accent-text: var(--accent-light);
  --s-pending: #dfb063;
  --s-process: #9db7cf;
  --s-done: #9dc2a9;
  --s-reject: #e3928d;
  --primary-bg: var(--accent-light);
  --primary-fg: #101b2b;
  --primary-hover: color-mix(in srgb, var(--accent-light) 82%, #ffffff);
  --field: #0b1420;
  --field-fg: #f4f0e7;
  --field-line: rgb(244 240 231 / 14%);
  --field-placeholder: #7d8594;
  --bar-bg: rgb(16 27 43 / 92%);
  --viewer-bg: #0b1420;
  --knob-on: #101b2b;
  --shadow-raised: 0 1px 2px rgb(3 7 14 / 35%), 0 8px 20px rgb(3 7 14 / 30%);
  --shadow-lift: 0 2px 4px rgb(3 7 14 / 38%), 0 16px 32px rgb(3 7 14 / 40%);
  --shadow-dialog: 0 24px 60px rgb(3 7 14 / 55%);
}
:root[data-mode="dark"] dialog::backdrop { background: rgb(5 10 18 / 72%); }
/* Cambio de modo o color: transición suave de superficies (solo mientras se cambia) */
:root.recoloring *, :root.recoloring *::before, :root.recoloring *::after {
  transition: background-color 280ms ease, border-color 280ms ease, color 280ms ease, box-shadow 280ms ease !important;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 17px/1.5 var(--sans);
  color: var(--fg);
  background: var(--bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}
body.panel { height: 100dvh; overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.sprite { position: absolute; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Versalitas: rótulos, estados, datos auxiliares (tracking contenido para que se lean como palabra) */
.caps {
  font: 600 12px/1.25 var(--sans);
  letter-spacing: 0.07em;
  text-transform: uppercase;
}
.wordmark { margin: 0; font: 400 36px/1 var(--serif); letter-spacing: 0.01em; color: var(--fg); }

/* Divisor regla · rombo · regla */
.rule-diamond { display: flex; align-items: center; gap: 12px; width: 100%; }
.rule-diamond i { flex: 1; height: 1px; background: var(--accent); }
.rule-diamond i:first-child { transform-origin: right center; }
.rule-diamond i:last-child { transform-origin: left center; }
.rule-diamond b { width: 12px; height: 12px; background: var(--accent); transform: rotate(45deg); flex: none; }
.rule-diamond.sm { gap: 8px; }
.rule-diamond.sm b { width: 6px; height: 6px; }
.rule-diamond.sm i { background: var(--line); }

/* ---------- Movimiento ---------- */
@keyframes nava-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes nava-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes nava-grow-x { from { opacity: 0; transform: scaleX(0); } to { opacity: 1; transform: scaleX(1); } }
@keyframes nava-wipe { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes nava-pop { 0% { opacity: 0; transform: rotate(45deg) scale(0.4); } 60% { opacity: 1; transform: rotate(45deg) scale(1.15); } 100% { opacity: 1; transform: rotate(45deg) scale(1); } }
@keyframes nava-arrive { 0% { opacity: 0; transform: translateY(-18px) scale(0.98); } 100% { opacity: 1; transform: none; } }
@keyframes nava-flash { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 70%, transparent); } 100% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--accent) 0%, transparent); } }
@keyframes nava-bump { 0% { transform: translateY(0); } 35% { transform: translateY(-4px); color: var(--accent-text); } 100% { transform: translateY(0); } }
@keyframes nava-breathe { 50% { opacity: 0.35; } }
@keyframes nava-spin { to { transform: rotate(360deg); } }
@keyframes nava-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
@keyframes nava-leave { to { opacity: 0; transform: translateX(28px) scale(0.97); } }
@keyframes nava-zoom-in { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes sheet-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes nava-beat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--s-done) 45%, transparent); } 70%, 100% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--s-done) 0%, transparent); } }

/* ---------- Barra superior ---------- */
.top {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px;
  padding: 14px 24px; padding-top: max(14px, env(safe-area-inset-top));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; margin-right: auto; min-width: 0; }
.brand-rule { width: 1px; height: 32px; background: var(--accent); }
.brand-text { display: flex; flex-direction: column; gap: 4px; line-height: 1; min-width: 0; }
.brand-text strong { font: 400 25px/1 var(--serif); color: var(--fg); }
.brand-text span { font: 600 12px/1.2 var(--sans); letter-spacing: 0.07em; text-transform: uppercase; color: var(--fg-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.views { display: flex; gap: 4px; }
.views button {
  position: relative; border: 0; background: transparent; min-height: 44px; padding: 0 14px;
  display: inline-flex; align-items: center; gap: 8px; font-weight: 500; font-size: 16px; color: var(--fg-muted);
  transition: color var(--base);
}
.views button::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: 7px; height: 2px; background: var(--accent);
  transform: scaleX(0); transition: transform var(--base) var(--ease-out);
}
.views button:hover { color: var(--fg); }
.views button[aria-pressed="true"] { color: var(--fg); }
.views button[aria-pressed="true"]::after { transform: scaleX(1); }

.tools { display: flex; align-items: center; gap: 10px; }
.tool {
  display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px;
  border-radius: var(--radius); border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); background: transparent;
  font-weight: 500; font-size: 15px; color: var(--fg);
  transition: background var(--base), border-color var(--base), color var(--base);
}
.tool:hover { background: var(--surface-hover); border-color: var(--accent); }
.tool[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: var(--accent); color: var(--accent-text); }
.tool.quiet { border-color: transparent; color: var(--fg-muted); }
.tool.quiet:hover { color: var(--fg); background: transparent; text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 5px; }

.live { display: inline-flex; align-items: center; gap: 8px; font: 600 12px/1 var(--sans); letter-spacing: 0.07em; text-transform: uppercase; color: var(--fg-muted); margin-right: 6px; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-muted); }
.live[data-state="on"] i { background: var(--s-done); animation: nava-beat 2.4s ease-out infinite; }
.live[data-state="retry"] i { background: var(--s-pending); animation: nava-breathe 1.2s ease-in-out infinite; }

.count {
  display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 6px;
  border-radius: var(--radius); border: 1px solid var(--line-2); color: var(--fg-soft);
  font: 600 13px/1 var(--sans);
}
.count.bump, .stat dd.bump { animation: nava-bump 420ms var(--ease-out); }

/* ---------- Franja de resumen (como «Siguiente turno» de la agenda NAVA) ---------- */
.ledger {
  display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 2fr); align-items: stretch;
  margin: 18px 24px 4px; background: var(--surface); color: var(--fg); border: 1px solid var(--edge);
  border-radius: var(--radius); box-shadow: var(--shadow-raised); position: relative; overflow: hidden;
}
.ledger::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.ledger-next { padding: 14px 22px 14px 26px; display: grid; gap: 4px; align-content: center; border-right: 1px solid var(--line); min-width: 0; }
.ledger-next > .caps { color: var(--accent-text); }
.ledger-next-body { display: flex; align-items: center; gap: 16px; min-width: 0; }
.ledger-next-body .next-main { min-width: 0; flex: 1; }
.ledger-next-body .next-name { display: block; font: 400 28px/1.1 var(--serif); color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ledger-next-body .next-meta { display: block; margin-top: 2px; font-size: 15px; color: var(--fg-muted); }
.ledger-next-body .next-meta.late { color: var(--s-reject); font-weight: 600; }
.next-meta span { white-space: nowrap; }
.next-meta span + span::before { content: "·"; margin: 0 0.5em; color: var(--accent-text); }
.ledger-next-body .btn { min-height: 42px; padding: 0 16px; font-size: 15px; flex: none; }
.ledger-stats { margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 14px 20px; display: grid; gap: 2px; align-content: center; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat dt { color: var(--fg-muted); }
.stat dd { margin: 0; font: 400 34px/1.05 var(--serif); color: var(--fg); display: inline-block; }
.stat.hot dd { color: var(--s-pending); }

/* Pestañas (solo móvil) */
.tabs { display: none; gap: 0; margin: 12px 12px 0; padding: 3px; border: 1px solid var(--line-2); border-radius: var(--radius); background: var(--surface-sunken); }
.tabs button {
  flex: 1 1 auto; min-width: 0; white-space: nowrap; border: 0; background: transparent; min-height: 44px; padding: 6px 6px; border-radius: 1px;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-weight: 500; font-size: 14px; color: var(--fg-muted);
  transition: background var(--base), color var(--base);
}
.tabs button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: inset 0 -2px 0 var(--accent); }

/* ---------- Tablero ---------- */
.board {
  flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  padding: 10px 12px 0;
}
.col { display: flex; flex-direction: column; min-height: 0; padding: 0 12px; position: relative; }
.col + .col::before {
  content: ""; position: absolute; left: 0; top: 14px; bottom: 0; width: 0;
  border-left: 1px dashed var(--line-2);
}
.col-pendiente { --col: var(--s-pending); }
.col-en_proceso { --col: var(--s-process); }
.col-finalizado { --col: var(--s-done); }
.col-rechazado { --col: var(--s-reject); }

.col-head { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 4px 8px; }
.col-head::after {
  content: ""; position: absolute; left: 4px; right: 4px; bottom: 0; height: 1px;
  background: linear-gradient(90deg, var(--col, var(--accent)), color-mix(in srgb, var(--accent) 35%, transparent) 40%, transparent);
}
.col-head h2 { margin: 0; font: 400 28px/1.05 var(--serif); color: var(--fg); }
.col-head .count { margin-left: auto; }
.state-mark { width: 8px; height: 8px; background: var(--col, var(--accent)); transform: rotate(45deg); flex: none; }
.col-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 14px 4px 32px; display: flex; flex-direction: column; gap: 16px;
  overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent;
}

.rejected { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 24px 32px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.rejected .col-head { margin-bottom: 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }

/* Estado de página: regla-rombo-regla + titular serif */
.empty { display: grid; justify-items: center; gap: 8px; padding: 36px 20px; text-align: center; color: var(--fg-muted); font-size: 16px; }
.empty .rule-diamond { width: 140px; margin-bottom: 4px; }
.empty .rule-diamond i { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.empty strong { font: 400 26px/1.15 var(--serif); color: var(--fg); }
.empty span { max-width: 30ch; }
.rejected .empty { grid-column: 1 / -1; }

.loading { display: grid; justify-items: center; gap: 14px; padding: 48px 20px; color: var(--fg-muted); font-size: 16px; }
.spinner { position: relative; width: 40px; height: 40px; }
.spinner::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid var(--accent); border-right-color: transparent; animation: nava-spin 900ms linear infinite;
}
.spinner::after { content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px; margin: -3.5px; background: var(--accent); transform: rotate(45deg); }

/* ---------- Ficha del pedido (marfil levantado) ---------- */
.ticket-wrap { position: relative; flex: none; border-radius: var(--radius); }
.ticket {
  position: relative; background: var(--surface); color: var(--fg-soft); border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 20px 20px 18px; box-shadow: var(--shadow-raised); overflow: hidden;
  transition: transform var(--base) var(--ease-out), box-shadow var(--base) var(--ease-out), border-color var(--base);
}
.ticket-wrap:hover .ticket { transform: translateY(-2px); box-shadow: var(--shadow-lift); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.age { position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--age, var(--sage)); transform-origin: left; }
.age-fresh { --age: var(--sage); }
.age-waiting { --age: var(--s-pending); }
.age-late { --age: var(--s-reject); }
.age-process { --age: var(--s-process); }
.age-late .age { animation: nava-breathe 2.2s ease-in-out infinite; }

/* Entradas: primera carga escalonada, pedido nuevo, pedido que cambia de columna, pedido que se va */
.ticket-wrap.enter { animation: nava-rise var(--enter) var(--ease-out) both; animation-delay: calc(var(--i, 0) * var(--stagger) + 140ms); }
.ticket-wrap.is-new { animation: nava-arrive 560ms var(--ease-spring) both; }
.ticket-wrap.is-new::after, .ticket-wrap.is-moved::after, .ticket-wrap.flash::after {
  content: ""; position: absolute; inset: 0; border-radius: var(--radius); pointer-events: none;
  animation: nava-flash 1100ms var(--ease-out) 200ms both;
}
.ticket-wrap.is-moved { animation: nava-rise 460ms var(--ease-out) both; }
.ticket-wrap.leaving { animation: nava-leave 280ms var(--ease-out) forwards; pointer-events: none; }

.t-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.code { font: 600 14px/1 var(--sans); letter-spacing: 0.06em; color: var(--accent-text); }
.when { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 500; color: var(--fg-muted); }
.age-waiting .when { color: var(--s-pending); font-weight: 600; }
.age-late .when { color: var(--s-reject); font-weight: 700; }
.who { margin: 8px 0 0; font: 400 30px/1.08 var(--serif); color: var(--fg); overflow-wrap: anywhere; }
.phone {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 15px; color: var(--fg-muted); text-decoration: none;
  border-bottom: 1px solid transparent; transition: color var(--fast), border-color var(--fast);
}
.phone:hover { color: var(--fg); border-bottom-color: var(--accent); }

.items { list-style: none; margin: 14px 0 0; padding: 0; display: grid; font-size: 17px; }
.items li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; padding: 6px 0; border-top: 1px solid var(--line); color: var(--fg); }
.items li:first-child { border-top: 0; padding-top: 0; }
.items .q { font-weight: 700; font-size: 15px; color: var(--accent-text); min-width: 2em; }
.items .p { font-size: 16px; color: var(--fg-soft); }
.items small { display: block; color: var(--fg-muted); font-size: 14px; line-height: 1.3; }
.sum { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: baseline; margin-top: 4px; font-size: 15px; color: var(--fg-muted); }
.sum .rule-diamond { grid-column: 1 / -1; margin: 2px 0 4px; }
.sum span:nth-child(even) { text-align: right; }
.sum .total-label { font: 600 12px/1.25 var(--sans); letter-spacing: 0.07em; text-transform: uppercase; color: var(--fg-soft); align-self: center; }
.sum .total { font: 400 36px/1 var(--serif); color: var(--fg); }

/* Pago y entrega: renglón reglado con rótulo pegado a su línea */
.block { margin-top: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.block-label { display: block; color: var(--accent-text); margin-bottom: 6px; }
.block-row { display: flex; gap: 12px; align-items: flex-start; }
.block-row > .ic { margin-top: 3px; color: var(--fg-muted); }
.block-main { flex: 1; min-width: 0; }
.block strong { display: block; font-weight: 600; font-size: 17px; color: var(--fg); line-height: 1.3; }
.block-main > span, .block-main > small { display: block; font-size: 15.5px; line-height: 1.4; color: var(--fg-soft); overflow-wrap: anywhere; }
.block .ref { font-size: 15px; color: var(--fg-muted); }
.pay-verify .block-row, .pay-paid .block-row { padding: 10px 12px; border-radius: var(--radius); border-left: 3px solid; }
.pay-verify .block-row { background: color-mix(in srgb, var(--s-pending) 9%, transparent); border-color: var(--s-pending); }
.pay-verify .block-row > .ic, .pay-verify strong { color: var(--s-pending); }
.pay-paid .block-row { background: color-mix(in srgb, var(--s-done) 8%, transparent); border-color: var(--s-done); }
.pay-paid .block-row > .ic, .pay-paid strong { color: var(--s-done); }
.block-main > .address { color: var(--fg); font-size: 16.5px; }
.maps-link {
  display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; font: 600 13px/1.2 var(--sans); letter-spacing: 0.04em;
  color: var(--accent-text); text-decoration: none; border-bottom: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); padding-bottom: 2px;
  transition: color var(--fast), border-color var(--fast);
}
.maps-link .ic { width: 14px; height: 14px; }
.maps-link:hover { color: var(--fg); border-bottom-color: var(--accent); }
/* Cómo llegar: lo que escribió el cliente, legible de un vistazo */
.directions {
  margin-top: 10px; padding: 10px 14px 11px; background: var(--surface-sunken); border-left: 3px solid var(--accent);
  border-radius: var(--radius);
}
.directions .caps { color: var(--accent-text); }
.directions p { margin: 3px 0 0; font-size: 16.5px; line-height: 1.45; color: var(--fg); overflow-wrap: anywhere; }
.block small.proof-missing { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-weight: 600; color: var(--s-pending); }
.proof-missing .ic { width: 1em; height: 1em; }

/* Vista previa del comprobante: grande, abre el visor propio */
.proof {
  position: relative; display: block; width: 100%; height: 190px; margin-top: 10px; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-sunken); color: var(--fg-muted);
  cursor: zoom-in;
}
.proof img { width: 100%; height: 100%; object-fit: cover; object-position: center top; display: block; transition: transform 400ms var(--ease-out), filter var(--base); }
.proof:hover img { transform: scale(1.04); }
.proof-zoom {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 26px 12px 10px; font: 600 13px/1 var(--sans); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ivory);
  background: linear-gradient(to top, rgb(11 20 32 / 92%), rgb(11 20 32 / 0%));
  transition: padding var(--base) var(--ease-out);
}
.proof:hover .proof-zoom { padding-bottom: 14px; }
.proof.no-image { height: auto; cursor: pointer; }
.proof.no-image .proof-zoom { position: static; padding: 16px 12px; background: none; color: var(--accent-text); }

/* Lectura automática del comprobante: pistas, nunca una decisión. Marca + texto, no solo color. */
.autocheck { margin-top: 10px; padding: 4px 0 2px 14px; border-left: 2px solid var(--accent); }
.autocheck h4 { margin: 0 0 6px; font: 600 12px/1.3 var(--sans); letter-spacing: 0.07em; text-transform: uppercase; color: var(--accent-text); }
.autocheck h4 span { display: block; margin-top: 2px; font-size: 14px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--fg-muted); }
.autocheck ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.autocheck li { display: grid; grid-template-columns: 1.3em minmax(0, 1fr); gap: 6px; align-items: start; font-size: 15px; line-height: 1.4; color: var(--fg-soft); }
.autocheck .mark { font-weight: 700; text-align: center; }
.autocheck .ac-text { overflow-wrap: anywhere; }
.autocheck strong { color: var(--fg); font-weight: 600; }
.autocheck li.ok .mark { color: var(--s-done); }
.autocheck li.warn .mark { color: var(--s-pending); }
.autocheck li.warn .ac-text { color: var(--fg); font-weight: 600; }
.autocheck li.none .mark { color: var(--fg-muted); }

.note {
  position: relative; margin: 12px 0 0; padding: 10px 12px 10px 36px; background: var(--surface-sunken); border-radius: var(--radius);
  color: var(--fg-soft); font-size: 16px; overflow-wrap: anywhere;
}
.note::before { content: "“"; position: absolute; left: 11px; top: 4px; font: 400 36px/1 var(--serif); color: var(--accent-text); }

/* ---------- Botones (radio 2px) ---------- */
.actions { display: flex; gap: 10px; margin-top: 16px; }
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid transparent; font-weight: 600; font-size: 16px; line-height: 1;
  transition: background var(--base), color var(--base), border-color var(--base), transform var(--fast), box-shadow var(--base);
}
.btn:active { transform: scale(0.98); }
.btn[disabled] { cursor: progress; opacity: 0.7; }
.btn.wide { width: 100%; }
/* Primaria sobre marfil (acceso): tinta llena */
.btn.primary { background: var(--ink); color: var(--ivory); }
.btn.primary:hover { background: var(--ink-hover); box-shadow: inset 0 -2px 0 var(--accent); }
.btn.primary:active { background: var(--ink-active); }
/* Primaria sobre marfil: tinta llena; al pasar, filete de latón */
.btn.accept, .btn.progress { background: var(--primary-bg); color: var(--primary-fg); }
.btn.accept:hover, .btn.progress:hover { background: var(--primary-hover); box-shadow: inset 0 -2px 0 var(--accent); }
.btn.accept { flex: 1.5; }
.btn.progress { flex: 1; }
.btn.outline { background: transparent; color: var(--fg); border-color: var(--accent); }
.btn.outline:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); border-color: var(--accent); }
.btn.reject { flex: 1; background: transparent; color: var(--s-reject); border-color: color-mix(in srgb, var(--s-reject) 40%, transparent); border-bottom: 2px solid var(--s-reject); }
.btn.reject:hover { background: color-mix(in srgb, var(--s-reject) 7%, transparent); }
.btn.danger { background: #a43a3a; color: #fff; }
.btn.danger:hover { background: #b54545; }
.btn.ghost { background: transparent; color: var(--fg); border-color: color-mix(in srgb, var(--accent) 45%, transparent); border-bottom: 2px solid var(--accent); }
.btn.ghost:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.btn.loading > span { opacity: 0.85; }
.btn.loading::after {
  content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: nava-spin 800ms linear infinite;
}

.status-line { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 15px; font-weight: 600; }
.status-line .ic { width: 1.1em; height: 1.1em; }
.status-line.ok { color: var(--s-done); }
.status-line.wait { color: var(--fg-muted); }
.status-line.fail { color: var(--s-reject); flex-wrap: wrap; }
.linkbtn {
  border: 0; background: none; padding: 4px 0; font: 600 13px/1.3 var(--sans); letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 9px; border-radius: var(--radius); border: 1px solid currentColor;
  font: 600 12px/1.2 var(--sans); letter-spacing: 0.06em; text-transform: uppercase;
}
.chip .ic { width: 1.1em; height: 1.1em; }
.chip.process { color: var(--s-process); }
.chip.done { color: var(--s-done); }
.chip.reject { color: var(--s-reject); }

/* Fichas cerradas: un registro terminal cambia de material (solo contorno), no de peso */
.ticket.closed { background: transparent; box-shadow: none; border: 1px solid var(--line-2); padding: 16px 18px 16px 20px; }
.ticket-wrap:hover .ticket.closed { transform: none; box-shadow: none; border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: color-mix(in srgb, var(--fg) 3%, transparent); }
.ticket.closed .age { inset: 0 auto 0 0; width: 2px; height: auto; background: var(--age-closed, var(--line-2)); }
.ticket.closed .code { color: var(--fg-muted); }
.ticket.closed .who { font-size: 24px; margin-top: 6px; }
.ticket.closed .note { background: color-mix(in srgb, var(--fg) 5%, transparent); }
.closed-items { margin: 6px 0 0; font-size: 15.5px; color: var(--fg-muted); }
.closed-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.closed-foot .money { font: 400 27px/1 var(--serif); color: var(--fg); }
.done-ticket { --age-closed: var(--s-done); }
.rej-ticket { --age-closed: var(--s-reject); }

/* ---------- Diálogos ---------- */
dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto; padding: 26px 26px 24px;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: 3px; background: var(--surface); color: var(--fg-soft); box-shadow: var(--shadow-dialog);
}
dialog::backdrop { background: rgb(16 27 43 / 42%); }
dialog[open] { animation: nava-rise 300ms var(--ease-out); }
dialog[open]::backdrop { animation: nava-fade 300ms ease; }
.dialog-kicker { margin: 0 0 4px; color: var(--accent-text); }
dialog h2 { margin: 0 0 6px; font: 400 34px/1.05 var(--serif); color: var(--fg); }
.hint { margin: 0 0 16px; color: var(--fg-muted); font-size: 16px; }
fieldset { border: 0; margin: 0 0 18px; padding: 0; display: grid; gap: 8px; }
.reason { position: relative; display: block; cursor: pointer; }
.reason input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.reason > span {
  display: block; position: relative; padding: 11px 14px 11px 46px; background: var(--surface-sunken); border: 1px solid var(--line);
  border-radius: var(--radius); transition: border-color var(--base), background var(--base), box-shadow var(--base);
}
.reason > span::before {
  content: ""; position: absolute; left: 18px; top: 50%; width: 11px; height: 11px; margin-top: -6px;
  border: 1.5px solid var(--fg-muted); transform: rotate(45deg); transition: background var(--base), border-color var(--base), transform var(--base) var(--ease-spring);
}
.reason:hover > span { border-color: var(--line-2); }
.reason strong { display: block; font-weight: 600; font-size: 17px; color: var(--fg); line-height: 1.3; }
.reason small { color: var(--fg-muted); font-size: 14.5px; }
.reason input:checked + span { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); }
.reason input:checked + span::before { background: var(--accent); border-color: var(--accent); transform: rotate(45deg) scale(1.15); }
.reason input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.dialog-actions .btn { min-width: 130px; }

/* Campo reglado: papel claro sobre línea base de tinta de 2px */
.ruled { display: grid; gap: 6px; }
.ruled > .caps { color: var(--accent-dark); }
.ruled > .caps em { font-style: normal; color: var(--graphite-2); letter-spacing: 0.04em; }
.ruled-box {
  display: flex; align-items: center; background: var(--field); border: 1px solid var(--field-line); border-bottom: 2px solid var(--fg);
  border-radius: var(--radius); transition: border-color var(--base), box-shadow var(--base);
}
.ruled-box:focus-within { border-bottom-color: var(--accent-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.ruled.invalid .ruled-box { border-color: var(--bad-line); }
.ruled input, .ruled textarea {
  flex: 1; min-width: 0; border: 0; background: transparent; font: 400 17px/1.4 var(--sans); color: var(--field-fg);
  padding: 14px 16px; outline: none; resize: vertical;
}
.ruled input::placeholder, .ruled textarea::placeholder { color: var(--field-placeholder); }
.reveal {
  border: 0; background: none; padding: 8px 16px; font: 600 12px/1 var(--sans); letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--accent-dark); text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 3px;
}

/* ---------- Visor del comprobante ---------- */
dialog.viewer {
  width: min(1100px, calc(100vw - 32px)); height: min(900px, calc(100dvh - 32px)); max-height: none; padding: 0;
  display: none; flex-direction: column; overflow: hidden; background: var(--viewer-bg);
}
dialog.viewer[open] { display: flex; animation: nava-zoom-in 260ms var(--ease-out); }
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px 12px 22px; border-bottom: 1px solid var(--line); background: var(--surface); }
.viewer-heading { min-width: 0; }
.viewer-heading .caps { margin: 0 0 2px; color: var(--accent-text); }
.viewer-heading h2 { margin: 0; font-size: 26px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-tools { display: flex; align-items: center; gap: 6px; flex: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: var(--radius); border: 1px solid var(--line-2);
  background: transparent; color: var(--fg); text-decoration: none; transition: background var(--base), border-color var(--base);
}
.icon-btn:hover { background: var(--surface-hover); border-color: var(--accent); }
.icon-btn[disabled] { opacity: 0.4; cursor: default; }
.icon-btn .ic { width: 20px; height: 20px; }
.viewer-level { min-width: 56px; text-align: center; font: 600 14px/1 var(--sans); color: var(--fg-muted); }
.viewer-stage { flex: 1; min-height: 0; overflow: auto; display: flex; padding: 12px; overscroll-behavior: contain; }
/* margin:auto centra cuando cabe y deja desplazar sin recortar cuando se acerca */
.viewer-stage img { display: block; flex: none; margin: auto; cursor: zoom-in; border-radius: var(--radius); box-shadow: 0 10px 30px rgb(16 27 43 / 22%); background: var(--white); }
.viewer-stage.zoomed img { cursor: zoom-out; }
.viewer-fail { color: var(--fg-muted); font-size: 16px; }
.viewer-help { margin: 0; padding: 8px 16px 12px; text-align: center; font-size: 13px; color: var(--fg-muted); }

/* ---------- Ajustes ---------- */
body[data-view="ajustes"] .ledger, body[data-view="ajustes"] .tabs { display: none; }
.settings { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 24px 0; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.settings-inner { max-width: 1040px; margin: 0 auto; }
.settings-head { margin-bottom: 18px; }
.settings-head h2 { margin: 0 0 4px; font: 400 40px/1.05 var(--serif); color: var(--fg); }
.settings-head .hint { margin: 0; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.set-card {
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--radius); box-shadow: var(--shadow-raised);
  padding: 18px 20px 20px; display: grid; gap: 14px; position: relative; overflow: hidden;
  animation: nava-rise var(--enter) var(--ease-out) both;
}
.set-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); }
.set-col { display: grid; gap: 16px; align-content: start; min-width: 0; }
.set-col:nth-child(2) .set-card { animation-delay: 60ms; }
.set-col:nth-child(2) .set-card:nth-child(2) { animation-delay: 120ms; }
.set-col:nth-child(2) .set-card:nth-child(3) { animation-delay: 180ms; }
.set-head { display: flex; align-items: center; gap: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.set-head .ic { color: var(--accent-text); width: 20px; height: 20px; }
.set-head h3 { margin: 0; font: 400 26px/1.1 var(--serif); color: var(--fg); }
.set-help { display: block; color: var(--fg-muted); font-size: 14.5px; line-height: 1.4; }
.set-label { display: block; color: var(--accent-text); margin-bottom: 2px; }
.set-help code { font-size: 13.5px; background: var(--surface-sunken); padding: 1px 5px; border-radius: var(--radius); color: var(--fg-soft); }

/* Interruptor: pista con rombo de latón */
.switch { position: relative; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  position: relative; width: 50px; height: 28px; border-radius: 14px; background: var(--surface-sunken); border: 1px solid var(--line-2);
  transition: background var(--base), border-color var(--base);
}
.switch-track i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 3px rgb(16 27 43 / 25%); transition: transform 260ms var(--ease-spring), background var(--base);
}
.switch input:checked + .switch-track { background: var(--primary-bg); border-color: var(--primary-bg); }
.switch input:checked + .switch-track i { transform: translateX(22px); background: var(--knob-on); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-text strong { display: block; font-weight: 600; font-size: 17px; color: var(--fg); line-height: 1.3; }
.switch-text small { display: block; color: var(--fg-muted); font-size: 14.5px; line-height: 1.35; }

.set-dependent { display: grid; gap: 14px; transition: opacity var(--base); }
.set-dependent.off { opacity: 0.45; pointer-events: none; }

/* Opciones de intervalo: fichas con selección de tinta */
.choices { margin: 0; }
.choices legend { color: var(--accent-text); margin-bottom: 8px; padding: 0; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.choice span {
  display: inline-flex; align-items: center; min-height: 42px; padding: 0 15px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); font-weight: 600; font-size: 15px; color: var(--fg-soft);
  transition: background var(--base), color var(--base), border-color var(--base), transform var(--fast);
}
.choice:hover span { border-color: var(--accent); }
.choice input:checked + span { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); box-shadow: inset 0 -2px 0 var(--accent); }
.choice input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.choice input:active + span { transform: scale(0.97); }
.custom-every { max-width: 320px; animation: nava-rise 300ms var(--ease-out) both; }
.ruled-box .unit { padding: 0 14px; color: var(--fg-muted); font-size: 15px; }
.ruled input[type="number"] { -moz-appearance: textfield; }
.ruled input::-webkit-outer-spin-button, .ruled input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.stepper { display: inline-flex; align-items: center; gap: 6px; flex: none; }
.stepper input {
  width: 64px; height: 42px; text-align: center; border: 1px solid var(--line-2); border-bottom: 2px solid var(--fg); border-radius: var(--radius);
  background: var(--field); font: 400 24px/1 var(--serif); color: var(--fg); -moz-appearance: textfield;
}
.stepper input:focus { outline: none; border-bottom-color: var(--accent-text); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }

.set-summary {
  margin: 0; padding: 12px 14px; background: var(--surface-sunken); border-left: 3px solid var(--accent); border-radius: var(--radius);
  font-size: 16px; line-height: 1.45; color: var(--fg-soft);
}
.set-summary strong { color: var(--fg); font-weight: 600; }
.set-summary.off { border-left-color: var(--line-2); color: var(--fg-muted); }

.time-pair { grid-template-columns: 1fr 1fr; }
.ruled input[type="time"] { font-variant-numeric: tabular-nums; }
.recipients { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.recipients li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface-sunken); border-radius: var(--radius); font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.recipients li .ic { color: var(--accent-text); }
.recipients li.none { font-weight: 400; color: var(--fg-muted); }
.set-warning { margin: 0; padding: 10px 12px; border-left: 3px solid var(--s-pending); background: color-mix(in srgb, var(--s-pending) 9%, transparent); color: var(--fg); font-size: 15px; border-radius: var(--radius); }
.ruled.invalid .caps { color: var(--bad-ink); }

/* Apariencia: modo (tres tarjetas) y color (muestras redondas con rombo al elegir) */
.mode-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mode { position: relative; }
.mode input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.mode span {
  display: grid; justify-items: center; gap: 6px; padding: 12px 6px 11px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--surface); color: var(--fg-soft); text-align: center;
  transition: background var(--base), color var(--base), border-color var(--base), transform var(--fast);
}
.mode .ic { width: 22px; height: 22px; }
.mode strong { font-weight: 600; font-size: 15px; }
.mode:hover span { border-color: var(--accent); }
.mode input:checked + span { background: var(--primary-bg); border-color: var(--primary-bg); color: var(--primary-fg); box-shadow: inset 0 -2px 0 var(--accent); }
.mode input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.mode input:active + span { transform: scale(0.97); }

.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatch { position: relative; display: grid; justify-items: center; gap: 5px; width: 64px; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch i {
  position: relative; display: block; width: 40px; height: 40px; border-radius: 50%; background: var(--sw);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 12%), 0 0 0 3px var(--surface), 0 0 0 4px transparent;
  transition: box-shadow var(--base), transform 220ms var(--ease-spring);
}
.swatch i::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 10px; height: 10px; margin: -5px; background: #fff;
  transform: rotate(45deg) scale(0); transition: transform 260ms var(--ease-spring);
}
.swatch small { font-size: 12.5px; line-height: 1.2; color: var(--fg-muted); text-align: center; }
.swatch:hover i { transform: scale(1.06); }
.swatch input:checked + i { box-shadow: inset 0 0 0 1px rgb(0 0 0 / 12%), 0 0 0 3px var(--surface), 0 0 0 5px var(--sw); }
.swatch input:checked + i::after { transform: rotate(45deg) scale(1); }
.swatch input:checked ~ small { color: var(--fg); font-weight: 600; }
.swatch input:focus-visible + i { outline: 2px solid var(--focus); outline-offset: 6px; }

/* Muestra del correo: siempre en claro, como llega a la bandeja de entrada */
.mail-sample { display: grid; gap: 6px; }
.mail-sample > .caps { color: var(--accent-text); }
.mail-sample-card { background: #ece6db; padding: 12px; border-radius: var(--radius); border: 1px solid var(--line); }
.mail-sample-top { display: flex; align-items: baseline; gap: 8px; padding: 0 2px 8px; font-family: Georgia, "Times New Roman", serif; }
.ms-word { font-size: 18px; letter-spacing: 4px; color: #142032; }
.ms-sep, .ms-sub { color: var(--accent); font-size: 15px; }
.mail-sample-body { display: grid; gap: 8px; justify-items: start; background: #f8f5ef; border: 1px solid #ddd3c3; border-top: 3px solid var(--accent); padding: 12px 14px 14px; }
.ms-label { font: 700 11px/1.3 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-dark); }
.ms-line { width: 100%; height: 8px; border-left: 3px solid var(--accent); background: linear-gradient(#efe9de, #efe9de) 0 0 / 70% 100% no-repeat; }
.ms-button { padding: 7px 12px; background: #101b2b; color: #f4f0e7; border-bottom: 2px solid var(--accent); font: 700 13px/1 var(--sans); }

/* Barra de guardado: fija abajo, cambia de tono cuando hay cambios */
.save-bar {
  position: sticky; bottom: 0; z-index: 5; margin: 18px -24px 0; padding: 14px 24px max(14px, env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--bar-bg); backdrop-filter: blur(6px); border-top: 1px solid var(--line);
}
.save-state { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--fg-muted); }
.save-state::before { content: ""; width: 8px; height: 8px; transform: rotate(45deg); background: var(--s-done); flex: none; }
.save-bar[data-state="dirty"] .save-state { color: var(--s-pending); }
.save-bar[data-state="dirty"] .save-state::before { background: var(--s-pending); animation: nava-breathe 1.4s ease-in-out infinite; }
.save-bar[data-state="error"] .save-state { color: var(--s-reject); }
.save-bar[data-state="error"] .save-state::before { background: var(--s-reject); }
.save-actions { display: flex; gap: 10px; }
.save-actions .btn { min-width: 150px; }
.save-actions .btn[disabled] { cursor: default; opacity: 0.45; }

/* ---------- Avisos ---------- */
.toast {
  position: fixed; right: 24px; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 50;
  width: min(440px, calc(100vw - 24px)); padding: 12px 16px 13px 18px; display: grid; gap: 2px;
  background: var(--surface); color: var(--fg); border: 1px solid var(--edge); border-left: 4px solid var(--s-done);
  border-radius: 3px; box-shadow: var(--shadow-dialog);
  opacity: 0; transform: translateY(16px); pointer-events: none; transition: opacity var(--base), transform 320ms var(--ease-out);
}
.toast.show { opacity: 1; transform: none; }
.toast.error { border-left-color: var(--s-reject); }
.toast-word { color: var(--accent-text); }
.toast p { margin: 0; font-size: 16px; line-height: 1.4; }

/* Alerta en línea (acceso): tinta para que destaque sobre marfil */
.alert {
  display: grid; gap: 2px; padding: 11px 14px 12px; background: var(--ink); color: var(--ivory);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-left: 4px solid var(--s-reject); border-radius: 3px;
}
.alert-word { color: var(--accent); }
.alert p { margin: 0; font-size: 15px; }
.alert.shake { animation: nava-shake 380ms ease; }

/* ---------- Acceso ---------- */
body.login-page { background: var(--ivory); color: var(--graphite); }
.auth { flex: 1; display: grid; grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr); min-height: 100dvh; }
.auth-brand { background: var(--ink); color: var(--ivory); display: grid; place-items: center; padding: 48px 40px; position: relative; overflow: hidden; }
.auth-brand::before { content: ""; position: absolute; inset: 24px; border: 1px solid color-mix(in srgb, var(--accent) 18%, transparent); pointer-events: none; }
.auth-brand-inner { width: min(440px, 100%); display: grid; justify-items: center; text-align: center; }
.wordmark-xl { font-size: clamp(84px, 10vw, 128px); line-height: 0.9; }
.auth-brand .rule-diamond { margin: 30px 0 34px; }
.auth-tagline { margin: 0; font: 400 clamp(32px, 3.3vw, 44px)/1.1 var(--serif); color: var(--ivory); }
.auth-brand .wordmark { color: var(--ivory); }
.auth-sign { margin: 30px 0 0; color: #a8b0bd; letter-spacing: 0.16em; }

.auth-panel { --focus: var(--accent-dark); display: grid; place-items: center; padding: 48px 32px; }
.auth-form-wrap { width: min(440px, 100%); }
.auth-head { display: grid; justify-items: center; text-align: center; margin-bottom: 28px; }
.wordmark-sm { font-size: 52px; color: var(--ink); padding-bottom: 10px; position: relative; }
.wordmark-sm::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px; background: var(--accent); transform-origin: center; }
.auth-head h1 { margin: 20px 0 6px; font: 400 42px/1.05 var(--serif); color: var(--ink); }
.auth-head .hint { margin: 0; color: var(--graphite-2); }
.auth-form { display: grid; gap: 18px; }
.auth-form .btn { min-height: 52px; margin-top: 4px; font-size: 17px; }

/* Coreografía del acceso */
.login-page .wordmark-xl { animation: nava-rise 700ms var(--ease-out) 80ms both; }
.login-page .auth-brand .rule-diamond i { animation: nava-grow-x 700ms var(--ease-out) 320ms both; }
.login-page .auth-brand .rule-diamond b { animation: nava-pop 520ms var(--ease-out) 620ms both; }
.login-page .auth-tagline { animation: nava-rise 700ms var(--ease-out) 720ms both; }
.login-page .auth-sign { animation: nava-fade 800ms ease 1000ms both; }
.login-page .auth-brand::before { animation: nava-fade 1200ms ease 200ms both; }
.login-page .auth-head > *, .login-page .auth-form > * { animation: nava-rise var(--enter) var(--ease-out) both; }
.login-page .auth-head > :nth-child(1) { animation-delay: 160ms; }
.login-page .wordmark-sm::after { animation: nava-grow-x 600ms var(--ease-out) 420ms both; }
.login-page .auth-head > :nth-child(2) { animation-delay: 240ms; }
.login-page .auth-head > :nth-child(3) { animation-delay: 300ms; }
.login-page .auth-form > :nth-child(1) { animation-delay: 380ms; }
.login-page .auth-form > :nth-child(2) { animation-delay: 440ms; }
.login-page .auth-form > :nth-child(3) { animation-delay: 0ms; }
.login-page .auth-form > :nth-child(4) { animation-delay: 500ms; }
body.leaving .auth-panel > * { transition: opacity 320ms ease, transform 320ms var(--ease-out); opacity: 0; transform: translateY(-10px); }
body.leaving .auth-brand-inner { transition: transform 380ms var(--ease-out), opacity 380ms ease; transform: scale(0.96); opacity: 0.6; }

/* Coreografía del panel en la primera carga */
.panel.entering .top > * { animation: nava-fade 600ms ease both; }
.panel.entering .brand-rule { animation: nava-grow-x 500ms var(--ease-out) 200ms both; transform-origin: top; }
.panel.entering .ledger { animation: nava-rise var(--enter) var(--ease-out) 80ms both; }
.panel.entering .ledger::before { animation: nava-wipe 700ms var(--ease-out) 300ms both; }
.panel.entering .col { animation: nava-rise var(--enter) var(--ease-out) both; }
.panel.entering .col:nth-child(2) { animation-delay: 70ms; }
.panel.entering .col:nth-child(3) { animation-delay: 140ms; }
.panel.entering .col-head::after { animation: nava-wipe 900ms var(--ease-out) 260ms both; }
.panel.entering .state-mark { animation: nava-pop 480ms var(--ease-out) 380ms both; }
.empty { animation: nava-fade 500ms ease both; }
.empty .rule-diamond i { animation: nava-grow-x 600ms var(--ease-out) 100ms both; }
.empty .rule-diamond b { animation: nava-pop 480ms var(--ease-out) 360ms both; }

/* ---------- Pantallas medianas ---------- */
@media (max-width: 1180px) {
  .ledger { grid-template-columns: 1fr; }
  .ledger-next { border-right: 0; border-bottom: 1px solid var(--line); }
  .stat { padding: 10px 18px; }
  .stat dd { font-size: 28px; }
}

/* ---------- Pantallas angostas ---------- */
@media (max-width: 899px) {
  .top { padding: 12px 16px 0; padding-top: max(12px, env(safe-area-inset-top)); gap: 10px 14px; border-bottom: 0; }
  .wordmark { font-size: 30px; }
  .brand-rule { height: 26px; }
  .brand-text strong { font-size: 22px; }
  .brand-text span { display: none; }
  .views { order: 3; width: 100%; border-bottom: 1px solid var(--line); }
  .views button { flex: 1; justify-content: center; }
  .tool span { display: none; }
  .tool { padding: 0 11px; min-height: 42px; }
  .tool.quiet span, .tool.quiet { display: inline-flex; }
  .live span { display: none; }
  .ledger { margin: 12px 12px 0; }
  .ledger-next { padding: 12px 14px 12px 18px; }
  .ledger-next-body .next-name { font-size: 24px; }
  .ledger-stats { display: none; }
  .tabs { display: flex; }
  body[data-view="rechazados"] .tabs { display: none; }
  .board { display: block; padding: 0 12px; }
  .col { display: none; height: 100%; padding: 0; }
  .col + .col::before { display: none; }
  .board[data-tab="pendiente"] .col-pendiente,
  .board[data-tab="en_proceso"] .col-en_proceso,
  .board[data-tab="finalizado"] .col-finalizado { display: flex; }
  .col-head { display: none; }
  .col-body { padding: 14px 0 28px; }
  .rejected { padding: 4px 12px 28px; }
  .ticket { padding: 18px 16px 16px; }
  .who { font-size: 28px; }
  .proof { height: 170px; }
  .settings { padding: 14px 12px 0; }
  .settings-head h2 { font-size: 34px; }
  .settings-grid { grid-template-columns: 1fr; gap: 12px; }
  .set-col { gap: 12px; }
  .set-card { padding: 16px 16px 18px 18px; }
  .views button { padding: 0 8px; }
  .views button .ic { display: none; }
  .save-bar { margin: 14px -12px 0; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); flex-wrap: wrap; gap: 8px; }
  .save-state { width: 100%; }
  .save-actions { width: 100%; }
  .save-actions .btn { flex: 1; min-width: 0; }
  .swatches { gap: 6px; }
  .swatch { width: calc((100% - 18px) / 4); }
  .toast { right: 12px; left: 12px; width: auto; }
  dialog { margin: auto auto 0; width: 100vw; max-width: 100vw; border-radius: 3px 3px 0 0; border-width: 1px 0 0; padding: 24px 18px max(20px, env(safe-area-inset-bottom)); }
  dialog[open] { animation: sheet-up 340ms var(--ease-out); }
  .dialog-actions .btn { flex: 1; min-width: 0; }
  dialog.viewer { margin: 0; width: 100vw; height: 100dvh; border: 0; border-radius: 0; padding: 0; }
  dialog.viewer[open] { animation: nava-fade 220ms ease; }
  .viewer-bar { padding: max(10px, env(safe-area-inset-top)) 10px 10px 16px; }
  .viewer-heading h2 { font-size: 22px; }
  .viewer-level { display: none; }
  .viewer-stage { padding: 8px; }

  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .auth-brand { padding: 44px 24px 36px; }
  .auth-brand::before { inset: 12px; }
  .wordmark-xl { font-size: 72px; }
  .auth-brand .rule-diamond { margin: 18px 0 20px; width: 78%; }
  .auth-tagline { font-size: 28px; }
  .auth-tagline br { display: none; }
  .auth-sign { margin-top: 20px; }
  .auth-panel { padding: 32px 20px 40px; place-items: start center; }
  .auth-head { margin-bottom: 24px; }
  .wordmark-sm { display: none; }
  .auth-head h1 { margin-top: 0; font-size: 36px; }
}

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

/* Ajustes: campo con error */
.stepper.invalid input, .time-pair.invalid .ruled-box { border-color: var(--bad-line); }
