/* ARIA product styling. Keep the UI lightweight: Bootstrap provides the primitives. */

/* Design tokens (MASTER.md §7). Light values are the default; the dark block below
   and the explicit [data-theme="dark"] block below that must stay synced with each
   other — the navbar's .theme-toggle button (project.js) is what writes the
   explicit attribute and persists the choice in localStorage. */
:root {
  --bg: #F7F8FB;
  --surface: #FFFFFF;
  --surface-tint: #F1F2F7;
  --border: #E2E5EC;
  --border-strong: #C7CCDA;
  --ink: #171A24;
  --muted: #6B7280;
  --accent: #4552D6;
  --accent-ink: #FFFFFF;
  --accent-tint: #EBEDFB;
  --success: #1B7F5A;
  --success-tint: #E3F5EC;
  --warning: #8A5A14;
  --warning-tint: #FBF0DD;
  --critical: #B23B33;
  --critical-tint: #FBEAE8;
  --shadow-float: 0 4px 16px rgba(23, 26, 36, .08);
  --radius-sm: 4px;
  --radius-base: 6px;
  --radius-lg: 8px;
  --radius-full: 100px;
  --dur: 120ms;
  --ease: cubic-bezier(.4, 0, .2, 1);
  /* Derived navbar tokens required by MASTER §6: the navbar stays dark in both
     themes, so it cannot reuse --ink directly (that variable inverts). */
  --navbar-bg: #171A24;
  --navbar-ink: #FFFFFF;
  --navbar-muted: rgba(255, 255, 255, .66);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161E;
    --surface: #1B1E29;
    --surface-tint: #20232F;
    --border: #2B2F3D;
    --border-strong: #3A3F52;
    --ink: #E8EAF2;
    --muted: #9CA3B4;
    --accent: #8892F2;
    --accent-ink: #12131C;
    --accent-tint: #262B4A;
    --success: #5FD1A4;
    --success-tint: #173428;
    --warning: #E8B865;
    --warning-tint: #3A2C10;
    --critical: #E58A83;
    --critical-tint: #3A1E1C;
    --shadow-float: 0 4px 16px rgba(0, 0, 0, .5);
    --navbar-bg: #12131C;
    --navbar-ink: #E8EAF2;
    --navbar-muted: rgba(255, 255, 255, .66);
  }
}

/* Explicit dark theme block — same values as the media query block above, kept in
   sync because the navbar's .theme-toggle button sets data-theme="dark" directly,
   overriding whatever prefers-color-scheme reports. */
:root[data-theme="dark"] {
  --bg: #14161E;
  --surface: #1B1E29;
  --surface-tint: #20232F;
  --border: #2B2F3D;
  --border-strong: #3A3F52;
  --ink: #E8EAF2;
  --muted: #9CA3B4;
  --accent: #8892F2;
  --accent-ink: #12131C;
  --accent-tint: #262B4A;
  --success: #5FD1A4;
  --success-tint: #173428;
  --warning: #E8B865;
  --warning-tint: #3A2C10;
  --critical: #E58A83;
  --critical-tint: #3A1E1C;
  --shadow-float: 0 4px 16px rgba(0, 0, 0, .5);
  --navbar-bg: #12131C;
  --navbar-ink: #E8EAF2;
  --navbar-muted: rgba(255, 255, 255, .66);
}

/* Accessible focus ring — the only outline style in the system. */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Typography (MASTER §2) ---------- */

body {
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.94rem;
  font-weight: 400;
  line-height: 1.5;
}

.mono,
.order-number,
.dashboard-table thead th {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.mono {
  font-variant-numeric: tabular-nums;
}

.dashboard-hero__title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.3;
}

.card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.4;
}

.dashboard-hero__subtitle,
.section-subtitle,
.orders-count,
.empty-state p,
.app-navbar__user {
  font-size: 0.82rem;
  line-height: 1.4;
}

.eyebrow,
.dashboard-table thead th {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--muted);
}

@media (max-width: 767.98px) {
  body {
    font-size: 1rem;
  }
}

/* ---------- Bootstrap component override layer ----------
   Bootstrap 5.2.3 has no native dark mode, so every primitive we use needs its
   background/text/border fixed by token or dark mode renders unreadable. */

