:root {
  --bg: #f4f6f3;
  --panel: #ffffff;
  --ink: #1d2424;
  --muted: #697574;
  --line: #aebab4;
  --line-strong: #aebab4;
  --side: #153d3b;
  --side-soft: #1f5651;
  --accent: #d4573f;
  --accent-dark: #b84431;
  --focus: #2f7b74;
  --ok: #2d7a4f;
  --warn: #a45c18;
  --danger: #b63838;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  letter-spacing: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  /* Reserva el hueco del scrollbar (a la derecha) para que no se coma el padding derecho:
     asi el espacio a izquierda y derecha queda simetrico. */
  scrollbar-gutter: stable;
  background: var(--side);
  color: #f4fbf8;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
}

.logo img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 4px;
}

.logo span,
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.logo strong {
  font-size: 18px;
}

.sidebar nav {
  display: grid;
  gap: 7px;
}

.nav-group {
  display: grid;
  gap: 6px;
  padding: 8px 0 2px;
  border-top: 1px solid rgba(255, 255, 255, .12);
}

.nav-group-title {
  padding: 0 8px 1px;
  color: rgba(244, 251, 248, .68);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 9px;
  border-radius: 8px;
  color: #dbece8;
  border: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
}

.sidebar nav a:hover {
  background: var(--side-soft);
  color: #fff;
}

/* ===== Item activo del menu lateral (pagina actual) =====
   Opcion 2 (aplicada): barra de acento a la izquierda + fondo destacado + icono en acento.
   Para cambiar de opcion, comenta este bloque y descomenta el que prefieras mas abajo. */
.sidebar nav a.is-active {
  background: var(--side-soft);
  color: #fff;
  font-weight: 700;
  border-color: rgba(255, 255, 255, .18);
  box-shadow: inset 3px 0 0 0 var(--accent), inset -3px 0 0 0 var(--accent);
}

.sidebar nav a.is-active .nav-icon {
  background: var(--accent);
  color: #fff;
}

/* --- Opcion 1: fondo relleno sobrio (verde mas claro), sin barra ---
.sidebar nav a.is-active {
  background: var(--side-soft);
  color: #fff;
  font-weight: 700;
  border-color: rgba(255, 255, 255, .25);
}
*/

/* --- Opcion 3: relleno naranja de marca (muy evidente) ---
.sidebar nav a.is-active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  border-color: var(--accent);
}
.sidebar nav a.is-active .nav-icon {
  background: rgba(255, 255, 255, .22);
  color: #fff;
}
*/

/* --- Opcion 4: minimal, solo texto e icono en acento + negrita, sin fondo ---
.sidebar nav a.is-active {
  color: var(--accent);
  font-weight: 800;
}
.sidebar nav a.is-active .nav-icon {
  background: var(--accent);
  color: #fff;
}
*/

.nav-icon {
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

.sidebar-status {
  margin-top: auto;
  padding: 8px 10px 2px;
  color: #b7d2ce;
  font-size: 12px;
  font-weight: 800;
}

/* Boton Salir en el pie del menu (solo movil) */
.sidebar-logout {
  margin-top: 10px;
  display: none;
  text-align: center;
  padding: 10px 10px;
  border-radius: 8px;
  color: #f4fbf8;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .06);
  font-weight: 700;
}

/* Boton Salir en la cabecera (escritorio) */
.topbar-logout {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 700;
  white-space: nowrap;
}
.topbar-logout:hover {
  background: var(--focus, #eef4f2);
}
/* Si no hay "Estado" (no admin), el logout se empuja al fondo */
.sidebar-status + .sidebar-logout {
  margin-top: 10px;
}
.sidebar nav + .sidebar-logout,
.sidebar > .sidebar-logout:not(.sidebar-status + .sidebar-logout) {
  margin-top: auto;
}

.nav-section {
  margin: 14px 12px 4px;
  color: #9fc0bb;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.content {
  min-width: 0;
  padding: 22px;
}

.topbar {
  position: static;
  z-index: 35;
  min-height: 48px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin: -12px 0 9px;
  padding: 7px 0;
  background: transparent;
  color: var(--muted);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}

body.is-scrolled .topbar {
  box-shadow: none;
}

.topbar-spacer {
  flex: 1;
}

/* Boton hamburguesa (solo visible en movil/tablet) */
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 42px;
  height: 42px;
  padding: 9px;
  border: 1px solid var(--line, #d8e2de);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.menu-toggle span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--side, #123);
  border-radius: 2px;
  transition: transform .2s ease, opacity .2s ease;
}

body.sidebar-open .menu-toggle span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
body.sidebar-open .menu-toggle span:nth-child(2) {
  opacity: 0;
}
body.sidebar-open .menu-toggle span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* Overlay oscuro tras el menu off-canvas */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 45;
}
body.sidebar-open .sidebar-overlay {
  display: block;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: min(360px, 46vw);
  padding: 6px 10px 6px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

.user-avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--focus);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}

.user-avatar img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.user-text {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.user-text strong,
.user-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-text strong {
  margin-right: auto;
  color: var(--ink);
  font-weight: 700;
}

.user-text small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.page-head {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

.sticky-head {
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  backdrop-filter: blur(8px);
  transition: padding-right .22s ease;
}

.sticky-head .head-actions {
  position: relative;
  z-index: 21;
}

/* Reserva de espacio para la campana fija cuando hay avisos y se hace scroll. Es un valor de respaldo
   aproximado; el JS lo ajusta exacto para que el ultimo boton quede a la misma distancia de la campana
   (10px, el gap de .head-actions) que hay entre los demas botones. */
body.has-active-notifications.is-scrolled .sticky-head {
  padding-right: 84px;
}

.back-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  font-size: 0;
  line-height: 0;
  color: var(--focus);
  --back-size: 16px;
  --back-stroke: 3px;
}

/* Flecha de volver dibujada con CSS (en lugar del glifo de la tipografia, que queda desplazado en vertical): mismo patron que .x-icon.
   Un <span aria-hidden> hijo del enlace con un angulo (bordes izquierdo e inferior girados 45 grados) centrado en su caja.
   Tamano y trazo con --back-size / --back-stroke; color currentColor (tema claro y noche). El translateX compensa que el angulo
   girado ocupa solo la mitad izquierda de su caja. */
.back-icon {
  position: relative;
  display: block;
  flex: none;
  box-sizing: border-box;
  width: var(--back-size, 16px);
  height: var(--back-size, 16px);
  margin: 0 !important;
  font-size: 0;
  line-height: 0;
  pointer-events: none;
}
.back-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  box-sizing: border-box;
  width: calc(var(--back-size, 16px) * .62);
  height: calc(var(--back-size, 16px) * .62);
  border-left: var(--back-stroke, 3px) solid currentColor;
  border-bottom: var(--back-stroke, 3px) solid currentColor;
  border-radius: 1px;
  transform: translate(-50%, -50%) translateX(calc(var(--back-size, 16px) * .22)) rotate(45deg);
}

.record-nav {
  display: inline-flex;
  gap: 6px;
}

.icon-link {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--focus);
  font-size: 24px;
  font-weight: 900;
}

.icon-link.disabled {
  color: var(--muted);
  background: #f0f3f0;
  pointer-events: none;
}

.head-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-line {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}

.info-popover-wrap {
  position: relative;
  display: inline-flex;
}

.info-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  border-color: #c9d6d0;
  background: #fff;
  color: var(--focus);
  font-weight: 900;
}

.info-popover {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 45;
  width: 280px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 42px rgba(29, 36, 36, .16);
  font-size: 13px;
}

/* El popover de info (Vacaciones / Control de recogidas) se muestra al pasar el raton
   por encima, sin necesidad de clicar. El puente ::before evita perder el hover en el hueco. */
.info-popover-wrap:hover .info-popover,
.info-popover-wrap:focus-within .info-popover {
  display: block;
}

/* Etiqueta de campo con boton info (p.ej. "Tipo Servicio" en la ficha de servicio):
   texto y boton en linea; el boton se muestra mas pequeno que en las cabeceras. */
.label-with-info {
  display: flex;
  align-items: center;
  gap: 6px;
}

.label-with-info .info-button {
  width: 18px;
  height: 18px;
  min-height: 18px;
  font-size: 11px;
}

.info-popover-wide {
  width: 320px;
}

.info-popover::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

.info-popover p {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 0 0;
}

.legend-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.legend-ok {
  background: #edf8f1;
}

.legend-warn {
  background: #fff3d3;
}

.legend-alert {
  background: #fde7dd;
}

.legend-empty {
  background: #fff;
}

/* Leyendas de las listas de Albaranes y Facturas (mismo .legend-dot que Control de recogidas). */
.legend-generic {
  background: #eaf1fb;
}

.legend-diff {
  background: #fbecec;
}

.legend-invoice-notice {
  background: #fff8ed;
  border-color: #ebcf9e;
}

/* Dentro del popover reutilizable (.service-type-info) los parrafos son de bloque: las filas de leyenda vuelven a ser flex. */
.service-type-info .info-popover p.info-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Campo con simbolo de euro */
.input-euro {
  position: relative;
  display: block;
}

.input-euro input {
  width: 100%;
  padding-right: 26px;
}

.input-euro::after {
  content: "\20AC";
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 700;
  pointer-events: none;
}

/* Leyenda del calendario de vacaciones */
.legend-box {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--line);
  margin-right: 8px;
  vertical-align: middle;
  flex: 0 0 auto;
}

.legend-box.legend-vacation {
  background: #e7f4e4;
  border-color: #1b6a2c;
}

.legend-box.legend-holiday {
  background: #fff8d8;
  border-color: #d8b400;
}

.legend-box.legend-weekend {
  background: #ed8479;
  border-color: #d1594c;
}

.legend-box.legend-today {
  background: #2e7dd7;
  border-color: #1f5fa8;
}

.order-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 0 12px;
  font-weight: 800;
  color: var(--focus);
}

.order-badge-inline {
  border-color: var(--focus);
}
/* Codigo de orden grande (formato como en Introduccion) manteniendo el recuadro. */
.order-badge-big {
  font-size: 30px;
  line-height: 1;
  min-height: 48px;
  padding: 2px 16px;
  letter-spacing: .5px;
  color: var(--accent);
}

.inline-form {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.inline-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
}

.inline-select select {
  min-height: 36px;
  min-width: 150px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: #eaf4ee;
  color: #266343;
  font-weight: 800;
}

