/* =====================================================================
   Registros de Producción · Alborch Limpiezas
   Mobile-first. Tokens como custom properties. Sin dependencias.
   ===================================================================== */

:root {
  /* Marca */
  --brand-900: #16181c;     /* casi negro (logo) */
  --brand-800: #22252b;
  --brand-700: #33373f;     /* grafito */
  --brand-600: #4a4f59;

  /* Neutros */
  --gray-50: #f7f8fa;
  --gray-100: #f1f2f5;
  --gray-150: #eaecf0;
  --gray-200: #e1e4e9;
  --gray-300: #cdd1d8;
  --gray-400: #a3a9b4;
  --gray-500: #6c7380;
  --gray-600: #545b67;
  --gray-700: #3d434d;

  /* Acento: azul tinta de bolígrafo */
  --ink-700: #182f78;
  --ink-600: #1d3a94;
  --ink-500: #2547b0;
  --ink-100: #e7ecfa;
  --ink-50: #f2f5fd;

  /* Semánticos */
  --amber-700: #8a5300; --amber-100: #fff1d1; --amber-300: #f1c464;
  --red-700: #b42318;   --red-600: #d0342b; --red-100: #fdeceb; --red-300: #f3b4af;
  --blue-700: #1d4ed8;  --blue-100: #e5edff;
  --green-700: #116a3a; --green-600: #15803d; --green-100: #e2f5e9; --green-300: #a7dcb8;

  --surface: #ffffff;
  --bg: #f3f4f6;
  --text: #1a1d22;
  --text-muted: var(--gray-500);
  --border: var(--gray-200);
  --border-strong: var(--gray-300);
  --focus: #2f5bdc;

  /* Tipografía */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --fs-xs: 0.75rem; --fs-sm: 0.875rem; --fs-md: 1rem; --fs-lg: 1.125rem; --fs-xl: 1.375rem; --fs-2xl: 1.75rem;

  /* Espaciado / forma */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 16px; --r-xl: 20px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, .08), 0 2px 4px rgba(16, 24, 40, .05);
  --shadow-3: 0 20px 40px -12px rgba(16, 24, 40, .28);
  --touch: 48px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --dur: 160ms;

  --topbar-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  font-family: var(--font); font-size: var(--fs-md); line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--ink-600); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
::selection { background: var(--ink-100); }

.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--brand-900); color: #fff; padding: 10px 14px; border-radius: var(--r-sm); text-decoration: none; }
.skip-link:focus { top: 8px; }
.muted { color: var(--text-muted); }
.small { font-size: var(--fs-sm); }
.tiny { font-size: var(--fs-xs); }
.center { text-align: center; }
.mono { font-family: var(--font-mono); font-size: .92em; }
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.ink { color: var(--ink-600); }
.stack { display: flex; flex-direction: column; min-width: 0; }
.noscript { padding: 24px; text-align: center; }

.icon { display: inline-flex; width: 20px; height: 20px; flex: none; }
.icon svg { width: 100%; height: 100%; }
.icon--xs { width: 14px; height: 14px; }

/* ---------- Marca ---------- */
.brand { display: inline-flex; flex-direction: column; align-items: center; color: var(--brand-900); line-height: 1; gap: 2px; }
.brand .sun svg { width: 44px; height: 22px; }
.brand__text { display: flex; flex-direction: column; align-items: center; }
.brand__name { font-weight: 800; font-size: 15px; letter-spacing: .02em; }
.brand__sub { font-weight: 600; font-size: 8.5px; letter-spacing: .18em; margin-top: 1px; }
.brand--lg { gap: 6px; }
.brand--lg .sun svg { width: 112px; height: 56px; }
.brand--lg .brand__name { font-size: 40px; letter-spacing: .01em; }
.brand--lg .brand__sub { font-size: 19px; letter-spacing: .2em; margin-top: 2px; }

.credit { display: inline-flex; align-items: center; gap: 6px; color: var(--gray-400); text-decoration: none; font-size: var(--fs-xs); line-height: 1; padding: 6px 4px; border-radius: 6px; transition: color var(--dur) var(--ease); }
.credit:hover, .credit:focus-visible { color: var(--gray-700); }
.credit__logo { width: 16px; height: 16px; border-radius: 4px; }
.credit__name { font-weight: 500; }
.credit--center { align-self: center; }

/* ---------- Shell ---------- */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; outline: none; }
.boot { min-height: 100dvh; display: grid; place-content: center; gap: var(--sp-6); justify-items: center; }

