/* ==========================================================================
   Gadax — Sistema de diseño
   Una familia (Manrope), paleta de marca fija, sombras con jerarquía:
     plano (borde) → elevado (tarjeta flotante) → superpuesto (menús, modales)
   ========================================================================== */

:root {
  /* Marca */
  --tp-primary: #2563EB;
  --tp-primary-600: #1D4ED8;
  --tp-primary-050: #EFF4FF;
  --tp-primary-100: #DBE6FE;
  --tp-dark: #0F172A;
  --tp-dark-900: #0B1222;
  --tp-dark-800: #162033;
  --tp-dark-700: #22304A;
  --tp-cyan: #06B6D4;
  --tp-cyan-050: #E7F9FC;
  --tp-success: #10B981;
  --tp-success-050: #E8F8F1;
  --tp-warning: #F59E0B;
  --tp-warning-050: #FEF6E7;
  --tp-danger: #EF4444;
  --tp-danger-050: #FEEFEF;
  --tp-bg: #F8FAFC;
  --tp-white: #FFFFFF;

  /* Tinta y líneas (derivadas de la navy, nunca grises puros) */
  --tp-ink: #0F172A;
  --tp-ink-2: #475569;
  --tp-ink-3: #64748B;
  --tp-ink-4: #94A3B8;
  --tp-line: #E6EBF2;
  --tp-line-2: #D5DCE6;
  --tp-surface: #FFFFFF;
  --tp-surface-2: #F3F6FA;

  /* Tipografía: escala de cuarta (1.333) sobre 16px, recortada a lo que se usa */
  --tp-font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --fs-12: .75rem; --fs-13: .8125rem; --fs-14: .875rem; --fs-16: 1rem; --fs-18: 1.125rem;
  --fs-21: 1.3125rem; --fs-28: 1.75rem; --fs-37: 2.3125rem; --fs-50: 3.125rem; --fs-67: 4.1875rem;

  /* Radios con jerarquía */
  --r-xs: 6px; --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 24px;

  /* Sombras */
  --sh-1: 0 1px 2px rgba(15,23,42,.05);
  --sh-2: 0 1px 2px rgba(15,23,42,.04), 0 6px 16px -6px rgba(15,23,42,.10);
  --sh-3: 0 2px 4px rgba(15,23,42,.04), 0 24px 48px -16px rgba(15,23,42,.22);
  --sh-4: 0 4px 8px rgba(2,6,23,.20), 0 40px 80px -24px rgba(2,6,23,.55);

  --focus: 0 0 0 3px rgba(37,99,235,.28);
  --ease: cubic-bezier(.2,.7,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--tp-font);
  font-size: var(--fs-16);
  line-height: 1.6;
  color: var(--tp-ink);
  background: var(--tp-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { font-family: var(--tp-font); color: var(--tp-ink); font-weight: 700; letter-spacing: -0.025em; text-wrap: balance; }
p { text-wrap: pretty; }
h1 { line-height: 1.04; letter-spacing: -0.04em; }
h2 { line-height: 1.1; letter-spacing: -0.035em; }
h3, h4 { line-height: 1.3; letter-spacing: -0.015em; }
p { color: var(--tp-ink-2); }
a { color: var(--tp-primary); text-decoration-thickness: 1px; text-underline-offset: 3px; }
::selection { background: var(--tp-primary-100); color: var(--tp-ink); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--tp-ink-3); }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-xs); }
.visually-hidden-focusable:focus { position: fixed; top: 8px; left: 8px; z-index: 2000; background: var(--tp-white); padding: 8px 12px; border-radius: var(--r-sm); box-shadow: var(--sh-3); }