.status-pill.warning-pill {
  background: #fdecec;
  color: #b3261e;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

h3 {
  font-size: 15px;
  margin-bottom: 10px;
}

.eyebrow {
  margin-bottom: 5px;
  color: var(--accent-dark);
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
}

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

.button,
button {
  border: 1px solid var(--line-strong);
  background: var(--btn-bg, #fff);
  color: var(--ink);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
  min-height: 38px;
}

.button:hover,
button:hover {
  border-color: var(--focus);
}

/* Boton Exportar (descargas de Excel): outline con el color de marca + icono de descarga */
.button[href*="-export"] {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  border-color: var(--accent);
  background: transparent;
  font-weight: 600;
}

.button[href*="-export"]:hover {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.export-ico {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.form-actions .primary {
  background: #57AB71;
  border-color: #57AB71;
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.form-actions .primary:hover {
  background: #4f9f68;
  border-color: #4f9f68;
}

.pickup-status-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pickup-status-actions .inline-form {
  margin: 0;
}

.danger-button {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  font-weight: 700;
}

.danger-button:hover {
  filter: brightness(.94);
  border-color: var(--danger);
}

.ghost {
  background: transparent;
}

.searchbar,
.scan-panel {
  display: flex;
  gap: 10px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
}

.compact-filter {
  grid-template-columns: repeat(5, minmax(105px, 1fr));
  gap: 9px;
  padding: 12px;
}

.firefighter-filter {
  grid-template-columns: minmax(140px, 1.05fr) minmax(140px, 1.05fr) minmax(110px, .8fr) minmax(115px, .85fr) minmax(115px, .85fr) minmax(115px, .85fr) auto;
}

.garment-filter {
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) minmax(120px, .85fr) minmax(120px, .9fr) minmax(115px, .8fr) minmax(115px, .8fr) auto;
}

.pickup-filter {
  grid-template-columns: minmax(170px, 1.2fr) minmax(135px, .9fr) minmax(145px, .95fr) minmax(110px, .7fr) minmax(122px, .72fr) minmax(122px, .72fr) minmax(112px, .68fr) minmax(150px, auto);
  gap: 8px;
  align-items: end;
}

.pickup-filter > label,
.pickup-filter .combo-filter,
.pickup-filter .date-stack,
.pickup-filter .filter-actions {
  align-self: end;
}

.firefighter-filter .filter-actions,
.garment-filter .filter-actions,
.pickup-filter .filter-actions,
.aligned-filter .filter-actions {
  grid-column: auto;
  flex-wrap: nowrap;
  align-self: end;
  padding-bottom: 16px;
}

.pickup-filter .filter-actions {
  padding-bottom: 0;
  min-width: 150px;
  justify-content: flex-start;
}

.pickup-filter > label {
  display: grid;
  grid-template-rows: auto 34px;
  gap: 4px;
  margin: 0;
}

.pickup-filter > label > span,
.pickup-filter .combo-filter > span {
  min-height: 14px;
  margin-bottom: 0;
  line-height: 1.15;
}

.pickup-filter > label > input,
.pickup-filter > label > select,
.pickup-filter .combo-filter > input {
  min-height: 34px;
}

.sack-display,
.sack-color-field {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.sack-dot,
.sack-color-preview {
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 1px solid #87918c;
  border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .28);
}

.sack-color-preview {
  cursor: pointer;
  padding: 0;
  min-height: 16px;
}

.sack-color-green { background: #57AB71; }
.sack-color-blue { background: #3c7bdc; }
.sack-color-red { background: #d94b4b; }
.sack-color-black { background: #1e2224; }
.sack-color-white { background: #fff; }
.sack-color-empty { background: #eef2ef; }

/* Lista: varios colores de saca (un punto por color y sus nombres en texto pequeno). */
.sack-display {
  flex-wrap: wrap;
  gap: 4px 5px;
}

.sack-display > .sack-dot {
  flex: 0 0 auto;
}

.sack-display .sack-color-names {
  margin-left: 2px;
  color: var(--muted);
  font-size: 12px;
}

/* Ficha de control de recogidas: seleccion multiple de colores como chips con muestra de color. */
.sack-color-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.sack-color-chips .sack-color-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 4px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

/* La casilla sigue existiendo (foco, envio y :checked) pero no se ve. */
.sack-color-chips .sack-color-chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 1px;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.sack-color-chips .sack-color-chip .sack-dot {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  opacity: .7;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease;
}

.sack-color-chips .sack-color-chip:hover .sack-dot {
  opacity: 1;
}

.sack-color-chips .sack-color-chip input:checked + .sack-dot {
  opacity: 1;
  border: 2px solid #1e2224;
  transform: scale(1.12);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0b6bcb;
}

.sack-color-chips .sack-color-chip input:focus-visible + .sack-dot {
  outline: 3px solid rgba(11, 107, 203, .6);
  outline-offset: 3px;
}

.sack-color-chips .sack-color-chip input:disabled + .sack-dot {
  cursor: not-allowed;
}

.sack-color-chips .sack-color-chip input:disabled:not(:checked) + .sack-dot {
  opacity: .35;
}

.sack-color-chips .sack-color-hint {
  flex: 1 1 100%;
  color: #c0261c;
  font-size: 12px;
  font-weight: 700;
}

.sack-color-chips .sack-color-hint[hidden] {
  display: none;
}

html.theme-dark .sack-color-chips .sack-color-hint {
  color: #ffb3ad;
}

/* Ficha de control de recogidas: Peticiones como chips de texto seleccionables (sin interruptor ni casilla visibles). */
.pickupcontrol-form .request-options {
  gap: 10px;
}

.pickupcontrol-form .request-options .email-switch {
  min-height: 36px;
  padding: 6px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(127, 127, 127, .08);
  color: var(--text);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}

.pickupcontrol-form .request-options .email-switch:hover {
  border-color: #0b6bcb;
}

.pickupcontrol-form .request-options .email-switch .email-switch-track {
  display: none;
}

.pickupcontrol-form .request-options .email-switch .email-switch-label {
  font-size: 14px;
  font-weight: 600;
}

.pickupcontrol-form .request-options .email-switch:has(input:checked) {
  background: #0b6bcb;
  border: 3px solid #084b8f;
  padding: 4px 14px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35), 0 1px 4px rgba(11, 107, 203, .45);
  color: #fff;
}

.pickupcontrol-form .request-options .email-switch:has(input:checked) .email-switch-label {
  color: #fff;
  font-weight: 800;
}

.pickupcontrol-form .request-options .email-switch:has(input:focus-visible) {
  outline: 3px solid rgba(11, 107, 203, .6);
  outline-offset: 3px;
}

.pickupcontrol-form .request-options .email-switch:has(input:disabled) {
  cursor: not-allowed;
  opacity: .5;
}

.pickupcontrol-form .request-options .email-switch:has(input:disabled:checked) {
  opacity: 1;
}

.request-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
}

.request-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  margin: 0;
  color: var(--text);
}

.sack-color-panel {
  width: min(420px, 94vw);
}

.sack-color-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(58px, 1fr));
  gap: 10px;
}

.sack-color-choice {
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 62px;
  color: #10201a;
  border: 1px solid var(--line);
}

.sack-color-choice::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 1px solid rgba(0, 0, 0, .28);
  border-radius: 5px;
  background: inherit;
}

.sack-color-choice.sack-color-black {
  color: #fff;
}

.date-stack {
  display: grid;
  gap: 4px;
}

.date-stack label span {
  font-size: 11px;
  margin-bottom: 2px;
}

.date-stack input {
  min-height: 30px;
  padding: 5px 8px;
}

.compact-filter > label:not(.combo-filter) {
  padding-bottom: 16px;
}

.compact-filter label span,
.compact-filter .combo-filter span {
  font-size: 12px;
}

.compact-filter input,
.compact-filter select {
  min-height: 34px;
  padding: 7px 8px;
}

.filter-actions .filter-button,
.filter-actions .filter-clear {
  background: #f7faf7;
  border-color: #aebab4;
  color: #31514c;
}

.filter-actions .filter-button:hover,
.filter-actions .filter-clear:hover {
  background: #edf5f0;
  border-color: #bfd1c8;
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.combo-filter,
.text-combo-filter {
  position: relative;
}

.combo-filter:focus-within,
.text-combo-filter:focus-within {
  z-index: 35;
}

.record-combo input,
.combo-filter > input,
.text-combo-filter > input {
  color: var(--ink);
  padding-right: 32px;
}

.record-combo::after,
.combo-filter::after,
.text-combo-filter::after {
  content: "";
  position: absolute;
  right: 12px;
  pointer-events: none;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #8d9a96;
}

.record-combo::after {
  top: 50%;
  transform: translateY(-35%);
}

.combo-filter::after {
  top: 37px;
}

.text-combo-filter::after {
  top: 37px;
}

.combo-clear {
  position: absolute;
  right: 7px;
  z-index: 2;
  display: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #edf2ef;
  color: #5d6b66;
  font-size: 21px;
  line-height: 1;
  --x-size: 11px;
  --x-stroke: 2px;
}

.combo-clear:hover {
  background: #dde8e1;
  color: var(--ink);
}

.record-combo .combo-clear {
  top: 50%;
  transform: translateY(-50%);
}

/* Combos de filtro (etiqueta encima + caja): la "x" se ancla al BORDE INFERIOR de la caja, que no depende de la altura de la etiqueta
   (con top fijo en px quedaba ligeramente elevada). Centrado = (altura de la caja - 28px de la "x") / 2: caja de 38px -> 5px; cajas
   de 34px (filtros compactos, buscadores mini y de recogidas) -> 3px. */
.combo-filter .combo-clear,
.text-combo-filter .combo-clear {
  top: auto;
  transform: none;
}

/* .combo-filter reserva 16px de padding abajo para el aviso (.combo-hint): la caja termina 16px por encima del borde inferior del
   contenedor, asi que a los 5px / 3px se les suman esos 16px. .text-combo-filter no reserva ese espacio. */
.combo-filter .combo-clear { bottom: 21px; }
.text-combo-filter .combo-clear { bottom: 5px; }

.compact-filter .combo-filter .combo-clear,
.mini-searchbar .combo-filter .combo-clear { bottom: 19px; }
.compact-filter .text-combo-filter .combo-clear,
.mini-searchbar .text-combo-filter .combo-clear { bottom: 3px; }

/* Barra de recogidas: el combo no reserva el padding de abajo (padding-bottom: 0) y su caja es de 34px. */
.pickup-filter .combo-filter .combo-clear { bottom: 3px; }

.combo-clear:disabled {
  display: none !important;
}

.record-combo.is-filled .combo-clear,
.combo-filter.is-filled .combo-clear,
.text-combo-filter.is-filled .combo-clear {
  display: inline-flex;
}

.record-combo.is-filled::after,
.combo-filter.is-filled::after,
.text-combo-filter.is-filled::after {
  display: none;
}

/* El combo "Cod. bombero / Nombre" incluye el boton Filtrar dentro del .combo-filter, por lo que la flecha
   ::after quedaba mal colocada (sobre la "r" de Filtrar). Se oculta para este combo. */
[data-preq-ff-combo]::after {
  display: none !important;
}

/* Selector nativo (p. ej. parque en la solicitud de recogida del cliente) con boton de limpiar (x). */
.combo-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.combo-select-wrap select {
  flex: 1;
  width: 100%;
  padding-right: 52px;
}

.combo-select-wrap .combo-clear {
  display: inline-flex;
  top: 50%;
  right: 30px;
  transform: translateY(-50%);
}

/* Cobertura de una orden por encima del 100%: se resalta en negrita y rojo suave. */
input.coverage-over {
  color: #c0392b;
  font-weight: 700;
}

/* Filas de "Mis ordenes" (portal) que son solicitudes de recogida aun sin orden: en espera de recepcion. */
.pending-pickup-row {
  background: #fff8e6;
  font-style: italic;
}

/* Tabla de prendas de la solicitud de recogida: redimensionable solo en vertical (ancho fijo). */
.preq-lines-wrap {
  resize: vertical;
  overflow: auto;
  width: 100%;
  min-height: 160px;
  max-height: 80vh;
}

.searchbar input,
.scan-panel input {
  width: min(720px, 100%);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #aebab4;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
  min-height: 38px;
}

textarea {
  resize: vertical;
}

/* Observaciones de fichas con auto-alto: sin barra de scroll hasta superar el maximo de 3 lineas
   (el JS pone overflow-y:auto cuando hace falta). Redimensionable en vertical (heredado de textarea). */
textarea[data-obs-autosize] {
  overflow-y: hidden;
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(47, 123, 116, .18);
  border-color: var(--focus);
}

label span {
  display: block;
  color: #31403e;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 5px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.work-metric-grid {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric {
  display: grid;
  gap: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 28px;
}

/* Tarjetas de contadores del Inicio (escritorio y tablet): cada tarjeta mide lo que ocupa su texto (max-content) y se reparte el
   espacio sobrante, de modo que todas quedan en una sola fila mientras el texto quepa. Si el total no cabe, pasan a otra fila
   (flex-wrap) y, si una tarjeta sola no cabe, su rotulo se parte en dos lineas. Padding y letra se reducen un poco con el ancho.
   En movil (<=640px) rige la rejilla de 2 columnas de abajo. */
@media (min-width: 641px) {
  .work-metric-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: clamp(8px, 1vw, 12px);
  }

  .work-metric-grid > .metric {
    flex: 1 1 max-content;
    min-width: 0;
    max-width: 100%;
    padding: clamp(10px, 1.1vw, 14px);
  }

  .work-metric-grid > .metric span {
    font-size: clamp(12px, 1vw, 13px);
  }

  .work-metric-grid > .metric strong {
    font-size: clamp(22px, 2vw, 28px);
  }
}

.dashboard-welcome {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.dashboard-welcome h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.dashboard-welcome p {
  margin-bottom: 0;
  color: var(--muted);
  font-weight: 650;
}

.dashboard-welcome p strong {
  color: var(--ink);
}

.today-strip {
  /* Los resumenes de hoy (quesitos de entradas/salidas + chip de solicitudes) van en paralelo,
     con el mismo ancho que las cajas anteriores. */
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: start;
}

/* Selector de dia de los quesitos de Entradas/Salidas: flechas + etiqueta (va en la tercera columna, encima de las tarjetas). */
.today-nav {
  /* Una sola fila: flecha - etiqueta (encoge con puntos suspensivos) - flecha. El estado (vacio casi siempre) va en una fila propia. */
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.today-nav-btn {
  width: 32px;
  height: 32px;
  min-height: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  color: var(--ink);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}

.today-nav-btn:hover {
  border-color: var(--focus);
  background: #eef8f3;
}

.today-nav-btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.today-nav-btn[aria-disabled="true"] {
  opacity: .4;
  cursor: not-allowed;
}

.today-nav-btn[aria-disabled="true"]:hover {
  border-color: var(--line);
  background: #f7faf7;
}

.today-nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-weight: 800;
  color: var(--ink);
}

.today-nav-status {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.today-nav-status:empty {
  display: none;
}

/* "Recogidas por llegar" y "Equipos por llegar": dos tarjetas iguales, una debajo de la otra, en la tercera columna. */
.today-chip-stack {
  display: grid;
  gap: 10px;
  min-width: 0;
  align-content: start;
}

@media (max-width: 760px) {
  /* Movil: el selector pasa a una fila propia arriba; debajo los dos quesitos y las tarjetas apiladas en la tercera columna. */
  /* El selector de dia va dentro de .today-chip-stack, asi que el contenedor se "disuelve" (display:contents) para que sus hijos sean
     celdas de la tira. Filas: 1 = selector, 2 y 3 = las dos tarjetas (una justo debajo de la otra, columna 3), 4 = fila flexible que
     absorbe la altura sobrante. Los quesitos ocupan las filas 2 a 4 (columnas 1 y 2), asi las tarjetas quedan pegadas arriba y
     "Equipos por llegar" no se va abajo del todo. */
  .today-strip {
    grid-template-rows: auto auto auto 1fr;
  }

  .today-chip-stack {
    display: contents;
  }

  .today-nav {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .today-strip > .today-pie {
    grid-row: 2 / span 3;
  }

  .today-chip-stack > .today-chip {
    grid-column: 3;
    align-self: start;
  }

  .today-chip-stack > .today-chip:nth-of-type(1) {
    grid-row: 2;
  }

  .today-chip-stack > .today-chip:nth-of-type(2) {
    grid-row: 3;
  }
}

.today-strip.is-loading .today-pie {
  opacity: .55;
}

/* Administrador con el script 045: tercer quesito «Reparadas» (por costurera) junto a Entradas y Salidas, sin enlace (no se resalta al pasar el raton). */
.today-strip.has-repairs {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.today-pie.today-pie-static:hover {
  border-color: var(--line);
  background: #f7faf7;
}

html.theme-dark .today-pie.today-pie-static:hover {
  border-color: var(--line-strong);
  background: #232a2d;
}

@media (max-width: 760px) {
  /* Movil: Entradas y Salidas siguen en paralelo (columnas 1 y 2) y Reparadas ocupa una fila propia debajo, a todo el ancho. */
  .today-strip.has-repairs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .today-strip.has-repairs > .today-pie-static {
    grid-column: 1 / -1;
    grid-row: 5;
  }
}

.today-chip {
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  transition: border-color .18s ease, background .18s ease;
}

.today-chip:hover {
  border-color: var(--focus);
  background: #eef8f3;
}

.today-chip small {
  color: var(--muted);
  font-weight: 800;
}

.today-chip strong {
  font-size: 24px;
}

/* Tarjeta-quesito de "Entradas hoy" / "Salidas hoy": pie + leyenda por cliente + total. */
.today-pie {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf7;
  color: var(--ink);
  text-decoration: none;
  transition: border-color .18s ease, background .18s ease;
}

.today-pie:hover {
  border-color: var(--focus);
  background: #eef8f3;
}

.today-pie > small {
  color: var(--muted);
  font-weight: 800;
}

/* Pie arriba y leyenda debajo (apilados) para caber en el ancho estrecho de cada columna. */
.today-pie-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.pie-svg {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
}

.pie-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 3px;
  width: 100%;
  min-width: 0;
}

.pie-legend li {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  min-width: 0;
}

.pie-dot {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  flex: 0 0 9px;
}

.pie-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pie-legend li strong {
  font-weight: 800;
}

.today-pie-total {
  border-top: 1px solid var(--line);
  padding-top: 6px;
  font-weight: 800;
}

.today-pie-total strong {
  color: var(--focus);
}

.today-pie-empty {
  color: var(--muted);
  padding: 8px 0;
}

.dashboard-block {
  min-width: 0;
}

.dashboard-block h2 {
  margin-bottom: 10px;
}

.admin-group-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.mini-catalog-card {
  min-width: 0;
}

/* Configuracion vacaciones: pagina de lista a alto completo (como Ordenes) con pestanas; la tabla de la pestana
   activa rellena el alto y hace scroll por dentro (.main-list-page .module-list-scroll). */
.vacation-config-page > .tabs {
  flex: 0 0 auto;
  margin-bottom: 12px;
}

.vacation-config-page > .vacation-config-card {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.vacation-config-card > .mini-card-head,
.vacation-config-card > .mini-searchbar {
  flex: 0 0 auto;
}

/* Usuarios: pagina de lista a alto completo (como Ordenes) con una pestana por tabla; la tabla de la pestana visible
   rellena el alto y hace scroll por dentro con carga incremental (sin la caja de 280px de .mini-catalog-card). */
.users-config-page > .tabs {
  flex: 0 0 auto;
  margin-bottom: 12px;
}

.users-config-page > .users-tab-panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.users-config-page > .users-tab-panel[hidden] {
  display: none;
}

.users-tab-panel > .mini-card-head,
.users-tab-panel > .filter-panel {
  flex: 0 0 auto;
}

.users-tab-panel > [data-list-region] {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 640px) {
  .main-list-page.users-config-page {
    height: auto;
    overflow: visible;
  }

  .users-config-page .module-list-scroll {
    flex: 0 1 auto;
    min-height: 240px;
    max-height: 70vh;
    max-height: 72dvh;
  }
}

.mini-catalog-card .table-wrap {
  max-height: 280px;
  overflow: auto;
}

.mini-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.mini-card-head h2 {
  margin: 0;
}

.mini-card-head .button {
  padding: 7px 10px;
  min-height: 32px;
}

/* Acciones de la cabecera de una tarjeta ([Exportar][+]): pegadas entre si y alineadas a la derecha, como en Ordenes / Prendas. */
.mini-card-head .card-head-actions {
  margin-left: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 640px) {
  .mini-card-head {
    flex-wrap: wrap;
  }

  .mini-card-head .card-head-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

.mini-searchbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}

.mini-searchbar input,
.mini-searchbar select {
  min-height: 34px;
  padding: 7px 9px;
}

.mini-searchbar button,
.mini-searchbar .button {
  min-height: 34px;
  padding: 7px 10px;
}

.dashboard-notifications {
  margin-bottom: 24px;
}

/* Aviso sin leer: acento naranja suave (mismo tono que el verde de expedidas) */
.dashboard-notifications .dashboard-alert-table table tbody tr td {
  background: #fdf1e3;
}

.dashboard-alert-table {
  margin-bottom: 4px;
}

.dashboard-alert-table .table-action {
  width: 1%;
  min-width: max-content;
  white-space: nowrap;
}

/* Accion: los botones (p. ej. Completar + Posponer) van siempre en una sola linea. Antes .inline-actions
   hacia wrap y, dentro de una celda de ancho 1%, cada boton caia en su propia linea. */
.dashboard-alert-table .table-action .inline-actions {
  flex-wrap: nowrap;
}

/* Aviso/Mensaje absorben el ancho restante y pueden partirse en varias lineas. */
.dashboard-alert-table td.alert-text {
  white-space: normal;
  min-width: 180px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1100px);
  justify-content: center;
  gap: 16px;
  margin-bottom: 18px;
}

/* Cabecera del asistente: numero de orden grande a la izquierda del titulo (como en la ficha de
   una orden pero a mayor tamano). */
.assistant-head .assistant-head-main {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.assistant-order-code {
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  color: var(--accent);
  letter-spacing: .5px;
  white-space: nowrap;
}

.assistant-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.assistant-grid .field > span {
  font-weight: 700;
}

/* Campos destacados del asistente (Ejercicio y Num. orden): texto mas grande y en color de marca,
   sin alterar el tamano del recuadro (la altura la fija min-height del input). */
.assistant-key-field input {
  color: var(--accent);
  -webkit-text-fill-color: var(--accent);
  font-size: 17px;
  font-weight: 800;
  /* Se reduce el line-height y el padding vertical para que, pese a la letra mas grande, la altura
     del recuadro (min-height 38px) sea igual que la de los demas campos. */
  line-height: 1.1;
  padding-top: 5px;
  padding-bottom: 5px;
}

/* Valores de los campos de "Entrada de material" en negrita */
.assistant-grid input,
.assistant-grid select,
.assistant-grid textarea,
.assistant-grid .record-combo input {
  font-weight: 700;
}

.assistant-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

/* Observaciones en Entrada de material: una linea de alto, de lado a lado */
.assistant-grid .field.assistant-observations {
  grid-column: 1 / -1;
}

/* Marca de campo obligatorio */
.required-mark {
  display: inline;
  color: #c0392b;
  font-weight: 700;
}

/* Fila de campo con valor-enlace y botones (copiar / cambiar) */
.field-linkrow {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* El recuadro clicable ocupa el ancho del campo (no se encoge al texto). */
.field-linkrow .readonly-link {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

/* Los botones (copiar / cambiar) mantienen su tamaño pequeno. */
.field-linkrow .copy-icon-btn,
.field-linkrow .icon-button {
  flex: 0 0 auto;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  line-height: 1;
  font-size: 14px;
}

.icon-button:hover {
  border-color: var(--line-strong);
}

.copy-button.copied {
  background: #2e7d32;
  color: #fff;
  border-color: #2e7d32;
}

/* Boton de copiar sin recuadro (ficha de prenda: cod. barras y arnes) */
.copy-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  vertical-align: middle;
}

.copy-icon-btn:hover {
  color: var(--ink);
}

.copy-icon-btn.copied {
  color: #2e7d32;
}

/* Fila del cod. barras editable con su boton de copiar al lado */
.field-copy-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.field-copy-row input {
  flex: 1 1 auto;
  min-width: 0;
}

/* Columna de icono de notificacion sin leer en la lista de ordenes */
.notif-col {
  width: 30px;
  text-align: center;
  padding-left: 4px;
  padding-right: 4px;
}

.notif-warning {
  font-size: 16px;
  line-height: 1;
  color: #e6a100;
  font-weight: 700;
}

/* Icono de aviso: rojo mientras no se ha descartado, ambar una vez descartado. */
.notif-warning.notif-warning-red {
  color: #e5484d;
}
.notif-warning.notif-warning-dismissed {
  color: #e6a100;
}

/* Region de tabla mientras se recarga por AJAX (filtrado de listas) */
[data-list-region].is-loading {
  opacity: 0.55;
  transition: opacity 0.12s ease;
  pointer-events: none;
}

/* Avisos del asistente (Introduccion): mismo ancho (1100px) y centrado que los recuadros, para que
   no queden a ancho completo y descuadrados. */
.assistant-alert {
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}

/* Buscador de codigo de barras del asistente: mismo ancho y centrado que la tarjeta Entrada de material */
.assistant-search {
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}

.assistant-search input[name="q"] {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
}

/* Codigo de barras bloqueado (prenda ya seleccionada): en negrita y no editable; solo se cambia con Limpiar. */
.assistant-search input.assistant-search-locked {
  font-weight: 800;
}

.assistant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.assistant-cleaning {
  grid-column: 1 / -1;
  margin-top: 14px;
}

.assistant-cleaning h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.assistant-service-editor {
  min-width: 0;
  width: 100%;
  table-layout: fixed;
}

.service-editor .service-line-number {
  display: inline-block;
  min-width: 2ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--muted, #667);
}

/* Ocultar columnas F. limite y F. final cuando el cliente no usa presupuestos.
   Se marcan con la clase svc-col-budget (la columna Cant. es opcional, por eso no se usa nth-child). */
.service-editor.hide-budget-dates th.svc-col-budget,
.service-editor.hide-budget-dates td.svc-col-budget {
  display: none;
}

.assistant-code-col {
  width: 18%;
}

.assistant-description-col {
  width: 61%;
}

/* Columna Cant. de Introduccion (solo si algun tipo ofrecido tiene la cantidad editable). */
.assistant-qty-col {
  width: 56px;
}

.assistant-service-editor td.svc-col-qty input.service-qty {
  min-width: 0;
  width: 100%;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.assistant-price-col {
  width: 12%;
}

.assistant-delete-col {
  width: 42px;
}

.assistant-service-editor td:nth-child(1) input,
.assistant-service-editor td:nth-child(2) input,
.assistant-service-editor td:nth-child(3) input {
  min-width: 0;
}

.assistant-cleaning .table-wrap {
  overflow-x: hidden;
}

.assistant-service-editor input[name="Price"] {
  min-width: 0;
  max-width: 8ch;
}

.assistant-service-editor th,
.assistant-service-editor td {
  padding: 6px 7px;
}

.assistant-service-editor .service-delete {
  width: 30px;
  height: 30px;
  min-height: 30px;
  font-size: 14px;
  line-height: 1;
}

.assistant-operations-table {
  max-height: 560px;
  overflow-y: auto;
  overflow-x: auto;
}

.assistant-detail {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

.assistant-detail dt {
  color: var(--muted);
  font-weight: 800;
}

.assistant-detail dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.assistant-detail-table {
  min-width: 0;
  table-layout: fixed;
}

.assistant-detail-table th,
.assistant-detail-table td {
  white-space: normal;
  padding: 8px 10px;
}

.assistant-detail-table th {
  position: static;
  width: 42%;
  background: #f4f7f5;
  color: var(--muted);
  text-transform: none;
  font-size: 13px;
}

.assistant-detail-table td {
  overflow-wrap: anywhere;
}

.bulk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.upload-panel {
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.upload-panel form {
  margin-top: 4px;
}

.split-layout > div,
.form-section,
.related,
.notice,
.related-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap.module-list-scroll {
  max-height: calc(100vh - 300px);
  min-height: 300px;
  overflow-y: auto;
  overflow-x: auto;
}

.main-list-page {
  height: calc(100vh - 104px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.main-list-page .page-head,
.main-list-page .searchbar,
.main-list-page .filter-panel {
  flex: 0 0 auto;
}

.main-list-page .module-list-scroll {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

/* La region de tabla (recargable por AJAX) debe comportarse como contenedor flex transparente
   para que el contenedor de scroll interno (.module-list-scroll / .orders-scroll-table) rellene
   el alto disponible y pueda hacer scroll, igual que cuando la tabla era hija directa. */
.main-list-page > [data-list-region],
.orders-page-shell > [data-list-region] {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pickup-controls-table td:nth-child(9) {
  font-weight: 800;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
  user-select: text;
}

th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: #eef3ef;
  color: #38504b;
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  cursor: default;
}

tbody tr[data-href] {
  cursor: pointer;
}

tbody tr:hover {
  background: #f6ddb8;
}

.empty {
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 22px;
}

.record-form {
  display: grid;
  gap: 14px;
}

.compact-form {
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

/* Bloque superior de la ficha de orden: recuadros de ANCHO FIJO (~20 caracteres) para que todos midan
   igual y el bloque quede simetrico/uniforme (evita que la ultima fila se estire con 1fr). */
.order-top-block .form-grid {
  grid-template-columns: repeat(auto-fill, 20ch);
  justify-content: start;
  gap: 10px 12px;
}
/* Cada campo ocupa exactamente su celda; los controles (incluido el desplegable "Estado prenda") se
   ajustan al ancho y pueden encogerse (min-width:0) para no ensancharse por su contenido. */
.order-top-block .form-grid > .field {
  width: 20ch;
  min-width: 0;
}
.order-top-block .form-grid input,
.order-top-block .form-grid select,
.order-top-block .form-grid .record-combo,
.order-top-block .form-grid .field-linkrow {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
/* La etiqueta no rompe la altura de la fila: una sola linea con puntos suspensivos si no cabe. */
.order-top-block .form-grid > .field > span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 640px) {
  .order-top-block .form-grid {
    grid-template-columns: 1fr;
  }
  .order-top-block .form-grid > .field {
    width: 100%;
  }
}

.field.wide {
  grid-column: 1 / -1;
}

/* Configuracion de impresiones: desplegable de logo + previsualizacion debajo. */
.logo-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 8px;
  border: 1px dashed #c9d6d0;
  border-radius: 8px;
  background: #fff;
}

.logo-preview img {
  max-width: 100%;
  max-height: 96px;
  object-fit: contain;
}

.logo-preview-empty {
  color: #8a968f;
  font-size: 12px;
}

/* El texto es un <span> dentro de un <label>, y la regla global "label span { display:block }"
   anula el atributo hidden. Esta regla mas especifica restaura el ocultado. */
.logo-preview-empty[hidden] {
  display: none;
}

/* Valor de un campo mostrado como enlace clicable (p.ej. "Albaran" en la ficha de orden).
   Se muestra dentro de un recuadro igual que el resto de controles del formulario. */
.record-link-value {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 9px 10px;
  width: 100%;
  border: 1px solid #aebab4;
  border-radius: 8px;
  background: #fff;
  font-weight: 700;
  color: var(--focus);
  text-decoration: none;
}

.record-link-value:hover {
  text-decoration: underline;
}

/* Titulo de seccion con boton a la derecha */
.section-head-inline {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.warning-add-head {
  font-size: 1.4em;
  line-height: 1;
  padding: 2px 12px;
}

/* Acordeon */
.accordion-section .accordion-head[data-accordion-toggle] {
  cursor: pointer;
}

.accordion-section .accordion-head {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
  margin: 0;
  justify-content: space-between;
}

.accordion-head-left {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.accordion-head-right {
  display: inline-flex;
  align-items: center;
}

.discount-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .9rem;
  font-weight: 600;
}

.discount-inline input {
  width: 90px;
}

.fixed-price-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .9rem;
  font-weight: 600;
  margin-right: 16px;
  cursor: pointer;
  user-select: none;
}

.fixed-price-inline input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.accordion-toggle-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  line-height: 24px;
  text-align: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--focus);
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.accordion-toggle-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.accordion-body {
  margin-top: 12px;
}

/* Checkboxes a mitad de tamano, alineados con su texto */
.checkbox-list.small-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.checkbox-list.small-checkboxes .checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .92rem;
}

.checkbox-list.small-checkboxes .checkbox-item input[type="checkbox"] {
  width: 13px;
  height: 13px;
  min-height: 13px;
  margin: 0;
  transform: none;
  flex: 0 0 auto;
}

.checkbox-list.small-checkboxes .checkbox-item span {
  line-height: 1;
}

/* Dos secciones del formulario en paralelo (misma fila) */
.section-parallel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}

.section-parallel > .form-section {
  margin: 0;
}

@media (max-width: 900px) {
  .section-parallel {
    grid-template-columns: 1fr;
  }
}

.field input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

/* Marcado de campos obligatorios sin rellenar */
.field.field-required-error > span {
  color: #c0261c;
}

.field.field-required-error input,
.field.field-required-error select,
.field.field-required-error textarea,
.field.field-required-error .record-combo input {
  border-color: #c0261c;
  background: #fdf1f0;
}

/* Mensaje en linea bajo un campo con error (p. ej. las contraseñas no coinciden), sin recargar la pagina */
.field .field-error-text {
  color: #c0261c;
  font-size: 12px;
  font-weight: 700;
}

html.theme-dark .field .field-error-text {
  color: #ff8f86;
}

/* Politica de contraseñas: requisitos siempre visibles bajo el campo (site.js los marca en vivo) y aviso de caducidad */
.pw-reqs {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.pw-reqs li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--muted, #5f6b68);
}

.pw-reqs .pw-mark {
  flex: 0 0 auto;
  width: 14px;
  text-align: center;
  font-weight: 800;
}

.pw-reqs .pw-mark::before {
  content: "\2022";
}

.pw-reqs li.is-pending .pw-mark::before {
  content: "\25CB";
}

.pw-reqs li.is-ok {
  color: #1f7a3d;
  font-weight: 700;
}

.pw-reqs li.is-ok .pw-mark::before {
  content: "\2713";
}

/* Texto "cumplido"/"pendiente" solo para lectores de pantalla (aria-live). */
.pw-reqs .pw-state {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

html.theme-dark .pw-reqs li {
  color: #aeb9b6;
}

html.theme-dark .pw-reqs li.is-ok {
  color: #6fd08c;
}

.pw-expiry-banner {
  background: #fff7e0;
  border-color: #e6c36a;
  color: #7a5200;
}

.pw-expiry-banner a {
  color: inherit;
  font-weight: 800;
  text-decoration: underline;
}

html.theme-dark .pw-expiry-banner {
  background: #3a3220;
  border-color: #7a6430;
  color: #f2d98c;
}

/* Albaran sin prendas/ordenes elegidas: el bloque de lineas se marca en rojo */
.deliverynote-orders.field-required-error > h2 {
  color: #c0261c;
}

.deliverynote-orders.field-required-error .deliverynote-order-panel {
  border: 1px solid #c0261c;
  border-radius: 8px;
  background: #fdf1f0;
}

html.theme-dark .deliverynote-orders.field-required-error > h2 {
  color: #ff8f86;
}

html.theme-dark .deliverynote-orders.field-required-error .deliverynote-order-panel {
  border-color: #e5484d;
  background: #3a2326;
}

/* Ficha de fabricante sin ningun grupo de prenda marcado: la seccion "Grupo prenda" se marca en rojo */
.manufacturer-groups.field-required-error > h2 {
  color: #c0261c;
}

.manufacturer-groups.field-required-error .checkbox-list {
  border: 1px solid #c0261c;
  border-radius: 8px;
  background: #fdf1f0;
}

.manufacturer-groups .field-error-text {
  display: block;
  margin-top: 6px;
  color: #c0261c;
}

html.theme-dark .manufacturer-groups.field-required-error > h2,
html.theme-dark .manufacturer-groups .field-error-text {
  color: #ff8f86;
}

html.theme-dark .manufacturer-groups.field-required-error .checkbox-list {
  border-color: #e5484d;
  background: #3a2326;
}

/* Campo de combo bloqueado (autorrellenado, p.ej. transportista del cliente/parque) */
input.combo-locked {
  background: #eceff1;
  color: #000;
  -webkit-text-fill-color: #000;
  cursor: not-allowed;
}

.record-combo {
  display: block;
  width: 100%;
  position: relative;
  z-index: 3;
}

.record-combo:focus-within {
  z-index: 30;
}

.record-combo-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(17, 24, 39, .16);
  padding: 4px;
  color: var(--ink);
}

.record-combo-option {
  width: 100%;
  min-height: 32px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 7px 9px;
  text-align: left;
  white-space: normal;
  color: var(--ink);
}

.record-combo-option:hover,
.record-combo-option:focus {
  background: #edf7f2;
  border-color: transparent;
  outline: 0;
}

.record-combo-empty {
  padding: 8px 9px;
  color: var(--muted);
  font-size: 12px;
}

.checkbox-field {
  align-self: end;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.record-head-actions {
  margin-bottom: 0;
  justify-content: flex-end;
}

.delete-form {
  margin: -8px 0 18px;
}

.hidden-delete-form {
  display: none;
}

.combo-filter {
  position: relative;
  padding-bottom: 16px;
}

.combo-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.readonly-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid #aebab4;
  border-radius: 8px;
  background: #fafbf9;
  color: #285a6a;
  font-weight: 750;
  text-decoration: none;
  user-select: text;
}

.readonly-link:hover {
  border-color: #9fc6d0;
  background: #eef8f9;
}

.assignment-picker-trigger {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  cursor: pointer;
}

.assignment-picker-panel .table-wrap {
  max-height: 520px;
}

.orders-page-shell {
  height: calc(100vh - 104px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.orders-page-shell .filter-panel {
  flex: 0 0 auto;
}

.orders-scroll-table {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overflow-x: auto;
}

.mini-button {
  min-height: 30px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

/* Campos NO editables (deshabilitados o de solo lectura): gris claro claramente distinto del blanco
   de los editables, con texto atenuado, para que se distinga de un vistazo que no se pueden editar. */
input:disabled,
select:disabled,
textarea:disabled,
input[readonly],
textarea[readonly] {
  background: #e6eaec;
  border-color: #b7c2bc;
  color: #000;
  -webkit-text-fill-color: #000;
  cursor: default;
  opacity: 1;
}

input:disabled::placeholder,
input[readonly]::placeholder,
textarea:disabled::placeholder,
textarea[readonly]::placeholder {
  color: #555;
  -webkit-text-fill-color: #555;
  opacity: 1;
}

.values-panel {
  margin-top: 18px;
}

.order-services {
  /* Sin margen extra: el hueco con Observaciones lo da el gap del formulario (igual que el de arriba). */
  margin-bottom: 0;
}
/* Filas del editor de servicios de la ORDEN mas compactas (menos alto por linea). */
.service-editor:not(.assistant-service-editor) th,
.service-editor:not(.assistant-service-editor) td {
  padding: 2px 6px;
}
.service-editor:not(.assistant-service-editor) input,
.service-editor:not(.assistant-service-editor) select {
  padding: 4px 8px;
}

.deliverynote-orders {
  margin-top: 14px;
}

.deliverynote-order-panel {
  display: grid;
  gap: 10px;
}

.deliverynote-order-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deliverynote-pickup-notices {
  display: grid;
  gap: 8px;
}

.deliverynote-pickup-notice {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid #d8b15e;
  border-radius: 6px;
  background: #fff3cf;
  color: #4a3410;
}

.deliverynote-pickup-notice strong {
  color: #2f210a;
}

.pickup-observations {
  font-weight: 700;
}

.deliverynote-add-button {
  width: 28px;
  min-height: 28px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
}

.deliverynote-orders .table-wrap {
  max-height: 360px;
  overflow: auto;
}

.deliverynote-selected-table th,
.deliverynote-selected-table td {
  white-space: nowrap;
}

.deliverynote-picker-panel .table-wrap {
  max-height: min(560px, 64vh);
  overflow: auto;
}

.assistant-pickup-requirement {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid #d8b15e;
  border-radius: 7px;
  background: #fff3cf;
}

.assistant-pickup-requirement.is-selected {
  border-color: #eadc9c;
  background: #fffbe8;
  padding: 5px 10px;
  min-height: 30px;
}

.assistant-pickup-requirement p {
  margin: 2px 0 0;
  color: #5d4420;
}

.assistant-pickup-summary strong {
  color: #4a3410;
  font-weight: 700;
  line-height: 1.15;
}

.assistant-pickup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.assistant-pickup-panel .table-wrap {
  max-height: min(540px, 62vh);
  overflow: auto;
}

.assistant-pickup-panel [data-assistant-pickup-row] {
  cursor: pointer;
}

.assistant-pickup-panel [data-assistant-pickup-row]:hover td {
  background: #e8f5ef;
}

.deliverynote-picker-empty:empty {
  display: none;
}

.picker-table [data-deliverynote-candidate-row] {
  cursor: pointer;
}

.picker-table [data-deliverynote-candidate-row].is-selected td {
  background: #e6f5ed;
}

.picker-table [data-deliverynote-candidate-row][data-budget-pending="1"] {
  cursor: not-allowed;
  opacity: 0.6;
}

.budget-pending-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  background: #fdecc8;
  color: #7a4b00;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.selection-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1px solid var(--muted);
  border-radius: 50%;
}

.is-selected .selection-dot {
  background: #57AB71;
  border-color: #57AB71;
}

.service-form {
  display: grid;
  gap: 12px;
}

.service-editor {
  min-width: 960px;
}

.assistant-service-editor.service-editor {
  min-width: 0;
}

.service-editor th,
.service-editor td {
  white-space: normal;
}

.service-editor input,
.service-editor select {
  min-width: 90px;
  padding: 7px 8px;
}

/* Anchos de columna del editor de servicios de la ORDEN (clases de columna: la columna Cant. es opcional).
   Se excluye el editor del asistente, que tiene su propio layout. */
.service-editor:not(.assistant-service-editor) td.svc-col-code input {
  min-width: 120px;
}

.service-editor:not(.assistant-service-editor) td.svc-col-name input {
  min-width: 320px;
}

/* Cantidad: campo escrito de 1 a 9. Solo lectura (limpiezas / orden en albaran) = gris, como el resto de campos no editables. */
.service-editor:not(.assistant-service-editor) th.svc-col-qty,
.service-editor:not(.assistant-service-editor) td.svc-col-qty {
  width: 72px;
}

.service-editor:not(.assistant-service-editor) td.svc-col-qty input.service-qty {
  min-width: 0;
  width: 56px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.service-editor input.service-qty.qty-locked {
  background: #e6eaec;
  border-color: #b7c2bc;
  color: #000;
  -webkit-text-fill-color: #000;
  cursor: not-allowed;
}

html.theme-dark .service-editor input.service-qty.qty-locked {
  background: #171c1f;
  border-color: #384744;
  color: var(--muted, #667);
  -webkit-text-fill-color: var(--muted, #667);
}

.service-editor input.service-qty[aria-invalid="true"] {
  border-color: #b3261e;
}

/* Precio unit. + Total (cantidad x precio unitario, solo lectura) en la misma columna, a mitades. */
.service-editor:not(.assistant-service-editor) th.svc-col-price,
.service-editor:not(.assistant-service-editor) td.svc-col-price {
  min-width: 220px;
}

/* Dos cajones de ancho fijo (minimo que muestra 99999,99 + el simbolo € sin recortar), alineados a la izquierda de la columna. */
.service-editor .svc-price-pair {
  display: flex;
  justify-content: flex-start;
  gap: 12px; /* igual que la separacion entre columnas: 6px + 6px del padding de las celdas */
}

.service-editor .svc-price-pair > input,
.service-editor .svc-price-pair > span {
  flex: 0 0 98px;
  min-width: 98px;
  width: 98px;
  text-align: left;
}

/* Cajon con el simbolo € a la derecha (dibujado por CSS: no forma parte del value, que sigue siendo numerico). */
.service-editor .svc-price-pair > .svc-money {
  display: block;
  margin: 0;
}

.service-editor .svc-price-pair > .svc-money > input {
  box-sizing: border-box;
  width: 100%;
  padding-left: 3px;
  padding-right: 20px;
  -moz-appearance: textfield;
  appearance: textfield;
}

.svc-money {
  position: relative;
  display: block;
  margin: 0;
}

.svc-money::after {
  content: "\20AC";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  opacity: .7;
}

.service-editor .svc-price-pair > .svc-money > input::-webkit-outer-spin-button,
.service-editor .svc-price-pair > .svc-money > input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.service-editor .svc-price-pair.svc-price-head > span {
  white-space: nowrap;
  overflow: hidden;
}

.service-editor input.service-line-total {
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.service-qty-msg {
  margin: 6px 0 0;
  color: #b3261e;
  font-weight: 600;
}

.service-qty-msg[hidden] {
  display: none;
}

.service-qty-hint {
  margin: 4px 0 0;
  font-size: .85em;
}

html.theme-dark .service-qty-msg {
  color: #ff8a80;
}

.assistant-service-editor td:nth-child(1) input,
.assistant-service-editor td:nth-child(2) input,
.assistant-service-editor td:nth-child(3) input {
  min-width: 0;
  max-width: 100%;
}

.compact-money-section .form-grid {
  grid-template-columns: repeat(5, minmax(105px, 1fr));
}

.compact-money-section input {
  max-width: 160px;
}

/* Ficha de orden, Importes: el simbolo € queda a la derecha del cajon (mismo ancho maximo que el input) y el texto no lo solapa. */
.compact-money-section .svc-money {
  max-width: 160px;
}

.compact-money-section .svc-money > input {
  box-sizing: border-box;
  width: 100%;
  padding-right: 20px;
}

.service-delete {
  width: 38px;
  height: 34px;
  min-height: 34px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* El icono (emoji) tiene una altura propia mayor que la de la letra: con line-height 1 y sin relleno queda centrado y no se corta por abajo. */
  line-height: 1;
  font-size: 16px;
  overflow: visible;
  vertical-align: middle;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #efc3c3;
  background: #fff5f5;
  color: var(--danger);
}

.service-delete:hover {
  background: #ffe7e7;
}

/* Icono de "borrar" dibujado con CSS (circulo rojo con barra blanca, como el emoji de prohibido) en lugar del emoji, que se cortaba
   por arriba/abajo segun la fuente. Siempre redondo y centrado en el boton. */
.service-delete .no-entry-icon {
  position: relative;
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger, #d1342f);
}
.service-delete .no-entry-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 3px;
  border-radius: 1px;
  background: #fff;
  transform: translate(-50%, -50%);
}
.assistant-service-editor .service-delete .no-entry-icon {
  width: 16px;
  height: 16px;
}
.assistant-service-editor .service-delete .no-entry-icon::after {
  width: 9px;
  height: 2.5px;
}
.service-delete:disabled .no-entry-icon {
  opacity: .45;
}

.add-line {
  font-weight: 800;
}

.print-body {
  background: #e9ece8;
}

.print-actions {
  width: 210mm;
  max-width: calc(100% - 24px);
  margin: 18px auto 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.print-sheet {
  width: 210mm;
  min-height: 297mm;
  max-width: calc(100% - 24px);
  box-sizing: border-box;
  margin: 0 auto 32px;
  background: #fff;
  color: #111;
  padding: 15mm;
  border: 1px solid #d9dedb;
  box-shadow: 0 12px 30px rgba(18, 28, 26, .12);
  overflow-wrap: anywhere;
}

/* Evita que el contenido de las impresiones (ordenes y albaranes) se salga de la hoja. */
.print-sheet * {
  box-sizing: border-box;
}
.print-sheet img {
  max-width: 100%;
  height: auto;
}
.print-sheet table {
  table-layout: fixed;
  max-width: 100%;
}
.print-sheet th,
.print-sheet td {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.service-print-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  border-bottom: 2px solid #111;
  padding-bottom: 10px;
  margin-bottom: 16px;
}

.service-print-head h1 {
  margin: 0;
  font-size: 28px;
}

.print-meta {
  width: 100%;
  min-width: 0;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.print-meta th,
.print-meta td {
  border: 1px solid #222;
  padding: 7px 8px;
  white-space: normal;
  font-size: 12px;
}

.print-meta th {
  position: static;
  background: #f3f3f3;
  color: #111;
}

/* Hoja de servicio: los 4 recuadros de abajo (Estado conservacion, Validacion de estado, Revisado por, Reparado por) con
   el doble de alto que antes (fila de datos ~30px -> 60px, p. ej. para escribir/firmar); la cabecera (th) no cambia. */
.order-final-meta td {
  height: 60px;
  vertical-align: middle;
}

/* Hoja de servicio: INSPECCION FINAL + los 4 recuadros se llevan al pie de la hoja (justo encima del pie de pagina
   configurado). La hoja es una columna flex con altura minima de pagina; el bloque lleva margin-top:auto, asi
   absorbe el espacio libre. Si el contenido es largo, el bloque simplemente sigue al contenido (sin solaparse). */
.print-sheet.order-sheet {
  display: flex;
  flex-direction: column;
}
.print-sheet.order-sheet > * {
  flex-shrink: 0;
}
/* Hoja de servicio: 1a Inspeccion (+ su Mantenimiento), 2a Inspeccion (+ su Mantenimiento) y Observaciones se reparten
   el espacio libre de la hoja (flex-grow 1 : 1 : 2; Observaciones, que es donde mas se escribe, recibe el doble).
   Cada bloque conserva su altura natural (flex-basis auto, flex-shrink 0): si hay muchos servicios no se recorta nada
   y la hoja pasa a 2 paginas como antes. El espacio extra queda como zona libre dentro de cada recuadro. */
.print-sheet.order-sheet > .order-grow-1 { flex-grow: 1; }
.print-sheet.order-sheet > .order-grow-2 { flex-grow: 2; }
.print-sheet.order-sheet > div.order-grow {
  display: flex;
  flex-direction: column;
}
.print-sheet.order-sheet > div.order-grow > .print-block { flex: 0 0 auto; }
.print-sheet.order-sheet > div.order-grow > .print-block:last-child { flex: 1 1 auto; }
.order-bottom-block {
  margin-top: auto;
  break-inside: avoid;
  page-break-inside: avoid;
}
.order-bottom-block > .order-final-meta {
  margin-bottom: 0;
}

/* Hoja de servicio: la columna "Cliente y parque" mas ancha (1,5x, 30%) a costa de las 3 columnas
   de fecha de su derecha (que pasan de 20% a ~16,66% cada una). Orden de trabajo se mantiene al 20%. */
.order-work-meta th:nth-child(1),
.order-work-meta td:nth-child(1) { width: 20%; }
.order-work-meta th:nth-child(2),
.order-work-meta td:nth-child(2) { width: 30%; }
.order-work-meta th:nth-child(3),
.order-work-meta td:nth-child(3),
.order-work-meta th:nth-child(4),
.order-work-meta td:nth-child(4),
.order-work-meta th:nth-child(5),
.order-work-meta td:nth-child(5) { width: 16.66%; }

/* Recuadro del codigo de barras en la hoja de servicio: numero arriba y codigo escaneable debajo. */
.barcode-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}

.barcode-number {
  font-weight: 700;
  letter-spacing: 1px;
  /* Un codigo de 13 digitos no debe partirse en dos lineas: la columna es mas ancha y el numero no salta de linea. */
  white-space: nowrap;
}

/* Tabla Codigo Equipo | Tipo prenda | Cod. Bombero | Bombero/a | Talla | Fecha: la columna del codigo de equipo es mas ancha
   (cabe un codigo de 13 digitos) y el resto se reparte el espacio. */
.equip-meta {
  table-layout: fixed;
}
.equip-meta th:nth-child(1),
.equip-meta td:nth-child(1) { width: 20%; }
.equip-meta th:nth-child(2),
.equip-meta td:nth-child(2) { width: 15%; }
.equip-meta th:nth-child(3),
.equip-meta td:nth-child(3) { width: 12%; }
.equip-meta th:nth-child(4),
.equip-meta td:nth-child(4) { width: 25%; }
.equip-meta th:nth-child(5),
.equip-meta td:nth-child(5) { width: 12%; }
.equip-meta th:nth-child(6),
.equip-meta td:nth-child(6) { width: 16%; }
.equip-meta td { overflow-wrap: anywhere; }
.equip-meta td .barcode-number { overflow-wrap: normal; }

.barcode-svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.print-block {
  min-height: 70px;
  border-bottom: 1px solid #222;
  padding: 10px 0;
}

.print-block h2 {
  margin: 0 0 8px;
  font-size: 15px;
}

/* Bloques de "1a/2a Inspeccion": la linea inferior va pegada al texto, sin espacio. */
.print-block.tight {
  min-height: 0;
  padding: 6px 0 0;
}
.print-block.tight h2 {
  margin: 0;
}

.print-lines {
  min-height: 42px;
}

.print-service-list {
  margin: 0;
  padding-left: 20px;
}

.print-final {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 10px;
  margin: 18px 0;
  border: 1px solid #222;
  padding: 12px;
}

.print-final p {
  margin: 0;
}

.totals {
  width: 320px;
  margin-left: auto;
}

.permission-table {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.permission-table table {
  min-width: 720px;
}

.permission-table td:first-child {
  white-space: normal;
}

.permission-table td:first-child span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.permission-table th:not(:first-child),
.permission-table td:not(:first-child) {
  text-align: center;
  width: 110px;
}

.permission-select-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.permission-select-all span {
  margin: 0;
  color: inherit;
  font-size: inherit;
  font-weight: 800;
}

.permission-table input[type="checkbox"] {
  width: auto;
  min-height: auto;
}

.permission-copy {
  width: max-content;
  max-width: min(520px, 100%);
  margin: 10px 0 14px;
}

.permission-copy select {
  width: auto;
  max-width: min(520px, 100%);
}

.permission-table input[type="checkbox"]:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.permission-table td:has(input[type="checkbox"]:disabled) {
  background: #fafbf9;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(14, 24, 23, .42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(1120px, 96vw);
  max-height: min(780px, 92vh);
  display: grid;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 24px 72px rgba(29, 36, 36, .28);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.modal-head h2 {
  margin: 0;
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 24px;
  --x-size: 16px;
  --x-stroke: 2.5px;
}

.reason-modal .modal-panel {
  width: min(520px, 94vw);
}

/* Copiar festivos del año anterior (Configuracion vacaciones): la tabla de revision hace scroll dentro del modal. */
.holiday-copy-modal .modal-panel {
  width: min(980px, 96vw);
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.holiday-copy-form {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 0;
}

.holiday-copy-form p {
  margin: 0;
}

.holiday-copy-table-wrap {
  overflow: auto;
  min-height: 0;
}

.holiday-copy-table td,
.holiday-copy-table th {
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}

.holiday-copy-table input[type="date"] {
  min-height: 32px;
  padding: 4px 8px;
}

.holiday-copy-table tr.is-blocked td {
  opacity: .6;
}

.holiday-copy-table tr.is-weekend [data-hol-weekday] {
  color: #b35a00;
  font-weight: 600;
}

.holiday-copy-note {
  font-size: 12px;
  color: #8a5300;
}

.holiday-copy-modal .form-actions {
  justify-content: flex-end;
}

/* Banner de cambio de talla: mas estrecho (aprox. la mitad) */
.size-change-modal .modal-panel {
  width: min(420px, 92vw);
}

.modal-panel-narrow {
  width: min(420px, 90vw) !important;
}

.harness-filter-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 12px;
}

.export-limit-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

/* Exportar ordenes: ventana flotante con formato (Excel / PDF), precios y cuantas ordenes */
.export-format-modal .modal-panel {
  width: min(520px, 92vw) !important;
  overflow-y: auto;
}

.export-format-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 12px 0;
}

.export-format-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  padding: 14px 10px;
  text-align: center;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  background: var(--btn-bg, #fff);
  color: var(--ink);
  cursor: pointer;
}

.export-format-btn strong {
  font-size: 1.15rem;
}

.export-format-btn span {
  font-size: .85rem;
  color: var(--muted);
}

.export-format-btn:hover,
.export-format-btn:focus-visible {
  border-color: var(--accent);
}

.export-format-btn:focus-visible,
.export-format-modal .button:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.export-format-btn:disabled {
  opacity: .6;
  cursor: progress;
}

.export-format-status {
  min-height: 1.3em;
  margin: 0;
  color: var(--muted);
}

/* Exportar HOJA SERVICIO: barra de avance de la generacion */
.export-sheets-progress {
  display: block;
  width: 100%;
  height: 14px;
  margin: 12px 0;
  accent-color: var(--accent);
}

@media (max-width: 480px) {
  .export-format-modal {
    padding: 12px;
  }

  .export-format-options {
    grid-template-columns: 1fr;
  }

  .export-format-btn {
    min-height: 76px;
  }
}

.harness-table-wrap {
  max-height: 300px;
  overflow: auto;
}

.reason-modal p {
  margin: 0;
  color: var(--muted);
}

.reason-modal textarea {
  min-height: 120px;
  resize: vertical;
}

.reason-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  align-items: center;
}

.garment-picker-panel .table-wrap {
  max-height: 520px;
}

.picker-table tr[hidden] {
  display: none;
}

.table-wrap th[data-sortable] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.table-wrap th[data-sortable]:hover {
  background: #eef4f0;
}

.table-wrap th.sort-asc::after,
.table-wrap th.sort-desc::after {
  display: inline-block;
  margin-left: 6px;
  color: var(--focus);
  font-size: 10px;
}

.table-wrap th.sort-asc::after {
  content: "▲";
}

.table-wrap th.sort-desc::after {
  content: "▼";
}

.notification-wrap {
  position: relative;
  transition: transform .22s ease, top .22s ease, right .22s ease;
}

.table-wrap th.sort-asc::after {
  content: "\25B2";
}

.table-wrap th.sort-desc::after {
  content: "\25BC";
}

body.is-scrolled .notification-wrap.has-notifications {
  position: fixed;
  /* Centrada verticalmente con la fila de botones de la cabecera sticky (que queda pegada arriba). */
  top: 20px;
  right: 22px;
  z-index: 45;
  transform: scale(.96);
}

/* En la pagina de inicio (tiene .dashboard-welcome) la campana NO baja al sticky: se queda en su sitio
   y desaparece con el scroll como el resto de la barra superior. */
body.is-scrolled:has(.dashboard-welcome) .notification-wrap.has-notifications {
  position: static;
  top: auto;
  right: auto;
  transform: none;
}

.notification-bell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 10px;
  color: var(--ink);
  font-weight: 800;
}

.notification-bell strong {
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
}

/* Cuando hay avisos activos, la campana se resalta y el contador (rojo) late para llamar la atencion. */
.notification-wrap.has-notifications .notification-bell {
  border-color: #e5484d;
  background: #fdecec;
  box-shadow: 0 0 0 1px rgba(229, 72, 77, .35);
}

.notification-wrap.has-notifications .notification-bell strong {
  background: #e5484d;
  animation: notif-pulse 1.8s ease-out infinite;
}

@keyframes notif-pulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 72, 77, .6); }
  70% { box-shadow: 0 0 0 9px rgba(229, 72, 77, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 72, 77, 0); }
}

.notification-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  display: none;
  width: 300px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 38px rgba(29, 36, 36, .16);
  padding: 12px;
  color: var(--ink);
}

.notification-wrap:hover .notification-popover {
  display: grid;
  gap: 8px;
}

.notification-popover ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 7px;
}

.notification-popover li a {
  display: grid;
  gap: 2px;
  padding: 8px;
  border-radius: 8px;
  background: #f7faf7;
}

.notification-popover small {
  color: var(--muted);
  font-weight: 700;
}

.notification-list {
  display: grid;
  gap: 12px;
}

.notification-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
}

.notification-card p {
  margin-bottom: 8px;
}

.notification-card small {
  color: var(--muted);
  font-weight: 700;
}

.notification-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.notification-actions form {
  margin: 0;
}

.notification-inline {
  display: grid;
  gap: 10px;
}

.toast-message {
  position: fixed;
  right: 22px;
  bottom: 84px;
  z-index: 50;
  display: grid;
  gap: 4px;
  max-width: 360px;
  border: 1px solid var(--accent);
  border-left: 6px solid var(--accent);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(216, 122, 40, .28);
  padding: 15px 16px;
  color: var(--ink);
  transition: opacity .24s ease, transform .24s ease;
  animation: toast-pop .34s cubic-bezier(.2, .8, .25, 1);
}

.toast-message strong {
  color: var(--accent-dark);
  font-size: 15px;
}

.toast-message form {
  margin: 6px 0 0;
}

.toast-dismiss-button {
  min-height: 32px;
  padding: 6px 11px;
  font-weight: 800;
}

.toast-message.is-hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.related {
  margin-top: 18px;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.related-grid > h2 {
  grid-column: 1 / -1;
}

.related-block {
  margin-top: 12px;
  padding: 0;
  border: 0;
}

.related-grid .related-block {
  margin-top: 0;
  min-width: 0;
}

@media (max-width: 1000px) {
  .related-grid {
    grid-template-columns: 1fr;
  }
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(350px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.login-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-panel h1 {
  margin: 0;
}

.stack {
  display: grid;
  gap: 12px;
}

.alert,
.notice {
  background: #fff8ed;
  border: 1px solid #ebcf9e;
  color: var(--warn);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.alert-danger {
  background: #fff2f2;
  border-color: #edb9b9;
  color: var(--danger);
}

.garment-warning-alert {
  background: #ffefd7;
  border-color: #dea85c;
  color: #8d4b10;
  font-weight: 800;
}

.success {
  background: #f0fff4;
  border-color: #b9dfc8;
  color: var(--ok);
}

.table-wrap tr.expedited-row td {
  background: #edf8f1;
}

/* Al pasar el raton, igual que las filas normales (tbody tr:hover). */
.table-wrap tr.expedited-row:hover td {
  background: #f6ddb8;
}

.table-wrap tr.retired-row td {
  background: #fbecec;
}

/* Albaranes genericos: fila con un tinte azulado para distinguirlos de los normales. */
.table-wrap tr.generic-note-row td {
  background: #eaf1fb;
}

/* Al pasar el raton, igual que las filas normales (tbody tr:hover). */
.table-wrap tr.generic-note-row:hover td {
  background: #f6ddb8;
}

/* Prenda de mas entre albaran y control de recogidas: toda la linea en rojo suave (solo aviso, no bloquea). */
.table-wrap tr.diff-extra-row td {
  background: #fbecec;
}

.table-wrap tr.diff-extra-row:hover td {
  background: #f6d5d5;
}

/* Aviso de diferencias de prendas albaran <-> recogida: mismo aspecto que el aviso de prenda, una linea por prenda. */
.diff-warning-alert .diff-warning-title {
  margin-bottom: 4px;
}

.diff-warning-alert .diff-warning-lines {
  margin: 0;
  padding-left: 20px;
  font-weight: 600;
}

.diff-warning-alert .diff-warning-lines a {
  color: inherit;
  text-decoration: underline;
}

.table-wrap tr.pickup-warning-row td {
  background: #fff3d3;
}

.table-wrap tr.pickup-alert-row td {
  background: #fde7dd;
}

.save-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  background: #e4f8ec;
  border: 1px solid #7fce9e;
  border-left: 6px solid var(--ok);
  color: #14713f;
  border-radius: 10px;
  padding: 14px 20px;
  box-shadow: 0 18px 48px rgba(20, 113, 63, .28);
  font-weight: 800;
  font-size: 15px;
  transition: opacity .24s ease, transform .24s ease;
  animation: toast-pop .34s cubic-bezier(.2, .8, .25, 1);
}

@keyframes toast-pop {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.save-toast.is-hidden {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.save-toast.toast-error {
  background: #fdecea;
  border-color: #e08079;
  border-left-color: #c0261c;
  color: #b0231a;
}

.vacations-page {
  display: grid;
  gap: 12px;
  height: auto;
  overflow: visible;
}

.year-switcher {
  display: flex;
  justify-content: flex-end;
}

.vacation-period-switcher {
  justify-content: center;
  width: min(430px, 100%);
}

.vacation-period-switcher,
.admin-year-switcher {
  gap: 10px;
  align-items: end;
}

/* Resumen por usuario: el selector de año va a la derecha de su fila (solo esa pestana). En movil (<=640px) el
   formulario ocupa el ancho completo (width: 100% del grid) y el selector queda alineado a la derecha, sin desbordar. */
.vacation-period-switcher.vacation-summary-year-switcher {
  justify-self: end;
  margin-left: auto;
  justify-content: flex-end;
}

.year-switcher label {
  display: grid;
  gap: 4px;
  min-width: 120px;
}

.vacation-summary-grid {
  /* 5 tarjetas (con Asuntos propios): en una fila si caben y, si no, pasan a la siguiente. */
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  align-items: center;
}

.vacation-summary-note {
  margin: 4px 0 0;
  font-size: 13px;
}

/* Fechas de asuntos propios con estado y justificacion (tarjetas del trabajador y detalle del resumen de admin) */
.vacation-personal-list {
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.vacation-personal-list li > span {
  color: var(--muted);
}

.vac-justification {
  display: block;
  color: var(--muted);
  font-style: italic;
  overflow-wrap: anywhere;
}

.vacation-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-height: auto;
  padding: 6px 0;
  background: transparent;
  border: 0;
  box-shadow: none;
}

.vacation-metric strong,
.vacation-metric span {
  color: var(--ink);
}

.vacation-request-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.vacation-request-form .wide {
  grid-column: span 2;
}

.vacation-board {
  padding: 22px;
}

.vacation-calendar-layout {
  display: grid;
  grid-template-columns: minmax(330px, 430px) minmax(250px, 390px);
  gap: 24px;
  align-items: start;
}

.vacation-calendar-card {
  background: #f6f8fb;
  border: 1px solid #e8edf4;
  border-radius: 8px;
  padding: 18px;
}

.vacation-add-day-btn {
  max-width: 430px;
  width: 100%;
  text-align: center;
}

.vacation-calendar-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 20px;
  margin-bottom: 18px;
}

.vacation-calendar-head span {
  display: flex;
  gap: 8px;
}

.vacation-calendar-head span .mini-button {
  background: rgba(21, 61, 59, .12);
  border: 1px solid rgba(21, 61, 59, .25);
  color: var(--ink);
  border-radius: 6px;
  padding: 4px 10px;
  font-weight: 700;
}

.vacation-weekdays,
.vacation-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
}

.vacation-weekdays {
  color: var(--muted);
  font-weight: 800;
  text-align: center;
  margin-bottom: 8px;
}

.vacation-day {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
  position: relative;
}

.vacation-day:hover {
  background: #e9eef7;
}

.vacation-day.is-muted {
  color: #a4adb8;
}

.vacation-day.is-weekend:not(.is-selected) {
  background: #ed8479;
  color: #fff;
}

.vacation-day.is-selected {
  background: #2e7dd7;
  color: #fff;
  box-shadow: 0 8px 18px rgba(46, 125, 215, .26);
}

.vacation-day.has-vacation:not(.is-selected) {
  background: #e7f4e4;
  color: #1b6a2c;
}

.vacation-day.is-holiday:not(.is-selected) {
  background: #fff8d8;
}

.vacation-day.is-holiday.is-weekend:not(.is-selected) {
  background: #fff8d8;
  color: #1d2424;
}

.day-count {
  position: absolute;
  right: 4px;
  top: 3px;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #1f7f33;
  color: #fff;
  font-size: 11px;
  line-height: 16px;
}

.holiday-dot {
  position: absolute;
  left: 7px;
  bottom: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #d88415;
}

.vacation-side-card {
  display: grid;
  gap: 14px;
  justify-items: center;
}

.vacation-side-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.vacation-big-action,
.vacation-add-button {
  min-width: 72px;
  min-height: 72px;
  border-radius: 12px;
  border: 2px solid #2a8a35;
  background: linear-gradient(180deg, #bfe8b8, #95cb86);
  color: #09170d;
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.head-actions .vacation-add-button {
  min-width: 42px;
  min-height: 42px;
  font-size: 28px;
  padding: 0 14px;
}

.vacation-people-box {
  width: min(100%, 360px);
  min-height: 230px;
  border: 2px solid #1f7f33;
  border-radius: 32px;
  padding: 18px 22px;
  background: #fff;
}

.vacation-people-box h2 {
  text-align: center;
  margin-bottom: 14px;
}

.vacation-people-list {
  list-style: none;
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
}

.vacation-people-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #f3f7f3;
}

.vacation-people-list li > strong,
.vacation-people-list li > span,
.vacation-people-list li > small {
  grid-column: 1;
}

.vacation-people-list span,
.vacation-people-list small,
.vacation-holiday-line {
  color: var(--muted);
}

.vacation-day-delete-form {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  margin: 0;
}

.vacation-day-remove {
  border: none;
  background: #e6584822;
  color: #c0392b;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  min-width: 26px;
  padding: 0;
  border-radius: 50%;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  --x-size: 10px;
  --x-stroke: 2px;
  transition: background 0.15s ease;
}

.vacation-day-remove:hover {
  background: #e65848;
  color: #fff;
}

.vacation-approval-block .table-wrap,
.vacation-calendar-block .table-wrap {
  max-height: 360px;
  overflow: auto;
}

.vacation-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

/* Pendientes de aprobar (AJAX): la fila resuelta se desvanece antes de quitarse; el contador del titulo es una insignia. */
.vacation-approval-block tr[data-vacation-request-id] {
  transition: opacity 0.18s ease;
}

.vacation-approval-block tr.is-leaving {
  opacity: 0;
  pointer-events: none;
}

.count-badge {
  display: inline-block;
  min-width: 1.6em;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #e9efec;
  color: var(--ink);
  font-size: 0.75em;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
  vertical-align: middle;
}

html.theme-dark .count-badge {
  background: #2c3a38;
  color: #e8efed;
}

@media (prefers-reduced-motion: reduce) {
  .vacation-approval-block tr[data-vacation-request-id] {
    transition: none;
  }
}

.mini-button.ok {
  border-color: #b6d9c1;
  background: #ecf8ef;
  color: #1c6b38;
}

.approve-btn {
  background: var(--ok) !important;
  border-color: var(--ok) !important;
  color: #fff !important;
}

.approve-btn:hover {
  background: #246840 !important;
  border-color: #246840 !important;
}

.mini-button.danger,
.primary.danger {
  border-color: #efc1bc;
  background: #fff0ed;
  color: #9f2f25;
}

tr.holiday-national-row td {
  background: #eef6ff;
}

tr.holiday-local-row td {
  background: #fff4dc;
}

.vacation-reject-modal textarea {
  min-height: 120px;
}

.vacation-request-modal .modal-panel {
  max-width: 680px;
}

.mini-inline-form {
  display: grid;
  grid-template-columns: 110px 150px minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.mini-inline-form label {
  display: grid;
  gap: 4px;
}

.table-wrap.user-vacation-table {
  max-height: 220px;
  overflow: auto;
}

.notice {
  color: var(--ink);
}

pre,
code {
  font-family: Consolas, "Courier New", monospace;
}

pre {
  overflow: auto;
  background: #f0f2ef;
  border-radius: 8px;
  padding: 12px;
}

.definition {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr);
  gap: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.definition dt {
  font-weight: 800;
  color: var(--muted);
}

.definition dd {
  margin: 0;
}

@media (max-width: 1560px) {
  .pickup-filter {
    grid-template-columns: minmax(190px, 1.25fr) minmax(145px, 1fr) minmax(145px, 1fr) minmax(120px, .8fr);
  }

  .pickup-filter .filter-actions {
    grid-column: 4;
  }
}

/* ===== Tablet: menu off-canvas (deslizante) con hamburguesa ===== */
@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .menu-toggle {
    display: flex;
  }

  /* En movil/tablet el boton Salir va dentro del menu; se oculta el de la cabecera */
  .topbar-logout {
    display: none;
  }
  .sidebar-logout {
    display: block;
  }

  /* El menu pasa a ser un panel deslizante desde la izquierda */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    max-width: 82vw;
    height: 100vh;
    height: 100dvh;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 2px 0 18px rgba(0, 0, 0, .18);
    gap: 10px;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  /* El menu se muestra como lista vertical comoda al tacto */
  .sidebar nav {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .sidebar nav a {
    min-height: 46px;
    font-size: 15px;
  }

  .content {
    padding: 16px;
  }

  /* Rejillas a 2 columnas para aprovechar el ancho */
  .metric-grid,
  .work-metric-grid,
  .split-layout,
  .assistant-layout,
  .assistant-grid,
  .dashboard-welcome,
  .admin-group-grid,
  .bulk-grid,
  .filter-panel,
  .form-grid,
  .vacation-summary-grid,
  .vacation-request-form,
  .vacation-calendar-layout,
  .mini-inline-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .today-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  /* Tablas con scroll horizontal propio para que no tapen el contenido */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ===== Movil ===== */
@media (max-width: 640px) {
  .content {
    padding: 12px;
  }

  .page-head,
  .searchbar,
  .scan-panel {
    align-items: stretch;
    flex-direction: column;
    margin-top: 0;
  }

  /* El topbar se mantiene en fila: hamburguesa + acciones a la derecha */
  .topbar {
    flex-direction: row;
    align-items: center;
    margin: 0 0 10px;
    gap: 8px;
  }

  /* El chip de usuario no debe desbordar: se limita y se trunca el texto */
  .user-chip {
    max-width: 55vw;
    overflow: hidden;
  }
  .user-text {
    max-width: 40vw;
  }
  .user-text strong,
  .user-text small {
    max-width: 100%;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .metric-grid,
  .work-metric-grid,
  .split-layout,
  .assistant-layout,
  .assistant-grid,
  .dashboard-welcome,
  .admin-group-grid,
  .bulk-grid,
  .filter-panel,
  .form-grid,
  .vacation-summary-grid,
  .vacation-request-form,
  .vacation-calendar-layout,
  .mini-inline-form,
  .notification-card {
    grid-template-columns: 1fr;
  }

  /* Tarjetas de metricas del inicio: 2 por fila y compactas (hasta 360px sin desbordar). */
  .metric-grid,
  .work-metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
  }
  .metric {
    min-width: 0;
    gap: 4px;
    padding: 10px;
  }
  .metric span {
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }
  .metric strong {
    font-size: 22px;
  }

  /* Los resumenes de hoy se mantienen en paralelo (3 columnas), compactos. */
  .today-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }
  .today-chip {
    padding: 8px 6px;
  }
  .today-chip small {
    font-size: 10px;
  }

  .vacation-request-form .wide {
    grid-column: auto;
  }

  .vacation-board {
    padding: 14px;
  }

  .vacation-side-card {
    justify-items: stretch;
  }

  .vacation-people-box {
    width: auto;
  }

  /* Controles de formulario tactiles y a ancho completo */
  .record-form input,
  .record-form select,
  .record-form textarea,
  .record-form .field,
  .record-form .field.wide {
    width: 100%;
    box-sizing: border-box;
    min-height: 42px;
  }

  /* Botones de cabecera reajustados */
  .head-actions {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .head-actions .button,
  .head-actions button {
    flex: 1 1 auto;
  }

  h1 {
    font-size: 22px;
  }
}

@media print {
  /* margin 0 evita que el navegador imprima cabecera/pie (URL, fecha, hora, pagina 1/1, titulo). */
  @page {
    size: A4;
    margin: 0;
  }

  body.print-body {
    background: #fff;
  }

  .no-print,
  .print-actions {
    display: none !important;
  }

  .print-sheet {
    width: 100%;
    min-height: auto;
    max-width: none;
    margin: 0;
    padding: 12mm;
    border: 0;
    box-shadow: none;
  }

  /* Hoja de servicio: altura minima = pagina A4 (297mm, @page margin 0) menos 4mm de holgura para que nunca
     genere una pagina en blanco extra (padding 12mm arriba/abajo incluido: border-box). */
  .print-sheet.order-sheet {
    min-height: 293mm;
  }
}

/* "Guardar PDF": reproduce las reglas de @media print de .print-sheet (A4, @page margin 0) para la captura. */
.pdf-export .print-sheet {
  width: 100%;
  min-height: auto;
  max-width: none;
  margin: 0;
  padding: 12mm;
  border: 0;
  box-shadow: none;
}
.pdf-export .print-sheet.order-sheet {
  min-height: 293mm;
}

/* Rejilla de checkboxes para seleccion multi-cliente (usuarios cliente) */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px 18px;
  margin-top: 8px;
}

.checkbox-grid .checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .95rem;
  padding: 4px 0;
}

.checkbox-grid .checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  flex: 0 0 auto;
}

/* ===== Impresiones configurables ===== */
.print-company-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.print-company-info {
  display: flex;
  flex-direction: column;
  text-align: right;
  font-size: 12px;
  line-height: 1.35;
}
.print-logo-box {
  max-width: 260px;
}
.print-logo-box img {
  max-width: 240px;
  max-height: 120px;
  object-fit: contain;
}
.print-logo-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 240px;
  height: 110px;
  border: 3px solid #111;
  font-size: 40px;
  font-weight: 800;
}
.print-footer {
  margin-top: 18px;
  padding-top: 8px;
  border-top: 1px solid #ccc;
  font-size: 11px;
  color: #444;
  white-space: pre-wrap;
}

/* Albaran de transporte */
.transport-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.order-print-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 8px;
}
.order-print-topbar .op-title {
  flex: 1;
  text-align: center;
  margin: 0;
  font-size: 28px;
}
.order-print-topbar .op-logo {
  width: 180px;
  display: flex;
  align-items: center;
}
.order-print-topbar .op-logo-right {
  justify-content: flex-end;
}
.order-print-topbar .op-logo img {
  max-width: 180px;
  max-height: 90px;
}
.op-sentby {
  text-align: center;
  margin-bottom: 12px;
}
.op-sentby p {
  display: inline-block;
  border: 1px solid #333;
  padding: 4px 14px;
  margin: 0;
}
.transport-company {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  flex: 1 1 45%;
  overflow-wrap: anywhere;
}
.transport-company img {
  max-width: 200px;
  max-height: 90px;
  width: auto;
  height: auto;
  object-fit: contain;
  align-self: flex-start;
}
.transport-company .print-company-info {
  font-size: 12px;
}
.transport-carrier {
  font-size: 50px;
  font-weight: 800;
  text-align: right;
  line-height: 1.1;
  flex: 1 1 50%;
  min-width: 0;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.transport-sheet .transport-head {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin: 18px 0 10px;
}
.transport-title {
  font-weight: 800;
  font-size: 18px;
  margin: 0 0 4px;
}
.transport-label {
  font-weight: 800;
  margin: 8px 0 2px;
}
.transport-box {
  border: 1px solid #111;
  padding: 8px 12px;
  min-height: 20px;
}
.transport-number {
  text-align: center;
  font-weight: 800;
  font-size: 16px;
}
.transport-address {
  flex: 0 0 45%;
  min-height: 90px;
  font-size: 22px;
  font-weight: 800;
  display: flex;
  align-items: center;
}
.transport-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  margin: 8px 0 18px;
}
.transport-table th,
.transport-table td {
  border: 1px solid #111;
  padding: 6px 8px;
  text-align: left;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.transport-table th:first-child,
.transport-table td.c-code,
.transport-table th:last-child,
.transport-table td.c-qty {
  text-align: center;
}
.transport-table th:first-child,
.transport-table td.c-code {
  width: 20%;
}
.transport-table th:last-child,
.transport-table td.c-qty {
  width: 20%;
}
.transport-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid #111;
  padding: 14px 12px;
}

/* Modal de eleccion de impresion */
.print-choice-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 0 4px;
}
.print-choice-actions .button {
  text-align: center;
}
.print-choice-modal .modal-panel {
  width: min(420px, 92vw);
}

/* ===== Modo noche (activable/desactivable) ===== */
/* El aspecto del interruptor .theme-toggle esta mas abajo (seccion "Interruptor dia / noche"). */
html.theme-dark {
  --bg: #14181a;
  --panel: #1e2427;
  --ink: #e6ecea;
  --muted: #9aa8a5;
  --line: #2c3538;
  --line-strong: #3a4548;
  --side: #0f2c2b;
  --side-soft: #164541;
  --focus: #3f9b93;
  --btn-bg: #232a2d; /* fondo de los botones normales en modo noche (texto claro legible) */
}

/* Controles de formulario y tablas en modo noche (los que usan colores fijos) */
html.theme-dark input,
html.theme-dark select,
html.theme-dark textarea {
  background: #232a2d;
  color: var(--ink);
  border-color: var(--line-strong);
}
/* Campos no editables en modo noche: mas oscuros y atenuados que los editables, para distinguirlos. */
html.theme-dark input:disabled,
html.theme-dark select:disabled,
html.theme-dark textarea:disabled,
html.theme-dark input[readonly],
html.theme-dark textarea[readonly] {
  background: #171c1f;
  border-color: #384744;
  color: #92a19b;
  -webkit-text-fill-color: #92a19b;
}
html.theme-dark input:disabled::placeholder,
html.theme-dark input[readonly]::placeholder,
html.theme-dark textarea:disabled::placeholder,
html.theme-dark textarea[readonly]::placeholder {
  color: #7f8c89;
  -webkit-text-fill-color: #7f8c89;
}
html.theme-dark input::placeholder,
html.theme-dark textarea::placeholder { color: #7f8c89; }
/* Etiquetas de campos (filtros, asistente, formularios) legibles en modo noche */
html.theme-dark label span { color: var(--ink); }
html.theme-dark table th,
html.theme-dark table thead th,
html.theme-dark table tr:hover th,
html.theme-dark table thead tr:hover th {
  background: #232a2d !important;
  color: var(--ink) !important;
}
html.theme-dark .topbar,
html.theme-dark .content {
  background: var(--bg);
  color: var(--ink);
}
html.theme-dark .save-toast {
  background: #22312b;
  color: #d7f0e2;
}
/* Barra superior: avisos, chip de usuario, salir, hamburguesa, desplegable de avisos y toasts */
html.theme-dark .topbar-logout,
html.theme-dark .user-chip,
html.theme-dark .notification-bell,
html.theme-dark .menu-toggle,
html.theme-dark .notification-popover,
html.theme-dark .toast-message {
  background: #232a2d;
  color: var(--ink);
  border-color: var(--line-strong);
}
html.theme-dark .topbar-logout:hover { background: #2f3a3e; }
html.theme-dark .notification-popover li a { background: #2a343a; }

/* Desplegable de los combos (filtros y fichas): fondo blanco fijo -> oscuro en modo noche */
html.theme-dark .record-combo-menu {
  background: #232a2d;
  border-color: var(--line-strong);
}
html.theme-dark .record-combo-option:hover,
html.theme-dark .record-combo-option:focus {
  background: #2a343a;
}

/* Recuadros del panel de inicio (Entradas, Salidas, Recogidas y Equipos por llegar) con fondo claro fijo */
html.theme-dark .today-chip {
  background: #232a2d;
  border-color: var(--line-strong);
}
html.theme-dark .today-chip:hover {
  background: #2a343a;
}
html.theme-dark .today-chip strong { color: var(--ink); }
html.theme-dark .today-pie {
  background: #232a2d;
  border-color: var(--line-strong);
  color: var(--ink);
}
html.theme-dark .today-pie:hover { background: #2a343a; }
html.theme-dark .today-nav-btn {
  background: #232a2d;
  border-color: var(--line-strong);
  color: var(--ink);
}
html.theme-dark .today-nav-btn:hover,
html.theme-dark .today-nav-btn[aria-disabled="true"]:hover { background: #2a343a; }
html.theme-dark .today-nav-btn[aria-disabled="true"]:hover { border-color: var(--line-strong); }
html.theme-dark .dashboard-welcome h2 { color: var(--ink); }

/* Resaltado de fila al pasar el raton (en claro es crema; en noche, gris oscuro) */
html.theme-dark tbody tr:hover {
  background: #2a343a;
}
html.theme-dark .assistant-pickup-panel [data-assistant-pickup-row]:hover td {
  background: #223027;
}

/* Filas con estado (ordenes: expedida, baja, recogidas; festivos): en noche, fondos oscuros
   con el matiz del color para que el texto (claro) se lea. Sin esto quedaban fondo claro + texto blanco. */
html.theme-dark .table-wrap tr.expedited-row td { background: #1e3527; }
html.theme-dark .table-wrap tr.retired-row td { background: #3a2424; }
html.theme-dark .table-wrap tr.diff-extra-row td { background: #3a2424; }
html.theme-dark .table-wrap tr.diff-extra-row:hover td { background: #4a2c2c; }
html.theme-dark .table-wrap tr.generic-note-row td { background: #1e2a3a; }
html.theme-dark .table-wrap tr.pickup-warning-row td { background: #38321b; }
html.theme-dark .table-wrap tr.pickup-alert-row td { background: #3a2a22; }
html.theme-dark tr.holiday-national-row td { background: #1e2a3a; }
html.theme-dark tr.holiday-local-row td { background: #33301c; }
html.theme-dark .dashboard-notifications .dashboard-alert-table table tbody tr td { background: #33291d; }

/* Hover sobre esas filas de estado en noche: aclarar un poco manteniendo legibilidad */
html.theme-dark .table-wrap tr.expedited-row:hover td,
html.theme-dark .table-wrap tr.retired-row:hover td,
html.theme-dark .table-wrap tr.generic-note-row:hover td,
html.theme-dark .table-wrap tr.pickup-warning-row:hover td,
html.theme-dark .table-wrap tr.pickup-alert-row:hover td,
html.theme-dark tr.holiday-national-row:hover td,
html.theme-dark tr.holiday-local-row:hover td {
  background: #2f3b42;
}

/* Las impresiones y su previsualizacion se mantienen siempre en claro */
html.theme-dark .print-sheet,
html.theme-dark .print-body { background: #fff; color: #111; }

/* ===== Revision/certificacion de arnes ===== */
/* Checklist en la ficha de la orden (bajo Servicios) */
.harness-revision-table {
  width: 100%;
  border-collapse: collapse;
}
.harness-revision-table th,
.harness-revision-table td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}
.harness-revision-table .harness-ok-cell {
  text-align: center;
  width: 64px;
}
.harness-revision-table .email-switch {
  vertical-align: middle;
}
/* Toda la fila del checklist es clicable para marcar el Ok (concepto y celda Ok). */
.harness-revision-table tbody tr {
  cursor: pointer;
}
.harness-revision-table tbody tr:hover {
  background: var(--surface-alt, rgba(0, 0, 0, 0.03));
}

/* Hoja impresa de arnes */
.harness-sheet .harness-disclaimer p {
  white-space: normal;
  font-size: 12px;
  line-height: 1.35;
}
.harness-check-sheet th {
  text-align: center;
}
.harness-check-sheet th.harness-mark-head {
  width: 28px;
}
.harness-check-sheet td.harness-concept {
  text-align: left;
}
.harness-check-sheet td.harness-mark {
  text-align: center;
  width: 28px;
  font-weight: 800;
}
.harness-final th {
  text-align: left;
  width: 40%;
}
.harness-final td {
  text-align: left;
}

/* Solicitud de recogida: tabla de lineas (una por prenda) y boton de prendas ajenas */
.preq-ajenas {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}
.preq-lines-table {
  width: 100%;
  border-collapse: collapse;
}
.preq-lines-table th,
.preq-lines-table td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
  vertical-align: middle;
}
.preq-lines-table .email-switch-compact {
  vertical-align: middle;
}
.preq-lines-table input[type="date"],
.preq-lines-table input[type="text"],
.preq-lines-table select {
  min-width: 120px;
}
/* Observaciones ocupa el espacio que dejan las columnas eliminadas (repuesto/arnes). */
.preq-lines-table td input.preq-obs {
  width: 100%;
  min-width: 220px;
}

/* ===== Movil y tablet: la tabla de lineas se apila en tarjetas etiquetadas (una prenda por bloque) ===== */
@media (max-width: 1024px) {
  .preq-lines-table,
  .preq-lines-table tbody {
    display: block;
    width: 100%;
  }
  .preq-lines-table thead {
    display: none;
  }
  .preq-lines-table tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 10px;
    margin-bottom: 12px;
    box-sizing: border-box;
  }
  /* Campos apilados (etiqueta encima del campo) para que TODO quepa a lo ancho sin recortes. */
  .preq-lines-table td {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 3px;
    border: none;
    border-bottom: 1px solid var(--line);
    padding: 7px 0;
  }
  .preq-lines-table tr td:last-child {
    border-bottom: none;
  }
  .preq-lines-table td:empty {
    display: none;
  }
  .preq-lines-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 12px;
    color: var(--muted, #64748b);
  }
  .preq-lines-table td input[type="date"],
  .preq-lines-table td input[type="text"],
  .preq-lines-table td input.preq-obs {
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
    min-height: 38px;
    font-size: 16px; /* evita el zoom automatico de iOS al enfocar */
  }
  /* La casilla "Solicitar" se queda en fila: etiqueta + check (el check no ocupa todo el ancho). */
  .preq-lines-table td:first-child {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .preq-lines-table td:first-child::before {
    font-size: 14px;
  }
  /* Interruptor compacto: area de toque ampliada (~54x44 px) sin cambiar la maquetacion (padding compensado con margen negativo). */
  .preq-lines-table td:first-child .email-switch-compact {
    flex: 0 0 auto;
    padding: 12px 10px;
    margin: -12px -10px;
  }
}

/* Boton "+" cuadrado con el signo centrado (nueva tarea, vincular arnes, etc.). */
.add-plus-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
  border-radius: 8px;
}
.add-plus-btn > span {
  display: block;
  line-height: 1;
}
/* Dentro de un <label class="field"> la regla global "label span" (margin-bottom 5px, color de rotulo) alcanzaba al icono y lo subia 2,5px
   y lo oscurecia (boton de vincular arnes/prenda): se anula para que el signo quede centrado y con el color del boton. */
.add-plus-btn > .plus-icon {
  margin: 0;
  color: inherit;
}

/* Boton "+" de las cabeceras de listas (enlace PlusNewLink): el signo se dibuja con dos barras centradas en la caja en lugar de
   usar el glifo de la tipografia, que queda desplazado en vertical segun la fuente. El texto "+" sigue en el DOM (lectores de pantalla). */
a.add-plus-btn {
  position: relative;
  font-size: 0;
}
a.add-plus-btn::before,
a.add-plus-btn::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: currentColor;
  border-radius: 1px;
  transform: translate(-50%, -50%);
}
a.add-plus-btn::before {
  width: 14px;
  height: 2.5px;
}
a.add-plus-btn::after {
  width: 2.5px;
  height: 14px;
}

/* Signos "+" y "-" dibujados con CSS (no con el glifo de la tipografia, que queda desplazado en vertical): un <span> hijo del boton
   con dos barras centradas en su caja. El tamano y el trazo se ajustan por boton con --plus-size / --plus-stroke; el color es currentColor
   (tema claro y noche). El boton que lo contiene debe centrar al hijo (inline-flex + align-items/justify-content center). */
.plus-icon,
.minus-icon {
  position: relative;
  display: block;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: var(--plus-size, 14px);
  height: var(--plus-size, 14px);
  font-size: 0;
  line-height: 0;
  pointer-events: none;
}
.plus-icon::before,
.plus-icon::after,
.minus-icon::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  background: currentColor;
  border-radius: 1px;
  transform: translate(-50%, -50%);
}
.plus-icon::before,
.minus-icon::before {
  width: 100%;
  height: var(--plus-stroke, 2.5px);
}
.plus-icon::after {
  width: var(--plus-stroke, 2.5px);
  height: 100%;
}

/* Aspa "x" dibujada con CSS (cerrar ventanas, borrar valor de un combo, quitar una linea) en lugar del glifo de la tipografia, que queda desplazado en
   vertical. Un <span aria-hidden> hijo del boton con dos barras diagonales centradas en su caja. Tamano y trazo por boton con --x-size / --x-stroke;
   color currentColor (tema claro y noche). El boton que lo contiene debe centrar al hijo (inline-flex + align-items/justify-content center). */
.x-icon {
  position: relative;
  display: block;
  flex: none;
  box-sizing: border-box;
  width: var(--x-size, 14px);
  height: var(--x-size, 14px);
  margin: 0 !important;
  font-size: 0;
  line-height: 0;
  pointer-events: none;
}
.x-icon::before,
.x-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--x-size, 14px);
  height: var(--x-stroke, 2.5px);
  background: currentColor;
  border-radius: 1px;
}
.x-icon::before {
  transform: translate(-50%, -50%) rotate(45deg);
}
.x-icon::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* Botones que llevan el signo dentro: centrado en horizontal y vertical, con el tamano propio de cada boton. */
.warning-add-head,
.deliverynote-add-button,
.vacation-big-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.warning-add-head {
  --plus-size: 11px;
  --plus-stroke: 2.2px;
}
.deliverynote-add-button {
  --plus-size: 12px;
  --plus-stroke: 2.4px;
}
.accordion-toggle-btn {
  --plus-size: 12px;
  --plus-stroke: 2.5px;
}
/* Boton con signo "+" y texto (p. ej. "+ Generico"): signo dibujado con CSS y texto centrados en vertical entre si. */
.button.button-with-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  --plus-size: 12px;
  --plus-stroke: 2px;
}
.button.button-with-plus > span {
  display: block;
  line-height: 1;
}
.button.button-with-plus > .plus-icon {
  line-height: 0;
}
.vacation-big-action {
  --plus-size: 28px;
  --plus-stroke: 5px;
  padding: 0;
}

/* Asignados de una tarea: pastillas seleccionables con un clic (sin tecla Ctrl). */
.assignee-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip-check {
  display: inline-flex;
  cursor: pointer;
}
.chip-check input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.chip-check span {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  user-select: none;
  transition: background .12s, border-color .12s, color .12s;
}
.chip-check input:checked + span {
  background: var(--focus);
  border-color: var(--focus);
  color: #fff;
  font-weight: 600;
}
.chip-check input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
html.theme-dark .chip-check span {
  background: #1f262b;
}

/* Toast de aviso de tarea: clicable (lleva a la tarea), sin boton de descartar. */
a.toast-message.toast-link {
  display: block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}
a.toast-message.toast-link:hover {
  filter: brightness(0.98);
}

/* "Asignar a:" con la etiqueta y las pastillas en la misma linea. */
.assignee-field {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}
.assignee-field > span {
  flex: 0 0 auto;
}

/* Botones Completar/Posponer de una notificacion de tarea, uno al lado del otro. */
.inline-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ==========================================================================
   Menu lateral v2: panel flotante redondeado, sin barra de desplazamiento,
   contraible a solo iconos (escritorio). Mantiene colores, logo y nombre.
   ========================================================================== */
.sidebar {
  display: block;
  padding: 0;
  overflow: visible;
  scrollbar-gutter: auto;
}

/* Zona con scroll del menu: la barra se oculta (el scroll sigue funcionando con rueda/tactil/teclado). */
.sidebar-inner {
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-radius: inherit;
}

.sidebar-inner::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.sidebar .logo {
  min-height: 46px;
  padding: 5px 8px;
  gap: 10px;
}

.sidebar .logo img {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.sidebar .logo strong {
  white-space: nowrap;
}

.sidebar nav {
  gap: 4px;
}

.sidebar nav a {
  position: relative;
  min-height: 46px;
  gap: 10px;
  padding: 5px 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #cfe3de;
  font-size: 14px;
  line-height: 1.2;
  transition: background .15s ease, color .15s ease;
}

.sidebar nav a:hover {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar nav a.is-active {
  background: var(--side-soft);
  border: 0;
  box-shadow: none;
  color: #fff;
  font-weight: 700;
}

.sidebar nav a:focus-visible,
.sidebar .logo:focus-visible,
.sidebar-collapse:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar .nav-icon {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: rgba(255, 255, 255, .09);
  color: #e6f3f0;
  transition: background .15s ease;
}

.sidebar .nav-icon svg {
  width: 19px;
  height: 19px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar nav a:hover .nav-icon {
  background: rgba(255, 255, 255, .16);
}

.sidebar nav a.is-active .nav-icon {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .22);
}

.sidebar .nav-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sidebar .nav-section {
  display: block;
  margin: 16px 10px 4px;
  color: #9fc0bb;
}

/* Boton de contraer/expandir: circulo pequeno sobre el borde derecho del panel (solo escritorio). */
.sidebar .sidebar-collapse {
  position: absolute;
  top: 28px;
  right: -13px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  min-height: 26px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #fff;
  color: var(--side);
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  transition: background .15s ease, color .15s ease;
}

.sidebar .sidebar-collapse svg {
  width: 14px;
  height: 14px;
  display: block;
  transition: transform .22s ease;
}

.sidebar .sidebar-collapse:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

html.sidebar-collapsed .sidebar .sidebar-collapse svg {
  transform: rotate(180deg);
}

html.theme-dark .sidebar .sidebar-collapse {
  background: #232a2d;
  color: var(--ink);
}

html.theme-dark .sidebar .sidebar-collapse:hover {
  background: var(--accent);
  color: #fff;
}

/* Globo con el nombre del item cuando el menu esta contraido (lo crea site.js). */
.sidebar-tooltip {
  position: fixed;
  z-index: 90;
  max-width: 260px;
  padding: 7px 12px;
  border-radius: 10px;
  background: #0b2322;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity .12s ease, transform .12s ease;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .3);
}

.sidebar-tooltip.is-visible {
  opacity: 1;
  transform: none;
}

/* ----- Escritorio: panel flotante + contraido ----- */
@media (min-width: 1025px) {
  .app-shell {
    grid-template-columns: 226px minmax(0, 1fr);
    transition: grid-template-columns .22s ease;
  }

  html.sidebar-collapsed .app-shell {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .sidebar {
    top: 12px;
    align-self: start;
    height: calc(100vh - 24px);
    margin: 12px 8px 12px 12px;
    border-radius: 22px;
    box-shadow: 0 10px 30px rgba(8, 28, 27, .28);
    z-index: 40;
  }

  html.sidebar-collapsed .sidebar-inner {
    padding: 16px 9px;
  }

  html.sidebar-collapsed .sidebar .logo {
    justify-content: center;
    padding: 5px 0;
  }

  html.sidebar-collapsed .sidebar .logo strong {
    display: none;
  }

  html.sidebar-collapsed .sidebar nav a {
    justify-content: center;
    padding: 5px 0;
  }

  /* Etiqueta solo para lectores de pantalla (display:none la quitaria del arbol de accesibilidad). */
  html.sidebar-collapsed .sidebar .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* Los titulos de seccion pasan a ser una linea fina separadora. */
  html.sidebar-collapsed .sidebar .nav-section {
    height: 1px;
    margin: 12px 14px 8px;
    padding: 0;
    overflow: hidden;
    background: rgba(255, 255, 255, .18);
    color: transparent;
    font-size: 0;
  }

  html.sidebar-collapsed .sidebar-status {
    padding: 6px 0 2px;
    text-align: center;
    font-size: 10px;
  }
}

@media (max-width: 1024px) {
  .sidebar .sidebar-collapse {
    display: none;
  }

  .sidebar-inner {
    gap: 10px;
  }

  .sidebar-tooltip {
    display: none;
  }
}

/* ==========================================================================
   Imagen de usuario (arriba a la derecha, junto al nombre)
   ========================================================================== */
.user-chip {
  gap: 10px;
  padding: 5px 12px 5px 5px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 11px;
  background: #fff;
  border: 1px solid var(--line);
}

.user-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

/* Si la imagen no carga se muestra la inicial sobre el color de marca. */
.user-avatar.avatar-initial {
  background: var(--focus);
  border-color: var(--focus);
  color: #fff;
}

/* ==========================================================================
   Modo noche: Avisos, botones de informacion y leyendas
   ========================================================================== */
/* Con avisos activos la campana tenia fondo rosa claro (mas especifico que la regla de modo noche)
   y el texto claro no se leia. En modo noche: fondo rojo oscuro con texto casi blanco. */
html.theme-dark .notification-wrap.has-notifications .notification-bell {
  background: #3d2024;
  border-color: #e5484d;
  color: #fff1f1;
  box-shadow: 0 0 0 1px rgba(229, 72, 77, .45);
}

html.theme-dark .info-button {
  background: #232a2d;
  border-color: var(--line-strong);
  color: #8fd3cb;
}

html.theme-dark .info-button:hover,
html.theme-dark .info-popover-wrap:focus-within .info-button {
  background: #2f3a3e;
  color: #fff;
}

html.theme-dark .info-popover {
  background: #232a2d;
  border-color: var(--line-strong);
  color: var(--ink);
  box-shadow: 0 16px 42px rgba(0, 0, 0, .55);
}

html.theme-dark .legend-ok { background: #1e3527; }
html.theme-dark .legend-warn { background: #38321b; }
html.theme-dark .legend-alert { background: #3a2a22; }
html.theme-dark .legend-empty { background: #232a2d; }
html.theme-dark .legend-generic { background: #1e2a3a; }
html.theme-dark .legend-diff { background: #3a2424; }
html.theme-dark .legend-invoice-notice { background: #3a3320; border-color: #7a6532; }
html.theme-dark .legend-box.legend-vacation { background: #1e3527; border-color: #4caf6a; }
html.theme-dark .legend-box.legend-holiday { background: #4a4218; border-color: #d8b400; }
html.theme-dark .legend-box.legend-weekend { background: #8a3f38; border-color: #d1594c; }

/* ==========================================================================
   Control de recogidas: Cliente y Parque alineados con el resto de campos del filtro
   (el .combo-filter reserva 16px abajo para el aviso; en esta barra lo hacia subir).
   ========================================================================== */
.pickup-filter .combo-filter {
  padding-bottom: 0;
}

.pickup-filter .combo-filter::after {
  top: auto;
  bottom: 14px;
}

.pickup-filter .combo-filter .combo-clear {
  top: auto;
  bottom: 3px;
  transform: none;
}

.pickup-filter .combo-filter .combo-hint {
  top: 100%;
  bottom: auto;
}

/* ==========================================================================
   Modo noche: Vacaciones (calendario, personas de vacaciones) y cuadros vacios
   ========================================================================== */
html.theme-dark .vacation-calendar-card {
  background: #1e2427;
  border-color: var(--line-strong);
}

html.theme-dark .vacation-calendar-head span .mini-button {
  background: #2a343a;
  border-color: var(--line-strong);
  color: var(--ink);
}

html.theme-dark .vacation-day:hover {
  background: #2a343a;
}

html.theme-dark .vacation-day.is-muted {
  color: #6f7c79;
}

html.theme-dark .vacation-day.is-weekend:not(.is-selected) {
  background: #7a3a35;
  color: #ffe9e6;
}

html.theme-dark .vacation-day.has-vacation:not(.is-selected) {
  background: #1e3527;
  color: #a6e3b4;
}

html.theme-dark .vacation-day.is-holiday:not(.is-selected),
html.theme-dark .vacation-day.is-holiday.is-weekend:not(.is-selected) {
  background: #4a4218;
  color: var(--ink);
}

html.theme-dark .vacation-people-box {
  background: #1e2427;
  border-color: #3f9b6a;
  color: var(--ink);
}

html.theme-dark .vacation-people-list li {
  background: #2a343a;
}

html.theme-dark .vacation-big-action,
html.theme-dark .vacation-add-button {
  background: linear-gradient(180deg, #2f6b3c, #245a31);
  border-color: #4caf6a;
  color: #eafaf0;
}

html.theme-dark .vacation-day-remove {
  background: rgba(230, 88, 72, .22);
  color: #ff8d80;
}

html.theme-dark .empty {
  background: #1e2427;
  color: var(--muted);
}

/* ==========================================================================
   Modo noche: botones y componentes que tenian colores claros fijos
   (Filtrar / Limpiar de los filtros, enlaces-boton, insignias, avisos, etc.)
   ========================================================================== */
html.theme-dark .filter-actions .filter-button,
html.theme-dark .filter-actions .filter-clear,
html.theme-dark .back-link,
html.theme-dark .icon-link,
html.theme-dark .order-badge,
html.theme-dark .accordion-toggle-btn,
html.theme-dark .record-link-value,
html.theme-dark .readonly-link,
html.theme-dark .logo-preview {
  background: #232a2d;
  border-color: var(--line-strong);
  color: var(--ink);
}

html.theme-dark .filter-actions .filter-button:hover,
html.theme-dark .filter-actions .filter-clear:hover,
html.theme-dark .back-link:hover,
html.theme-dark .icon-link:hover,
html.theme-dark .accordion-toggle-btn:hover,
html.theme-dark .readonly-link:hover {
  background: #2f3a3e;
  border-color: var(--focus);
  color: #fff;
}

html.theme-dark .icon-link.disabled {
  background: #1a2023;
  color: #6f7c79;
}

html.theme-dark .combo-clear {
  background: #2f3a3e;
  color: #c3cfcc;
}

html.theme-dark .combo-clear:hover {
  background: #3a4a50;
  color: #fff;
}

html.theme-dark input.combo-locked {
  background: #171c1f;
  color: #92a19b;
  -webkit-text-fill-color: #92a19b;
}

html.theme-dark .field.field-required-error input,
html.theme-dark .field.field-required-error select,
html.theme-dark .field.field-required-error textarea,
html.theme-dark .field.field-required-error .record-combo input {
  background: #3a2326;
  border-color: #e5484d;
  color: var(--ink);
}

/* Insignias y avisos */
html.theme-dark .status-pill {
  background: #1e3527;
  color: #a6e3b4;
}

html.theme-dark .status-pill.warning-pill {
  background: #3a2424;
  color: #ffb3ad;
}

html.theme-dark .alert,
html.theme-dark .notice,
html.theme-dark .deliverynote-pickup-notice,
html.theme-dark .assistant-pickup-requirement {
  background: #3a3320;
  border-color: #7a6532;
  color: #f1d9a0;
}

html.theme-dark .assistant-pickup-requirement.is-selected {
  background: #2f2c1c;
  border-color: #7a6532;
}

html.theme-dark .alert-danger {
  background: #3a2326;
  border-color: #8a3a3f;
  color: #ffb3ad;
}

html.theme-dark .garment-warning-alert {
  background: #3d2e1c;
  border-color: #9a6a2c;
  color: #ffd29a;
}

html.theme-dark .success {
  background: #1e3527;
  border-color: #3f7a55;
  color: #a6e3b4;
}

html.theme-dark .save-toast.toast-error {
  background: #3a2326;
  border-color: #8a3a3f;
  color: #ffd0cc;
}

html.theme-dark .pending-pickup-row {
  background: #38321b;
}

/* Botones pequenos de acciones */
html.theme-dark .mini-button.ok {
  background: #1e3527;
  border-color: #3f7a55;
  color: #a6e3b4;
}

html.theme-dark .mini-button.danger,
html.theme-dark .primary.danger {
  background: #3a2424;
  border-color: #8a3a3f;
  color: #ffb3ad;
}

html.theme-dark .service-delete {
  background: #3a2424;
  border-color: #8a3a3f;
  color: #ffb3ad;
}

html.theme-dark .service-delete:hover {
  background: #4a2c2c;
}

html.theme-dark .picker-table [data-deliverynote-candidate-row].is-selected td {
  background: #1e3527;
}

html.theme-dark .permission-table td:has(input[type="checkbox"]:disabled) {
  background: #1a2023;
}

html.theme-dark pre {
  background: #171c1f;
  color: var(--ink);
}

/* ==========================================================================
   Interruptor dia / noche en forma de pildora.
   Dia: pista ambar, sol blanco a la izquierda y bola blanca a la derecha.
   Noche: pista indigo, bola blanca a la izquierda y luna blanca a la derecha.
   El boton mide 60x40 (area de toque, transparente); la pista visible (::before) mide 52x28
   y la bola (::after) 22x22.
   ========================================================================== */
.theme-toggle {
  position: relative;
  flex: 0 0 auto;
  width: 60px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: transparent;
  font-size: 0;
  cursor: pointer;
}

.theme-toggle:hover {
  background: transparent;
}

/* Pista (con el icono del sol) */
.theme-toggle::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 4px;
  box-sizing: border-box;
  width: 52px;
  height: 28px;
  border: 2px solid #f3c66b;
  border-radius: 999px;
  background-color: #e8a92e;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='1.6' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2.5v3M12 18.5v3M2.5 12h3M18.5 12h3M5.3 5.3l2.1 2.1M16.6 16.6l2.1 2.1M18.7 5.3l-2.1 2.1M7.4 16.6l-2.1 2.1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 16px 16px;
  background-position: 7px center;
  transition: background-color .25s ease, border-color .25s ease;
}

/* Bola */
.theme-toggle::after {
  content: "";
  position: absolute;
  top: 9px;
  left: 7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transform: translateX(24px);
  transition: transform .25s ease;
}

.theme-toggle:focus-visible {
  outline: none;
}

.theme-toggle:focus-visible::before {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Noche: pista indigo, luna a la derecha y bola a la izquierda */
html.theme-dark .theme-toggle::before {
  border-color: #7586d4;
  background-color: #4054b2;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23fff' d='M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z'/%3E%3C/svg%3E");
  background-position: right 7px center;
}

html.theme-dark .theme-toggle::after {
  transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle::before,
  .theme-toggle::after {
    transition: none;
  }
}

/* ==========================================================================
   Solicitud de recogida
   ========================================================================== */
/* Selector de parque del cliente: la "x" solo aparece si hay un parque seleccionado. */
.combo-select-wrap .combo-clear {
  display: none;
}

.combo-select-wrap.is-filled .combo-clear {
  display: inline-flex;
}

/* Combo de bombero + boton Filtrar: los spans internos heredaban el margen inferior de "label span"
   y el campo quedaba mas arriba que el boton. Se anulan y se alinean al mismo alto. */
[data-preq-ff-combo] > span + span {
  align-items: stretch !important;
  margin-bottom: 0;
}

[data-preq-ff-combo] > span + span > span {
  margin-bottom: 0;
}

[data-preq-ff-combo] > span + span > .button,
[data-preq-ff-combo] > span + span > button {
  min-height: 38px;
  align-self: stretch;
}

[data-preq-ff-combo] .combo-clear {
  top: 50%;
  transform: translateY(-50%);
}

/* Paso previo del bombero en movil/tablet: prenda propia / prenda ajena */
.preq-chooser {
  display: grid;
  gap: 14px;
  padding: 22px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}

.preq-chooser[hidden] {
  display: none;
}

.preq-chooser h2 {
  margin: 0 0 4px;
  font-size: 18px;
  text-align: center;
}

.preq-chooser .button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  font-size: 16px;
  font-weight: 700;
}

body.preq-choosing #pickup-request-form,
body.preq-choosing .page-head .head-actions {
  display: none;
}

/* Movil y tablet: todos los campos se adaptan al ancho (nada cortado) */
@media (max-width: 1024px) {
  #pickup-request-form {
    grid-template-columns: minmax(0, 1fr);
    min-width: 0;
  }

  #pickup-request-form .form-section,
  #pickup-request-form .form-grid > *,
  #pickup-request-form .field {
    min-width: 0;
    max-width: 100%;
  }

  #pickup-request-form .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  #pickup-request-form input,
  #pickup-request-form select,
  #pickup-request-form textarea,
  #pickup-request-form .combo-select-wrap,
  #pickup-request-form [data-preq-ff-combo] > span {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* La tabla se apila en tarjetas dentro de la propia pagina: sin contenedor con scroll propio (evita el doble scroll)
     y sin el ancho minimo de 760px de las tablas, que desplazaba los campos fuera de la pantalla. */
  #pickup-request-form .preq-lines-wrap {
    resize: none;
    overflow: visible;
    max-height: none;
    min-height: 0;
    max-width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
  }

  #pickup-request-form .preq-lines-table {
    min-width: 0;
    width: 100%;
  }

  #pickup-request-form .preq-lines-table td {
    white-space: normal;
    min-width: 0;
  }

  #pickup-request-form .preq-lines-table td input[type="date"],
  #pickup-request-form .preq-lines-table td input[type="text"] {
    min-width: 0;
    max-width: 100%;
  }

  #pickup-request-form .preq-ajenas .button {
    width: 100%;
  }
}

/* ==========================================================================
   Menu lateral: grupos desplegables (Configuracion)
   ========================================================================== */
.sidebar nav .nav-folder-toggle {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 5px 8px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #cfe3de;
  font-size: 14px;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}

.sidebar nav .nav-folder-toggle:hover,
.sidebar nav .nav-folder.is-open > .nav-folder-toggle {
  background: rgba(255, 255, 255, .08);
  color: #fff;
}

.sidebar nav .nav-folder-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar nav .nav-folder-toggle:hover .nav-icon {
  background: rgba(255, 255, 255, .16);
}

.sidebar nav .nav-folder.has-active > .nav-folder-toggle .nav-icon {
  background: var(--accent);
  color: #fff;
}

.sidebar .nav-chevron {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  margin-left: auto;
  width: 20px;
  height: 20px;
  opacity: .85;
  transform: rotate(-90deg);
  transition: transform .2s ease;
}

.sidebar .nav-chevron svg {
  width: 16px;
  height: 16px;
  display: block;
}

.sidebar .nav-folder.is-open > .nav-folder-toggle .nav-chevron {
  transform: none;
}

.sidebar .nav-submenu {
  display: grid;
  gap: 2px;
  margin: 2px 0 6px 21px;
  padding-left: 8px;
  border-left: 1px solid rgba(255, 255, 255, .16);
}

.sidebar .nav-submenu[hidden] {
  display: none;
}

.sidebar nav .nav-submenu a {
  min-height: 40px;
  padding: 4px 8px;
  font-size: 13.5px;
}

.sidebar .nav-submenu .nav-icon {
  flex-basis: 28px;
  width: 28px;
  height: 28px;
  border-radius: 9px;
}

.sidebar .nav-submenu .nav-icon svg {
  width: 16px;
  height: 16px;
}

@media (min-width: 1025px) {
  html.sidebar-collapsed .sidebar .nav-folder-toggle {
    justify-content: center;
    padding: 5px 0;
  }

  html.sidebar-collapsed .sidebar .nav-chevron,
  html.sidebar-collapsed .sidebar .nav-submenu {
    display: none;
  }
}

/* ==========================================================================
   Configuracion -> Correo electronico
   ========================================================================== */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  /* Sin esto, overflow-x:auto convierte tambien el eje vertical en auto y el margen negativo de .tab (1px de desborde)
     hacia aparecer una barra de desplazamiento vertical diminuta (flechas arriba/abajo) a la derecha de las pestanas. */
  overflow-y: hidden;
}

.tab {
  margin-bottom: 0;
  padding: 10px 16px;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.tab:hover {
  color: var(--ink);
}

.tab.is-active {
  color: var(--focus);
  border-bottom-color: var(--accent);
}

.tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
  border-radius: 6px;
}

/* Fichas de talla / color / fabricante: pestana "Prendas asignadas" (tabla de 3 columnas, sin el ancho minimo global). */
.record-tab-panel[hidden] {
  display: none;
}

/* Carga incremental: la tabla ocupa el alto de la ventana y hace scroll por dentro (sin tope de filas). */
.assigned-garments-wrap {
  max-height: calc(100vh - 280px);
}

.assigned-garments-wrap table {
  min-width: 0;
}

.assigned-garments-wrap tr[data-href] {
  cursor: pointer;
}

/* Ficha de Control de recogidas: "Prendas vinculadas" con scroll interno y carga incremental. */
.pickup-garments-wrap {
  max-height: calc(100vh - 280px);
}

.pickup-garments-wrap table {
  min-width: 0;
}

.email-help {
  margin: 6px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

.email-stored {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.email-errors {
  margin: 0;
  padding-left: 18px;
}

.email-panel {
  margin-top: 14px;
}

.email-panel[hidden] {
  display: none;
}

/* Interruptor "Activar el envio de correos" */
.email-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

/* El input nativo siempre queda oculto (accesible por teclado: el foco se dibuja en la pista) en cualquier pagina, modal o tabla.
   La especificidad (0,2,2) supera a las reglas genericas de casillas (.field / .switch-checkboxes input[type="checkbox"]). */
.record-form .email-switch input,
label.email-switch input[type="checkbox"],
span.email-switch input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
}

.email-switch .email-switch-track {
  position: relative;
  display: inline-block;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .2s ease;
}

.email-switch .email-switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s ease;
}

.email-switch input:checked + .email-switch-track {
  background: var(--focus);
}

.email-switch input:checked + .email-switch-track::after {
  transform: translateX(14px);
}

.email-switch input:focus-visible + .email-switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.email-switch .email-switch-label {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.3;
}

/* Estados comunes del interruptor: deshabilitado y parcial (casilla "marcar todos" con seleccion mixta). */
.email-switch input:disabled + .email-switch-track {
  opacity: .42;
  cursor: not-allowed;
}

.email-switch input:indeterminate + .email-switch-track {
  background: var(--focus);
  opacity: .55;
}

.email-switch input:indeterminate + .email-switch-track::after {
  transform: translateX(7px);
}

/* Tamano unico de todos los interruptores: pista 34x20, bola 14px (mismo que "Prendas por defecto" de la ficha de cliente).
   Variante compacta (celdas de tabla): sin texto, mismas medidas. */
.email-switch.email-switch-compact {
  gap: 6px;
  vertical-align: middle;
}

.email-switch-compact .email-switch-track {
  width: 34px;
  height: 20px;
}

.email-switch-compact .email-switch-track::after {
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
}

.email-switch-compact input:checked + .email-switch-track::after {
  transform: translateX(14px);
}

.email-switch-compact input:indeterminate + .email-switch-track::after {
  transform: translateX(7px);
}

/* Modal "Motivo de eliminacion": opcion de eliminar tambien el arnes vinculado (texto largo: el interruptor se alinea arriba). */
.email-switch.delete-harness-option {
  display: flex;
  align-items: flex-start;
  margin: 12px 0 0;
}

.delete-harness-option .email-switch-track {
  margin-top: 1px;
}

/* Caracteristicas prendas (fabricantes, colores, tallas): el interruptor de un campo no se estira a todo el ancho de la etiqueta y
   las listas de interruptores (tallas, grupos de prenda) separan algo mas las filas que las casillas antiguas. */
.field > .email-switch {
  justify-self: start;
  align-self: flex-start;
}

.checkbox-list.small-checkboxes:has(> .email-switch) {
  gap: 10px 22px;
}

/* Matriz de permisos: el input nativo sigue oculto aunque este deshabilitado (la regla de la tabla le daba opacidad .42). */
.permission-table .email-switch input[type="checkbox"],
.permission-table .email-switch input[type="checkbox"]:disabled {
  opacity: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
}

.permission-table th .email-switch {
  justify-content: center;
}

.permission-table .email-switch-label {
  font-size: inherit;
  font-weight: 800;
  color: inherit;
}

/* Ayuda breve bajo el nombre de cada pantalla de la matriz (solo efectos no obvios). */
.permission-table td:first-child .permission-help {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.35;
}

.permission-table td:first-child .permission-help .permission-help-item {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: inherit;
}

.permission-help-item + .permission-help-item::before {
  content: " \00b7  ";
}

.permission-help-item b {
  font-weight: 700;
  color: var(--ink);
}

/* Historial */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 16px 0;
}

.pager .button.is-disabled {
  opacity: .45;
  pointer-events: none;
}

/* Impresion de albaran bloqueada (recogidas sin marcar como enviadas): botones en gris con tooltip en el span contenedor. */
.print-blocked-wrap {
  display: inline-block;
  cursor: not-allowed;
}

.print-blocked-wrap .button.is-print-blocked,
.print-blocked-wrap .button.is-print-blocked:hover {
  background: #e6eaec;
  border-color: #cfd6d9;
  color: #8a949a;
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

html.theme-dark .print-blocked-wrap .button.is-print-blocked,
html.theme-dark .print-blocked-wrap .button.is-print-blocked:hover {
  background: #171c1f;
  border-color: #2b3338;
  color: #6f7a80;
}

.print-blocked-notice a {
  font-weight: 700;
  text-decoration: underline;
}

.pager-info {
  color: var(--muted);
  font-size: 14px;
}

.email-dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 20px;
  margin: 0 0 16px;
}

.email-dl dt {
  color: var(--muted);
  font-weight: 800;
}

.email-dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.email-pre {
  max-height: 420px;
  margin: 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f6f4;
  color: var(--ink);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.email-body-frame {
  display: block;
  width: 100%;
  min-height: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

html.theme-dark .email-pre {
  background: #171c1f;
}

@media (max-width: 640px) {
  .email-dl {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .email-dl dd {
    margin-bottom: 10px;
  }

  /* Historial: cada envio se muestra como tarjeta etiquetada */
  .email-history table,
  .email-history tbody {
    display: block;
    width: 100%;
  }

  .email-history thead {
    display: none;
  }

  .email-history tr {
    display: block;
    margin-bottom: 12px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
  }

  .email-history td {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border: 0;
    border-bottom: 1px solid var(--line);
    overflow-wrap: anywhere;
  }

  .email-history td:last-child {
    border-bottom: 0;
  }

  .email-history td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
  }
}

/* Boton hamburguesa en modo noche: las lineas usaban el verde oscuro del menu y no se veian sobre el fondo oscuro. */
html.theme-dark .menu-toggle span {
  background: var(--ink);
}

/* Cliente / parque -> Contacto: contactos adicionales (hasta 5 en total) dentro del mismo recuadro, con el "+" abajo a la derecha. */
.extra-contacts {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
}
.extra-contacts-list {
  display: grid;
  gap: 12px;
}
.extra-contacts-list:empty {
  display: none;
}
.extra-contact {
  display: grid;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-strong);
}
.extra-contact-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.extra-contact-title {
  font-weight: 700;
}
.extra-contact-remove {
  border: none;
  background: #e6584822;
  color: #c0392b;
  flex: 0 0 auto;
  box-sizing: border-box;
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  --x-size: 10px;
  --x-stroke: 2px;
  transition: background 0.15s ease;
}
.extra-contact-remove:hover {
  background: #e65848;
  color: #fff;
}
html.theme-dark .extra-contact-remove {
  background: rgba(230, 88, 72, .22);
  color: #ff8d80;
}
html.theme-dark .extra-contact-remove:hover {
  background: #e65848;
  color: #fff;
}
.extra-contacts-footer {
  display: flex;
  justify-content: flex-end;
}
.extra-contacts-add[hidden] {
  display: none;
}

/* Cliente -> Acceso web: lista de correos de aviso de solicitudes de recogida */
.pickup-email-list {
  display: grid;
  gap: 8px;
  align-content: start;
}

.pickup-email-list[hidden] {
  display: none;
}

.pickup-email-list .pickup-email-title {
  font-weight: 700;
}

.pickup-email-list .email-help {
  margin: 0;
}

.pickup-email-rows {
  display: grid;
  gap: 8px;
  max-width: 520px;
}

.pickup-email-list .add-plus-btn {
  justify-self: start;
}

.pickup-email-list .add-plus-btn[hidden] {
  display: none;
}

.pickup-email-warning {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid #ebcf9e;
  border-radius: 8px;
  background: #fff8ed;
  color: var(--warn);
  font-size: 13px;
}

html.theme-dark .pickup-email-warning {
  background: #3a3320;
  border-color: #7a6532;
  color: #f1d9a0;
}

/* Ayuda bajo "Solicitudes recogida usuarios" cuando no hay Usuarios web ni Cliente web activos */
.web-access-help {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.web-access-help[hidden] {
  display: none;
}

/* Cada correo de aviso: caja + boton Eliminar (solo en cajas vacias) + mensaje de formato */
.pickup-email-rows {
  max-width: 640px;
}

.pickup-email-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
}

.pickup-email-row [data-pickup-email-remove] {
  white-space: nowrap;
}

.pickup-email-row [data-pickup-email-remove][hidden] {
  display: none;
}

.pickup-email-row input.is-invalid {
  border-color: #c0261c;
  background: #fdf1f0;
}

html.theme-dark .pickup-email-row input.is-invalid {
  border-color: #e5484d;
  background: #3a2326;
}

.pickup-email-error {
  grid-column: 1 / -1;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

.pickup-email-error[hidden] {
  display: none;
}

html.theme-dark .pickup-email-error {
  color: #ffb3ad;
}

/* ==========================================================================
   Reportar error: enlace discreto del menu (cliente y bombero) y ventana flotante
   ========================================================================== */
.sidebar .sidebar-report {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  margin: auto 0 0;
  padding: 4px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(244, 251, 248, .5);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}

.sidebar .sidebar-report:hover,
.sidebar .sidebar-report:focus-visible {
  color: rgba(244, 251, 248, .95);
  background: rgba(255, 255, 255, .08);
}

.sidebar .sidebar-report:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sidebar .sidebar-report-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}

.sidebar .sidebar-report-icon svg {
  width: 13px;
  height: 13px;
  display: block;
}

/* Si el boton Salir (movil) va despues, el empuje al fondo lo hace "Reportar error". */
.sidebar .sidebar-report + .sidebar-logout {
  margin-top: 6px;
}

@media (min-width: 1025px) {
  html.sidebar-collapsed .sidebar .sidebar-report {
    align-self: center;
    padding: 6px;
  }

  html.sidebar-collapsed .sidebar .sidebar-report-label {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
}

.bug-status {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.bug-status[hidden] {
  display: none;
}

.bug-status.is-error {
  background: #fff2f2;
  border: 1px solid #edb9b9;
  color: var(--danger);
}

.bug-status.is-ok {
  background: #f0fff4;
  border: 1px solid #b9dfc8;
  color: var(--ok);
}

html.theme-dark .bug-status.is-error {
  background: #3a2326;
  border-color: #8a3a3f;
  color: #ffb3ad;
}

html.theme-dark .bug-status.is-ok {
  background: #1e3527;
  border-color: #3f7a55;
  color: #a6e3b4;
}

[data-bug-form] {
  display: grid;
  gap: 12px;
}

/* Administracion: Errores reportados */
.bug-reports table {
  min-width: 1100px;
}

.bug-reports td.bug-desc {
  min-width: 260px;
  max-width: 420px;
  white-space: normal;
}

.bug-reports td.bug-page {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bug-image {
  display: block;
  max-width: min(100%, 720px);
  max-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 640px) {
  .bug-reports table {
    min-width: 0;
  }

  .bug-reports td.bug-desc,
  .bug-reports td.bug-page {
    max-width: none;
    white-space: normal;
  }
}

/* ==========================================================================
   Fichas de cliente, bombero y tipo de servicio: las casillas pasan a ser interruptores (como "Activar el envio de correos"),
   situados a la izquierda y al mismo nivel que su texto.
   ========================================================================== */
.switch-checkboxes input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background .2s ease;
}

.switch-checkboxes input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s ease;
}

.switch-checkboxes input[type="checkbox"]:checked {
  background: var(--focus);
}

.switch-checkboxes input[type="checkbox"]:checked::after {
  transform: translateX(14px);
}

.switch-checkboxes input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.switch-checkboxes input[type="checkbox"]:disabled {
  opacity: .5;
  cursor: not-allowed;
}

/* Etiqueta: interruptor primero (izquierda) y texto a continuacion, en la misma linea. */
.switch-checkboxes label.field:has(> input[type="checkbox"]) {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
}

.switch-checkboxes label.field:has(> input[type="checkbox"]) > input[type="checkbox"] {
  order: -1;
}

.switch-checkboxes label.field:has(> input[type="checkbox"]) > span {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}

.switch-checkboxes .fixed-price-inline {
  gap: 10px;
}

/* Ficha de cliente -> Opciones: boton triple del alcance del arnes (Pecho | Ambos | Cubre), con el mismo color que los interruptores. */
.harness-scope-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Etiqueta "Localizacion del arnes" en negrita y mismo tamano/color que las de los otros interruptores (label span + .email-switch-label). */
.harness-scope-field > span {
  margin: 0;
  color: #31403e;
  font-size: 13.5px;
  font-weight: 700;
}

html.theme-dark .harness-scope-field > span {
  color: var(--ink);
}

.triple-switch {
  display: inline-flex;
  align-self: flex-start;
  border-radius: 999px;
  background: var(--line-strong);
  padding: 2px;
  gap: 2px;
}

/* Altura total 20px (= pista de los interruptores normales); ancho -15% respecto a la version anterior (62px / 11px de relleno). */
.triple-switch .triple-switch-option {
  min-width: 53px;
  min-height: 16px;
  height: 16px;
  margin: 0;
  padding: 0 9px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  line-height: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease, color .2s ease;
}

.triple-switch .triple-switch-option[aria-checked="true"] {
  background: var(--focus);
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}

.triple-switch .triple-switch-option:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.triple-switch .triple-switch-option:disabled {
  cursor: not-allowed;
}

/* Sin Arnes activo (o ficha de solo lectura) el control se ve gris y atenuado. */
.harness-scope-field.is-off,
.harness-scope-field[data-readonly="1"] {
  opacity: .5;
}

.harness-scope-field.is-off .triple-switch-option[aria-checked="true"],
.harness-scope-field[data-readonly="1"] .triple-switch-option[aria-checked="true"] {
  background: #7d8a85;
}

html.theme-dark .triple-switch {
  background: #3a4548;
}

html.theme-dark .triple-switch .triple-switch-option {
  color: var(--ink);
}

html.theme-dark .triple-switch .triple-switch-option[aria-checked="true"] {
  background: var(--focus);
  color: #fff;
}

html.theme-dark .harness-scope-field.is-off .triple-switch-option[aria-checked="true"],
html.theme-dark .harness-scope-field[data-readonly="1"] .triple-switch-option[aria-checked="true"] {
  background: #5a6663;
}

/* Ficha de cliente -> "Tipos de limpieza por defecto": interruptores compactos (34x20, bola de 14px) en una rejilla
   de 3 columnas (2 en tablet, 1 en movil). Solo esta seccion; el resto de interruptores no cambia.
   El selector es mas especifico que ".checkbox-list.small-checkboxes ..." (que fija 13px) y que ".switch-checkboxes input". */
.switch-checkboxes .client-default-services .checkbox-list.small-checkboxes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 20px;
  margin-top: 6px;
}

.switch-checkboxes .client-default-services .checkbox-list.small-checkboxes .checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  min-width: 0;
  padding: 2px 0;
  font-size: 13.5px;
  cursor: pointer;
}

.switch-checkboxes .client-default-services .checkbox-list.small-checkboxes .checkbox-item input[type="checkbox"] {
  width: 34px;
  height: 20px;
  min-height: 20px;
  margin: 0;
  flex: 0 0 auto;
}

.switch-checkboxes .client-default-services .checkbox-list.small-checkboxes .checkbox-item input[type="checkbox"]::after {
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
}

.switch-checkboxes .client-default-services .checkbox-list.small-checkboxes .checkbox-item input[type="checkbox"]:checked::after {
  transform: translateX(14px);
}

.switch-checkboxes .client-default-services .checkbox-list.small-checkboxes .checkbox-item span {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.switch-checkboxes .client-default-services .default-services-block + .default-services-block {
  margin-top: 14px;
}

@media (max-width: 1100px) {
  .switch-checkboxes .client-default-services .checkbox-list.small-checkboxes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .switch-checkboxes .client-default-services .checkbox-list.small-checkboxes {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .switch-checkboxes .client-default-services .checkbox-list.small-checkboxes .checkbox-item {
    min-height: 36px;
  }
}

/* Solicitudes de recogida (no portal): solicitada hace mas de una semana y sin recibir -> rojo */
.table-wrap tr.pickup-overdue-row td {
  background: #f8d0d0;
  color: #6d1616;
}

.table-wrap tr.pickup-overdue-row:hover td {
  background: #f3bcbc;
}

html.theme-dark .table-wrap tr.pickup-overdue-row td {
  background: #4d2024;
  color: #ffd3d0;
}

html.theme-dark .table-wrap tr.pickup-overdue-row:hover td {
  background: #5d282c;
}

/* Invitaciones de bomberos */
/* El popover de informacion lleva parrafos de texto (no leyendas en linea) y debe caber en pantallas estrechas. */
.firefighter-invite .info-popover p {
  display: block;
  line-height: 1.4;
}

.firefighter-invite .info-popover-wide {
  width: min(360px, calc(100vw - 48px));
  max-height: 70vh;
  overflow-y: auto;
}

@media (max-width: 640px) {
  .firefighter-invite .info-popover-wide {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-height: 60vh;
  }
}

/* Boton (i) de los catalogos de "Tipos de servicios" (cabeceras de pagina y etiqueta Tipo Servicio de la ficha de servicio).
   Reutiliza .info-popover-wrap / .info-popover (hover, clic y modo noche). El contenido va en .info-popover-scroll
   para que el scroll no recorte el puente ::before que mantiene el hover. */
.service-type-info .info-popover-wide {
  width: 320px;
  max-width: calc(100vw - 32px);
}

.service-type-info .info-popover-scroll {
  max-height: 70vh;
  overflow-y: auto;
}

.service-type-info .info-popover p {
  display: block;
  line-height: 1.4;
}

.service-type-info .info-popover ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.service-type-info .info-popover li {
  margin: 4px 0;
  line-height: 1.4;
}

.service-type-info .info-popover-section + .info-popover-section {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.service-type-info .info-popover-subhead {
  display: block;
  font-size: 12px;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Boton (i) en la cabecera (h2) de las secciones Recogidas / Opciones / Acceso web del cliente: el popover no hereda el estilo del titulo. */
.section-head-inline .info-popover {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
}

.section-head-inline .info-popover li {
  margin: 6px 0;
}

/* Insignia SI / NO (popover y linea "Pide costurera" de la ficha de Tipo Servicio) */
.seamstress-badge {
  display: inline-block;
  min-width: 26px;
  padding: 0 6px;
  border-radius: 6px;
  background: #e8ecee;
  color: #4a5558;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

.seamstress-badge.is-yes {
  background: #eaf4ee;
  color: #266343;
}

.seamstress-line {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

html.theme-dark .seamstress-badge {
  background: #2c3538;
  color: #c3cfcc;
}

html.theme-dark .seamstress-badge.is-yes {
  background: #1e3527;
  color: #a6e3b4;
}

/* Movil: el popover ocupa el ancho de su contenedor (cabecera o campo) en lugar de salirse de la pantalla. */
@media (max-width: 640px) {
  .info-anchor {
    position: relative;
  }

  .info-popover-wrap.service-type-info {
    position: static;
  }

  .service-type-info .info-popover-wide {
    left: 0;
    right: 0;
    width: auto;
    max-width: calc(100vw - 32px);
  }

  .service-type-info .info-popover-scroll {
    max-height: 60vh;
  }
}

.firefighter-invite .invite-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.firefighter-invite[hidden] {
  display: none;
}

.invite-body h3 {
  margin: 14px 0 6px;
  font-size: 15px;
}

.invite-body p {
  margin: 6px 0;
}

.invite-body ul {
  margin: 4px 0 8px;
  padding-left: 20px;
}

.invite-body .invite-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 8px 0 4px;
}

.invite-body .invite-count {
  flex: 1 1 180px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.invite-body .invite-count strong {
  display: block;
  font-size: 24px;
  line-height: 1.1;
}

.invite-body .invite-problem {
  padding: 8px 10px;
  border: 1px solid #edb9b9;
  border-radius: 8px;
  background: #fff2f2;
  color: var(--danger);
  font-weight: 600;
}

html.theme-dark .invite-body .invite-problem {
  background: #3a2326;
  border-color: #8a3a3f;
  color: #ffb3ad;
}

.invite-body .invite-result {
  padding: 10px 12px;
  border-radius: 8px;
  background: #f0fff4;
  border: 1px solid #b9dfc8;
  color: var(--ok);
  font-weight: 600;
}

html.theme-dark .invite-body .invite-result {
  background: #1e3527;
  border-color: #3f7a55;
  color: #a6e3b4;
}

.status-pill.invite-pending {
  background: #fff3d3;
  color: #7a4d00;
}

.status-pill.invite-expired {
  background: #e8ecee;
  color: #4a5558;
}

html.theme-dark .status-pill.invite-pending {
  background: #38321b;
  color: #f1d9a0;
}

html.theme-dark .status-pill.invite-expired {
  background: #2c3538;
  color: #c3cfcc;
}

.email-history small.invite-error {
  display: block;
  margin-top: 2px;
  color: var(--danger);
  font-size: 12px;
  white-space: normal;
}

html.theme-dark .email-history small.invite-error {
  color: #ffb3ad;
}

.email-history small.muted {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

/* Configuracion de impresiones: lista de interruptores, uno por linea (interruptor a la izquierda). */
.checkbox-list.switch-list {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-top: 6px;
}

/* Configuracion de impresiones -> Logos: lista de logos subidos con boton Eliminar. */
.logo-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.logo-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.logo-list img {
  height: 32px;
  width: 64px;
  object-fit: contain;
  flex: 0 0 auto;
}

.logo-list .logo-list-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Configuracion de impresiones -> Logos: el boton "Subir logo" queda alineado con la caja de seleccionar archivo. */
.logo-upload-grid {
  align-items: end;
}

.logo-upload-grid .form-actions {
  margin: 0;
  padding: 0;
  align-self: end;
}

/* ==========================================================================
   Acordeon "Filtros" (Ordenes, Parques, Bomberos, Prendas, Control de recogidas), movil y escritorio.
   site.js (y el script en linea de FilterStateScript) anade is-ready al boton y is-collapsed al panel segun el
   estado recordado; sin JS el boton no se ve y los filtros quedan visibles. El plegado solo se anima con .is-anim,
   que site.js anade tras el primer pintado (el estado inicial no parpadea ni se anima).
   Escritorio: boton compacto a la izquierda; al plegar, la tabla (flex: 1 1 auto; min-height: 0 dentro de
   .main-list-page / .orders-page-shell) ocupa el espacio liberado.
   Movil (<=640px): el panel de filtros (1 columna, ~900px) llenaba toda la altura fija de .orders-page-shell /
   .main-list-page (100vh-104px, overflow hidden) y la tabla se quedaba con 0px: ahi la pagina hace scroll.
   ========================================================================== */
.filter-toggle {
  display: none;
}

.filter-toggle.is-ready {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  align-self: flex-start;
  gap: 10px;
  flex: 0 0 auto;
  min-height: 36px;
  margin: 0 0 10px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--btn-bg, #fff);
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

.filter-toggle.is-ready:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.filter-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.filter-toggle-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--focus);
  color: #fff;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
}

.filter-toggle-count[hidden] {
  display: none;
}

.filter-toggle-chevron {
  flex: 0 0 auto;
  transition: transform .2s ease;
}

.filter-toggle[aria-expanded="true"] .filter-toggle-chevron {
  transform: rotate(180deg);
}

.filter-panel[data-filter-panel] {
  max-height: 2400px;
}

.filter-panel[data-filter-panel].is-anim {
  transition: max-height .25s ease, opacity .2s ease, padding .25s ease, margin .25s ease;
}

.filter-panel[data-filter-panel].is-collapsed {
  max-height: 0;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-width: 0;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
}

.filter-panel[data-filter-panel].is-collapsed.is-anim {
  transition: max-height .25s ease, opacity .2s ease, padding .25s ease, margin .25s ease, visibility 0s linear .25s;
}

/* Escritorio con el panel ABIERTO: site.js mueve el boton "Filtros" al final de .filter-actions (misma fila que Filtrar / Limpiar,
   en el extremo derecho) y marca el contenedor con .has-toggle. Cerrado o en movil el boton vuelve justo antes del panel (reglas de arriba). */
.filter-actions > .filter-toggle.is-ready {
  align-self: auto;
  margin: 0 0 0 auto;
  min-height: 38px;
  padding: 9px 14px;
  font-weight: inherit;
  background: #f7faf7;
  border-color: #aebab4;
  color: #31514c;
}

.filter-actions > .filter-toggle.is-ready:hover {
  background: #edf5f0;
  border-color: #bfd1c8;
}

html.theme-dark .filter-actions > .filter-toggle.is-ready {
  background: #232a2d;
  border-color: var(--line-strong);
  color: var(--ink);
}

html.theme-dark .filter-actions > .filter-toggle.is-ready:hover {
  background: #2f3a3e;
}

/* Parques y Prendas: Filtrar/Limpiar caen en la 2a fila de la rejilla, en una sola celda estrecha; con el boton dentro ocupan toda la fila. */
#centers-filter-panel .filter-actions.has-toggle,
#garments-filter-panel .filter-actions.has-toggle {
  grid-column: 1 / -1;
}

/* Control de recogidas (<=1560px, rejilla de 4 columnas) y tablet (<=1024px, 2 columnas): fila propia para que quepan los tres botones. */
@media (max-width: 1560px) {
  #pickupcontrols-filter-panel .filter-actions.has-toggle {
    grid-column: 1 / -1;
  }
}

@media (max-width: 1024px) {
  .filter-panel[data-filter-panel] .filter-actions.has-toggle {
    grid-column: 1 / -1;
  }
}

/* Anchos medios (tablet): en Bomberos (6 campos + columna "auto" de botones) y Parques (7 campos, la ultima columna "auto") las
   columnas minimas sumaban mas que el ancho util y los botones / el ultimo campo quedaban cortados a la derecha. Aqui los campos
   se reparten en columnas flexibles (minmax(0, 1fr)) y la fila de botones (Filtrar / Limpiar / Filtros) ocupa toda la fila, debajo,
   como en Prendas. Escritorio ancho (>1400px) sin cambios. */
@media (min-width: 1025px) and (max-width: 1400px) {
  .filter-panel.firefighter-filter {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .filter-panel.garment-filter {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 1400px) {
  .filter-panel.firefighter-filter .filter-actions,
  .filter-panel.garment-filter .filter-actions {
    grid-column: 1 / -1;
  }
}

/* Control de recogidas en tablet (<=1024px, rejilla de 2 columnas): "grid-column: 4" creaba columnas implicitas fuera de la vista. */
@media (max-width: 1024px) {
  .filter-panel.pickup-filter .filter-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  /* Mismo arreglo para Parques, Bomberos, Prendas y Control de recogidas (.main-list-page.filter-accordion-page). */
  .orders-page-shell,
  .main-list-page.filter-accordion-page {
    height: auto;
    overflow: visible;
  }

  .orders-page-shell .orders-scroll-table,
  .main-list-page.filter-accordion-page .module-list-scroll {
    flex: 0 1 auto;
    min-height: 240px;
    max-height: 70vh;
    max-height: 72dvh;
  }

  /* Botones Filtrar/Limpiar a todo el ancho del panel de 1 columna (evita columnas implicitas por grid-column: 4). */
  .filter-panel[data-filter-panel] .filter-actions {
    grid-column: 1 / -1;
    min-width: 0;
  }

  /* Boton a todo el ancho y con zona tactil de 44px solo en movil. */
  .filter-toggle.is-ready {
    display: flex;
    align-self: stretch;
    width: 100%;
    min-height: 44px;
    margin: 0 0 12px;
    padding: 10px 14px;
  }
}

/* ==========================================================================
   Vacaciones -> Resumen por usuario y solicitudes canceladas
   ========================================================================== */
/* Solicitud cancelada: fila gris atenuada (distinta de la rechazada, que es rojiza). */
.table-wrap tr.cancelled-row td {
  background: #eceff1;
  color: var(--muted);
}

html.theme-dark .table-wrap tr.cancelled-row td { background: #262b2e; color: var(--muted); }
html.theme-dark .table-wrap tr.cancelled-row:hover td { background: #2f3b42; }

.vacation-summary-table table {
  min-width: 620px;
}

.vacation-summary-table th,
.vacation-summary-table td {
  padding: 7px 10px;
}

/* Fila de trabajador: clicable/enfocable; la seleccionada queda resaltada (no pisa el rojo de .vacation-over). */
.vacation-summary-table tbody tr.vacation-summary-row {
  cursor: pointer;
}

.vacation-summary-table tbody tr.vacation-summary-row:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.vacation-summary-table tbody tr.vacation-summary-row.is-selected td:not(.vacation-over) {
  background: #e1eee8;
}

.vacation-summary-table tbody tr.vacation-summary-row.is-selected td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
  font-weight: 800;
}

html.theme-dark .vacation-summary-table tbody tr.vacation-summary-row.is-selected td:not(.vacation-over) {
  background: #263a38;
}

.vacation-summary-table th.vacation-num,
.vacation-summary-table td.vacation-num {
  text-align: center;
}

/* Vacaciones agotadas / medico superado: mismos colores que .alert-danger (claro y noche). */
.vacation-summary-table td.vacation-over {
  background: #fff2f2;
  color: var(--danger);
  font-weight: 800;
}

html.theme-dark .vacation-summary-table td.vacation-over {
  background: #3a2326;
  color: #ffb3ad;
}

.vacation-summary-table tr.vacation-total-row td {
  background: #eef3ef;
  border-top: 2px solid var(--line);
  font-weight: 800;
}

html.theme-dark .vacation-summary-table tr.vacation-total-row td {
  background: #232a2d;
}

.vacation-summary-table td.vacation-pending strong {
  font-weight: 800;
}

/* Detalle del trabajador seleccionado (debajo de la tabla). Usa variables del tema, asi sirve en claro y en noche. */
.vacation-detail-host {
  margin-top: 12px;
}

.vacation-detail {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
}

.vacation-detail[hidden] {
  display: none;
}

.vacation-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.vacation-detail-head h3 {
  margin: 0;
  font-size: 17px;
}

.vacation-detail-head h3 small {
  color: var(--muted);
  font-weight: 600;
}

.vacation-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

.vacation-detail-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
}

.vacation-detail-card h4 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.vacation-detail-card dl {
  margin: 0;
}

.vacation-detail-pair {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  border-bottom: 1px dotted var(--line);
}

.vacation-detail-pair:last-child {
  border-bottom: 0;
}

.vacation-detail-pair dt {
  color: var(--muted);
}

.vacation-detail-pair dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.vacation-detail-pair dd.vacation-over {
  color: var(--danger);
  font-weight: 800;
}

html.theme-dark .vacation-detail-pair dd.vacation-over {
  color: #ffb3ad;
}

/* Observaciones de vacaciones (por usuario): textarea editable dentro del detalle. */
.vacation-detail-notes {
  margin-top: 12px;
}

.vacation-detail-notes label {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
}

.vacation-detail-notes p {
  margin: 4px 0 0;
  font-size: 13px;
}

.vacation-detail textarea.vacation-notes-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 3.4em;
  box-sizing: border-box;
  padding: 6px 8px;
  resize: vertical;
  font-size: 13px;
  line-height: 1.35;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.vacation-detail textarea.vacation-notes-input:focus {
  border-color: var(--focus);
}

.vacation-detail textarea.vacation-notes-input:disabled {
  background: #e6eaec;
  color: #000;
  -webkit-text-fill-color: #000;
  cursor: not-allowed;
}

html.theme-dark .vacation-detail textarea.vacation-notes-input {
  background: #232a2d;
  color: var(--ink);
  border-color: #384744;
}

html.theme-dark .vacation-detail textarea.vacation-notes-input:disabled {
  background: #171c1f;
  color: var(--muted);
  -webkit-text-fill-color: var(--muted);
}

.vacation-detail .vacation-notes-status {
  display: block;
  min-height: 1.2em;
  font-size: 12px;
  color: var(--muted);
}

.vacation-detail .vacation-notes-status.is-error {
  color: var(--danger);
  font-weight: 700;
}

html.theme-dark .vacation-detail .vacation-notes-status.is-error {
  color: #ffb3ad;
}

.vacation-summary-help {
  margin: 8px 0 0;
  font-size: 13px;
}

@media (max-width: 640px) {
  /* La tabla del resumen hace scroll horizontal dentro de su contenedor (table{min-width:760px} global). */
  .vacation-summary-table {
    overflow-x: auto;
  }

  /* Detalle: una columna, pares etiqueta/valor apilados en filas, sin desbordar. */
  .vacation-detail {
    padding: 10px;
  }

  .vacation-detail-grid {
    grid-template-columns: 1fr;
  }

  .vacation-detail-head h3 {
    font-size: 15px;
    overflow-wrap: anywhere;
  }
}

.vacation-summary-hint {
  margin: 8px 0 0;
  font-size: 13px;
}
/* Configuracion vacaciones > Calculo anual: calendario anual y tabla comparativa.
   Los colores usan fondos translucidos sobre var(--panel), asi sirven igual en modo claro y oscuro. */
.vacation-annual-page .annual-calc {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.annual-panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.annual-panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 10px;
}

.annual-panel-head h2,
.annual-panel-head p {
  margin: 0;
}

.annual-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.annual-legend li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.annual-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 1px solid var(--line);
  border-radius: 3px;
}

.annual-months {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.annual-month {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.annual-month h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--ink);
}

.annual-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.annual-dow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  padding-bottom: 2px;
}

.annual-day {
  display: block;
  padding: 4px 0;
  border-radius: 4px;
  color: var(--ink);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  cursor: default;
}

.annual-day.is-blank {
  visibility: hidden;
}

.annual-day.is-workday,
.annual-swatch.is-workday {
  background: rgba(45, 122, 79, .16);
}

.annual-day.is-weekend,
.annual-swatch.is-weekend {
  background: rgba(128, 138, 136, .28);
  color: var(--muted);
}

.annual-day.is-holiday,
.annual-swatch.is-holiday {
  background: rgba(214, 120, 40, .55);
  font-weight: 800;
}

.annual-day.is-holiday-weekend {
  box-shadow: inset 0 0 0 2px rgba(214, 120, 40, .8);
}

.annual-month-total {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--muted);
}

.annual-month-total strong,
.annual-year-total strong {
  color: var(--ink);
}

.annual-year-total {
  margin: 12px 0 0;
  font-size: 15px;
}

.annual-table-wrap {
  max-width: 760px;
}

.annual-table {
  min-width: 0;
}

.annual-table thead th,
.annual-table tbody th {
  text-align: left;
}

.annual-table tbody th {
  position: static;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  text-transform: none;
  font-weight: 700;
}

.annual-table td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.annual-table thead th:not(:first-child) {
  text-align: right;
}

.annual-table tr.annual-total-row th,
.annual-table tr.annual-total-row td {
  background: rgba(45, 122, 79, .18);
  font-weight: 800;
}

.annual-formula {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.annual-formula summary {
  cursor: pointer;
  font-weight: 700;
}

.annual-formula p {
  margin: 6px 0 0;
}

@media (max-width: 640px) {
  .annual-panel {
    padding: 12px;
  }
  .annual-months {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Calendario de Vacaciones: otros tipos de ausencia (solo admin / permiso de modificacion)
   Un color por tipo. Variables: --vac-bg (fondo), --vac-fg (texto), --vac-accent (punto / franja / borde).
   La lista tipo -> clase -> etiqueta vive en Program.cs (VacationCalendarTypeStyles).
   ========================================================================== */
.vac-type-vacaciones { --vac-bg: #e7f4e4; --vac-fg: #1b6a2c; --vac-accent: #1f7f33; }
.vac-type-enfermedad { --vac-bg: #f1e0fa; --vac-fg: #6a2390; --vac-accent: #a64bd0; }
.vac-type-medico { --vac-bg: #dbeafe; --vac-fg: #1e4fa0; --vac-accent: #3b82f6; }
.vac-type-medico-familiar { --vac-bg: #e3e1fb; --vac-fg: #3b2f9e; --vac-accent: #6b5be0; }
.vac-type-asuntos { --vac-bg: #d2f1ee; --vac-fg: #0d625a; --vac-accent: #17a398; }
.vac-type-festivo-compensado { --vac-bg: #ffe2c2; --vac-fg: #8a4300; --vac-accent: #ef8a17; }
.vac-type-festivo-trabajado { --vac-bg: #eadfcf; --vac-fg: #5e4220; --vac-accent: #a67c3d; }
.vac-type-mudanza { --vac-bg: #e1e6ea; --vac-fg: #37454f; --vac-accent: #6b7f8d; }
.vac-type-otros { --vac-bg: #eef3c9; --vac-fg: #4f5a0b; --vac-accent: #a3b11c; }

html.theme-dark .vac-type-vacaciones { --vac-bg: #1e3527; --vac-fg: #a6e3b4; --vac-accent: #4caf6a; }
html.theme-dark .vac-type-enfermedad { --vac-bg: #3a2646; --vac-fg: #e3c3f5; --vac-accent: #b866dd; }
html.theme-dark .vac-type-medico { --vac-bg: #1f3550; --vac-fg: #b5d3fb; --vac-accent: #5b9bf5; }
html.theme-dark .vac-type-medico-familiar { --vac-bg: #2d2b57; --vac-fg: #cdc8fb; --vac-accent: #8576ee; }
html.theme-dark .vac-type-asuntos { --vac-bg: #1c3f3c; --vac-fg: #a6e8e0; --vac-accent: #2fbfb3; }
html.theme-dark .vac-type-festivo-compensado { --vac-bg: #4d3318; --vac-fg: #ffd09b; --vac-accent: #f39a33; }
html.theme-dark .vac-type-festivo-trabajado { --vac-bg: #3f3523; --vac-fg: #e6d0aa; --vac-accent: #b98f4d; }
html.theme-dark .vac-type-mudanza { --vac-bg: #2c353b; --vac-fg: #c4d0d8; --vac-accent: #8396a4; }
html.theme-dark .vac-type-otros { --vac-bg: #404618; --vac-fg: #e3ec9a; --vac-accent: #b9c63a; }

/* Celda del dia: sin fondo propio si es festivo (el amarillo del festivo manda, como con vacaciones). */
.vacation-day.has-vacation.vac-type:not(.is-selected):not(.is-holiday) {
  background: var(--vac-bg);
  color: var(--vac-fg);
}

.day-types {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: flex;
  gap: 2px;
  pointer-events: none;
}

.vac-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--vac-accent);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .85);
}

html.theme-dark .vac-dot {
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .6);
}

/* Leyenda del boton (i) */
.legend-subtitle {
  display: block;
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.legend-box.vac-type {
  background: var(--vac-bg);
  border-color: var(--vac-accent);
}

/* Lista de personas del dia: franja de color y texto del tipo */
.vacation-people-list li.vac-type {
  border-left: 4px solid var(--vac-accent);
}

.vacation-people-list li.vac-type > span {
  color: var(--vac-fg);
  font-weight: 700;
}

html.theme-dark .vacation-people-list li.vac-type {
  border-left-color: var(--vac-accent);
}

html.theme-dark .vacation-people-list li.vac-type > span {
  color: var(--vac-fg);
}

/* Usuario trabajador "Esta de baja" (script 019): insignia en la lista y texto de la ficha */
.sick-leave-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #fdecec;
  color: #b3261e;
  border: 1px solid #f3b8b4;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
html.theme-dark .sick-leave-badge {
  background: #3a2424;
  color: #ffb3ad;
  border-color: #6b3a37;
}
.sick-leave-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.sick-leave-field .sick-leave-since {
  font-weight: 800;
  color: #b3261e;
}
html.theme-dark .sick-leave-field .sick-leave-since {
  color: #ffb3ad;
}

/* Solicitud de recogida: celdas/filas/tabla con error (se marcan sin recargar ni borrar lo escrito) */
.preq-lines-table td.preq-cell-error input {
  border-color: #c0261c;
  background: #fdf1f0;
}
.preq-lines-table tr.preq-row-error > td:nth-child(2) {
  color: #c0261c;
  font-weight: 700;
}
.preq-lines-wrap.preq-lines-error {
  outline: 2px solid #c0261c;
  outline-offset: 2px;
  border-radius: 8px;
}
html.theme-dark .preq-lines-table td.preq-cell-error input {
  border-color: #e5484d;
  background: #3a2326;
}
html.theme-dark .preq-lines-table tr.preq-row-error > td:nth-child(2) {
  color: #ff8f86;
}
html.theme-dark .preq-lines-wrap.preq-lines-error {
  outline-color: #e5484d;
}

/* Lista de Ordenes: al volver desde una ficha se resalta la fila que se habia abierto (site.js, highlightReturnedRow).
   Se usa background-image (capa semitransparente) para no tapar los colores de fila existentes (expeditada, aviso...). */
tr.row-returned > td {
  background-image: linear-gradient(rgba(47, 123, 116, .22), rgba(47, 123, 116, .22)) !important;
  animation: row-returned-pulse 1.4s ease-out 1;
}

tr.row-returned > td:first-child {
  box-shadow: inset 4px 0 0 var(--focus);
}

html.theme-dark tr.row-returned > td {
  background-image: linear-gradient(rgba(120, 200, 190, .24), rgba(120, 200, 190, .24)) !important;
}

@keyframes row-returned-pulse {
  0% { filter: brightness(1.35); }
  100% { filter: brightness(1); }
}

@media (prefers-reduced-motion: reduce) {
  tr.row-returned > td { animation: none; }
}

/* Filtro "Reparaciones" de Ordenes: es un <select> normal dentro de un panel donde el resto de desplegables son .combo-filter, que reservan
   16px abajo para el aviso (ver .combo-filter). Con la misma reserva, su caja queda a la altura de Cliente / Parque / Estado. */
.filter-panel > label.filter-select-aligned {
  padding-bottom: 16px;
}

/* Recuadro "Prendas de bombero": boton "+" (alta rapida) a la derecha del titulo, y ventana flotante de alta rapida de prenda. */
.ff-garment-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.ff-quick-open {
  position: relative;
}
.ff-quick-open[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 30;
  padding: 4px 8px;
  border-radius: 6px;
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
}
.ff-quick-open[data-tooltip]:hover::after,
.ff-quick-open[data-tooltip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
}
.ff-quick-panel {
  width: min(520px, 94vw);
}
.ff-quick-form {
  display: grid;
  gap: 12px;
}
.ff-quick-summary {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}
.ff-quick-summary > div {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.ff-quick-summary dt {
  flex: 0 0 64px;
  color: var(--muted);
  font-size: 12px;
}
.ff-quick-summary dd {
  margin: 0;
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.ff-quick-grid {
  grid-template-columns: 1fr 1fr;
}
/* El rojo de los campos erroneos usa las reglas generales de .field.field-required-error (tema noche incluido). */
.ff-quick-grid .field .field-error-text {
  display: block;
  margin-top: 4px;
}
@media (max-width: 560px) {
  .ff-quick-grid {
    grid-template-columns: 1fr;
  }
}

/* Ventana "Falta la fecha de fabricacion / el fabricante" al imprimir una orden: reutiliza la rejilla de la alta rapida, en una columna. */
.mfgp-grid {
  grid-template-columns: 1fr;
}
.mfgp-grid .field .field-error-text {
  display: block;
  margin-top: 4px;
}

/* Revision de arnes pendiente: el boton (i) vive dentro de la pildora roja; el popover no hereda su color ni su negrita y se alinea a la derecha. */
.status-pill.warning-pill {
  gap: 8px;
}
.status-pill .info-popover-wrap {
  vertical-align: middle;
}
.status-pill .info-button {
  width: 22px;
  height: 22px;
  min-height: 22px;
  font-size: 12px;
}
.status-pill .info-popover {
  left: auto;
  right: 0;
  color: var(--ink, #1d2424);
  font-weight: 400;
  text-align: left;
  white-space: normal;
}
@media (max-width: 640px) {
  .status-pill .info-popover-wide {
    position: fixed;
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
}
/* Facturas: Reflejar por (De / a), resumen previo y avisos */
.invoice-criteria [hidden] { display: none !important; }
.invoice-preview { margin-top: 12px; }
.invoice-preview-totals { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-bottom: 8px; }
.invoice-preview-totals b { margin-left: 6px; font-variant-numeric: tabular-nums; }
.invoice-preview .alert { margin: 6px 0 0; }
.invoice-notes { margin: 0; padding-left: 18px; }
.invoice-lines th.num, .invoice-lines td.num { text-align: right; }
/* ===== Hoja de factura A4 (/invoice-print) ===== */
.invoice-sheet .invoice-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 10px; min-height: 8mm; }
.invoice-sheet .invoice-top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.invoice-sheet .invoice-heading h1 { margin: 0; font-size: 28px; }
.invoice-sheet .invoice-number { margin: 2px 0 12px; font-size: 18px; font-weight: 700; }
.invoice-sheet .invoice-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; font-size: 12px; }
.invoice-sheet .invoice-client { border: 1px solid #222; padding: 8px 10px; }
.invoice-sheet .invoice-client p, .invoice-sheet .invoice-meta-left p { margin: 2px 0; }
.invoice-sheet .invoice-client-name { font-weight: 700; }
/* Causa del desborde: la regla global "table { min-width: 760px }" (y "th, td { white-space: nowrap }") ganaba al
   max-width:100% de .print-sheet table; el area util de la hoja (A4 210mm - 2x12mm = ~703px) es menor de 760px, asi que la tabla
   y los totales se salian por la derecha. Aqui se anulan solo para la hoja de factura. */
.invoice-sheet { max-width: 100%; }
.invoice-sheet .invoice-top, .invoice-sheet .invoice-meta, .invoice-sheet .invoice-top > *, .invoice-sheet .invoice-meta > * { min-width: 0; max-width: 100%; }
.invoice-sheet .invoice-top-right { max-width: 60%; text-align: right; overflow-wrap: anywhere; }
.invoice-sheet .invoice-logo { min-width: 0; max-width: 40%; }
.invoice-sheet .invoice-client { max-width: 100%; overflow-wrap: anywhere; word-break: break-word; }
.invoice-sheet table { min-width: 0; width: 100%; max-width: 100%; table-layout: fixed; }
.invoice-sheet th, .invoice-sheet td { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.invoice-sheet th { position: static; }
.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.invoice-table th, .invoice-table td { border: 1px solid #222; padding: 6px 8px; font-size: 12px; vertical-align: top; }
.invoice-table th { background: #f3f3f3; text-align: left; }
.invoice-table th.num, .invoice-table .num { text-align: right; white-space: nowrap; }
.invoice-table thead { display: table-header-group; }
.invoice-table tr { page-break-inside: avoid; break-inside: avoid; }
.invoice-totals { margin-left: auto; width: 46%; max-width: 100%; min-width: 0; page-break-inside: avoid; break-inside: avoid; }
.invoice-totals table { width: 100%; min-width: 0; border-collapse: collapse; page-break-inside: avoid; break-inside: avoid; }
.invoice-totals tr { page-break-inside: avoid; break-inside: avoid; }
.invoice-totals th, .invoice-totals td { border: 1px solid #222; padding: 6px 8px; font-size: 12px; }
.invoice-totals th { text-align: left; background: #f3f3f3; }
.invoice-totals td { text-align: right; white-space: nowrap; }
.invoice-grand th, .invoice-grand td { font-size: 14px; font-weight: 800; }
.invoice-order-count { margin: 6px 0 0; font-size: 10px; color: #555; text-align: right; }
.invoice-sheet .invoice-payment, .invoice-sheet .invoice-remarks { page-break-inside: avoid; break-inside: avoid; }
@media print {
  /* El relleno de 12 mm se repite en cada hoja (sin tocar @page, que debe seguir en margin 0 para no imprimir cabecera/pie del navegador). */
  .print-sheet.invoice-sheet { -webkit-box-decoration-break: clone; box-decoration-break: clone; }
}
.pdf-export .print-sheet.invoice-sheet { padding: 0 12mm; }
/* Historial eliminados: las etiquetas Desde: / Hasta: del filtro de fechas llevan el mismo tamano y peso que las de los filtros de Ordenes
   (13px, negrita 700, color de tema noche del estilo global "label span"); .compact-filter las dejaba en 12px. */
.filter-panel[data-dh-filter] > label span {
  font-size: 13px;
  font-weight: 700;
}
/* Historial eliminados (escritorio): Buscar ancho + Desde + Hasta + botones en una fila. En tablet y movil rige la rejilla de una columna global. */
@media (min-width: 1025px) {
  .filter-panel[data-dh-filter] {
    grid-template-columns: minmax(220px, 1.4fr) repeat(2, minmax(150px, 1fr)) auto;
  }
}
/* Vinculacion obligatoria del arnes nuevo a un cubrepantalon (Revision arnes): la regla global de .field anula el atributo hidden. */
.field[data-harness-link-field][hidden],
.field[data-ffq-harness][hidden] {
  display: none;
}
/* Bloqueo de cuentas (script 038): boton Desbloquear junto a la insignia de la lista y aviso de la ficha de usuario. */
td .lock-badge + .button {
  margin-left: 6px;
  padding: 2px 8px;
}
.lock-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.lock-notice form {
  margin: 0;
}

/* Tipos de servicios -> % Actualizar precios (vista previa, aplicar e historial). */
.price-update-modal .modal-panel {
  width: min(900px, 96vw);
  overflow-y: auto;
  align-content: start;
}
.price-update-modal [hidden] {
  display: none !important;
}
.price-update-tabs {
  display: flex;
  gap: 8px;
}
.price-update-tabs .button.is-active {
  border-color: #57AB71;
  color: #2f7a4b;
  font-weight: 700;
}
.price-update-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 10px 14px;
  margin: 8px 0;
}
.price-update-message {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 6px 0;
}
.price-update-message.price-update-ok {
  background: #edf8f1;
  border-color: #b7dcc4;
}
.price-update-warning {
  padding: 8px 12px;
  border: 1px solid;
  border-radius: 6px;
}
.price-update-summary {
  margin: 8px 0;
}
.price-update-table {
  max-height: 320px;
  overflow: auto;
}
.price-update-table th.num,
.price-update-table td.num {
  text-align: right;
  white-space: nowrap;
}
.price-update-table td.price-up {
  color: #2f7a4b;
}
.price-update-table td.price-down {
  color: #b23a3a;
}
.price-update-modal .form-actions {
  justify-content: flex-end;
  margin-top: 8px;
}
@media (max-width: 640px) {
  .price-update-form {
    grid-template-columns: 1fr;
  }
}
/* Tipos de servicio > pestana Configuracion (script 042): tabla editable con interruptores 34x20 y maximo de cantidad por tipo. */
.users-tab-panel > .service-type-settings-form {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.service-type-settings-form .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.service-type-settings-table th,
.service-type-settings-table td {
  text-align: center;
  vertical-align: middle;
}

.service-type-settings-table th:first-child,
.service-type-settings-table td:first-child,
.service-type-settings-table th:nth-child(2),
.service-type-settings-table td:nth-child(2) {
  text-align: left;
}

.service-type-settings-table input.service-type-max {
  width: 96px;
  min-height: 34px;
  text-align: center;
}

.service-type-settings-note {
  margin: 0 0 8px;
}

.service-type-rules .info-anchor {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Control de recogidas: botones y ventana flotante DUA (script 043) ===== */
.dua-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dua-actions .dua-buttons { display: inline-flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.dua-modal[hidden], .dua-modal [hidden] { display: none !important; }
.dua-modal .modal-panel { width: min(460px, 94vw); }
.dua-modal textarea[data-dua-obs] { width: 100%; min-height: 64px; resize: vertical; }
/* Lapiz de editar (al lado de cada boton DUA): boton pequeno con el lapiz dibujado con CSS (mismo patron que .plus-icon / .x-icon). */
.dua-actions .dua-edit-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; padding-left: 8px; padding-right: 8px; }
.dua-actions .dua-edit-btn:disabled { opacity: .55; cursor: not-allowed; }
.dua-pencil-icon { position: relative; display: block; flex: none; box-sizing: border-box; width: 14px; height: 14px; font-size: 0; line-height: 0; pointer-events: none; }
.dua-pencil-icon::before { content: ""; position: absolute; left: 50%; top: 50%; width: 5px; height: 16px; background: currentColor; clip-path: polygon(0 0, 100% 0, 100% 78%, 50% 100%, 0 78%); transform: translate(-50%, -50%) rotate(45deg); }
.dua-modal .dua-summary { margin: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-weight: 700; }
.dua-modal .dua-error { margin: 0; color: #b42318; font-weight: 700; }
.dua-modal input.dua-qty-invalid { border-color: #b42318; }

/* ===== Hoja DUA A4 (/dua-print): recogida DUA y devolucion DUA ===== */
/* Mismo remedio que la hoja de factura: la regla global "table { min-width: 760px }" y "th, td { white-space: nowrap }" desbordaban la hoja por la derecha. */
.dua-sheet { max-width: 100%; font-family: Arial, Helvetica, sans-serif; font-size: 10px; font-weight: 700; color: #000; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.dua-sheet .dua-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 6mm; min-height: 8mm; }
.dua-sheet .dua-top > *, .dua-sheet .dua-addresses > * { min-width: 0; max-width: 100%; }
.dua-sheet .dua-logo { max-width: 50%; }
.dua-sheet .dua-title { font-size: 16px; font-weight: 800; text-align: right; overflow-wrap: anywhere; }
.dua-sheet .dua-addresses { display: grid; grid-template-columns: 1fr 1fr; gap: 8mm; margin-bottom: 5mm; }
.dua-sheet .dua-box { border: 1px solid #000; padding: 2.5mm 3mm; min-height: 26mm; overflow-wrap: anywhere; word-break: break-word; }
.dua-sheet .dua-box-client { margin-top: 8mm; }
.dua-sheet .dua-line { display: block; }
.dua-sheet .dua-line-name { font-size: 11px; }
.dua-sheet table { min-width: 0; width: 100%; max-width: 100%; table-layout: fixed; border-collapse: collapse; margin: 0 0 4mm; page-break-inside: avoid; break-inside: avoid; }
.dua-sheet th, .dua-sheet td { white-space: normal; overflow-wrap: anywhere; word-break: break-word; border: 1px solid #000; padding: 1.5mm 2mm; font-size: 10px; font-weight: 700; color: #000; text-align: left; vertical-align: top; text-transform: none; }
.dua-sheet th { position: static; background: #fff; text-align: center; }
.dua-sheet tbody tr:hover { background: transparent; }
.dua-sheet .dua-meta td { text-align: center; }
.dua-sheet .dua-lines tbody td { border-top: 0; border-bottom: 0; }
.dua-sheet .dua-lines tbody tr:last-child td { border-bottom: 1px solid #000; }
.dua-sheet .dua-num { text-align: center; }
.dua-sheet .dua-total-col { background: #e8e8e8; text-align: center; }
.dua-sheet .dua-detail { text-align: center; }
.dua-sheet .dua-addr-title { display: block; margin: 3mm 0 1mm; font-size: 13px; font-weight: 800; }
.dua-sheet .dua-addr-title:first-child { margin-top: 0; }
.dua-sheet .dua-sign { min-height: 34mm; padding: 1.5mm 2mm; text-align: center; }
.dua-sheet .dua-sign-label { display: block; font-size: 13px; font-weight: 800; }
.dua-sheet .dua-sign img { max-height: 26mm; max-width: 100%; width: auto; height: auto; }
.dua-sheet .dua-section-title { margin: 0 0 1mm; font-size: 11px; font-weight: 800; }
.dua-sheet .dua-payment tbody td { height: 8mm; }
.dua-sheet .dua-observations { border: 1px solid #000; min-height: 22mm; padding: 2mm 3mm; margin-bottom: 4mm; overflow-wrap: anywhere; word-break: break-word; }
.dua-sheet .dua-observations-title { font-weight: 800; }

/* ===== Control de recogidas -> Estado: una fila (Estado | albaran vinculado | botones DUA) ===== */
.pickup-state-row { grid-column: 1 / -1; display: flex; flex-wrap: nowrap; align-items: flex-end; gap: 8px; min-width: 0; }
/* El campo Estado mide la mitad de una columna de la rejilla de 4 columnas (12px de hueco), con minimo legible. */
.pickup-state-row > .field { flex: 0 0 max(140px, calc((100% - 36px) / 8)); width: auto; min-width: 140px; max-width: none; }
.pickup-state-row > .button { flex: none; white-space: nowrap; }
.pickup-state-row > .dua-actions { grid-column: auto; flex: 0 1 auto; min-width: 0; }
@media (max-width: 640px) {
  .pickup-state-row { flex-wrap: wrap; }
  .pickup-state-row > .field { flex: 1 1 140px; }
}

/* ===== Control de recogidas -> ficha: recuadros de texto un 20% mas estrechos (Observaciones y el apartado Estado no cambian) ===== */
.pickupcontrol-form .form-grid > .field:not(.wide) > input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="button"]):not([type="submit"]),
.pickupcontrol-form .form-grid > .field:not(.wide) > select,
.pickupcontrol-form .form-grid > .field:not(.wide) > .record-combo {
  max-width: 80%;
}
/* El menu del desplegable de cliente/parque conserva espacio para nombres largos. */
.pickupcontrol-form .form-grid > .field:not(.wide) > .record-combo .record-combo-menu {
  min-width: 125%;
}

/* Direccion de cliente / parque: textarea con la altura de un campo de texto (1 linea), ampliable solo hacia abajo
   arrastrando la esquina inferior derecha. Admite saltos de linea (se imprimen en varias lineas). */
textarea.address-textarea {
  display: block;
  height: 38px;
  min-height: 38px;
  line-height: normal;
  resize: vertical;
  overflow-y: auto;
}
