/* Solicitud de horas extra — se apoya en los tokens y componentes de app.css.
   Todo lo de acá aplica solo a horas-extra.php (no toca el tablero). */
.he-titulo { font-size: 15px; font-weight: 650; color: var(--ink); padding-left: 12px; border-left: 1px solid var(--border-strong); }

.he { padding: 16px 24px 64px; display: grid; gap: 16px; max-width: 1400px; margin: 0 auto; }
.he > * { min-width: 0; }
.he .card { padding: 20px; }
.he .card-head { margin-bottom: 16px; align-items: flex-start; }
.he .card-head h2 { font-size: 16px; }

/* Botones: el disabled de app.css hace girar el ícono (pensado para "actualizando");
   acá solo gira mientras se envía (aria-busy lo pone horas-extra.js). */
.he .btn:disabled { cursor: not-allowed; }
.he .btn:disabled .ico { animation: none; }
.he .btn[aria-busy="true"] { cursor: progress; }
.he .btn[aria-busy="true"] .ico { animation: girar 1s linear infinite; }

/* ---------- pasos ---------- */
.pasos { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.pasos a {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  color: var(--ink-2); text-decoration: none; background: var(--glass); border: 1px solid var(--border);
  transition: border-color .12s, color .12s;
}
.pasos a:hover { color: var(--ink); border-color: var(--accent); }

/* ---------- formularios (pasos 1 y 3) ----------
   Etiqueta arriba, campo, y la ayuda siempre debajo del campo: así los campos de una
   misma fila quedan alineados aunque alguno tenga ayuda y otro no. */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; align-items: start; }
.form-grid label {
  display: flex; flex-direction: column; gap: 5px; min-width: 0;
  font-size: 12px; font-weight: 600; line-height: 1.35; color: var(--ink-2);
}
.form-grid label small, .form-grid .ayuda { font-size: 11.5px; font-weight: 400; color: var(--muted); }
.form-grid .ayuda { margin-top: -1px; }
.form-grid .campo { max-width: none; width: 100%; min-height: 38px; }
.form-grid textarea.campo { resize: vertical; font: inherit; font-size: 13px; line-height: 1.5; padding: 8px 10px; }
.col-2 { grid-column: span 2; }
.col-full { grid-column: 1 / -1; }
.campo[aria-invalid="true"] { border-color: var(--critical); }