.topbar { position: sticky; top: 0; z-index: 30; background: var(--brand-900); color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,.04), var(--shadow-1); padding-top: env(safe-area-inset-top, 0px); }
.topbar__inner { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-3); min-height: var(--topbar-h); flex-wrap: wrap; }
.topbar__brand { display: flex; align-items: center; gap: var(--sp-3); color: #fff; text-decoration: none; padding: 6px 4px; border-radius: var(--r-sm); }
.topbar__brand .brand { color: #fff; }
.topbar__app { display: none; font-weight: 600; font-size: var(--fs-sm); color: var(--gray-300); padding-left: var(--sp-3); border-left: 1px solid rgba(255,255,255,.16); }
.topbar__user { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand-700); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .02em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12); }
.topbar__who { display: none; flex-direction: column; line-height: 1.15; }
.topbar__name { font-weight: 600; font-size: var(--fs-sm); max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__role { font-size: var(--fs-xs); color: var(--gray-400); }
.topbar .icon-btn { color: #fff; }
.topbar .icon-btn:hover { background: rgba(255,255,255,.1); }
.topbar__nav { order: 5; width: 100%; margin: 0 calc(-1 * var(--sp-3)); padding: 0 var(--sp-2) var(--sp-2); overflow-x: auto; scrollbar-width: none; }
.topbar__nav::-webkit-scrollbar { display: none; }
.nav { display: flex; gap: var(--sp-1); }
.nav__link { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: var(--r-pill); color: var(--gray-300); text-decoration: none; font-weight: 600; font-size: var(--fs-sm); white-space: nowrap; transition: background var(--dur) var(--ease), color var(--dur) var(--ease); }
.nav__link .icon { width: 18px; height: 18px; }
.nav__short { display: none; }
.nav__link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav__link[aria-current="page"] { background: #fff; color: var(--brand-900); }
@media (max-width: 559.98px) {
  /* En móvil la navegación son pestañas (icono + texto corto) que se reparten el ancho. */
  .nav { gap: 2px; }
  .nav__link { flex: 1 1 0; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; min-height: 48px; padding: 4px 2px; border-radius: var(--r-md); font-size: 11px; }
  .nav__label { display: none; }
  .nav__short { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .page-header__actions { width: 100%; }
  .page-header__actions > .btn { flex: 1 1 auto; justify-content: center; }
}

.app-footer { display: flex; justify-content: center; align-items: center; gap: var(--sp-3); flex-wrap: wrap; padding: var(--sp-4) var(--sp-4) calc(var(--sp-4) + var(--safe-b)); color: var(--gray-400); font-size: var(--fs-xs); }

/* ---------- Páginas ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: var(--sp-4) var(--sp-3) var(--sp-10); }
.page--narrow { max-width: 760px; }
.page-header { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-2) 0 var(--sp-4); flex-wrap: wrap; }
.page-header__titles { flex: 1 1 16rem; min-width: 0; }
.page-title { font-size: var(--fs-xl); font-weight: 750; letter-spacing: -.01em; overflow-wrap: break-word; }
.page-subtitle { color: var(--text-muted); font-size: var(--fs-sm); margin-top: 2px; }
.page-header__actions { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.page-header__back { margin-left: -6px; }
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-4); }
.page-actions--subtle { justify-content: center; }

/* ---------- Cards / secciones ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.section { padding: var(--sp-4); margin-bottom: var(--sp-4); }
.section--lines { padding: 0; background: none; }
.section__title { display: flex; align-items: center; gap: 10px; font-size: var(--fs-md); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-700); margin-bottom: var(--sp-4); }
.section__title .icon { width: 18px; height: 18px; color: var(--gray-500); }
.section__bar { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); flex-wrap: wrap; margin: var(--sp-6) 0 var(--sp-3); }
.section__bar .section__title { margin: 0; }
.section-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--gray-600); margin: var(--sp-5) 0 var(--sp-3); }
.count { background: var(--gray-150); color: var(--gray-700); border-radius: var(--r-pill); font-size: var(--fs-xs); padding: 1px 8px; font-weight: 700; }
.fine-print { font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-3); font-style: italic; }

/* ---------- Grid ---------- */
.grid { display: grid; gap: var(--sp-3) var(--sp-4); grid-template-columns: 1fr; }
.span-2 { grid-column: 1 / -1; }

/* ---------- Botones ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--touch); padding: 0 18px; border-radius: var(--r-md);
  background: var(--btn-bg); color: var(--btn-fg); border: 1px solid var(--btn-bd);
  font-weight: 650; font-size: var(--fs-md); line-height: 1.1; text-decoration: none; cursor: pointer; user-select: none;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
  white-space: nowrap; position: relative;
}
.btn:hover { background: var(--gray-50); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--brand-900); --btn-fg: #fff; --btn-bd: var(--brand-900); box-shadow: var(--shadow-1); }
.btn--primary:hover { background: var(--brand-700); }
.btn--secondary { --btn-bg: var(--surface); --btn-fg: var(--brand-900); --btn-bd: var(--border-strong); }
.btn--ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--gray-700); }
.btn--ghost:hover { background: var(--gray-100); }
.btn--success { --btn-bg: var(--green-600); --btn-fg: #fff; --btn-bd: var(--green-600); box-shadow: var(--shadow-1); }
.btn--success:hover { background: var(--green-700); }
.btn--danger { --btn-bg: var(--red-700); --btn-fg: #fff; --btn-bd: var(--red-700); }
.btn--danger:hover { background: #9a1c13; }
.btn--danger-outline { --btn-bg: var(--surface); --btn-fg: var(--red-700); --btn-bd: var(--red-300); }
.btn--danger-outline:hover { background: var(--red-100); }
.btn--danger-text { --btn-fg: var(--red-700); }
.btn--danger-text:hover { background: var(--red-100); }
.btn--lg { min-height: 54px; font-size: var(--fs-lg); padding: 0 22px; border-radius: var(--r-md); }
.btn--sm { min-height: 40px; padding: 0 12px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn--sm .icon { width: 18px; height: 18px; }
.btn--block { width: 100%; }
.btn--dashed { border-style: dashed; border-width: 2px; color: var(--ink-600); --btn-bd: var(--gray-300); background: transparent; }
.btn--dashed:hover { background: var(--ink-50); --btn-bd: var(--ink-500); }
.btn.is-busy { color: transparent !important; pointer-events: none; }
.btn.is-busy > * { visibility: hidden; }
.btn.is-busy::after { content: ""; position: absolute; width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid currentColor; border-color: var(--btn-fg) transparent var(--btn-fg) transparent; animation: spin .7s linear infinite; }

.icon-btn { display: inline-grid; place-items: center; width: var(--touch); height: var(--touch); border-radius: var(--r-md); border: 0; background: transparent; color: var(--gray-700); cursor: pointer; text-decoration: none; flex: none; transition: background var(--dur) var(--ease); }
.icon-btn:hover { background: var(--gray-100); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn--danger:hover:not(:disabled) { background: var(--red-100); color: var(--red-700); }

.fab { position: fixed; right: 18px; bottom: calc(22px + var(--safe-b)); z-index: 20; width: 64px; height: 64px; border-radius: 22px; display: grid; place-items: center; background: var(--brand-900); color: #fff; box-shadow: var(--shadow-3); text-decoration: none; transition: transform var(--dur) var(--ease); }
.fab .icon { width: 28px; height: 28px; }
.fab:active { transform: scale(.96); }
.new-btn { display: none; }

/* ---------- Formularios ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: 600; color: var(--gray-700); }
.req { color: var(--red-700); }
.field__hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field__error { font-size: var(--fs-sm); color: var(--red-700); font-weight: 600; display: flex; gap: 6px; align-items: flex-start; }
.field__error::before { content: "!"; flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--red-700); color: #fff; font-size: 12px; display: grid; place-items: center; margin-top: 1px; }

.input {
  width: 100%; min-height: var(--touch); padding: 10px 14px;
  font-size: 16px; /* evita zoom en iOS */
  color: var(--ink-600); font-weight: 500;
  background: var(--surface); border: 1.5px solid var(--border-strong); border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  appearance: none; -webkit-appearance: none;
}
.input::placeholder { color: var(--gray-400); font-weight: 400; }
.input:hover { border-color: var(--gray-400); }
.input:focus { outline: none; border-color: var(--ink-500); box-shadow: 0 0 0 4px rgba(37, 71, 176, .16); }
.input[aria-invalid="true"], .field--invalid .input { border-color: var(--red-600); background: #fffafa; }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(208, 52, 43, .16); }
.input:disabled, .input[readonly] { background: var(--gray-50); color: var(--gray-600); }
.textarea { min-height: 80px; resize: vertical; line-height: 1.45; }
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236c7380' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; padding-right: 40px; }
input[type="date"].input, input[type="time"].input { min-width: 0; font-variant-numeric: tabular-nums; }
.input--time { text-align: center; font-size: 18px; font-weight: 600; letter-spacing: .02em; padding: 8px 6px; }
.input--search { padding-left: 42px; }
.input-group { display: flex; align-items: stretch; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-addon { min-width: 76px; border: 1.5px solid var(--border-strong); border-left: 0; border-radius: 0 var(--r-md) var(--r-md) 0; background: var(--gray-50); font-weight: 600; font-size: var(--fs-sm); color: var(--gray-700); cursor: pointer; }
.input-addon:hover { background: var(--gray-100); }
.input--pin { letter-spacing: .3em; font-size: 20px; }

.checkbox { width: 22px; height: 22px; accent-color: var(--brand-900); flex: none; margin: 0; }
.check-field { display: flex; align-items: center; gap: 10px; min-height: var(--touch); cursor: pointer; font-weight: 600; flex-wrap: wrap; }
.check-field .muted { font-weight: 400; flex-basis: 100%; margin-left: 32px; margin-top: -8px; }

/* Autocompletar */
.ac { position: relative; }
.ac__list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-3); max-height: 300px; overflow-y: auto; }
.ac__opt { display: flex; flex-direction: column; padding: 10px 12px; min-height: var(--touch); justify-content: center; border-radius: var(--r-sm); cursor: pointer; }
.ac__opt:hover, .ac__opt[aria-selected="true"] { background: var(--ink-50); }
.ac__opt[aria-selected="true"] { box-shadow: inset 3px 0 0 var(--ink-500); }
.ac__primary { font-weight: 600; color: var(--text); }
.ac__meta { font-size: var(--fs-sm); color: var(--text-muted); }
.ac__empty { padding: 12px; color: var(--text-muted); font-size: var(--fs-sm); }

/* ---------- Chips de estado ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 700; letter-spacing: .02em; white-space: nowrap; border: 1.5px solid transparent; line-height: 1.4; }
.chip__dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip--borrador { background: var(--gray-150); color: var(--gray-700); }
.chip--pendiente { background: var(--amber-100); color: var(--amber-700); border-color: #f6dc9b; }
.chip--rechazado { background: var(--red-100); color: var(--red-700); }
.chip--validado { background: var(--blue-100); color: var(--blue-700); }
.chip--exportado { background: var(--green-100); color: var(--green-700); }
.chip--error_envio { background: var(--surface); color: var(--red-700); border-color: var(--red-600); }

.role { font-size: var(--fs-xs); font-weight: 700; padding: 3px 8px; border-radius: 6px; background: var(--gray-100); color: var(--gray-700); text-transform: uppercase; letter-spacing: .04em; }
.role--admin { background: var(--brand-900); color: #fff; }
.role--encargado { background: var(--ink-100); color: var(--ink-700); }

.badge-night { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 6px; background: #1f2547; color: #dfe5ff; font-size: 11px; font-weight: 700; vertical-align: middle; }

/* ---------- Alertas ---------- */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); border: 1px solid; margin-bottom: var(--sp-4); font-size: var(--fs-sm); }
.alert > .icon { margin-top: 1px; }
.alert strong { display: block; }
.alert__body { flex: 1; }
.alert__title { font-size: var(--fs-md); margin-bottom: 4px; }
.alert__actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.alert--info { background: var(--ink-50); border-color: #d3dcf6; color: var(--ink-700); }
.alert--warning { background: #fff8e6; border-color: #f5d98f; color: #6d4400; }
.alert--error { background: var(--red-100); border-color: var(--red-300); color: #7a1610; }
.alert--success { background: var(--green-100); border-color: var(--green-300); color: #0c4d29; }
.alert--big { padding: 18px; border-width: 2px; border-left-width: 6px; font-size: var(--fs-md); }
.alert--big p { margin-top: 4px; }
.err-list { margin: 6px 0 0; padding-left: 18px; }

/* ---------- Estados (vacío/carga/error) ---------- */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-3); padding: var(--sp-10) var(--sp-4); color: var(--text-muted); }
.state--loading { flex-direction: row; justify-content: center; }
.state__icon { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--gray-500); box-shadow: var(--shadow-1); }
.state__icon .icon { width: 30px; height: 30px; }
.state--error .state__icon { color: var(--red-700); }
.state__title { color: var(--text); font-size: var(--fs-lg); }
.state__text { max-width: 44ch; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--gray-200); border-top-color: var(--brand-900); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton-list { display: grid; gap: var(--sp-3); }
.skeleton { height: 92px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--gray-150) 0%, var(--gray-100) 40%, var(--gray-150) 80%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- Login ---------- */
.app.is-login { background: radial-gradient(1200px 500px at 50% -10%, #ffffff 0%, var(--bg) 60%); }
.main--login { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--sp-6) var(--sp-4) calc(var(--sp-6) + var(--safe-b)); min-height: 100dvh; }
.login { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--sp-4); }
.login__card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-2); padding: var(--sp-8) var(--sp-6) var(--sp-6); }
.login__brand { display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-6); }
.login__title { text-align: center; font-size: var(--fs-xl); font-weight: 750; }
.login__subtitle { text-align: center; color: var(--text-muted); margin: 4px 0 var(--sp-6); }
.login__form { display: grid; gap: var(--sp-4); }
.login__form .btn { margin-top: var(--sp-2); }
.login__form .alert { margin: 0; }
.login__foot { display: flex; gap: 8px; align-items: flex-start; justify-content: center; color: var(--text-muted); font-size: var(--fs-sm); text-align: center; padding: 0 var(--sp-4); }
.login__foot .icon { width: 18px; height: 18px; margin-top: 2px; }

