/* RastreaTuPedido · Sistema de diseño
   CSS nativo moderno (2024+): cascade layers, nesting, light-dark(), color-mix(), :has(),
   container queries, dvh, <dialog>, View Transitions. Sin frameworks ni build. */

@layer reset, tokens, base, layout, components, pages, utilities, print;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; hanging-punctuation: first last; }
  body { min-height: 100dvh; line-height: 1.5; -webkit-font-smoothing: antialiased; }
  img, svg, video { display: block; max-width: 100%; }
  input, button, textarea, select { font: inherit; color: inherit; }
  button { cursor: pointer; background: none; border: 0; }
  a { color: inherit; text-decoration: none; }
  h1, h2, h3, h4 { text-wrap: balance; line-height: 1.15; }
  p { text-wrap: pretty; }
  table { border-collapse: collapse; }
  [hidden] { display: none !important; }
}

@layer tokens {
  :root {
    color-scheme: light dark;
    --brand: #123F73;
    --brand-ink: #fff;
    --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-display: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, sans-serif;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;

    --bg: light-dark(#F3F4F7, #08090C);
    --bg-2: light-dark(#ECEEF2, #0E1015);
    --surface: light-dark(#FFFFFF, #14161C);
    --surface-2: light-dark(#F7F8FA, #1A1D24);
    --glass: light-dark(rgb(255 255 255 / .66), rgb(24 26 33 / .58));
    --glass-strong: light-dark(rgb(255 255 255 / .86), rgb(26 28 36 / .86));
    --glass-tint: light-dark(rgb(255 255 255 / .5), rgb(255 255 255 / .04));
    --stroke: light-dark(rgb(16 24 40 / .08), rgb(255 255 255 / .08));
    --stroke-2: light-dark(rgb(16 24 40 / .14), rgb(255 255 255 / .15));
    --hi: light-dark(rgb(255 255 255 / .95), rgb(255 255 255 / .07));
    --text: light-dark(#0A1020, #F1F3F7);
    --text-2: light-dark(#475266, #A4ADBC);
    --text-3: light-dark(#8690A2, #6C7586);
    --fill: light-dark(rgb(16 24 40 / .05), rgb(255 255 255 / .06));
    --fill-2: light-dark(rgb(16 24 40 / .09), rgb(255 255 255 / .1));

    --brand-text: light-dark(var(--brand), color-mix(in oklab, var(--brand) 45%, white));
    --brand-fill: light-dark(var(--brand), color-mix(in oklab, var(--brand) 76%, white));
    --brand-soft: color-mix(in oklab, var(--brand) 11%, transparent);
    --brand-soft-2: color-mix(in oklab, var(--brand) 20%, transparent);

    --ok: light-dark(#0F7A45, #38D39F);
    --warn: light-dark(#A85A00, #F7B955);
    --bad: light-dark(#BE1E2D, #FF7A7A);
    --info: light-dark(#1F5BD6, #78A9FF);
    --ok-bg: color-mix(in oklab, var(--ok) 13%, transparent);
    --warn-bg: color-mix(in oklab, var(--warn) 15%, transparent);
    --bad-bg: color-mix(in oklab, var(--bad) 13%, transparent);
    --info-bg: color-mix(in oklab, var(--info) 13%, transparent);

    --r-xs: 8px; --r-s: 12px; --r-m: 16px; --r-l: 22px; --r-xl: 30px; --r-pill: 999px;
    --sh-1: 0 1px 1px rgb(10 16 32 / .03), 0 2px 10px -2px rgb(10 16 32 / .06);
    --sh-2: 0 1px 2px rgb(10 16 32 / .04), 0 12px 32px -8px rgb(10 16 32 / .14);
    --sh-3: 0 2px 6px rgb(10 16 32 / .06), 0 30px 80px -12px rgb(10 16 32 / .28);
    --blur: blur(22px) saturate(180%);
    --ease: cubic-bezier(.2, .8, .2, 1);
    --spring: cubic-bezier(.34, 1.4, .64, 1);
    --gutter: max(16px, env(safe-area-inset-left));
    --nav-h: 64px;
  }
  :root[data-theme="light"] { color-scheme: light; }
  :root[data-theme="dark"] { color-scheme: dark; }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) { --sh-1: 0 1px 1px rgb(0 0 0 / .3), 0 2px 12px -2px rgb(0 0 0 / .4); --sh-2: 0 1px 2px rgb(0 0 0 / .4), 0 16px 40px -8px rgb(0 0 0 / .55); --sh-3: 0 30px 90px -10px rgb(0 0 0 / .7); }
  }
  :root[data-theme="dark"] { --sh-1: 0 1px 1px rgb(0 0 0 / .3), 0 2px 12px -2px rgb(0 0 0 / .4); --sh-2: 0 1px 2px rgb(0 0 0 / .4), 0 16px 40px -8px rgb(0 0 0 / .55); --sh-3: 0 30px 90px -10px rgb(0 0 0 / .7); }
}

@layer base {
  html { scroll-behavior: smooth; scrollbar-gutter: stable; }
  body {
    font-family: var(--font); font-size: 15px; color: var(--text); background: var(--bg);
    background-image:
      radial-gradient(60rem 36rem at 110% -10%, color-mix(in oklab, var(--brand) 16%, transparent), transparent 70%),
      radial-gradient(50rem 30rem at -20% 10%, color-mix(in oklab, var(--brand) 9%, transparent), transparent 70%);
    background-attachment: fixed;
    overflow-x: clip;
  }
  ::selection { background: var(--brand-soft-2); }
  :focus-visible { outline: 3px solid color-mix(in oklab, var(--brand) 55%, transparent); outline-offset: 2px; border-radius: 6px; }
  h1 { font-family: var(--font-display); font-size: clamp(2rem, 1.2rem + 3.2vw, 3.6rem); font-weight: 760; letter-spacing: -0.035em; }
  h2 { font-family: var(--font-display); font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.25rem); font-weight: 720; letter-spacing: -0.028em; }
  h3 { font-size: 1.125rem; font-weight: 680; letter-spacing: -0.015em; }
  h4 { font-size: .95rem; font-weight: 650; }
  small, .small { font-size: .82rem; }
  code, .mono { font-family: var(--mono); font-feature-settings: "zero"; }
  .num { font-variant-numeric: tabular-nums; }
  hr { border: 0; border-top: 1px solid var(--stroke); }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; animation-timing-function: var(--ease); }
  @media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; } }
}

@layer layout {
  .wrap { width: min(1200px, 100% - var(--gutter) * 2); margin-inline: auto; }
  .wrap-narrow { width: min(880px, 100% - var(--gutter) * 2); margin-inline: auto; }
  .stack { display: grid; gap: var(--gap, 16px); align-content: start; }
  .row { display: flex; gap: var(--gap, 12px); align-items: center; flex-wrap: wrap; }
  .row.nowrap { flex-wrap: nowrap; }
  .spread { justify-content: space-between; }
  .grow { flex: 1 1 auto; min-width: 0; }
  .grid { display: grid; gap: var(--gap, 16px); grid-template-columns: repeat(auto-fit, minmax(min(var(--min, 260px), 100%), 1fr)); }
  .section { padding-block: clamp(48px, 8vw, 96px); }
  main { display: block; }
}

@layer components {
  /* Superficies */
  .glass {
    background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    border: 1px solid var(--stroke); box-shadow: var(--sh-1), inset 0 1px 0 var(--hi);
  }
  .card {
    background: color-mix(in oklab, var(--surface) 88%, transparent); border: 1px solid var(--stroke);
    border-radius: var(--r-l); box-shadow: var(--sh-1), inset 0 1px 0 var(--hi); padding: clamp(16px, 2.4vw, 24px);
    -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    &.flat { box-shadow: none; }
    &.tight { padding: 14px; }
    &.hover { transition: transform .25s var(--ease), box-shadow .25s var(--ease); &:hover { transform: translateY(-2px); box-shadow: var(--sh-2), inset 0 1px 0 var(--hi); } }
  }
  .card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
  .muted { color: var(--text-2); }
  .faint { color: var(--text-3); }
  .eyebrow { font-size: .75rem; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
  .divider { height: 1px; background: var(--stroke); margin-block: 14px; }

  /* Iconos */
  .i { width: 1.25em; height: 1.25em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  .i-sm { width: 1em; height: 1em; }
  .i-lg { width: 1.6em; height: 1.6em; }

  /* Botones */
  .btn {
    --h: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h); padding-inline: 18px;
    border-radius: var(--r-pill); font-weight: 600; font-size: .94rem; white-space: nowrap; letter-spacing: -0.005em;
    background: var(--fill); color: var(--text); border: 1px solid var(--stroke);
    transition: transform .18s var(--ease), background .2s, box-shadow .2s, opacity .2s; user-select: none; -webkit-tap-highlight-color: transparent;
    &:hover { background: var(--fill-2); }
    &:active { transform: scale(.97); }
    &:disabled, &[aria-disabled="true"] { opacity: .45; pointer-events: none; }
    &.primary { background: var(--brand-fill); color: var(--brand-ink); border-color: transparent; box-shadow: 0 6px 18px -6px color-mix(in oklab, var(--brand) 70%, transparent), inset 0 1px 0 rgb(255 255 255 / .18);
      &:hover { background: color-mix(in oklab, var(--brand) 88%, white); } }
    &.glassy { background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--sh-1), inset 0 1px 0 var(--hi); }
    &.ghost { background: transparent; border-color: transparent; &:hover { background: var(--fill); } }
    &.danger { color: var(--bad); }
    &.ok { background: var(--ok); color: #fff; border-color: transparent; }
    &.sm { --h: 34px; padding-inline: 12px; font-size: .85rem; }
    &.lg { --h: 54px; padding-inline: 26px; font-size: 1.02rem; }
    &.icon { width: var(--h); padding: 0; }
    &.block { width: 100%; }
    &.loading { color: transparent !important; position: relative; pointer-events: none;
      &::after { content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--text-3); border-top-color: transparent; animation: spin .7s linear infinite; }
      &.primary::after { border-color: var(--brand-ink); border-top-color: transparent; } }
  }
  @keyframes spin { to { rotate: 360deg; } }

  /* Formularios */
  .field { display: grid; gap: 6px; min-width: 0;
    & > span:first-child, & > label { font-size: .8rem; font-weight: 600; color: var(--text-2); }
    & .hint { font-size: .78rem; color: var(--text-3); }
  }
  .input, .select, .textarea {
    width: 100%; height: 46px; padding-inline: 14px; border-radius: var(--r-s); border: 1px solid var(--stroke-2);
    background: light-dark(rgb(255 255 255 / .85), rgb(255 255 255 / .04)); color: var(--text); font-size: 1rem;
    transition: border-color .15s, box-shadow .15s, background .15s; appearance: none;
    &::placeholder { color: var(--text-3); }
    &:hover { border-color: color-mix(in oklab, var(--text) 25%, transparent); }
    &:focus { outline: none; border-color: var(--brand-text); box-shadow: 0 0 0 4px var(--brand-soft); }
    &:user-invalid { border-color: var(--bad); }
  }
  /* La lista nativa no hereda el fondo translúcido: se le da un fondo sólido según el tema */
  .select option, .select optgroup { background-color: var(--surface); color: var(--text); }
  .select optgroup { color: var(--text-3); font-weight: 700; }
  .select { padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238690A2' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
  .textarea { height: auto; min-height: 96px; padding-block: 12px; resize: vertical; line-height: 1.45; }
  .input.sm, .select.sm { height: 36px; font-size: .9rem; border-radius: 10px; }
  .input-icon { position: relative; display: block;
    & > .i { position: absolute; left: 14px; top: 50%; translate: 0 -50%; color: var(--text-3); pointer-events: none; }
    & > .input { padding-left: 42px; }
  }
  .check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500;
    & input { width: 20px; height: 20px; accent-color: var(--brand); } }
  .switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500;
    & input { appearance: none; width: 46px; height: 28px; border-radius: 99px; background: var(--fill-2); transition: background .2s; position: relative; flex: none;
      &::after { content: ""; position: absolute; top: 2px; left: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgb(0 0 0 / .25); transition: translate .25s var(--spring); }
      &:checked { background: var(--ok); &::after { translate: 18px 0; } } } }
  .form-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }

  /* Control segmentado estilo iOS */
  .seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 3px; gap: 2px; border-radius: 13px; background: var(--fill); border: 1px solid var(--stroke); max-width: 100%; overflow-x: auto; scrollbar-width: none;
    & label, & button, & a { position: relative; display: grid; place-items: center; min-height: 36px; padding: 6px 14px; border-radius: 10px; font-weight: 600; font-size: .88rem; color: var(--text-2); cursor: pointer; white-space: nowrap; transition: color .2s, background .2s, box-shadow .2s; }
    & input { position: absolute; opacity: 0; pointer-events: none; }
    & label:has(input:checked), & button[aria-pressed="true"], & a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgb(0 0 0 / .12), 0 0 0 .5px var(--stroke-2); }
    & label:has(input:focus-visible) { outline: 3px solid var(--brand-soft-2); }
    &.block { display: grid; width: 100%; }
  }

  /* Insignias */
  .badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding-inline: 10px; border-radius: 99px; font-size: .78rem; font-weight: 650; white-space: nowrap; background: var(--fill); color: var(--text-2);
    &::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .9; }
    &.plain::before { display: none; }
    &.ok { background: var(--ok-bg); color: var(--ok); } &.warn { background: var(--warn-bg); color: var(--warn); }
    &.bad { background: var(--bad-bg); color: var(--bad); } &.info { background: var(--info-bg); color: var(--info); }
    &.brand { background: var(--brand-soft); color: var(--brand-text); }
    &.lg { height: 32px; padding-inline: 14px; font-size: .86rem; }
  }
  .live { display: inline-flex; align-items: center; gap: 7px; font-size: .78rem; font-weight: 650; color: var(--ok);
    &::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; }
    &.off { color: var(--text-3); &::before { animation: none; } } }
  @keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 55%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

  /* Logo */
  .logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 760; letter-spacing: -0.02em; font-size: 1.05rem; min-width: 0;
    & .mark { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; background: var(--brand); color: var(--brand-ink); font-size: .82rem; font-weight: 800; flex: none; box-shadow: inset 0 1px 0 rgb(255 255 255 / .25), 0 4px 12px -4px color-mix(in oklab, var(--brand) 60%, transparent); overflow: hidden;
      & img { width: 100%; height: 100%; object-fit: contain; background: #fff; } }
    & span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
      & > span { color: var(--text-2); font-weight: 600; } }
  }

  /* Barra superior flotante */
  .topbar { position: sticky; top: 0; z-index: 40; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: 10px; }
  .topbar-inner { display: flex; align-items: center; gap: 12px; height: var(--nav-h); padding-inline: 12px 10px; border-radius: 22px; }
  .topbar nav { display: flex; gap: 2px; margin-inline: auto;
    & a { padding: 8px 14px; border-radius: 99px; font-weight: 560; font-size: .92rem; color: var(--text-2); transition: background .2s, color .2s;
      &:hover, &[aria-current="page"] { background: var(--fill); color: var(--text); } } }
  @media (width < 860px) { .topbar nav { display: none; } .topbar .hide-m { display: none; } }
  @media (width >= 860px) { .topbar .hide-desk { display: none; } }

  /* Diálogos y hojas */
  dialog.modal {
    margin: auto; width: min(560px, 100% - 24px); max-height: min(88dvh, 900px); padding: 0; border: 1px solid var(--stroke); border-radius: var(--r-xl); color: var(--text);
    background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--sh-3); overflow: hidden;
    &.wide { width: min(880px, 100% - 24px); }
    &::backdrop { background: rgb(6 10 20 / .38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
    &[open] { display: flex; flex-direction: column; animation: pop .32s var(--spring); }
    & .modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px 10px; & h3 { display: flex; align-items: center; gap: 8px; } }
    & .modal-body { padding: 8px 20px 20px; overflow: auto; overscroll-behavior: contain; }
    & .modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--stroke); flex-wrap: wrap; }
    @media (width < 640px) {
      width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 26px 26px 0 0; max-height: 92dvh;
      &[open] { animation: sheet .38s var(--ease); }
      & .modal-foot .btn { flex: 1; }
    }
  }
  dialog.drawer {
    margin: 0 0 0 auto; height: 100dvh; max-height: 100dvh; width: min(560px, 100%); padding: 0; border: 0; border-left: 1px solid var(--stroke); color: var(--text);
    background: var(--glass-strong); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); box-shadow: var(--sh-3);
    &::backdrop { background: rgb(6 10 20 / .3); }
    &[open] { display: flex; flex-direction: column; animation: slide .34s var(--ease); }
  }
  @keyframes pop { from { opacity: 0; scale: .94; } }
  @keyframes sheet { from { translate: 0 100%; } }
  @keyframes slide { from { translate: 100% 0; } }

  /* Avisos */
  .toasts { position: fixed; z-index: 1000; inset: auto 0 calc(16px + env(safe-area-inset-bottom)) 0; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding-inline: 16px; }
  .toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; font-weight: 560; font-size: .92rem; max-width: 520px;
    background: light-dark(rgb(20 22 28 / .9), rgb(245 246 250 / .92)); color: light-dark(#fff, #0A1020); box-shadow: var(--sh-2);
    -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur); animation: toast .4s var(--spring);
    & .i { color: var(--tone, inherit); } }
  @keyframes toast { from { opacity: 0; translate: 0 16px; scale: .96; } }

  /* Esqueletos */
  .skel { border-radius: 10px; background: linear-gradient(90deg, var(--fill) 25%, var(--fill-2) 50%, var(--fill) 75%); background-size: 300% 100%; animation: shimmer 1.4s infinite; min-height: 16px; }
  @keyframes shimmer { to { background-position: -150% 0; } }

  /* Vacío */
  .empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 48px 16px; color: var(--text-2);
    & .ico { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--fill); color: var(--text-3); } }

  /* KPI */
  .kpis { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); }
  @media (width < 640px) { .kpis { grid-template-columns: 1fr 1fr; } .kpis .kpi { padding: 14px; } .kpis .k-foot { display: none; } }
  .kpi { display: grid; gap: 4px; padding: 18px; border-radius: var(--r-l);
    & .k-label { font-size: .8rem; font-weight: 600; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
    & .k-value { font-family: var(--font-display); font-size: clamp(1.5rem, 1.2rem + 1vw, 2rem); font-weight: 740; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
    & .k-foot { font-size: .78rem; color: var(--text-3); }
    & .k-ico { width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); }
  }

  /* Pestañas de etapa (panel) */
  .stages { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(176px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x mandatory; scrollbar-width: none;
    & button { scroll-snap-align: start; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-radius: 18px; text-align: left; font-weight: 620; color: var(--text-2); white-space: nowrap;
      background: var(--glass); border: 1px solid var(--stroke); box-shadow: var(--sh-1), inset 0 1px 0 var(--hi); transition: all .2s var(--ease);
      & .count { min-width: 34px; height: 28px; padding-inline: 8px; display: grid; place-items: center; border-radius: 99px; background: var(--fill); font-size: .82rem; font-variant-numeric: tabular-nums; color: var(--text); }
      &[aria-pressed="true"] { background: var(--brand-fill); color: var(--brand-ink); border-color: transparent; box-shadow: 0 10px 24px -10px color-mix(in oklab, var(--brand) 80%, transparent);
        & .count { background: rgb(255 255 255 / .22); color: inherit; } } }
  }

  /* Chips de filtro */
  .chips { display: flex; gap: 8px; flex-wrap: wrap;
    & .chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding-inline: 12px; border-radius: 99px; font-size: .84rem; font-weight: 600; background: var(--fill); color: var(--text-2); border: 1px solid transparent;
      &[aria-pressed="true"], &:has(input:checked) { background: var(--brand-soft); color: var(--brand-text); border-color: color-mix(in oklab, var(--brand) 30%, transparent); }
      & .n { font-variant-numeric: tabular-nums; opacity: .8; } } }

  /* Tabla responsiva (container query: se vuelve tarjetas en contenedores estrechos) */
  .table-wrap { container-type: inline-size; }
  .table { width: 100%; font-size: .9rem;
    & th { text-align: left; font-size: .76rem; font-weight: 650; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 1px solid var(--stroke); white-space: nowrap; position: sticky; top: 0; background: var(--surface-2); z-index: 1; }
    & td { padding: 12px; border-bottom: 1px solid var(--stroke); vertical-align: middle; }
    & tbody tr { transition: background .15s; cursor: pointer; content-visibility: auto; contain-intrinsic-size: auto 60px; }
    & tbody tr:hover { background: var(--fill); }
    & tbody tr:has(input:checked) { background: var(--brand-soft); }
    & .cell-main { font-weight: 620; }
    & .cell-sub { font-size: .8rem; color: var(--text-3); }
    & input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }
  }
  @container (width < 760px) {
    .table thead { display: none; }
    .table, .table tbody { display: block; }
    .table tbody tr { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 14px 6px; border-bottom: 1px solid var(--stroke); }
    .table td { padding: 0; border: 0; }
    .table td[data-c="sel"] { grid-column: 1; grid-row: 1 / span 3; align-self: center; }
    .table td[data-c="code"] { grid-column: 2; grid-row: 1; }
    .table td[data-c="status"] { grid-column: 3; grid-row: 1; justify-self: end; }
    .table td[data-c="route"] { grid-column: 2 / 4; grid-row: 2; }
    .table td[data-c="people"] { grid-column: 2; grid-row: 3; min-width: 0; }
    .table td[data-c="price"] { grid-column: 3; grid-row: 3; justify-self: end; text-align: right; }
    .table td[data-c="hide-m"] { display: none; }
  }

  /* Línea de tiempo */
  .timeline { list-style: none; padding: 0; display: grid; gap: 0; position: relative; }
  .tl-item { display: grid; grid-template-columns: 36px 1fr; gap: 12px; position: relative; padding-bottom: 18px;
    &::before { content: ""; position: absolute; left: 17px; top: 34px; bottom: 0; width: 2px; background: var(--stroke-2); border-radius: 2px; }
    &:last-child::before { display: none; }
    & .dot { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--fill); color: var(--text-2); border: 1px solid var(--stroke); }
    &.current .dot { background: var(--brand-fill); color: var(--brand-ink); border-color: transparent; box-shadow: 0 0 0 5px var(--brand-soft); }
    &.warn .dot { background: var(--warn-bg); color: var(--warn); }
    &.ok.current .dot { background: var(--ok); color: #fff; box-shadow: 0 0 0 5px var(--ok-bg); }
    & .t-title { font-weight: 650; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
    & .t-meta { font-size: .82rem; color: var(--text-3); }
    & .t-note { font-size: .88rem; color: var(--text-2); margin-top: 4px; }
  }
  details.tl-group { border-top: 1px solid var(--stroke);
    &:first-of-type { border-top: 0; }
    & > summary { list-style: none; display: flex; align-items: center; gap: 12px; padding: 14px 0; cursor: pointer;
      &::-webkit-details-marker { display: none; }
      & .chev { margin-left: auto; transition: rotate .25s var(--ease); color: var(--text-3); } }
    &[open] > summary .chev { rotate: 180deg; }
    & > .timeline { padding: 4px 0 6px 6px; }
  }
  details.tl-group::details-content { transition: height .3s var(--ease), content-visibility .3s allow-discrete; height: 0; overflow: clip; }
  details.tl-group[open]::details-content { height: auto; }
  @supports (interpolate-size: allow-keywords) { :root { interpolate-size: allow-keywords; } }

  /* Caja */
  .cash-move.voided { opacity: .55; & b.num { text-decoration: line-through; } }
  button.link { color: var(--brand-text); font-weight: 620; text-decoration: underline; text-underline-offset: 2px; padding: 0; background: none; border: 0; cursor: pointer; font: inherit; }

  /* Firma en pantalla */
  .sig-pad { position: relative; border-radius: 14px; border: 1.5px dashed var(--stroke-2); background: #fff; overflow: hidden; touch-action: none;
    & canvas { display: block; width: 100%; height: auto; aspect-ratio: 3 / 1; cursor: crosshair; }
    & .sig-hint { position: absolute; inset: auto 0 10px; text-align: center; color: #9AA1AD; font-size: .8rem; pointer-events: none; border-top: 1px solid #E3E6EC; margin-inline: 12%; padding-top: 4px; }
    &.signed .sig-hint { display: none; }
    & .sig-clear { position: absolute; top: 6px; right: 6px; color: #5B6474; } }
  .sig-thumb { width: 150px; height: 50px; object-fit: contain; background: #fff; border-radius: 8px; border: 1px solid var(--stroke); }
  /* Firma en el comprobante impreso */
  .dl-sig { margin-top: 6px; text-align: center; font-size: 7.5pt; color: #000;
    & img { display: block; width: 100%; max-width: 62mm; height: 18mm; object-fit: contain; margin: 0 auto -2mm; }
    & span { display: block; border-top: 1px solid #000; padding-top: 2px; }
    &.blank span { margin-top: 16mm; } }

  /* Mi trabajo: cola de tareas del puesto */
  .tasks { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 8px; }
  .task { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--fill); border: 1px solid var(--stroke); transition: background .2s, transform .2s var(--ease);
    &:hover { background: var(--brand-soft); transform: translateY(-1px); }
    & b { display: block; font-size: .92rem; } & small { display: block; color: var(--text-3); font-size: .76rem; line-height: 1.3; }
    & .k-ico { width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand-text); }
    & .task-n { font-size: 1.35rem; font-weight: 760; font-variant-numeric: tabular-nums; color: var(--brand-text); }
    &.zero { opacity: .6; & .task-n { color: var(--text-3); } }
  }
  /* Progreso por etapas */
  .stepper { display: grid; grid-template-columns: repeat(5, 1fr); position: relative; }
  .step { display: grid; justify-items: center; text-align: center; gap: 6px; position: relative; z-index: 1;
    & .s-dot { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 2px dashed var(--stroke-2); color: var(--text-3); transition: all .4s var(--ease); }
    & .s-label { font-size: .82rem; font-weight: 650; color: var(--text-3); }
    & .s-date { font-size: .74rem; color: var(--text-3); }
    &.done .s-dot { background: var(--brand-fill); border: 0; color: var(--brand-ink); }
    &.done .s-label { color: var(--text); }
    &.now .s-dot { box-shadow: 0 0 0 6px var(--brand-soft); animation: breathe 2.4s infinite var(--ease); }
    &.warn .s-dot { background: var(--warn); }
    &.final.done .s-dot { background: var(--ok); color: #fff; }
    &::before { content: ""; position: absolute; top: 21px; right: 50%; width: 100%; height: 3px; background: var(--stroke-2); z-index: -1; border-radius: 3px; }
    &:first-child::before { display: none; }
    &.done::before { background: var(--brand-fill); }
    &.final.done::before { background: linear-gradient(90deg, var(--brand), var(--ok)); }
  }
  @keyframes breathe { 50% { box-shadow: 0 0 0 10px transparent; } }
  @media (width < 420px) { .step .s-dot { width: 38px; height: 38px; } .step::before { top: 18px; } .step .s-label { font-size: .74rem; } }

  /* Mapa de red */
  .netmap { width: 100%; height: auto;
    & .road { stroke: var(--stroke-2); stroke-width: 2; fill: none; stroke-linecap: round; }
    & .road.on { stroke: var(--brand-text); stroke-width: 3.5; }
    & .road.done { stroke: var(--brand-text); stroke-width: 3.5; }
    & .road.todo { stroke: var(--brand-text); stroke-width: 3; stroke-dasharray: 2 7; opacity: .7; }
    & .city { fill: var(--surface); stroke: var(--text-3); stroke-width: 1.5; }
    & .city.cov { fill: var(--brand-text); stroke: var(--surface); stroke-width: 2; }
    & .city.end { fill: var(--brand-text); stroke: var(--surface); stroke-width: 2.5; }
    & text { font-size: 10.5px; font-weight: 600; fill: var(--text-2); paint-order: stroke; stroke: var(--bg); stroke-width: 3px; stroke-linejoin: round; }
    & text.strong { fill: var(--text); font-weight: 750; font-size: 12px; }
    & .pulse { fill: var(--brand-text); animation: ping 1.8s infinite; transform-box: fill-box; transform-origin: center; }
    & .truck { fill: var(--brand); stroke: var(--surface); stroke-width: 2.5; }
  }
  @keyframes ping { 0% { opacity: .5; scale: 1; } 100% { opacity: 0; scale: 3.2; } }

  /* Barra inferior (móvil) */
  .tabbar { position: fixed; z-index: 50; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); display: none; grid-auto-flow: column; grid-auto-columns: 1fr; padding: 6px; border-radius: 26px;
    & a, & button { display: grid; justify-items: center; gap: 2px; padding: 8px 4px; border-radius: 18px; font-size: .68rem; font-weight: 650; color: var(--text-2);
      &[aria-current="page"] { color: var(--brand-text); background: var(--brand-soft); } }
  }

  /* Calificación */
  .stars { display: inline-flex; gap: 4px;
    & button { color: var(--text-3); padding: 4px; border-radius: 8px; transition: transform .15s var(--spring), color .15s; &:hover { transform: scale(1.15); } }
    & button.on { color: #F5A524; & .i { fill: currentColor; } } }

  .kbd { font-family: var(--mono); font-size: .78rem; padding: 2px 6px; border-radius: 6px; background: var(--fill); border: 1px solid var(--stroke); }
  .code-big { font-family: var(--mono); font-weight: 700; letter-spacing: .04em; font-size: clamp(1.3rem, 1rem + 1.5vw, 1.9rem); }
  .pin { font-family: var(--mono); font-size: 2rem; font-weight: 800; letter-spacing: .3em; color: var(--brand-text); }
  .avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); font-weight: 750; font-size: .8rem; flex: none; }
  .list { display: grid; & > * + * { border-top: 1px solid var(--stroke); } }
  .list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; min-width: 0; }
  .dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: .9rem;
    & dt { color: var(--text-3); } & dd { margin: 0; font-weight: 560; text-align: right; overflow-wrap: anywhere; } }
  .notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-m); background: var(--warn-bg); color: var(--text); border: 1px solid color-mix(in oklab, var(--warn) 30%, transparent);
    & > .i { color: var(--warn); margin-top: 2px; }
    &.info { background: var(--info-bg); border-color: color-mix(in oklab, var(--info) 30%, transparent); & > .i { color: var(--info); } }
    &.ok { background: var(--ok-bg); border-color: color-mix(in oklab, var(--ok) 30%, transparent); & > .i { color: var(--ok); } } }
  .bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding-top: 10px;
    & .bar { flex: 1; display: grid; align-items: end; gap: 3px; height: 100%; position: relative; }
    & .bar i { display: block; border-radius: 6px 6px 3px 3px; background: var(--brand-soft-2); min-height: 3px; transition: height .6s var(--ease); }
    & .bar i.d { background: var(--brand); }
    & .bar small { position: absolute; bottom: -20px; left: 50%; translate: -50% 0; font-size: .68rem; color: var(--text-3); white-space: nowrap; }
  }
  .meter { height: 8px; border-radius: 8px; background: var(--fill-2); overflow: hidden; & i { display: block; height: 100%; border-radius: inherit; background: var(--brand); } }
}