.btn {
  border-radius: var(--radius-base);
  padding: 9px 16px;
  font-size: 0.82rem;
  font-weight: 500;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn-primary:hover,
.btn-primary:focus {
  background: color-mix(in srgb, var(--accent) 85%, black);
  border-color: color-mix(in srgb, var(--accent) 85%, black);
  color: var(--accent-ink);
}

.btn-primary:disabled,
.btn-primary.disabled {
  background: var(--surface-tint);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-secondary,
.btn-outline-primary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-secondary:hover,
.btn-outline-primary:hover,
.btn-secondary:focus,
.btn-outline-primary:focus {
  background: var(--surface-tint);
  border-color: var(--accent);
  color: var(--ink);
}

.btn-secondary:disabled,
.btn-outline-primary:disabled {
  background: var(--surface-tint);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

/* Non-solid danger button: MASTER §1 forbids saturated semantic colors on solid
   buttons, so destructive allauth actions use an outlined critical treatment. */
.btn-aria-danger {
  background: var(--surface);
  border-color: var(--critical);
  color: var(--critical);
}

.btn-aria-danger:hover,
.btn-aria-danger:focus {
  background: var(--critical-tint);
  border-color: var(--critical);
  color: var(--critical);
}

.form-control,
.form-select {
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-base);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.form-control:focus,
.form-select:focus {
  background-color: var(--surface);
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: none;
}

.form-control:disabled,
.form-select:disabled {
  background-color: var(--surface-tint);
  color: var(--muted);
}

.form-control.is-invalid,
.form-select.is-invalid,
.form-control:invalid {
  border-color: var(--critical);
}

.form-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--ink);
}

.card-body {
  padding: 16px 18px;
}

.card-header,
.card-footer {
  background: var(--surface-tint);
  border-color: var(--border);
  color: var(--ink);
}

.table {
  --bs-table-bg: var(--surface);
  --bs-table-color: var(--ink);
  --bs-table-striped-bg: var(--surface-tint);
  --bs-table-hover-bg: var(--surface-tint);
  --bs-table-border-color: var(--border);
  color: var(--ink);
}

.alert {
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
}

.alert-success {
  background: var(--success-tint);
  color: var(--success);
}

.alert-warning {
  background: var(--warning-tint);
  color: var(--warning);
}

.alert-error,
.alert-danger {
  background: var(--critical-tint);
  color: var(--critical);
}

.alert-info {
  background: var(--accent-tint);
  color: var(--ink);
}

.alert-debug {
  background: var(--surface-tint);
  color: var(--muted);
}

.badge {
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-weight: 500;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  color: var(--ink);
}

.modal-header {
  background: var(--surface-tint);
  border-bottom: 1px solid var(--border);
  color: var(--ink);
}

.modal-footer {
  background: var(--surface-tint);
  border-top: 1px solid var(--border);
  color: var(--ink);
}

.modal .employee-options {
  max-height: 240px;
}

.page-link {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.page-link:hover {
  background: var(--surface-tint);
  border-color: var(--border-strong);
  color: var(--ink);
}

.page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.page-item.disabled .page-link {
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}

/* ---------- Status pill component (MASTER §6) ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-full);
  padding: 5px 12px;
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: .04em;
  white-space: nowrap;
}

.pill__dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.pill--neutral {
  background: var(--surface-tint);
  border-color: var(--border-strong);
  color: var(--muted);
}

.pill--success {
  background: var(--success-tint);
  border-color: var(--success);
  color: var(--success);
}

.pill--warning {
  background: var(--warning-tint);
  border-color: var(--warning);
  color: var(--warning);
}

.pill--info {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}

.pill--critical {
  background: var(--critical-tint);
  border-color: var(--critical);
  color: var(--critical);
}

.text-critical {
  color: var(--critical) !important;
}

/* ---------- Shell ---------- */

body.app-body {
  background: var(--bg);
  color: var(--ink);
}

.app-navbar {
  min-height: 72px;
  background: var(--navbar-bg);
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.app-container {
  width: min(100% - 48px, 1440px);
  margin-inline: auto;
}

.app-brand,
.app-brand:hover {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  color: var(--navbar-ink);
  text-decoration: none;
}

.app-brand__logo {
  display: block;
  height: 34px;
  width: auto;
}

.app-brand__name,
.app-brand__tagline {
  display: block;
  line-height: 1.1;
}

.app-brand__name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.app-brand__tagline {
  margin-top: 3px;
  color: var(--navbar-muted);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-navbar .nav-link {
  margin-left: 4px;
  border-radius: var(--radius-base);
  color: var(--navbar-muted);
  font-size: 0.9rem;
  padding: 8px 12px;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.app-navbar .nav-link:hover,
.app-navbar .nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--navbar-ink);
}

.app-navbar__user {
  color: var(--navbar-muted);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 38px;
  height: 38px;
  margin-left: 12px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .16);
  border-radius: var(--radius-base);
  background: transparent;
  color: var(--navbar-muted);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), border-color var(--dur) var(--ease), color var(--dur) var(--ease);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .32);
  color: var(--navbar-ink);
}