/* ---------- Lista de partes (operario) ---------- */
.pcard-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--sp-3); }
.pcard { position: relative; display: block; padding: var(--sp-4) 44px var(--sp-4) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); color: inherit; text-decoration: none; box-shadow: var(--shadow-1); transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease); }
.pcard:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.pcard:active { transform: scale(.995); }
.pcard--rechazado { border-left: 4px solid var(--red-600); }
.pcard--borrador { border-left: 4px solid var(--gray-400); }
.pcard--pendiente { border-left: 4px solid var(--amber-300); }
.pcard__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.pcard__num { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-muted); font-weight: 600; }
.pcard__client { font-weight: 700; font-size: var(--fs-lg); line-height: 1.25; overflow-wrap: anywhere; }
.pcard__place { color: var(--text-muted); font-size: var(--fs-sm); }
.pcard__meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; }
.meta { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--gray-700); font-variant-numeric: tabular-nums; }
.meta .icon { width: 16px; height: 16px; color: var(--gray-400); }
.pcard__chev { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

/* ---------- Editor ---------- */
.lines { list-style: none; margin: 0 0 var(--sp-3); padding: 0; display: grid; gap: var(--sp-4); counter-reset: none; }
.line { padding: var(--sp-4); display: grid; gap: var(--sp-4); scroll-margin-top: calc(var(--topbar-h) + 60px); position: relative; overflow: visible; }
.line::before { content: ""; position: absolute; left: -1px; top: 18px; bottom: 18px; width: 4px; border-radius: 0 4px 4px 0; background: var(--ink-500); opacity: .85; }
.line--new { animation: flash 1.2s var(--ease); }
@keyframes flash { 0% { box-shadow: 0 0 0 4px rgba(37, 71, 176, .35); } 100% { box-shadow: var(--shadow-1); } }
.line__head { display: flex; align-items: center; gap: var(--sp-3); margin: -4px -6px -4px 0; }
.line__title { flex: 1; display: flex; align-items: center; gap: 10px; font-size: var(--fs-md); font-weight: 700; min-width: 0; }
.line__num { width: 30px; height: 30px; border-radius: 10px; background: var(--brand-900); color: #fff; display: grid; place-items: center; font-size: var(--fs-sm); flex: none; font-variant-numeric: tabular-nums; }
.line__total { font-weight: 750; font-variant-numeric: tabular-nums; color: var(--ink-600); background: var(--ink-50); border-radius: var(--r-pill); padding: 4px 12px; font-size: var(--fs-sm); white-space: nowrap; }
.line__total.is-zero { color: var(--gray-500); background: var(--gray-100); }
.line__foot { display: flex; justify-content: flex-end; border-top: 1px dashed var(--border); padding-top: var(--sp-3); margin-bottom: -6px; }

.tramos { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: var(--sp-2); }
.tramos > legend { padding: 0; margin-bottom: 8px; }
.tramo { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; padding: 10px 12px 12px; background: var(--gray-50); border: 1px solid var(--border); border-radius: var(--r-md); align-items: end; }
.tramo__label { grid-column: 1 / -1; font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-500); }
.tramo__dur { grid-column: 1 / -1; font-size: var(--fs-sm); font-weight: 650; color: var(--ink-600); min-height: 1.2em; font-variant-numeric: tabular-nums; }
.tramo__dur:empty { display: none; }
.field--compact .field__label { font-size: var(--fs-xs); font-weight: 600; color: var(--gray-600); }

.extras { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); }
.extras__summary { display: flex; align-items: center; gap: 10px; min-height: var(--touch); padding: 0 14px; cursor: pointer; list-style: none; font-weight: 600; font-size: var(--fs-sm); color: var(--gray-700); border-radius: var(--r-md); }
.extras__summary::-webkit-details-marker { display: none; }
.extras__summary:hover { background: var(--gray-50); }
.extras__summary .icon { width: 18px; height: 18px; color: var(--gray-500); }
.extras__chev { margin-left: auto; transition: transform var(--dur) var(--ease); }
.extras[open] .extras__chev { transform: rotate(180deg); }
.extras__body { padding: 4px 14px 14px; }