/* ---------- filtros (paso 2) ---------- */
.he-filtros { margin-bottom: 12px; gap: 10px 14px; }
.he-filtros .campo { min-width: 0; min-height: 36px; }
.he-filtros #f-q { min-width: 200px; }
.he .toolbar label.sec { line-height: 1.2; }
.chk { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 36px; }
.chk input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.plaza-pill {
  display: inline-flex; align-items: center; gap: 6px; min-height: 30px; padding: 0 12px; border-radius: 999px;
  background: var(--accent-wash-2); color: var(--accent-ink); font-size: 12.5px; font-weight: 650; white-space: nowrap;
}
.plaza-pill:empty { display: none; }
#leyenda { gap: 6px 22px; }
.leyenda-grupo { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.leyenda-grupo strong { font-weight: 650; color: var(--ink); }

.tabla-meta { justify-content: flex-end; margin-bottom: 8px; font-size: 12.5px; }
.orden-movil { display: none !important; }

/* ---------- tabla de facers ---------- */
.tabla-facers td { vertical-align: middle; }
.tabla-facers td.sel, .tabla-facers th.sel { width: 40px; padding-right: 0; }
.tabla-facers input[type="checkbox"] { display: block; width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.tabla-facers tr.elegido { background: var(--accent-wash-2) !important; }
.tabla-facers .horas-in { width: 76px; min-width: 0; text-align: right; padding: 4px 8px; }
.tabla-facers .horas-in:disabled { opacity: .35; }
.tabla-facers .sub { display: block; font-size: 11.5px; color: var(--muted); }
.badge-otra {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 650;
  background: rgba(250, 178, 25, 0.18); color: var(--ink); border: 1px solid rgba(250, 178, 25, 0.55); vertical-align: 1px;
}

/* ---------- otra plaza ---------- */
.otra-plaza { margin-top: 14px; }
.panel-otra-plaza {
  margin-top: 10px; padding: 14px; border-radius: var(--r-md); border: 1px dashed var(--border-strong);
  background: var(--surface-2); display: grid; gap: 10px;
}
.panel-otra-plaza[hidden] { display: none; }
.panel-otra-plaza .nota { margin: 0; }
.panel-otra-plaza .tabla-wrap { max-height: 360px; }

/* ---------- resumen (paso 3) ---------- */
.he-tile { display: flex; flex-direction: column; }
.he-tile .lbl { line-height: 1.3; }
.he-tile .val { margin-top: auto; padding-top: 6px; white-space: nowrap; }
.he-tile .tile-sub { min-height: 1.4em; margin-top: 2px; font-size: 12px; line-height: 1.4; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- mail (paso 3) ---------- */
.mail-campos { margin: 18px 0 14px; }
.preview-lbl { margin: 16px 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.mail-preview {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 20px; overflow-x: auto; color: var(--ink); max-width: 100%;
}
.mail-preview:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* El mail se arma con estilos en línea pensados para fondo blanco (así se pega en el correo);
   en tema oscuro la vista previa se muestra igual, sobre blanco. */
:root[data-theme="dark"] .mail-preview { background: #ffffff; color: #1a1a1a; }
/* La vista previa tiene que verse como el mail pegado: sin los estilos de tabla del tablero. */
.mail-preview table { width: auto; font-size: inherit; }
.mail-preview th, .mail-preview td { position: static; white-space: normal; cursor: default; }
.mail-preview tbody tr, .mail-preview tbody tr:hover, .mail-preview tbody tr:nth-child(even) { background: none; }
.mail-preview td, .mail-preview th { border-bottom: 0; }
.mail-preview tfoot td { position: static; background: none; border-top: 0; }
.mail-acciones { margin-top: 14px; }
.aviso[hidden] { display: none; }
#faltantes { margin-top: 4px; }

#copiado { font-size: 13px; }
#copiado:empty { display: none; }
#copiado.aviso-ok { color: var(--good-text); font-weight: 600; }
#copiado.aviso-error { color: var(--critical-text); font-weight: 600; }

/* ---------- celular ---------- */
@media (max-width: 640px) {
  .he { padding: 12px 16px 48px; gap: 12px; }
  .he .card { padding: 16px 14px; }
  .he .card-head { margin-bottom: 14px; }
  .he-titulo { padding-left: 0; border-left: 0; font-size: 14px; }
  .top .marca-titulo { flex-wrap: wrap; gap: 6px 10px; }
  .top .acciones { width: 100%; }
  .top .acciones .btn-icono { margin-left: auto; }
  .top .btn { min-height: 40px; }
  .top .btn-icono { width: 40px; }

  /* app.css esconde el texto de los botones en el celular; acá lo necesitamos. */
  .he .btn span { display: inline; }
  .he .btn { min-height: 44px; }

  .pasos { flex-wrap: nowrap; }
  .pasos li { flex: 1 1 0; min-width: 0; }
  .pasos a { justify-content: center; width: 100%; min-height: 40px; padding: 0 8px; white-space: nowrap; }

  .col-2 { grid-column: 1 / -1; }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  /* 16px en los campos: iOS no hace zoom al enfocarlos. */
  .he .campo, .form-grid textarea.campo { font-size: 16px; min-height: 44px; }
  #btn-nueva { width: 100%; border: 1px solid var(--border-strong); background: var(--surface); }

  /* Filtros apilados: período y búsqueda a lo ancho, ciudad y OSC lado a lado. */
  .he-filtros { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
  .he-filtros > label.sec:not(.chk) { display: flex; flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; font-weight: 600; min-width: 0; }
  .he-filtros .campo { width: 100%; max-width: none; }
  .he-filtros > label:first-child, .he-filtros #f-q { grid-column: 1 / -1; }
  .he-filtros #f-q { min-width: 0; }
  .he-filtros .plaza-pill { grid-column: 1 / -1; justify-self: start; grid-row: 1; }
  .he-filtros .chk { grid-column: 1 / -1; min-height: 40px; }
  .he-filtros .chk input { width: 20px; height: 20px; }
  .leyenda-estado { font-size: 11.5px; }

  .tabla-meta { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .orden-movil { display: flex !important; min-width: 0; align-items: center; gap: 10px; font-size: 12px !important; font-weight: 600; white-space: nowrap; }
  .orden-movil .campo { flex: 1 1 auto; min-width: 0; max-width: none; }
  .tabla-meta > .muted { font-size: 12px; }

  /* Lista de facers como tarjetas: sin scroll horizontal. */
  #tabla-facers .tabla-wrap, #tabla-otra-plaza .tabla-wrap {
    overflow: visible; max-height: none; background: none; border: 0; border-radius: 0;
  }
  .tabla-movil, .tabla-movil tbody { display: block; width: 100%; }
  .tabla-movil thead {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .tabla-movil tbody { display: grid; gap: 8px; }
  .tabla-movil tbody tr, .tabla-movil tbody tr:nth-child(even), .tabla-movil tbody tr:hover {
    display: grid; column-gap: 8px; row-gap: 6px; align-items: center;
    padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
    box-shadow: var(--shadow);
  }
  .tabla-movil tbody tr.elegido { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
  .tabla-movil td {
    display: block; padding: 0; border: 0; white-space: normal; text-align: left; min-width: 0;
  }
  .tabla-movil td.vacio { grid-column: 1 / -1; padding: 16px 0; text-align: center; }
  .tabla-movil .c-nombre { font-weight: 650; line-height: 1.3; overflow-wrap: anywhere; }
  .tabla-movil .c-nombre .sub { font-weight: 400; margin-top: 2px; }
  .tabla-movil .c-ciudad, .tabla-movil .c-osc { font-size: 12px; color: var(--ink-2); line-height: 1.35; overflow-wrap: anywhere; }
  .tabla-movil .c-ciudad .sub { display: none; }
  .tabla-movil .c-ciudad::before, .tabla-movil .c-osc::before { content: attr(data-label) ": "; color: var(--muted); }
  .tabla-movil .c-osc::before { content: "OSC: "; }
  /* Métricas: cuatro casillas iguales con su etiqueta arriba. */
  .tabla-movil .c-don, .tabla-movil .c-prodJ, .tabla-movil .c-montoProm, .tabla-movil .c-pctTC {
    display: flex; flex-direction: column; gap: 1px; padding: 6px 7px; border-radius: var(--r-sm);
    background: var(--surface-2); font-size: 13px; font-weight: 600; text-align: left; white-space: nowrap;
  }
  .tabla-movil tr.elegido .c-don, .tabla-movil tr.elegido .c-prodJ,
  .tabla-movil tr.elegido .c-montoProm, .tabla-movil tr.elegido .c-pctTC { background: color-mix(in srgb, var(--surface) 70%, transparent); }
  .tabla-movil .c-don::before, .tabla-movil .c-prodJ::before, .tabla-movil .c-montoProm::before, .tabla-movil .c-pctTC::before {
    content: attr(data-label); font-size: 10.5px; font-weight: 600; color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  }
  .tabla-movil .estado { gap: 5px; }
  .tabla-movil .c-montoProm::before { content: "Monto"; }

  /* Tarjeta de la lista principal */
  /* El checkbox va fijo arriba a la izquierda (fuera de la grilla) para que las cuatro
     métricas tengan todo el ancho de la tarjeta. */
  table.tabla-facers tbody tr {
    position: relative;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "nom nom nom hor"
      "ciu ciu osc osc"
      "don pc  mon tc";
  }
  table.tabla-facers td.sel {
    position: absolute; top: 12px; left: 6px; width: 44px; height: 44px; padding: 0;
    display: grid; place-items: center;
  }
  table.tabla-facers td.sel input { width: 22px; height: 22px; }
  table.tabla-facers .c-nombre { grid-area: nom; padding-left: 40px; min-height: 44px; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; }
  table.tabla-facers .c-nombre .sub { margin-top: 1px; }
  table.tabla-facers .c-nombre .badge-otra { margin: 3px 0 1px; }
  table.tabla-facers .c-ciudad { grid-area: ciu; }
  table.tabla-facers .c-osc { grid-area: osc; }
  table.tabla-facers .c-don { grid-area: don; }
  table.tabla-facers .c-prodJ { grid-area: pc; }
  table.tabla-facers .c-montoProm { grid-area: mon; }
  table.tabla-facers .c-pctTC { grid-area: tc; }
  table.tabla-facers .c-horas { grid-area: hor; display: flex; flex-direction: column; align-items: stretch; gap: 2px; }
  table.tabla-facers .c-horas::before { content: attr(data-label); font-size: 10.5px; font-weight: 600; color: var(--muted); text-align: center; }
  table.tabla-facers .horas-in { width: 100%; min-height: 40px; text-align: center; padding: 4px; }

  /* Tarjeta del panel "otra plaza" */
  .panel-otra-plaza { padding: 12px; }
  .panel-otra-plaza .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .panel-otra-plaza .toolbar label.sec { display: flex; flex-direction: column; align-items: stretch; gap: 4px; font-size: 12px; font-weight: 600; }
  .panel-otra-plaza .toolbar .campo { width: 100%; max-width: none; }
  #tabla-otra-plaza .tabla-wrap { max-height: 70vh; overflow-y: auto; }
  .tabla-otra tbody tr {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
      "nom nom agr agr"
      "ciu ciu ciu ciu"
      "don pc  mon tc";
  }
  .tabla-otra .c-nombre { grid-area: nom; }
  .tabla-otra .c-ciudad { grid-area: ciu; }
  .tabla-otra .c-don { grid-area: don; }
  .tabla-otra .c-prodJ { grid-area: pc; }
  .tabla-otra .c-montoProm { grid-area: mon; }
  .tabla-otra .c-pctTC { grid-area: tc; }
  .tabla-otra .c-agregar { grid-area: agr; justify-self: end; }
  .tabla-otra .c-agregar .btn { min-height: 40px; }

  /* Resumen: dos por fila, mismo alto. */
  .he .tiles { gap: 8px; }
  .he-tile { padding: 11px 12px 10px; }
  .he-tile .lbl { font-size: 11.5px; }
  .he-tile .tile-sub { font-size: 11.5px; }

  /* Vista previa: el mail mantiene su tabla; si no entra, se desliza dentro de su caja. */
  .mail-preview { padding: 14px; -webkit-overflow-scrolling: touch; }
  .mail-preview table:has(thead) th, .mail-preview table:has(thead) td { white-space: nowrap; }

  .mail-acciones { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .mail-acciones .btn { width: 100%; min-height: 48px; font-size: 15px; }
  #copiado { padding-top: 2px; }
}

@media (max-width: 380px) {
  .tabla-movil .c-don, .tabla-movil .c-prodJ, .tabla-movil .c-montoProm, .tabla-movil .c-pctTC { padding: 5px 5px; font-size: 12px; }
  .tabla-movil .estado { gap: 4px; }
  .tabla-movil .estado::before { width: 7px; height: 7px; }
  table.tabla-facers tbody tr { column-gap: 6px; padding: 10px; }
  table.tabla-facers td.sel { top: 10px; left: 4px; }
}