.theme-toggle__icon {
  display: block;
  width: 18px;
  height: 18px;
}

.theme-toggle__icon--sun {
  display: none;
}

.theme-toggle__icon--moon {
  display: block;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__icon--sun {
    display: block;
  }

  :root:not([data-theme="light"]) .theme-toggle__icon--moon {
    display: none;
  }
}

:root[data-theme="dark"] .theme-toggle__icon--sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle__icon--moon {
  display: none;
}

:root[data-theme="light"] .theme-toggle__icon--sun {
  display: none;
}

:root[data-theme="light"] .theme-toggle__icon--moon {
  display: block;
}

.app-main {
  padding: 40px 0 64px;
}

/* ---------- Auth surfaces (login/signup/manage password) ---------- */

.auth-body {
  background: var(--bg);
}

.auth-brand__logo {
  display: inline-block;
  height: 40px;
  width: auto;
}

/* El login no tiene navbar, asi que no tiene toggle de tema, pero si puede
   renderizarse oscuro: el script pre-paint de base.html fija data-theme desde
   localStorage, de modo que quien activa el modo oscuro en la app y luego cierra
   sesion vuelve a un login oscuro. Sobre ese fondo el logo positivo (navy
   #26224C) es ilegible, asi que se conmuta a la variante negativa.

   Como en los tokens de :root, los dos bloques de abajo deben mantenerse
   sincronizados: [data-theme="dark"] cubre la eleccion explicita y
   prefers-color-scheme cubre el caso sin localStorage, donde el pre-paint no
   llega a fijar el atributo. */
.auth-brand__logo--negative {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .auth-brand__logo--positive {
    display: none;
  }

  :root:not([data-theme="light"]) .auth-brand__logo--negative {
    display: inline-block;
  }
}

:root[data-theme="dark"] .auth-brand__logo--positive {
  display: none;
}

:root[data-theme="dark"] .auth-brand__logo--negative {
  display: inline-block;
}

.dashboard-page {
  max-width: 1440px;
  margin: 0 auto;
}

/* ---------- Landing (retinted, layout untouched) ---------- */

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  align-items: center;
  gap: 64px;
  min-height: 420px;
  padding: 64px clamp(28px, 7vw, 96px);
  border-radius: 20px;
  background: linear-gradient(120deg, var(--navbar-bg) 0%, color-mix(in srgb, var(--accent) 45%, var(--navbar-bg)) 100%);
  color: var(--navbar-ink);
  overflow: hidden;
  position: relative;
}

.home-hero__copy {
  position: relative;
  z-index: 1;
}

.home-hero .eyebrow {
  color: var(--navbar-muted);
}