/* Envío a Freematica (revisión) y panel de administración Freematica */
.fm-section { background: var(--surface); }
.fm-envios { display: grid; gap: 10px; }
.fm-envios__title { margin: 4px 0 0; font-weight: 600; }
.fm-envios__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.fm-envio > summary { cursor: pointer; padding: 6px 0; line-height: 1.6; }
.fm-envio__req { margin-top: 8px; }
.code-block { margin: 4px 0 8px; padding: 8px 10px; max-height: 260px; overflow: auto; background: var(--gray-50); border: 1px solid var(--border); border-radius: var(--r-sm, 6px); font-family: var(--font-mono); font-size: var(--fs-xs); white-space: pre-wrap; overflow-wrap: anywhere; }
.fm-admin { display: grid; gap: var(--sp-4, 16px); }
.fm-admin .card { padding: 16px; }
.fm-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.fm-table th, .fm-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: top; }
.fm-table th { font-size: var(--fs-xs); color: var(--gray-600); font-weight: 600; }
.fm-table select { max-width: 100%; }
.fm-table-wrap { overflow-x: auto; }
.fm-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.total-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-pill); background: var(--brand-900); color: #fff; font-size: var(--fs-sm); box-shadow: var(--shadow-1); }
.total-pill .icon { width: 18px; height: 18px; opacity: .8; }
.total-pill__value { font-size: var(--fs-md); font-variant-numeric: tabular-nums; }

/* Barra de acciones fija */
.action-bar { position: sticky; bottom: 0; z-index: 25; margin: var(--sp-6) calc(-1 * var(--sp-3)) calc(-1 * var(--sp-10)); padding: var(--sp-3) var(--sp-3) calc(var(--sp-3) + var(--safe-b)); background: rgba(255,255,255,.94); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-top: 1px solid var(--border); box-shadow: 0 -8px 24px -12px rgba(16,24,40,.18); display: grid; gap: var(--sp-2); }
.action-bar__info { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.action-bar__info strong { font-size: var(--fs-lg); color: var(--ink-600); }
.autosave { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); }
.action-bar__btns { display: grid; grid-template-columns: 1fr 1.4fr; gap: var(--sp-2); }
.action-bar__btns .btn { padding: 0 10px; font-size: var(--fs-md); }