/* ---------- Botones ------------------------------------------------------ */
.btn { font-weight: 600; border-radius: var(--r-sm); padding: .625rem 1.05rem; font-size: var(--fs-14); letter-spacing: -0.005em; line-height: 1.4;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .15s var(--ease); }
.btn:active { transform: translateY(1px); }
.btn-sm { padding: .45rem .8rem; font-size: var(--fs-13); }
.btn-lg { padding: .8rem 1.35rem; font-size: var(--fs-16); border-radius: var(--r-md); }
.btn-tp { background: var(--tp-primary); color: #fff; border: 1px solid var(--tp-primary-600);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 1px 2px rgba(29,78,216,.4); }
.btn-tp:hover, .btn-tp:focus-visible { background: var(--tp-primary-600); color: #fff; border-color: #1E40AF; }
.btn-ghost { background: var(--tp-white); color: var(--tp-ink); border: 1px solid var(--tp-line-2); box-shadow: var(--sh-1); }
.btn-ghost:hover { border-color: var(--tp-ink-4); color: var(--tp-ink); background: var(--tp-white); }
.btn-ghost-dark { background: rgba(255,255,255,.06); color: #E2E8F0; border: 1px solid rgba(226,232,240,.18); }
.btn-ghost-dark:hover { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(226,232,240,.35); }
.btn-white { background: #fff; color: var(--tp-ink); border: 1px solid #fff; }
.btn-white:hover { background: #F1F5F9; color: var(--tp-ink); }
.btn-link-tp { color: var(--tp-ink); font-weight: 600; padding-left: 0; padding-right: 0; }
.btn-link-tp:hover { color: var(--tp-primary); }

/* ---------- Placa vehicular: el elemento de firma ------------------------ */
.plate {
  display: inline-flex; align-items: center;
  font-weight: 800; letter-spacing: .08em; font-variant-numeric: tabular-nums;
  font-size: 12.5px; line-height: 1; color: var(--tp-dark);
  background: linear-gradient(#fff, #F6F8FB);
  border: 1.5px solid var(--tp-dark); border-radius: 5px;
  padding: .38em .55em .32em;
  box-shadow: inset 0 3px 0 var(--tp-primary), 0 1px 0 rgba(15,23,42,.06);
  white-space: nowrap;
}
.plate-lg { font-size: var(--fs-18); padding: .42em .65em .36em; box-shadow: inset 0 4px 0 var(--tp-primary), 0 2px 0 rgba(15,23,42,.06); }

/* ---------- Estados de orden -------------------------------------------- */
.status { display: inline-flex; align-items: center; gap: .45em; font-size: var(--fs-12); font-weight: 600; padding: .28em .62em .28em .55em; border-radius: 999px; white-space: nowrap; line-height: 1.4; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status--slate   { color: #475569; background: #EEF2F6; }
.status--cyan    { color: #0E7490; background: var(--tp-cyan-050); }
.status--warning { color: #B45309; background: var(--tp-warning-050); }
.status--primary { color: var(--tp-primary-600); background: var(--tp-primary-050); }
.status--success { color: #047857; background: var(--tp-success-050); }
.status--muted   { color: #64748B; background: #F1F5F9; }
.status--danger  { color: #B91C1C; background: var(--tp-danger-050); }

/* Avance de la orden: 7 tramos de Recibido a Listo */
.rail { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; width: 100%; min-width: 80px; }
.rail span { height: 4px; border-radius: 2px; background: var(--tp-line); }
.rail span.on { background: var(--tp-primary); }
.rail.is-ready span.on { background: var(--tp-success); }
.rail.is-waiting span.now { background: var(--tp-warning); }

/* ---------- Formularios -------------------------------------------------- */
.form-label { font-weight: 600; font-size: var(--fs-13); color: var(--tp-ink); margin-bottom: .4rem; }
.form-control, .form-select { border-radius: var(--r-sm); border-color: var(--tp-line-2); padding: .65rem .85rem; font-size: var(--fs-14); color: var(--tp-ink);
  box-shadow: var(--sh-1); transition: border-color .15s, box-shadow .15s; }
.form-control::placeholder { color: var(--tp-ink-4); }
.form-control:hover, .form-select:hover { border-color: var(--tp-ink-4); }
.form-control:focus, .form-select:focus { border-color: var(--tp-primary); box-shadow: var(--focus); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--tp-danger); background-image: none; padding-right: .85rem; }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.invalid-feedback { font-size: var(--fs-13); font-weight: 500; color: #B91C1C; }
.form-hint { font-size: var(--fs-13); color: var(--tp-ink-3); margin-top: .35rem; }
.form-check-input { border-color: var(--tp-line-2); }
.form-check-input:checked { background-color: var(--tp-primary); border-color: var(--tp-primary); }
.form-check-input:focus { box-shadow: var(--focus); border-color: var(--tp-primary); }

/* ---------- Avisos ------------------------------------------------------- */
.notice { display: flex; gap: .7rem; align-items: flex-start; padding: .8rem 1rem; border-radius: var(--r-md); font-size: var(--fs-14); font-weight: 500; border: 1px solid; }
.notice i { margin-top: .22rem; }
.notice--success { background: var(--tp-success-050); border-color: #BDEBD7; color: #065F46; }
.notice--danger  { background: var(--tp-danger-050);  border-color: #F9CACA; color: #991B1B; }
.notice--warning { background: var(--tp-warning-050); border-color: #F8DDA8; color: #92400E; }
.notice--info    { background: var(--tp-primary-050); border-color: #CBDAFC; color: #1E3A8A; }

/* Avisos flotantes (toast) — reemplazan a los avisos en el panel */
.toasts { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 2000; display: grid; gap: .5rem; max-width: min(420px, calc(100vw - 2rem)); }
.toast-tp { display: flex; gap: .75rem; align-items: flex-start; background: var(--tp-dark); color: #E2E8F0; padding: .85rem 1rem; border-radius: var(--r-md);
  box-shadow: var(--sh-4); font-size: var(--fs-14); animation: toast-in .35s var(--ease) both; }
.toast-tp i { margin-top: .2rem; color: var(--tp-success); }
.toast-tp.is-leaving { animation: toast-out .25s var(--ease) both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Logo --------------------------------------------------------- */
.logo { display: inline-flex; align-items: center; gap: .6rem; font-weight: 700; font-size: var(--fs-18); letter-spacing: -0.03em; color: var(--tp-ink); text-decoration: none; }
.logo:hover { color: var(--tp-ink); }
.logo__mark { width: 28px; height: 28px; flex: none; }
.logo--light, .logo--light:hover { color: #fff; }

/* Avatar de iniciales */
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--tp-primary-050); color: var(--tp-primary-600); display: inline-grid; place-items: center;
  font-weight: 700; font-size: var(--fs-12); flex: none; letter-spacing: .02em; }
.avatar--solid { background: var(--tp-primary); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Campo de contraseña (login, registro, perfil y Panel de Gadax) */
.pw-field { position: relative; }
.pw-field .form-control { padding-right: 2.8rem; }
.pw-toggle { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--tp-ink-4); padding: .4rem .55rem; border-radius: var(--r-xs); }
.pw-toggle:hover { color: var(--tp-ink); }
.pw-meter { height: 3px; border-radius: 2px; background: var(--tp-line); margin-top: .5rem; overflow: hidden; }
.pw-meter span { display: block; height: 100%; width: 0; background: var(--tp-danger); transition: width .2s, background-color .2s; }

/* Inspección digital (021): semáforo e informe; lo comparten el panel, la cotización del cliente y su portal */
.insp-resumen { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .5rem; font-size: var(--fs-13); color: var(--tp-ink-3); }
.insp-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-weight: 600; font-size: var(--fs-12); }
.insp-chip.is-urgente, .insp-tag.is-urgente { background: var(--tp-danger-050); color: #B91C1C; }
.insp-chip.is-pronto, .insp-tag.is-pronto { background: var(--tp-warning-050); color: #B45309; }
.insp-chip.is-ok { background: var(--tp-success-050); color: #047857; }
.insp-tag { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: var(--fs-12); font-weight: 600; white-space: nowrap; }
.insp-informe__meta { font-size: var(--fs-13); color: var(--tp-ink-3); margin: 0 0 .6rem; }
.insp-hallazgos { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: .6rem; }
.insp-hallazgos li { border: 1px solid var(--tp-line); border-left: 4px solid var(--tp-warning); border-radius: var(--r-sm); padding: .65rem .8rem; }
.insp-hallazgos li.is-urgente { border-left-color: var(--tp-danger); }
.insp-hallazgos li > div:first-child { display: flex; justify-content: space-between; gap: .6rem; align-items: baseline; }
.insp-hallazgos p { margin: .3rem 0 0; font-size: var(--fs-14); color: var(--tp-ink-2); }
.insp-galeria { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.insp-galeria img { width: 84px; height: 84px; object-fit: cover; border-radius: var(--r-sm); border: 1px solid var(--tp-line); display: block; }
.insp-bien { margin-top: .9rem; font-size: var(--fs-14); }
.insp-bien summary { cursor: pointer; color: #047857; font-weight: 600; }
.insp-bien p { margin: .4rem 0 0; color: var(--tp-ink-3); }
.insp-informe__obs { margin: .9rem 0 0; font-size: var(--fs-14); background: var(--tp-surface-2); border-radius: var(--r-sm); padding: .6rem .8rem; }
.insp-informe__obs i { margin-right: .4rem; color: var(--tp-ink-4); }

/* Tipos de vehículo (022): elegir con un toque e ícono del tipo junto a la placa */
.tipo-picks { display: flex; flex-wrap: wrap; gap: .5rem; }
.tipo-pick { position: relative; display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border: 1.5px solid var(--tp-line); border-radius: 999px; background: var(--tp-white); cursor: pointer; font-size: var(--fs-14); font-weight: 600; color: var(--tp-ink-2); user-select: none; }
.tipo-pick input { position: absolute; opacity: 0; pointer-events: none; }
.tipo-pick i { color: var(--tp-ink-4); }
.tipo-pick:has(input:checked) { border-color: var(--tp-primary); background: var(--tp-primary-050); color: #1D4ED8; }
.tipo-pick:has(input:checked) i { color: var(--tp-primary); }
.tipo-pick:has(input:focus-visible) { outline: 2px solid var(--tp-primary); outline-offset: 2px; }
.tipo-picks.is-invalid .tipo-pick { border-color: #FCA5A5; }
.veh-tipo { color: var(--tp-ink-4); margin-right: .3rem; }