.home-hero h1 {
  max-width: 680px;
  margin: 0;
  font-size: clamp(2.1rem, 5vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.05;
}

.home-hero__lead {
  max-width: 600px;
  margin: 22px 0 28px;
  color: var(--navbar-muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.home-hero__visual {
  position: relative;
  min-height: 260px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  transform: rotate(3deg);
}

.home-hero__visual-mark {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  width: 96px;
  height: 96px;
  place-items: center;
  border-radius: 26px;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-float);
  font-size: 3.5rem;
  font-weight: 700;
  transform: translate(-50%, -50%) rotate(-3deg);
}

.home-hero__visual-line {
  position: absolute;
  left: 14%;
  height: 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.22);
}

.home-hero__visual-line--one { top: 18%; width: 42%; }
.home-hero__visual-line--two { right: 14%; bottom: 23%; left: auto; width: 34%; }
.home-hero__visual-line--three { bottom: 15%; width: 24%; }

.home-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.home-feature {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.home-feature__number {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.home-feature h2 {
  margin: 18px 0 8px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
}

.home-feature p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ---------- Dashboard hero / stats ---------- */

.dashboard-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.dashboard-hero__subtitle,
.section-subtitle {
  color: var(--muted);
}

.dashboard-hero__subtitle {
  max-width: 620px;
  margin: 8px 0 0;
}

/* Barra de triaje (#247: cinco tarjetas separadas, la activa con borde de acento).
   Cada segmento es un .triage-bar__item (position: relative) que envuelve el
   <a> de navegación por querystring y su propio <details class="triage-info">
   — un <details>/<summary> no puede anidarse dentro de un <a> (elementos
   interactivos anidados son HTML inválido y romperían el click del enlace),
   así que va como hermano dentro del wrapper, posicionado en su esquina
   superior derecha. El antiguo `overflow: hidden` de .triage-bar (que
   recortaba el fondo de :hover/--active a las esquinas redondeadas de .card)
   se sustituye por radios explícitos en los items extremos: así el panel de
   cada .triage-info puede desbordar la barra hacia abajo sin quedar
   recortado. */
.triage-bar {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.triage-bar__item {
  position: relative;
  display: flex;
  flex: 1 1 0;
  min-width: 0;
}

.triage-bar__seg {
  display: flex;
  flex-direction: column;
  flex: 1 1 0;
  gap: 6px;
  min-width: 0;
  padding: 14px 44px 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  color: inherit;
  text-decoration: none;
  transition:
    background-color var(--dur) var(--ease),
    border-color var(--dur) var(--ease);
}

.triage-bar__seg:hover {
  background: var(--surface-tint);
  color: inherit;
  text-decoration: none;
}

.triage-bar__seg--active {
  background: var(--accent-tint);
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.triage-bar__label {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.triage-bar__seg--active .triage-bar__label {
  color: var(--accent);
}

.triage-bar__value {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 1.85rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}

/* Icono de info por segmento de triaje: cada .triage-bar__item lleva el suyo,
   posicionado en su propia esquina superior derecha. <details>/<summary>
   nativo: cero JS y cero dependencias (esta build de Bootstrap no incluye
   Popper, así que sus tooltips no están disponibles). Se abre con click y con
   Enter/Espacio, por lo que también funciona en táctil, a diferencia de un
   tooltip solo-hover. */
.triage-info {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
}

.triage-info__trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  color: var(--muted);
  cursor: pointer;
  list-style: none;
  transition: color var(--dur) var(--ease), background-color var(--dur) var(--ease);
}

.triage-info__trigger::-webkit-details-marker {
  display: none;
}

.triage-info__trigger:hover,
.triage-info__trigger:focus-visible,
.triage-info[open] .triage-info__trigger {
  color: var(--accent);
  background: var(--accent-tint);
}

.triage-info__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 3;
  width: min(260px, calc(100vw - 48px));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-float);
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  text-align: left;
}

.orders-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* Barra de filtros compacta: sustituye a la card con cabecera propia.
   El formulario ya se auto-envía on input/change (project.js), por eso no
   lleva botón submit explícito. */
.filters-bar {
  margin-bottom: 24px;
}

.filters-bar form {
  margin-bottom: 0;
}

.filters-bar .row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin: 0;
}

.filters-bar .row > div {
  flex: 1 1 160px;
  padding: 0;
}

.filters-bar .form-label {
  margin-bottom: 4px;
}

.filters-active {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.filters-active__clear {
  margin-left: 4px;
  font-size: 0.8rem;
}

.filters-active__label {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--surface-tint);
  color: var(--ink);
  font-size: 0.75rem;
  text-decoration: none;
  transition: border-color var(--dur) var(--ease);
}

.chip:hover {
  border-color: var(--border-strong);
  color: var(--ink);
  text-decoration: none;
}

.chip svg {
  color: var(--muted);
  flex: none;
}

.orders-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.orders-count {
  color: var(--muted);
}

.orders-card {
  overflow: hidden;
}

/* ---------- Orders table ---------- */

.dashboard-table {
  color: var(--ink);
}

.dashboard-table thead th {
  background: var(--surface-tint);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  padding: 13px 16px;
  white-space: nowrap;
}

.dashboard-table tbody td {
  border-color: var(--border);
  font-size: 0.86rem;
  padding: 15px 16px;
  vertical-align: middle;
}

.dashboard-table tbody tr {
  transition: background-color var(--dur) var(--ease);
}

/* Raíl de estado (#247): barra redondeada de 4 px dentro de la primera celda,
   separada de los bordes de la fila. */
.dashboard-table tbody td:first-child {
  position: relative;
  padding-left: 24px;
}

.dashboard-table tbody td:first-child::before {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  left: 8px;
  width: 4px;
  border-radius: 2px;
  background: var(--rail, transparent);
}

.dashboard-table tbody tr:not(:last-child) td {
  border-bottom: 1px solid var(--border);
}

.dashboard-table tbody tr:hover {
  background: var(--surface-tint);
}

/* Raíl de estado: solo border-left, nunca fondo de fila (MASTER §4 — la
   separación entre superficies es siempre borde, no relleno). */
.dashboard-table tbody tr.table-warning {
  --rail: #C98A2B;
}

.dashboard-table tbody tr.table-warning > * {
  --bs-table-bg: var(--surface);
  --bs-table-accent-bg: var(--surface);
  background-color: var(--surface);
  color: var(--ink);
}

.dashboard-table tbody tr.table-critical {
  --rail: var(--critical);
}

.dashboard-table tbody tr.table-critical > * {
  --bs-table-bg: var(--surface);
  --bs-table-accent-bg: var(--surface);
  background-color: var(--surface);
  color: var(--ink);
}

.dashboard-table tbody tr.table-success {
  --rail: var(--success);
}

/* Cancelado o devuelto del todo: cerrado, sin nada que hacer. */
.dashboard-table tbody tr.table-closed {
  --rail: var(--border-strong);
}

.dashboard-table tbody tr.table-success > * {
  --bs-table-bg: var(--surface);
  --bs-table-accent-bg: var(--surface);
  background-color: var(--surface);
  color: var(--ink);
}

.order-description {
  max-width: 460px;
  min-width: 260px;
}

.order-description > span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.35;
}

.order-issue-icon {
  flex: none;
}

.order-issue-icon--warning {
  color: var(--warning);
}

.order-issue-icon--critical {
  color: var(--critical);
}

.order-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.order-badges .pill {
  padding: 2px 8px;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  gap: 4px;
}

.order-badges .pill__dot {
  width: 5px;
  height: 5px;
}

.order-number {
  color: var(--muted);
  font-size: 0.75rem;
}

.order-date {
  color: var(--muted);
}

.order-who {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}

.order-person {
  width: 210px;
  min-width: 190px;
}

.order-who__company {
  display: block;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
}

.order-actions {
  text-align: right;
  white-space: nowrap;
  min-width: auto;
}

.order-actions .btn + .btn,
.order-actions form + .btn,
.order-actions .btn + form {
  margin-left: 6px;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  flex: none;
}

/* #247: la acción pendiente de la fila (emparejar o completar empleado). */
.btn-icon--todo,
.btn-icon--todo:hover {
  background: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent);
}