/* ---------- Firma ---------- */
.sig { display: grid; gap: 6px; }
.sig__label { font-size: var(--fs-sm); font-weight: 600; color: var(--gray-700); }
.sig__status { color: var(--green-700); font-weight: 600; }
.sig__pad { position: relative; border: 1.5px dashed var(--border-strong); border-radius: var(--r-md); background: #fff; background-image: linear-gradient(transparent calc(100% - 1px), transparent 0); overflow: hidden; }
.sig:not(.sig--empty) .sig__pad { border-style: solid; border-color: var(--gray-300); }
.sig--invalid .sig__pad { border-color: var(--red-600); background: #fffafa; }
.sig__canvas { display: block; width: 100%; touch-action: none; cursor: crosshair; position: relative; z-index: 2; }
.sig__hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--gray-400); font-size: var(--fs-sm); pointer-events: none; z-index: 1; }
.sig__line { position: absolute; left: 16px; right: 16px; bottom: 28px; border-bottom: 1px solid var(--gray-200); pointer-events: none; }
.sig__line::before { content: "✕"; position: absolute; left: 0; bottom: 2px; font-size: 12px; color: var(--gray-300); }
.sig__actions { display: flex; justify-content: flex-end; }
.sig--readonly { margin: 0; display: grid; gap: 4px; }
.sig__img { max-height: 110px; width: auto; max-width: 100%; background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 6px; }
.sig__none { padding: 18px; text-align: center; border: 1px dashed var(--border-strong); border-radius: var(--r-sm); color: var(--gray-400); font-size: var(--fs-sm); }
.sig__caption { font-size: var(--fs-xs); color: var(--text-muted); }

/* ---------- Solo lectura ---------- */
.dl { display: grid; grid-template-columns: 1fr; gap: 10px 20px; margin: 0; }
.dl__row { min-width: 0; }
.dl dt { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 600; }
.dl dd { margin: 2px 0 0; color: var(--ink-600); font-weight: 550; overflow-wrap: anywhere; }
.dl--compact { gap: 8px; margin-top: var(--sp-3); grid-template-columns: 1fr !important; }
.dl--compact .dl__row { display: flex; justify-content: space-between; gap: 12px; }
.dl--compact dd { margin: 0; text-align: right; color: var(--text); }
.line--ro .line__title { font-weight: 650; }
.ro-line { display: grid; gap: var(--sp-3); }
.ro-tramos { display: flex; flex-wrap: wrap; gap: 6px 18px; font-variant-numeric: tabular-nums; font-weight: 600; }
.ro-sigs { display: grid; gap: var(--sp-5); }
.ro-sigs .dl { margin-bottom: var(--sp-2); }

/* ---------- Bandeja de validación ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; padding: var(--sp-3); margin-bottom: var(--sp-3); }
.toolbar__search { position: relative; flex: 1 1 260px; }
.toolbar__search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); pointer-events: none; }
.toolbar__dates { display: flex; gap: var(--sp-2); flex: 1 1 240px; min-width: 0; }
.toolbar__dates .input { padding: 10px 8px; }
.toolbar__label { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: var(--fs-xs); font-weight: 600; color: var(--gray-600); gap: 2px; }
.tabs-wrap { overflow-x: auto; margin: 0 calc(-1 * var(--sp-3)) var(--sp-3); padding: 2px var(--sp-3); scrollbar-width: none; }
.tabs-wrap::-webkit-scrollbar { display: none; }
.tabs { display: inline-flex; gap: 6px; padding: 4px; background: var(--gray-150); border-radius: var(--r-md); }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; font-weight: 650; font-size: var(--fs-sm); color: var(--gray-600); cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--text); background: rgba(255,255,255,.6); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.tab__count { min-width: 22px; padding: 0 6px; height: 20px; border-radius: var(--r-pill); background: var(--gray-200); color: var(--gray-700); font-size: 12px; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.tab__count--hot { background: var(--amber-300); color: #4a2d00; }
.tab--error_envio .tab__count--hot { background: var(--red-700); color: #fff; }
.inbox__summary { margin: 0 2px var(--sp-2); }

.itable { display: grid; gap: var(--sp-2); }
.itable__head { display: none; }
.itable__row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "client state" "dates hours" "user num"; gap: 6px 12px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); color: inherit; text-decoration: none; box-shadow: var(--shadow-1); transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease); }
.itable__row:hover { box-shadow: var(--shadow-2); border-color: var(--border-strong); }
.itable__row > span { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.itable__row .icon { width: 16px; height: 16px; color: var(--gray-400); }
.c-client { grid-area: client; flex-direction: column; align-items: flex-start !important; gap: 0 !important; }
.c-client strong { font-size: var(--fs-md); overflow-wrap: anywhere; }
.c-state { grid-area: state; flex-direction: column; align-items: flex-end !important; gap: 2px !important; }
.c-dates { grid-area: dates; }
.c-hours { grid-area: hours; justify-content: flex-end; font-weight: 700; color: var(--ink-600); }
.c-user { grid-area: user; color: var(--gray-600); }
.c-num { grid-area: num; justify-content: flex-end; font-family: var(--font-mono); font-size: var(--fs-xs) !important; color: var(--text-muted); }
.c-chev { display: none !important; }
.irow--error_envio { border-color: var(--red-300); }
.irow--pendiente { border-left: 4px solid var(--amber-300); }
.irow--error_envio { border-left: 4px solid var(--red-600); }

/* ---------- Revisión (encargado) ---------- */
.review { display: grid; gap: var(--sp-4); }
.review__side { display: grid; gap: var(--sp-4); align-content: start; }
.summary { padding: var(--sp-4); }
.summary__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.summary__num { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--text-muted); font-weight: 600; }
.summary__client { font-size: var(--fs-lg); font-weight: 750; margin: 10px 0 12px; overflow-wrap: anywhere; }
.summary__stats { display: grid; grid-template-columns: repeat(3, auto); gap: 10px; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.summary__stats > div { display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.summary__total { color: var(--ink-600); font-size: var(--fs-lg); }
.summary__links { display: flex; gap: 4px; flex-wrap: wrap; margin-top: var(--sp-3); margin-left: -8px; }
.actions-panel { padding: var(--sp-4); display: grid; gap: var(--sp-3); }
.actions-panel .alert { margin: 0; }
.panel-title { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .06em; color: var(--brand-700); font-weight: 700; }
.panel-title .icon { width: 18px; height: 18px; color: var(--gray-500); }

.audit { padding: var(--sp-4); }
.timeline { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: 14px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--gray-150); }
.timeline__item { display: grid; grid-template-columns: 12px 1fr; gap: 12px; position: relative; }
.timeline__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2.5px solid var(--gray-400); margin-top: 4px; z-index: 1; }
.tl--validado .timeline__dot, .tl--validar .timeline__dot, .tl--envio_ok .timeline__dot, .tl--reenvio_ok .timeline__dot { border-color: var(--green-600); background: var(--green-600); }
.tl--rechazado .timeline__dot, .tl--rechazar .timeline__dot, .tl--envio_error .timeline__dot, .tl--reenvio_error .timeline__dot { border-color: var(--red-600); }
.tl--pendiente .timeline__dot, .tl--enviar .timeline__dot { border-color: var(--amber-300); }
.timeline__what { font-weight: 650; font-size: var(--fs-sm); }
.timeline__detail { color: var(--gray-600); margin-top: 2px; }