@layer pages {
  /* App shell panel */
  .shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100dvh; }
  .side { position: sticky; top: 0; height: 100dvh; padding: 14px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--stroke); background: var(--glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
    & .side-nav { display: grid; gap: 2px; margin-top: 10px; }
    & .side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 580; color: var(--text-2); transition: background .15s, color .15s;
      &:hover { background: var(--fill); color: var(--text); }
      &[aria-current="page"] { background: var(--brand-soft); color: var(--brand-text); }
      & .tag { margin-left: auto; font-size: .72rem; padding: 2px 8px; border-radius: 99px; background: var(--warn-bg); color: var(--warn); font-weight: 700; } }
    & .side-label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); padding: 14px 12px 4px; }
    & .side-foot { margin-top: auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px;
      & > * { min-width: 0; } & .btn:not(.icon) { overflow: hidden; text-overflow: ellipsis; }
      & .row { flex-wrap: wrap; row-gap: 2px; } & .row .grow { flex: 1 1 130px; }
      & .row .btn.icon { --h: 34px; width: 34px; flex: none; } & .side-actions { margin-left: auto; flex: none; } }
  }
  .main { min-width: 0; padding: 20px clamp(16px, 3vw, 36px) 48px; }
  .page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
    & h1 { font-size: clamp(1.6rem, 1.2rem + 1.4vw, 2.2rem); } }
  @media (width < 960px) {
    .shell { grid-template-columns: 1fr; }
    .side { display: none; }
    .tabbar { display: grid; }
    .main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); padding-top: max(14px, env(safe-area-inset-top)); }
  }

  /* Landing */
  .hero { padding-block: clamp(40px, 8vw, 100px) clamp(32px, 5vw, 64px); text-align: center; display: grid; justify-items: center; gap: 20px; }
  .hero p.lead { font-size: clamp(1.02rem, .95rem + .4vw, 1.25rem); color: var(--text-2); max-width: 640px; }
  .track-box { width: min(640px, 100%); padding: 8px; border-radius: 24px; display: flex; gap: 8px;
    & .input { border: 0; background: transparent; height: 52px; font-size: 1.08rem; font-family: var(--mono); letter-spacing: .03em; &:focus { box-shadow: none; } &::placeholder { font-family: var(--font); letter-spacing: 0; } }
    & .btn { --h: 52px; }
    @media (width < 520px) { flex-direction: column; & .btn { width: 100%; } }
  }
  .feature { display: grid; gap: 10px; align-content: start;
    & .f-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-text); } }
  .how { counter-reset: how; display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
    & li { list-style: none; counter-increment: how; position: relative; padding-top: 44px;
      &::before { content: counter(how, decimal-leading-zero); position: absolute; top: 0; font-family: var(--mono); font-size: 1.6rem; font-weight: 800; color: var(--brand-text); opacity: .9; } } }
  .stat-row { display: flex; gap: clamp(18px, 4vw, 48px); justify-content: center; flex-wrap: wrap;
    & div { display: grid; justify-items: center; }
    & b { font-family: var(--font-display); font-size: clamp(1.5rem, 1.2rem + 1vw, 2.1rem); letter-spacing: -0.03em; }
    & span { font-size: .82rem; color: var(--text-3); } }
  .faq details { border-bottom: 1px solid var(--stroke);
    & summary { list-style: none; cursor: pointer; padding: 18px 0; font-weight: 640; display: flex; justify-content: space-between; gap: 16px; &::-webkit-details-marker { display: none; } }
    & summary::after { content: "+"; font-size: 1.4rem; line-height: 1; color: var(--text-3); transition: rotate .25s; }
    &[open] summary::after { rotate: 45deg; }
    & p { padding-bottom: 18px; color: var(--text-2); } }
  .footer { padding-block: 40px calc(40px + env(safe-area-inset-bottom)); border-top: 1px solid var(--stroke); color: var(--text-2); font-size: .9rem; }

  /* Rastreo */
  .track-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start;
    @media (width < 980px) { grid-template-columns: 1fr; } }
  .status-hero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: clamp(20px, 3vw, 30px); color: var(--brand-ink);
    background: radial-gradient(120% 140% at 100% 0%, color-mix(in oklab, var(--brand) 70%, white) 0%, var(--brand) 45%, color-mix(in oklab, var(--brand) 70%, black) 100%);
    box-shadow: 0 24px 60px -24px color-mix(in oklab, var(--brand) 80%, transparent), inset 0 1px 0 rgb(255 255 255 / .2);
    & .muted { color: color-mix(in oklab, var(--brand-ink) 72%, transparent); }
    & h2 { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.6rem); }
    & .pill { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding-inline: 12px; border-radius: 99px; background: rgb(255 255 255 / .16); border: 1px solid rgb(255 255 255 / .22); font-size: .82rem; font-weight: 650; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
    & .route-line { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; margin-top: 22px; }
    & .route-track { position: relative; height: 4px; border-radius: 4px; background: rgb(255 255 255 / .22);
      & i { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: currentColor; transition: width 1s var(--ease); }
      & b { position: absolute; top: 50%; translate: -50% -50%; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #fff; color: var(--brand); box-shadow: 0 4px 14px rgb(0 0 0 / .25); transition: left 1s var(--ease); } }
    & .city-end { display: grid; gap: 0; & b { font-size: 1.05rem; } & span { font-size: .78rem; opacity: .75; } &.r { text-align: right; } }
    &::after { content: ""; position: absolute; inset: auto -40px -80px auto; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgb(255 255 255 / .16), transparent 70%); pointer-events: none; }
    &.tone-ok { --brand: #0F7A45; --brand-ink: #fff; }
    &.tone-warn { --brand: #9A5200; --brand-ink: #fff; }
    &.tone-bad { --brand: #A11826; --brand-ink: #fff; }
  }
  .brand-strip { display: flex; align-items: center; gap: 12px; }

  /* Login */
  .auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px var(--gutter); }
  .auth-card { width: min(440px, 100%); padding: clamp(22px, 4vw, 34px); border-radius: var(--r-xl); }

  /* Escáner */
  .scan-input { font-family: var(--mono); font-size: 1.3rem; height: 60px; letter-spacing: .04em; }
  .scan-list { max-height: 52dvh; overflow: auto; }
  video.cam { width: 100%; border-radius: var(--r-m); background: #000; aspect-ratio: 4 / 3; object-fit: cover; }
  /* Control por escaneo (uno por uno) */
  .ctl-cam { position: relative; & video.cam { display: block; aspect-ratio: 16 / 10; } }
  .ctl-aim { position: absolute; inset: 22% 8%; border: 2px solid rgb(255 255 255 / .75); border-radius: 14px; pointer-events: none; box-shadow: 0 0 0 999px rgb(0 0 0 / .25);
    &::after { content: ''; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff3b30; box-shadow: 0 0 8px #ff3b30; } }
  .ctl-result { @media (min-width: 760px) { position: sticky; top: 16px; } min-height: 260px; min-width: 0;
    & .btn { white-space: normal; height: auto; min-height: 44px; padding-block: 8px; text-align: center; }
    & .btn.lg { min-height: 54px; } & .code-big { overflow-wrap: anywhere; } & dd { min-width: 0; overflow-wrap: anywhere; } }
  .ctl-steps { text-align: left; padding-left: 20px; display: grid; gap: 4px; margin-top: 6px; }
  .ctl-dl { margin: 0; }
  .ctl-piece { width: 100%; font: inherit; color: inherit; background: transparent; border: 0; cursor: pointer; border-radius: var(--r-m);
    &.on .avatar { background: var(--ok-bg); color: var(--ok); } }
  .ctl-ok { & .ico { background: var(--ok-bg); color: var(--ok); } &.warn .ico { background: var(--warn-bg); color: var(--warn); } }

  /* Etiqueta y vista previa de impresión */
  .label-prev { background: #fff; color: #000; border-radius: 12px; padding: 10px; box-shadow: var(--sh-2); width: min(360px, 100%); margin-inline: auto; }
}

@layer utilities {
  .center { text-align: center; } .right { text-align: right; }
  .mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; } .mt-4 { margin-top: 40px; }
  .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
  .w-full { width: 100%; }
  .nowrap { white-space: nowrap; }
  .ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
  .fade-in { animation: fadeUp .5s var(--ease) both; }
  @keyframes fadeUp { from { opacity: 0; translate: 0 10px; } }
  .ok-t { color: var(--ok); } .warn-t { color: var(--warn); } .bad-t { color: var(--bad); } .brand-t { color: var(--brand-text); }
  @media (width < 640px) { .hide-sm { display: none !important; } }
  @media (width >= 640px) { .only-sm { display: none !important; } }
}

@layer print {
  #print-root { display: none; }
  /* Vista previa de impresión: la hoja se ve igual que en papel */
  .print-preview .modal-body { background: color-mix(in oklab, var(--text) 6%, transparent); }
  /* Comprobante de rastreo (vista previa y A4): colores fijos de papel, marca de la empresa en --rc */
  .paper.receipt { padding: clamp(10px, 3.5%, 9mm); }
  .rc { --ink: #0E1726; --muted: #5B6474; --line: #E3E6EC; --soft: #F5F7FA;
    container-type: inline-size; font-family: var(--font); color: var(--ink); font-size: 10pt; line-height: 1.4; display: grid; gap: 14px;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
    & b { font-weight: 700; }
    & small { display: block; color: var(--muted); font-size: 8.5pt; }
    & .rc-k { display: block; font-size: 7.5pt; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
    & .rc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 16px; border-radius: 14px; background: var(--rc); color: var(--rc-ink);
      background-image: linear-gradient(135deg, rgb(255 255 255 / .16), transparent 60%); }
    & .rc-brand { display: flex; align-items: center; gap: 12px; min-width: 0;
      & b { display: block; font-size: 14pt; letter-spacing: -.01em; }
      & span:not(.rc-mark) { display: block; font-size: 8.5pt; opacity: .85; } }
    & .rc-mark { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; font-weight: 800; font-size: 12pt; background: rgb(255 255 255 / .18); box-shadow: inset 0 0 0 1px rgb(255 255 255 / .35); overflow: hidden;
      & img { width: 100%; height: 100%; object-fit: contain; background: #fff; } }
    & .rc-doc { text-align: right; font-size: 8.5pt;
      & span { display: block; opacity: .85; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; font-size: 7.5pt; }
      & b { font-size: 9.5pt; } }
    & .rc-hero { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 4px 4px 0; }
    & .rc-code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 22pt; font-weight: 800; letter-spacing: .02em; margin: 2px 0 8px; white-space: nowrap; }
    & .rc-status { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px; border-radius: 99px; font-weight: 700; color: var(--rc-tone); background: color-mix(in srgb, var(--rc-tone) 11%, #fff); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rc-tone) 30%, #fff);
      & i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; } }
    & .rc-headline { margin: 10px 0 0; font-size: 11pt; }
    & .rc-sub { margin: 4px 0 0; color: var(--muted); font-size: 8.5pt; max-width: 60ch; }
    & .rc-qr { display: grid; justify-items: center; gap: 4px; flex: none; text-align: center;
      & svg { width: 112px; height: 112px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; }
      & span { font-size: 7.5pt; color: var(--muted); max-width: 120px; } }
    & .rc-steps { list-style: none; margin: 0; padding: 14px 8px 12px; display: grid; grid-template-columns: repeat(5, 1fr); border: 1px solid var(--line); border-radius: 14px;
      & li { position: relative; display: grid; justify-items: center; text-align: center; gap: 2px; padding: 0 4px; }
      & li::before { content: ''; position: absolute; top: 13px; right: 50%; width: 100%; height: 3px; background: var(--line); }
      & li:first-child::before { display: none; }
      & li.done::before, & li.now::before { background: var(--rc); }
      & .rc-dot { position: relative; z-index: 1; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: 9pt; background: #fff; color: var(--muted); box-shadow: inset 0 0 0 2px var(--line); }
      & li.done .rc-dot { background: var(--rc); color: var(--rc-ink); box-shadow: none; }
      & li.now .rc-dot { background: #fff; color: var(--rc); box-shadow: inset 0 0 0 3px var(--rc), 0 0 0 4px color-mix(in srgb, var(--rc) 18%, #fff); }
      & b { font-size: 9pt; margin-top: 4px; }
      & li:not(.done):not(.now) b { color: var(--muted); font-weight: 600; } }
    & .rc-route { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--soft); border: 1px solid var(--line);
      & b { display: block; font-size: 13pt; letter-spacing: -.01em; }
      & .rc-end { text-align: right; } }
    & .rc-line { display: grid; gap: 4px; text-align: center; min-width: 60px;
      & i { position: relative; display: block; height: 2px; background: repeating-linear-gradient(90deg, var(--rc) 0 6px, transparent 6px 11px); }
      & i::after { content: ''; position: absolute; right: -2px; top: -4px; border: 5px solid transparent; border-left: 7px solid var(--rc); border-right: 0; } }
    & .rc-grid { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
    & .rc-item { padding: 10px 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); min-width: 0;
      &:nth-child(3n) { border-right: 0; }
      &:nth-last-child(-n+3) { border-bottom: 0; }
      & .rc-v { display: block; font-weight: 650; margin-top: 2px; overflow-wrap: anywhere; } }
    & .rc-chip { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 7.5pt; font-weight: 700; color: var(--rc); background: color-mix(in srgb, var(--rc) 12%, #fff); vertical-align: 1px; }
    & .rc-track { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px 6px;
      & h4 { margin: 0 0 10px; font-size: 11.5pt; color: var(--ink); }
      & ol { list-style: none; margin: 0 0 0 13px; padding: 2px 0 6px 22px; border-left: 2px solid var(--line); }
      & li { display: grid; grid-template-columns: 122px 1fr; gap: 12px; padding: 6px 0; position: relative; break-inside: avoid; }
      & li::before { content: ''; position: absolute; left: -28px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px var(--muted); }
      & li.now::before { background: var(--rc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--rc) 20%, #fff); }
      & .rc-when { color: var(--muted); font-size: 8.5pt; padding-top: 1px; } }
    & .rc-group { padding-bottom: 6px; break-inside: avoid;
      & + .rc-group { border-top: 1px solid var(--line); padding-top: 10px; }
      &.done ol, &.now ol { border-left-color: color-mix(in srgb, var(--rc) 45%, #fff); } }
    & .rc-ghead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px;
      & b { font-size: 10.5pt; }
      & small { flex-basis: 100%; padding-left: 36px; margin-top: -2px; } }
    & .rc-gdot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--rc); color: var(--rc-ink); font-size: 9pt; font-weight: 800; }
    & .rc-foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; padding-top: 12px; border-top: 2px solid var(--ink);
      & .rc-bar svg { height: 44px; width: auto; max-width: 100%; display: block; }
      & .rc-contact { display: grid; gap: 2px; text-align: right; font-size: 8.5pt; color: var(--muted); overflow-wrap: anywhere;
        & b { color: var(--ink); } } }
    & .rc-powered { text-align: center; font-size: 7.5pt; color: #9AA1AD; letter-spacing: .04em; }
    /* Hoja angosta (celular): una columna */
    @container (max-width: 520px) {
      & .rc-hero { flex-direction: column; align-items: flex-start; }
      & .rc-qr { display: flex; align-items: center; gap: 10px; text-align: left;
        & svg { width: 86px; height: 86px; } }
      & .rc-code { font-size: 17pt; }
      & .rc-steps small { display: none; }
      & .rc-route { grid-template-columns: 1fr;
        & .rc-end, & .rc-line { text-align: left; } }
      & .rc-grid { grid-template-columns: 1fr 1fr; }
      & .rc-item { border-right: 1px solid var(--line) !important; border-bottom: 1px solid var(--line) !important;
        &:nth-child(2n) { border-right: 0 !important; }
        &:nth-last-child(-n+2) { border-bottom: 0 !important; } }
      & .rc-track li { grid-template-columns: 1fr; gap: 0; }
      & .rc-doc, & .rc-contact { text-align: left; }
    }
  }
  /* Guía del remitente · ticket térmico 80 mm (solo negro) */
  .paper.ticket { width: 80mm; max-width: 100%; padding: 4mm 4mm 6mm; border-radius: 4px; }
  .gt { width: 72mm; max-width: 100%; margin-inline: auto; font-family: Arial, Helvetica, sans-serif; color: #000; font-size: 8.5pt; line-height: 1.3; display: grid; gap: 2px;
    & hr { border: 0; border-top: 1px dashed #000; margin: 5px 0; width: 100%; }
    & small { display: block; font-size: 7.5pt; }
    & .gt-c { text-align: center; display: grid; justify-items: center; gap: 1px; }
    & .gt-name { font-size: 12pt; }
    & .gt-k { text-transform: uppercase; letter-spacing: .06em; font-weight: 700; font-size: 7pt; }
    & .gt-code { font-family: "Courier New", monospace; font-size: 15pt; font-weight: 800; letter-spacing: .02em; }
    & .gt-bar svg { width: 64mm; max-width: 100%; height: 12mm; display: block; }
    & .gt-row { display: flex; justify-content: space-between; gap: 8px; & span { min-width: 0; } & b { text-align: right; } }
    & .gt-note { border: 1px solid #000; padding: 3px 5px; margin-top: 3px; }
    & .gt-pay { text-align: center; font-weight: 800; font-size: 10pt; border: 2px solid #000; padding: 4px; margin-top: 4px; }
    & .gt-pin { text-align: center; border: 1px dashed #000; padding: 4px; margin-top: 5px; & b { display: block; font-family: "Courier New", monospace; font-size: 20pt; letter-spacing: .3em; } }
    & .gt-qr { display: flex; gap: 8px; align-items: center; & svg { width: 26mm; height: 26mm; flex: none; } & .gt-url { overflow-wrap: anywhere; } }
    & .gt-sign { margin: 22px 10mm 4px; border-top: 1px solid #000; text-align: center; padding-top: 2px; font-size: 7.5pt; }
  }

  /* Guía del remitente · hoja carta con dos copias */
  .paper.sheet { padding: clamp(10px, 3%, 8mm); }
  .gs-page { display: grid; gap: 4mm; font-family: Arial, Helvetica, sans-serif; color: #000; font-size: 8.5pt; line-height: 1.3; container-type: inline-size; }
  .gs-cut { text-align: center; color: #777; font-size: 8pt; letter-spacing: .1em; overflow: hidden; white-space: nowrap; }
  .gs { display: grid; gap: 2.5mm; break-inside: avoid;
    & small { display: block; color: #444; font-size: 7.5pt; }
    & .gs-k { text-transform: uppercase; letter-spacing: .06em; font-weight: 700; font-size: 6.8pt; color: #555; }
    & .gs-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; border-bottom: 2px solid #000; padding-bottom: 2mm; }
    & .gs-name { font-size: 13pt; display: block; }
    & .gs-doc { text-align: right; & b { display: block; font-family: "Courier New", monospace; font-size: 14pt; } }
    & .gs-copy { display: inline-block; margin-top: 2px; padding: 1px 6px; border: 1px solid #000; font-size: 6.8pt; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
    & .gs-route { display: grid; grid-template-columns: 1fr auto 1fr 1fr 1fr; gap: 3mm; align-items: center;
      & b { display: block; font-size: 10pt; } & span { display: block; color: #444; font-size: 7.5pt; } }
    & .gs-arrow { font-size: 14pt; }
    & .gs-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; }
    & .gs-box { border: 1px solid #999; border-radius: 4px; padding: 1.5mm 2.5mm; & b { display: block; font-size: 9.5pt; } & span { font-size: 7.5pt; } }
    & .gs-table { width: 100%; border-collapse: collapse; font-size: 8pt;
      & th, & td { border-bottom: 1px solid #ccc; padding: 1mm 1.5mm; text-align: left; }
      & th { font-size: 6.8pt; text-transform: uppercase; letter-spacing: .05em; color: #555; border-bottom: 1px solid #000; }
      & td:last-child, & th:last-child { text-align: right; }
      & tfoot td { font-weight: 700; border-bottom: 0; } }
    & .gs-note { border: 1px solid #000; padding: 1.2mm 2.5mm; }
    & .gs-bottom { display: grid; grid-template-columns: auto auto 1fr; gap: 4mm; align-items: center; }
    & .gs-pay { & b { display: block; font-size: 13pt; } & span { font-weight: 700; font-size: 7.5pt; } & .due { padding: 0 3px; border: 1.5px solid #000; } }
    & .gs-pin { border: 1px dashed #000; padding: 1mm 3mm; text-align: center; & b { display: block; font-family: "Courier New", monospace; font-size: 15pt; letter-spacing: .25em; } & span { font-size: 6.8pt; } }
    & .gs-codes { display: flex; justify-content: flex-end; align-items: center; gap: 3mm; }
    & .gs-bar svg { height: 11mm; width: auto; max-width: 60mm; display: block; }
    & .gs-qr svg { width: 20mm; height: 20mm; display: block; }
    & .gs-foot { display: grid; grid-template-columns: 1.4fr 1fr; gap: 4mm; align-items: end; }
    & .gs-terms { display: grid; gap: 1px; font-size: 6.8pt; color: #333; overflow-wrap: anywhere; }
    & .gs-signs { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; & > div:not(.dl-sig) { border-top: 1px solid #000; padding-top: 1mm; text-align: center; font-size: 7pt; margin-top: 10mm; } }
  }
  /* En pantalla angosta (celular) la vista previa se reacomoda; al imprimir se usa el diseño de hoja completo */
  @container (max-width: 560px) {
    .gs .gs-route { grid-template-columns: 1fr 1fr; & .gs-arrow { display: none; } }
    .gs .gs-parties, .gs .gs-foot { grid-template-columns: 1fr; }
    .gs .gs-bottom { grid-template-columns: 1fr 1fr; & .gs-codes { grid-column: 1 / -1; justify-content: flex-start; } }
  }
  .paper-stage { display: grid; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 16px; padding: 4px 0; overflow-x: auto; }
  .paper { background: #fff; color: #000; color-scheme: light; box-shadow: 0 10px 30px -12px rgb(0 0 0 / .4), 0 0 0 1px rgb(0 0 0 / .06); border-radius: 6px;
    &.a4 { width: min(210mm, 100%); min-height: 160mm; padding: clamp(14px, 5%, 14mm); overflow-wrap: anywhere;
      & table { font-size: inherit; } }
    &.label { display: grid; gap: 16px; background: transparent; box-shadow: none; border-radius: 0;
      & .lbl { background: #fff; box-shadow: 0 10px 30px -12px rgb(0 0 0 / .4); max-width: 100%; } }
  }
  @media print {
    body { background: #fff !important; }
    body.printing > *:not(#print-root) { display: none !important; }
    body.printing #print-root { display: block; color: #000; }
  }
  .lbl { width: 100mm; height: 148mm; padding: 4mm; font-family: Arial, Helvetica, sans-serif; color: #000; display: grid; grid-template-rows: auto auto 1fr auto; gap: 2.5mm; break-after: page; border: 0.3mm solid #000; overflow: hidden;
    & .lbl-head { display: flex; justify-content: space-between; align-items: center; border-bottom: 0.5mm solid #000; padding-bottom: 2mm; font-weight: 800; font-size: 13pt; }
    & .lbl-route { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; text-align: center; border-bottom: 0.3mm solid #000; padding-bottom: 2mm;
      & b { font-size: 20pt; display: block; letter-spacing: -0.02em; } & small { font-size: 7.5pt; } }
    & .lbl-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2mm 3mm; font-size: 8pt; align-content: start;
      & div { border-bottom: 0.2mm solid #999; padding-bottom: 1mm; } & strong { display: block; font-size: 9.5pt; } }
    & .lbl-codes { display: grid; grid-template-columns: 1fr 26mm; gap: 3mm; align-items: center; }
    & .lbl-code { font-family: monospace; font-weight: 800; font-size: 13pt; text-align: center; letter-spacing: 0.05em; }
    & .lbl-big { font-size: 10pt; font-weight: 800; background: #000; color: #fff; padding: 1mm 2mm; text-align: center; }
  }
}

/* Estado de cuenta (consola de la plataforma y suscripción de la empresa) */
@layer pages {
  .notice.bad { background: var(--bad-bg); border-color: color-mix(in oklab, var(--bad) 30%, transparent); & > .i { color: var(--bad); } }
  .acct-grid { display: grid; gap: 16px; align-items: start;
    @media (width >= 1100px) { grid-template-columns: minmax(0, 1fr) 360px; } }
  .ledger {
    & th.amt, & td.amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
    & tbody tr { cursor: default; }
    & td[data-c="credit"] { color: var(--ok); }
    & tr.void td { color: var(--text-3); }
    & tr.void .cell-main { text-decoration: line-through; }
  }
  @container (width < 760px) {
    .ledger tbody tr { grid-template-columns: minmax(0, 1fr) auto auto; grid-template-areas: "concept amt act" "date state act"; align-items: center; }
    .ledger td:empty { display: none; }
    .ledger td[data-c="concept"] { grid-area: concept; min-width: 0; }
    .ledger td[data-c="date"] { grid-area: date; font-size: .8rem; color: var(--text-3); }
    .ledger td[data-c="state"] { grid-area: state; justify-self: end; }
    .ledger td[data-c="debit"], .ledger td[data-c="credit"] { grid-area: amt; font-weight: 650; }
    .ledger td[data-c="bal"] { display: none; }
    .ledger td[data-c="act"] { grid-area: act; }
  }
  .audit { list-style: none; padding: 0; display: grid; gap: 12px; font-size: .88rem;
    & li { display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
    & .dot { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--fill); color: var(--text-2); }
    & .nota .dot { background: var(--brand-soft); color: var(--brand-text); }
    & .pago .dot { background: var(--ok-bg); color: var(--ok); }
    & .anulacion .dot { background: var(--bad-bg); color: var(--bad); }
  }
  .pay-info { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .92rem; line-height: 1.5; }
}
@layer pages {
  .notice:has(> .btn) { flex-wrap: wrap; & > .grow { flex: 1 1 220px; } }
}