.empty-state {
  padding: 72px 24px;
  text-align: center;
}

.empty-state__mark {
  display: grid;
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--surface-tint);
  color: var(--muted);
  font-size: 1.5rem;
}

.empty-state h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.dashboard-pagination {
  display: flex;
  justify-content: flex-end;
  margin-top: 20px;
}

.action-page-header {
  margin-bottom: 28px;
}

.action-page-header .dashboard-hero__subtitle {
  margin-bottom: 0;
}

.employee-picker {
  max-width: 720px;
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.employee-picker .form-label {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.match-selection-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-base);
  background: var(--accent-tint);
  color: var(--ink);
  font-size: 0.86rem;
}

.match-selection-hint span {
  color: var(--muted);
}

.dashboard-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

@media (max-width: 992px) {
  .app-container {
    width: min(100% - 32px, 1440px);
  }

  .dashboard-hero {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 768px) {
  .app-main {
    padding-top: 24px;
  }

  .triage-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .home-hero {
    grid-template-columns: 1fr;
    gap: 28px;
    min-height: auto;
    padding: 40px 28px;
  }

  .home-hero__visual {
    min-height: 180px;
  }

  .home-features {
    grid-template-columns: 1fr;
  }

  .orders-card__header {
    flex-direction: column;
  }

  .app-navbar__user {
    display: block;
    margin: 8px 12px;
  }

  .theme-toggle {
    margin: 8px 12px;
  }
}

/* Reduced motion: collapse every transition/animation to effectively instant. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* ---------- Claude Design implementation ---------- */

.home-hero {
  grid-template-columns: minmax(0, 1fr) minmax(480px, .95fr);
  gap: clamp(48px, 8vw, 120px);
  min-height: 444px;
  padding: 56px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
}

.home-hero .eyebrow { color: var(--muted); }
.home-hero h1 { max-width: 620px; font-size: clamp(2.5rem, 4vw, 3.4rem); line-height: 1.1; }
.home-hero__lead { max-width: 590px; margin: 22px 0 28px; color: var(--muted); line-height: 1.65; }
.home-hero__access { margin-left: 16px; color: var(--muted); font-size: .78rem; }

.home-preview { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.home-preview__bar { padding: 12px 16px; background: var(--navbar-bg); color: var(--navbar-muted); font-family: "IBM Plex Mono", monospace; font-size: .72rem; letter-spacing: .08em; }
.home-preview__stats { display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 1px solid var(--border); }
.home-preview__stats span { display: grid; gap: 8px; padding: 13px 16px; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: .62rem; text-transform: uppercase; }
.home-preview__stats span + span { border-left: 1px solid var(--border); }
.home-preview__stats .is-active { background: var(--accent-tint); color: var(--accent); }
.home-preview__stats strong { color: var(--ink); font-size: .95rem; }
.home-preview__row { display: grid; grid-template-columns: 54px 1fr 92px auto; align-items: center; gap: 12px; min-height: 46px; padding: 9px 14px; border-bottom: 1px solid var(--border); font-size: .72rem; }
.home-preview__row:last-child { border-bottom: 0; }
.home-preview__row > span:first-child { color: var(--muted); }
.home-preview__row strong { text-align: right; }
.home-preview__row em { padding: 3px 8px; border: 1px solid; border-radius: var(--radius-full); font-family: "IBM Plex Mono", monospace; font-size: .62rem; font-style: normal; white-space: nowrap; }
.home-preview__row em.is-warning { color: var(--warning); background: var(--warning-tint); }
.home-preview__row em.is-done { color: var(--success); background: var(--success-tint); }
.home-preview__row--empty span, .home-preview__row--empty strong, .home-preview__row--empty em { display: block; height: 8px; border: 0; border-radius: 4px; background: var(--surface-tint); }
.home-feature { min-height: 166px; padding: 30px 24px; }

.filters-bar { padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.filters-bar .row { flex-wrap: nowrap; gap: 8px; }
.filters-bar .row > div { flex: 0 1 145px; }
.filters-bar .row > div:first-child { flex: 1 1 520px; }
.filters-bar .form-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .68rem;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.filters-bar .form-control, .filters-bar .form-select { min-height: 38px; font-size: .8rem; }
.filters-active { margin-top: 10px; }
.orders-card__header { padding: 20px 24px; }
.dashboard-table tbody td { padding-top: 13px; padding-bottom: 13px; }
.dashboard-pagination { margin-top: 18px; }

.back-link { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; margin-bottom: 22px; padding: 0 14px 0 10px; border: 1px solid var(--border); border-radius: var(--radius-full); background: var(--surface); color: var(--ink); font-size: .82rem; font-weight: 500; text-decoration: none; transition: border-color var(--dur) var(--ease), color var(--dur) var(--ease), background-color var(--dur) var(--ease); }
.back-link svg { color: var(--muted); transition: transform var(--dur) var(--ease), color var(--dur) var(--ease); }
.back-link:hover, .back-link:focus-visible { border-color: var(--accent); background: var(--accent-tint); color: var(--accent); }
.back-link:hover svg, .back-link:focus-visible svg { color: var(--accent); transform: translateX(-2px); }
.action-page-header { margin-bottom: 26px; }
.action-layout { display: grid; grid-template-columns: minmax(0, 2.55fr) minmax(270px, 1fr); gap: 20px; align-items: start; }
.action-card { overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.action-card__header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.action-card__header h2 { margin: 0; font-size: 1.08rem; font-weight: 600; }
.action-card__header p { margin: 4px 0 0; color: var(--muted); font-size: .78rem; }
.action-card__header > span { color: var(--muted); font-size: .75rem; }
.action-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-tint); font-size: .8rem; }
.action-card__footer > div { display: flex; gap: 8px; }
.action-sidebar { display: grid; gap: 16px; }
.action-main { display: grid; gap: 16px; min-width: 0; }
.action-main > .alert { margin: 0; }
.match-fits { display: flex; flex-wrap: wrap; gap: 4px; }
.match-form { display: grid; gap: 14px; }
.article-card { overflow: hidden; }
.article-card__header { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.article-card__title { flex: 1 1 auto; min-width: 0; }
.article-card__badge { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: var(--radius-full); background: var(--accent-tint); color: var(--accent); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: .8rem; }
.article-card__candidates { display: grid; gap: 4px; padding: 10px; }
.article-candidate { display: grid; grid-template-columns: 24px 92px minmax(0, 1fr) 128px 220px; gap: 12px; align-items: center; margin: 0; padding: 10px 12px; border-radius: var(--radius-base); cursor: pointer; }
.article-candidate .pill { padding: 3px 10px; font-size: .7rem; letter-spacing: .02em; }
/* Etiquetas agrupadas en la última columna (#240): sueltas, una segunda etiqueta
   saltaba de fila y caía en la columna del radio, desbordando por la izquierda. */
.article-candidate__tags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; min-width: 0; }
.article-candidate__tags .pill { display: inline-block; max-width: 100%; white-space: normal; text-align: right; }
.article-candidate:hover { background: var(--surface-tint); }
.article-candidate.is-selected { background: var(--accent-tint); }
.article-candidate input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.article-candidate__summary { font-size: .85rem; }
.match-all > summary { padding: 12px 18px; cursor: pointer; font-size: .85rem; color: var(--muted); }
.action-sidebar .alert { margin: 0; padding: 13px 16px; font-size: .8rem; }
.order-summary .card-body { padding: 20px; }
.order-summary h2 { margin: 7px 0 8px; font-size: 1.08rem; }
.summary-amount { margin: 0 0 25px; font-size: 1.45rem; font-weight: 600; }
.order-summary dl { margin: 0; }
.order-summary dt { margin-top: 18px; color: var(--muted); font-family: "IBM Plex Mono", monospace; font-size: .7rem; font-weight: 500; letter-spacing: .08em; }
.order-summary dd { margin: 5px 0 0; font-size: .82rem; }
.match-table { margin: 0; }
.match-table tr.is-selected { --bs-table-bg: var(--accent-tint); border-left-color: var(--accent); }
.match-table td:first-child, .match-table th:first-child { width: 52px; text-align: center; }
.match-score { min-width: 120px; white-space: nowrap; }
/* #247: barra de 7 px con pista visible en los dos temas. */
.match-score i { display: inline-block; width: 72px; height: 7px; margin-right: 10px; border-radius: 4px; background: linear-gradient(to right, var(--accent) calc(var(--score) * 100%), var(--border-strong) 0); vertical-align: middle; }
.match-score span { display: inline-block; font-size: .8rem; font-weight: 600; line-height: 1; vertical-align: middle; }

.employee-search { display: grid; grid-template-columns: 20px 1fr; gap: 8px; margin: 18px 20px 0; padding: 10px 12px; border: 1px solid var(--accent); border-radius: var(--radius-base); }
.employee-search > span { color: var(--muted); }
.employee-search input { min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); }
.employee-search small { grid-column: 1 / -1; color: var(--muted); font-size: .74rem; }
.employee-options { max-height: 330px; overflow: auto; margin-top: 10px; border-top: 1px solid var(--border); }
.employee-option { display: grid; grid-template-columns: 20px 34px 1fr; align-items: center; gap: 12px; width: 100%; padding: 13px 20px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--ink); text-align: left; }
.employee-option:hover { background: var(--surface-tint); }
.employee-option.is-selected { background: var(--accent-tint); box-shadow: inset 3px 0 var(--accent); }
.employee-option__radio { width: 18px; height: 18px; border: 1px solid var(--border-strong); border-radius: 50%; }
.employee-option.is-selected .employee-option__radio { border: 5px solid var(--accent); }
.employee-option__avatar { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-tint); color: var(--muted); font-size: .68rem; }
.employee-option__text { display: flex; min-width: 0; flex-direction: column; gap: 2px; }
.employee-option__name { font-size: .86rem; }
.employee-option__email { overflow: hidden; color: var(--muted); font-size: .74rem; text-overflow: ellipsis; white-space: nowrap; }
.employee-options__empty { margin: 0; padding: 22px 20px; color: var(--muted); font-size: .8rem; text-align: center; }
.employee-options__loading { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0; padding: 22px 20px; color: var(--muted); font-size: .8rem; }
.employee-options__spinner { flex: none; width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; animation: employee-options-spin .8s linear infinite; }
@keyframes employee-options-spin { to { transform: rotate(360deg); } }
/* Empleado del pedido: cambiar / desvincular (#240). */
.current-employee { margin-bottom: 16px; }
.current-employee h3 { margin: 10px 0 4px; font-size: 1.05rem; }
.current-employee__email { margin: 0; color: var(--muted); font-size: .75rem; word-break: break-all; }
.employee-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; margin-top: 16px; }
.employee-unlink[open] { flex: 1 1 100%; }
.employee-unlink > summary { display: inline-block; list-style: none; }
.employee-unlink > summary::-webkit-details-marker { display: none; }
.employee-unlink[open] > summary { display: none; }
.employee-unlink__confirm { padding: 12px 14px; border: 1px solid var(--critical); border-radius: var(--radius-base); background: var(--critical-tint); }
.employee-unlink__confirm p { margin: 0 0 10px; font-size: .8rem; }
.company-preview { padding: 18px 20px; border: 1px solid var(--accent); border-radius: var(--radius-lg); background: var(--accent-tint); }
.company-preview h3 { margin: 10px 0; font-size: 1.05rem; }
.company-preview p:last-child { margin: 0; color: var(--muted); font-size: .75rem; }