/* ---------- Admin ---------- */
.atable { display: grid; gap: var(--sp-2); }
.atable__head { display: none !important; }
.atable__row { display: grid; gap: 4px 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); align-items: center; }
.atable__row.is-inactive { opacity: .62; }
.acell { min-width: 0; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.acell:first-child { grid-column: 1; font-size: var(--fs-md); }
.acell:not(:first-child):not(.acell--actions) { grid-column: 1; color: var(--gray-600); }
.acell:not(:first-child):not(.acell--actions)::before { content: attr(data-label) ": "; color: var(--gray-400); font-size: var(--fs-xs); }
.acell--actions { grid-column: 2; grid-row: 1 / span 3; justify-self: end; }
@media (max-width: 759.98px) { .atable__row { grid-template-columns: 1fr auto !important; } }

/* ---------- Modal ---------- */
.modal { border: 0; padding: 0; border-radius: var(--r-xl); width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow-3); color: var(--text); background: var(--surface); }
.modal--md { width: min(680px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(14, 16, 20, .55); backdrop-filter: blur(2px); }
.modal[open] { animation: pop .18s var(--ease); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal__form { display: flex; flex-direction: column; max-height: calc(100dvh - 24px); }
.modal__header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 10px 6px 20px; }
.modal__title { font-size: var(--fs-lg); font-weight: 750; }
.modal__body { padding: 8px 20px 16px; overflow-y: auto; }
.modal__text { color: var(--gray-700); }
.modal__text + .modal__text { margin-top: 8px; }
.modal__footer { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 16px calc(14px + var(--safe-b)); border-top: 1px solid var(--border); background: var(--gray-50); flex-wrap: wrap; }
.modal__footer .btn { min-width: 120px; }

/* ---------- Toasts ---------- */
.toasts { position: fixed; z-index: 100; left: 12px; right: 12px; bottom: calc(12px + var(--safe-b)); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; width: min(460px, 100%); padding: 12px 8px 12px 14px; border-radius: var(--r-md); background: var(--brand-900); color: #fff; box-shadow: var(--shadow-3); font-size: var(--fs-sm); animation: toast-in .22s var(--ease); }
.toast__icon { margin-top: 1px; }
.toast--success .toast__icon { color: #7ee2a3; }
.toast--error { background: #5c120c; }
.toast--error .toast__icon { color: #ffb4ad; }
.toast--warning .toast__icon { color: #ffd479; }
.toast__msg { flex: 1; padding-top: 1px; }
.toast__msg .err-list { margin-top: 4px; }
.toast__close { border: 0; background: transparent; color: rgba(255,255,255,.7); width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; cursor: pointer; flex: none; margin: -6px 0; }
.toast__close:hover { background: rgba(255,255,255,.12); color: #fff; }
.toast--out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

/* =====================================================================
   Responsive
   ===================================================================== */
@media (min-width: 560px) {
  .grid--2 { grid-template-columns: 1fr 1fr; }
  .grid--line { grid-template-columns: 1fr 180px; }
  .tramo { grid-template-columns: 70px 1fr 1fr minmax(96px, auto); align-items: center; }
  .tramo__label { grid-column: auto; }
  .tramo__dur { grid-column: auto; text-align: right; align-self: end; padding-bottom: 12px; }
  .dl { grid-template-columns: 1fr 1fr; }
  .ro-sigs { grid-template-columns: 1fr 1fr; }
  .action-bar__btns { display: flex; justify-content: flex-end; }
  .action-bar { grid-template-columns: 1fr auto; align-items: center; }
  .autosave { margin-left: 0; flex-basis: 100%; }
  .toasts { left: auto; right: 20px; bottom: 20px; justify-items: end; }
}

@media (min-width: 760px) {
  .topbar__inner { flex-wrap: nowrap; padding: 0 var(--sp-5); gap: var(--sp-5); }
  .topbar__nav { order: 0; width: auto; margin: 0; padding: 0; flex: 1; }
  .topbar__who { display: flex; }
  .page { padding: var(--sp-6) var(--sp-6) var(--sp-10); }
  .page-title { font-size: var(--fs-2xl); }
  .new-btn { display: inline-flex; }
  .fab { display: none; }
  .section { padding: var(--sp-6); }
  .line { padding: var(--sp-5) var(--sp-6); }
  .action-bar { margin-left: calc(-1 * var(--sp-6)); margin-right: calc(-1 * var(--sp-6)); padding-left: var(--sp-6); padding-right: var(--sp-6); border-radius: var(--r-lg) var(--r-lg) 0 0; }

  /* Bandeja como tabla */
  .itable { gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
  .itable__head, .itable__row { grid-template-columns: 130px minmax(180px, 2fr) minmax(150px, 1.2fr) 110px minmax(120px, 1fr) 150px 24px; grid-template-areas: none; align-items: center; }
  .itable__head { display: grid; gap: 12px; padding: 10px 16px; background: var(--gray-50); border-bottom: 1px solid var(--border); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }
  .itable__row { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 12px 16px; gap: 12px; }
  .itable__row:last-child { border-bottom: 0; }
  .itable__row:hover { background: var(--ink-50); box-shadow: none; }
  .itable__row > span { grid-area: auto; }
  .c-num { justify-content: flex-start; order: 0; }
  .c-hours { justify-content: flex-start; }
  .c-state { align-items: flex-start !important; }
  .c-chev { display: flex !important; color: var(--gray-400); }
  .irow--pendiente, .irow--error_envio { border-left: 0; box-shadow: inset 4px 0 0 var(--amber-300) !important; }
  .irow--error_envio { box-shadow: inset 4px 0 0 var(--red-600) !important; }

  /* Admin como tabla */
  .atable { gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
  .atable__head { display: grid !important; gap: 12px; padding: 10px 16px; background: var(--gray-50); border-bottom: 1px solid var(--border); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }
  .atable__row { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; box-shadow: none; padding: 8px 16px; gap: 12px; }
  .atable__row:last-child { border-bottom: 0; }
  .atable__row:hover { background: var(--gray-50); }
  .acell, .acell:first-child, .acell:not(:first-child):not(.acell--actions) { grid-column: auto; grid-row: auto; color: inherit; }
  .acell:not(:first-child):not(.acell--actions)::before { content: none; }
  .acell--actions { grid-row: auto; }
}

@media (min-width: 1024px) {
  .topbar__app { display: inline; }
  .review { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; gap: var(--sp-6); }
  .review__side { position: sticky; top: calc(var(--topbar-h) + var(--sp-4)); max-height: calc(100dvh - var(--topbar-h) - var(--sp-8)); overflow-y: auto; padding-bottom: var(--sp-2); scrollbar-width: thin; }
  .review__main .action-bar { margin: 0; }
}

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

/* Alto contraste forzado (Windows) */
@media (forced-colors: active) {
  .chip, .btn, .card, .input { border: 1px solid CanvasText; }
  .nav__link[aria-current="page"] { outline: 2px solid Highlight; }
}

/* Impresión desde la app (respaldo; la vista oficial es /api/partes/:id/pdf) */
@media print {
  .topbar, .app-footer, .action-bar, .fab, .page-actions, .review__side .actions-panel, .toasts, .sig__actions, .page-header__back { display: none !important; }
  body, .app { background: #fff; }
  .card { box-shadow: none; }
}

/* ===================== Hojas de servicio (Mi día, ficha, firma del cliente, bandeja) ===================== */
.spacer { flex: 1; }
.input--lg { min-height: 56px; font-size: var(--fs-lg); }
.input--xl { min-height: 60px; font-size: 22px; }
.grid-2 { display: grid; gap: var(--sp-3); }
.src-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 650; border: 1px solid; }
.src-chip--local { background: var(--gray-100); color: var(--gray-700); border-color: var(--gray-200); }
.src-chip--fm { background: var(--green-100); color: var(--green-700); border-color: var(--green-300); }

/* Selector de día */
.datesw { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 4px; box-shadow: var(--shadow-1); margin-bottom: var(--sp-3); }
.datesw__label { flex: 1; display: flex; flex-direction: column; align-items: center; line-height: 1.2; min-width: 0; text-align: center; }
.datesw__label strong { font-size: var(--fs-lg); }
.datesw__cal { position: relative; flex: none; }
.datesw__input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.datesw__input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

/* Mi día */
.midia__hello { margin: var(--sp-2) 0 var(--sp-3); }
.midia__src { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: var(--sp-3); flex-wrap: wrap; }
.midia__count { margin-bottom: var(--sp-2); }
.midia__otro { margin-top: var(--sp-4); }
.scard-list { display: grid; gap: var(--sp-3); }
.scard { display: grid; gap: 8px; padding: var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--gray-300); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.scard--todo { border-left-color: var(--ink-500); }
.scard--firmada { border-left-color: var(--amber-300); }
.scard--enviada, .scard--ok { border-left-color: var(--green-600); }
.scard--devuelta { border-left-color: var(--red-600); }
.scard__time { display: flex; align-items: center; gap: 8px; font-size: var(--fs-lg); flex-wrap: wrap; }
.scard__time .icon { color: var(--gray-500); }
.scard__tarea { font-weight: 650; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .03em; color: var(--brand-700); }
.scard__team { display: flex; align-items: center; gap: 6px; }
.scard__estado { font-weight: 650; font-size: var(--fs-sm); display: inline-flex; align-items: center; gap: 6px; }
.scard__estado::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.scard__estado--todo { color: var(--ink-600); }
.scard__estado--firmada { color: var(--amber-700); }
.scard__estado--enviada, .scard__estado--ok { color: var(--green-700); }
.scard__estado--devuelta { color: var(--red-700); }
.scard .alert { margin: 0; }
.lugar__cliente { font-weight: 750; font-size: var(--fs-lg); line-height: 1.25; overflow-wrap: anywhere; }
.lugar__centro { font-weight: 550; color: var(--gray-700); }
.devueltas { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 6px; }
.devueltas a { color: inherit; font-weight: 650; }
.pick-list { list-style: none; margin: var(--sp-3) 0 0; padding: 0; display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.pick-list__item { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; min-height: var(--touch); padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); cursor: pointer; font: inherit; color: inherit; }
.pick-list__item:hover { background: var(--gray-50); border-color: var(--border-strong); }
.pick-list__empty { padding: 10px; }

/* Hoja (operaria) */
.hoja__servicio { display: grid; gap: var(--sp-3); }
.hoja__plan { display: grid; gap: var(--sp-2); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.hoja__plan > div { display: flex; flex-direction: column; }
.hoja__obs { display: flex; gap: 6px; background: var(--gray-50); padding: 8px 10px; border-radius: var(--r-sm); }
.hoja__top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--sp-3); }
.ficha { display: grid; gap: var(--sp-4); }
.ficha .section__title { margin-bottom: 0; }
.tramo-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: var(--sp-2) var(--sp-3); align-items: end; }
.tramo-row__label { grid-column: 1 / -1; font-weight: 700; font-size: var(--fs-sm); color: var(--gray-700); }
.tramo-row__f { display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-xs); font-weight: 650; color: var(--gray-600); text-transform: uppercase; letter-spacing: .04em; }
.tramo-row > .icon-btn { margin-bottom: 6px; }
.ficha__total { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--ink-50); border: 1px solid var(--ink-100); border-radius: var(--r-md); color: var(--ink-700); }
.ficha__total > span:first-child { flex: 1; font-weight: 600; }
.ficha__total-num { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; }
.ficha__alt { display: flex; justify-content: center; }
.ficha-ro { display: grid; gap: 8px; }
.ficha-ro__horas { font-size: var(--fs-lg); font-weight: 650; }
.ficha-ro__total { font-size: var(--fs-xl); font-weight: 750; color: var(--ink-700); }
.hoja__cliente { display: grid; gap: var(--sp-3); }
.hoja__cliente .section__title { margin-bottom: 0; }
.team { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.team__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); }
.team__row--me { background: var(--ink-50); border-color: var(--ink-100); }
.team__row--pend { background: #fffafa; border-color: var(--red-300); }
.team__who { display: flex; flex-direction: column; min-width: 0; }

/* Firma del cliente */
.firma-cli .section { display: grid; gap: var(--sp-3); }
.firma-cli .section__title { margin-bottom: 0; }
.firma-cli__total { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 14px; background: var(--brand-900); color: #fff; border-radius: var(--r-md); font-weight: 700; letter-spacing: .04em; }
.firma-cli__total strong { font-size: var(--fs-xl); }
.firma-cli .alert { margin: 0; }

/* Encargado: hoja */
.disc { border-color: #f5d98f; background: #fffcf2; }
.disc .section__title { color: #6d4400; margin-bottom: var(--sp-3); }
.disc__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.disc__item { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.disc__item .icon { color: var(--amber-700); flex: none; }
.ttable { display: grid; gap: 6px; }
.ttable__head { display: none; }
.ttable__row, .ttable__foot { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md); align-items: center; }
.ttable__row > [data-l]::before { content: attr(data-l) ": "; color: var(--text-muted); font-size: var(--fs-xs); }
.ttable__row > * { grid-column: 1 / -1; }
.ttable__row--falta { background: #fffafa; border-color: var(--red-300); }
.ttable__who { display: flex; flex-direction: column; }
.ttable__diff--warn { color: var(--red-700); font-weight: 700; }
.ttable__sig { height: 40px; width: auto; max-width: 140px; object-fit: contain; }
.ttable__foot { background: var(--brand-900); color: #fff; font-weight: 700; border-color: var(--brand-900); }
.ttable__foot > span:empty { display: none; }
.conforme { display: grid; gap: var(--sp-3); }

/* Bandeja del encargado */
.hcard-list { display: grid; gap: var(--sp-3); }
.hcard { position: relative; display: grid; gap: 6px; padding: var(--sp-4) 44px var(--sp-4) var(--sp-4); background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--gray-300); border-radius: var(--r-lg); color: inherit; text-decoration: none; box-shadow: var(--shadow-1); transition: box-shadow var(--dur) var(--ease); }
.hcard:hover { box-shadow: var(--shadow-2); }
.hcard--pendiente { border-left-color: var(--amber-300); }
.hcard--rechazado { border-left-color: var(--red-600); }
.hcard--validado, .hcard--exportado { border-left-color: var(--green-600); }
.hcard--error_envio { border-left-color: var(--red-700); }
.hcard__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.hcard__fecha { display: inline-flex; align-items: center; gap: 6px; font-weight: 650; font-size: var(--fs-sm); color: var(--gray-700); }
.hcard__cliente { font-weight: 750; font-size: var(--fs-lg); line-height: 1.25; }
.hcard__team { list-style: none; margin: 2px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.hcard__team li { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 650; padding: 2px 8px; border-radius: var(--r-pill); background: var(--gray-100); }
.hcard__team li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.hcard__team .dot-ok::before { background: var(--green-600); }
.hcard__team .dot-warn::before { background: var(--amber-300); }
.hcard__team .dot-bad::before { background: var(--red-600); }
.hcard__meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: var(--fs-sm); }
.hcard__meta > span { display: inline-flex; align-items: center; gap: 4px; }
.hcard__meta .ok { color: var(--green-700); font-weight: 600; }
.hcard__disc { list-style: none; margin: 4px 0 0; padding: 8px 10px; display: grid; gap: 4px; background: #fff8e6; border: 1px solid #f5d98f; border-radius: var(--r-sm); font-size: var(--fs-sm); color: #6d4400; }
.hcard__disc li { display: flex; align-items: center; gap: 6px; }
.hcard__motivo { color: var(--red-700); margin: 0; }
.hcard__chev { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-400); }

/* Planificación */
.plan-list { display: grid; gap: var(--sp-3); }
.plan-card { padding: var(--sp-4); display: grid; gap: 8px; }
.plan-card__time { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.plan-card__time .icon { color: var(--gray-500); }
.plan-card__tarea { font-weight: 650; font-size: var(--fs-sm); text-transform: uppercase; letter-spacing: .03em; color: var(--brand-700); }
.plan-card__team { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.plan-card__team li { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); padding: 3px 10px; background: var(--gray-100); border-radius: var(--r-pill); }
.plan-card__actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.plan-form { display: grid; gap: var(--sp-3); }
.plan-form__tramos { display: grid; gap: var(--sp-3); }
.tramo-pair { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.tramo-pair .input { flex: 1; min-width: 0; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border: 1px solid var(--border); border-radius: var(--r-sm); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--brand-900); }
.check:has(input:checked) { background: var(--ink-50); border-color: var(--ink-100); font-weight: 650; }
.modal--lg { width: min(760px, calc(100vw - 24px)); }

@media (min-width: 560px) {
  .grid-2, .plan-form__tramos { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 900px) {
  .ttable__head { display: grid; grid-template-columns: 1.3fr 1.4fr 1.4fr .6fr 1fr .9fr; gap: 12px; padding: 0 12px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 650; }
  .ttable__row, .ttable__foot { grid-template-columns: 1.3fr 1.4fr 1.4fr .6fr 1fr .9fr; }
  .ttable__row > * { grid-column: auto; }
  .ttable__row > [data-l]::before { content: none; }
  .ttable__foot > span:empty { display: block; }
}
@media print {
  .datesw, .midia__otro, .plan-card__actions { display: none !important; }
}