/* #247: rediseño de Emparejar y Completar empleado. */
.article-candidate__title { display: block; }
.article-candidate--none { grid-template-columns: 24px minmax(0, 1fr); }
.action-card__footer .btn { white-space: nowrap; }
.article-candidate__meta { display: block; color: var(--muted); font-size: .74rem; }
.article-card__hint { margin: 12px 18px 0; padding: 10px 14px; border-radius: var(--radius-base); background: var(--surface-tint); font-size: .82rem; }
.match-all--more > summary { margin: 4px 0; padding: 10px 14px; border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); color: var(--accent); font-weight: 600; }
.match-all--more[open] > summary { border-style: solid; background: var(--surface-tint); }
.same-article .card-body { padding: 20px; }
.same-article__list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; font-size: .82rem; }
.same-article__list li { display: flex; justify-content: space-between; gap: 12px; }
.same-article__list span { color: var(--muted); text-align: right; }
/* Los sugeridos por el ticket van en su propio bloque, separados de la lista. */
.employee-suggestions { margin: 16px 20px; overflow: hidden; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface-tint); }
.employee-suggestions .eyebrow { margin: 0; padding: 12px 16px 6px; }
.employee-suggestions .employee-option { background: transparent; padding: 12px 16px; }
.employee-suggestions .employee-option:last-child { border-bottom: 0; }
.employee-suggestions .employee-option.is-selected { background: var(--accent-tint); }
.company-preview--mismatch { border-color: var(--warning); background: var(--warning-tint); }
.text-accent { color: var(--accent); }

@media (max-width: 992px) {
  .home-hero { grid-template-columns: 1fr; }
  .action-layout { grid-template-columns: 1fr; }
  .filters-bar .row { flex-wrap: wrap; }
  .filters-bar .row > div, .filters-bar .row > div:first-child { flex: 1 1 220px; }
}

@media (max-width: 600px) {
  .article-candidate { grid-template-columns: 24px minmax(0, 1fr) auto; grid-auto-flow: dense; }
  .article-candidate__summary, .article-candidate__tags { grid-column: 2 / -1; }
  .article-candidate__tags { justify-content: flex-start; }
  .article-candidate__tags .pill { text-align: left; }
  .home-hero { padding: 28px 22px; }
  .home-preview__row { grid-template-columns: 48px 1fr; }
  .home-preview__row strong, .home-preview__row em { display: none; }
  .home-hero__access { display: block; margin: 12px 0 0; }
  .action-card__footer { align-items: stretch; flex-direction: column; }
  .action-card__footer > div { justify-content: flex-end; }
}

/* ---------- Perfil de usuario ---------- */
.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background-color: var(--accent-tint);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 600;
}

/* #247: perfil en tarjetas (Cuenta, Seguridad, Preferencias). */
.profile-page { display: flex; flex-direction: column; gap: 20px; max-width: 820px; margin: 0 auto; }
.profile-header { display: flex; align-items: center; gap: 16px; }
.profile-header .profile-avatar { width: 56px; height: 56px; background: var(--accent); color: var(--accent-ink); font-size: 1.35rem; }
.profile-header__name { margin: 0; font-size: 1.6rem; font-weight: 600; letter-spacing: -0.02em; }
.profile-header__meta { margin: 2px 0 0; color: var(--muted); }
.profile-card { display: flex; flex-direction: column; gap: 14px; padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.profile-card h2 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.profile-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--border); }
.profile-line__help { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.segmented { display: inline-flex; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-base); }
.segmented__option { min-height: 36px; padding: 0 16px; border: 0; background: var(--surface); color: var(--ink); font-size: .85rem; }
.segmented__option + .segmented__option { border-left: 1px solid var(--border-strong); }
.segmented__option[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent); font-weight: 600; }

.profile-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}
