/* ==========================================================================
   Tablón · pantalla de Tareas, detalle e histórico (P4).
   Copia de la maqueta aprobada (Tablón · propuesta visual.html) con datos reales y las diferencias
   de la especificación 5.4: estado visible en los dos tejados, relleno = tejado de quien usa la app,
   mismo resumen en los dos tejados. Se carga detrás de estilos.css.
   Lo único rojo de la app es el triángulo del Aviso (.badge-bloqueado svg). El verde, solo «Entregada».
   ========================================================================== */

/* Iconos de 16 px de la maqueta (los crea icono() con la clase .ic) */
.ic { width: 16px; height: 16px; flex: none; }

/* ---------- Tablero (contenido de la pestaña Tareas) ---------- */

.tablero {
  padding: calc(20px + var(--seguro-arriba)) var(--margen) 28px;
  font-size: 15px; line-height: 1.5;
}

/* Cabecera: «Tablón», fecha y «Pedir a …» */
.tablero .cabecera { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.tablero .cabecera > div { min-width: 0; }
.tablero .titulo { font-size: 28px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.tablero .fecha { margin-top: 4px; font-size: 13px; font-weight: 400; color: var(--text-faint); }
.btn-pedir { min-height: 44px; padding: 0 18px; font-size: 15px; letter-spacing: -0.01em; white-space: nowrap; flex: none; }
.btn-pedir .ic { width: 16px; height: 16px; }
@media (hover: hover) { .btn-pedir:hover:not(:disabled) { transform: translateY(-2px); } }

/* Tejados: dos bloques que miden lo mismo; en móvil son un interruptor */
.tejados { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-bottom: 18px; }
.tejado {
  min-width: 0; min-height: 44px; display: flex; flex-direction: column; gap: 6px; padding: 16px 16px 15px;
  border: 1px solid var(--border); border-radius: 22px; background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  color: var(--text); font: inherit; text-align: left; overflow-wrap: break-word; cursor: pointer;
  transition: transform .3s var(--ease), opacity .3s var(--ease);
}
.tejado:active { transform: scale(0.98); }
.tejado-nombre { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; }
.tejado-cifra { display: flex; align-items: baseline; gap: 6px; }
.tejado-num {
  font-size: 44px; font-weight: 900; letter-spacing: -0.05em; line-height: 1; font-variant-numeric: tabular-nums;
  background: var(--gradient-text); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  padding-right: 0.08em; margin-right: -0.08em;
}
.tejado-ud, .tejado-res { font-size: 13px; font-weight: 400; color: var(--text-dim); }
.tejado-res { line-height: 1.35; }
/* En móvil cada parte del resumen va en su línea, sin «·» */
.res-p { display: block; }
.res-sep { display: none; }
/* Relleno en degradado, tinta negra: en móvil el tejado a la vista; en dos columnas el de quien usa la app */
.tejado.lleno { background: var(--gradient); border-color: transparent; box-shadow: var(--glow-sm); color: #000; }
.tejado.lleno .tejado-num { background: none; -webkit-text-fill-color: #000; color: #000; }
.tejado.lleno .tejado-ud, .tejado.lleno .tejado-res { color: rgba(0,0,0,0.74); }
.tejado:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Ordenar por · Proyecto (fila con rótulo; las pastillas saltan de línea) */
.tablero .orden { margin-bottom: 10px; }
.tablero .orden-rot { font-size: 13px; }
.tablero .filtro { margin-bottom: 18px; }
.tablero .filtro .orden-btns { flex: 1; }
.tablero .pill { font-size: 14px; }
.tablero .pill .n { font-variant-numeric: tabular-nums; }

/* Error y Reintentar, sin el margen lateral de las listas (el tablero ya lo lleva) */
.tablero-estado .lista-estado:not(.con-error) { padding: 0; }
/* Con error, la caja y «Reintentar» se quedan a la vista al hacer scroll (los datos cargados siguen debajo) */
.tablero-estado:has(.con-error) {
  position: sticky; top: 8px; z-index: 3; display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  margin: 0 -6px 14px; padding: 6px; border-radius: 26px; background: var(--bg); box-shadow: 0 6px 14px 4px var(--bg);
}
.tablero-estado .lista-estado.con-error { flex: 1 1 12rem; margin: 0; }
.tablero-estado .reintentar { flex: none; margin: 0; }

/* Columnas: en móvil solo la del tejado a la vista */
.tablero .col:not(.visible) { display: none; }
.tablero .lista { display: flex; flex-direction: column; gap: 10px; }
.col-vacio, .col-cargando { padding: 8px 2px; font-size: 13px; color: var(--text-faint); }
.tablero .rotulo { margin: 0 2px 8px; font-size: 13px; font-weight: 400; color: var(--text-faint); }

/* Rótulo de proyecto: amarillo de marca en una sola línea. La línea («Dubana») siempre entera en 800; «· Proyecto» (600) va
   entero detrás si cabe y, si no, salta a una segunda línea que queda oculta (alto de una línea y overflow hidden): nunca se
   corta una palabra a medias. En la tarjeta desplegada se ve el rótulo completo, en dos líneas si hace falta. */
.tablero .proyecto, .hist .proyecto { font-size: 16px; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); line-height: 1.3; }
.proyecto:has(> .pr-linea) {
  display: flex; flex-wrap: wrap; column-gap: 0.28em; min-width: 0; max-height: 1.2em; max-height: 1lh; overflow: hidden;
  white-space: nowrap; overflow-wrap: normal;
}
.pr-linea, .pr-proyecto { flex: none; }
.pr-proyecto { font-weight: 600; }
.tablero .tarea details[open] .proyecto:has(> .pr-linea) { max-height: none; white-space: normal; }
.tablero .tarea details[open] .pr-proyecto { flex: 0 1 auto; min-width: 0; }
/* Con el rótulo en dos líneas, las pastillas siguen arriba a la derecha, alineadas con la primera línea */
.tablero .tarea details[open] .t-l1 { align-items: baseline; }
.hist-l1 > .estado-pill { flex: none; }

/* ---------- Entregas ---------- */

.entregas { margin-bottom: 16px; }
.entregas-card { overflow: hidden; background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%); border: 1px solid var(--border); border-radius: 22px; }
.entrega { padding: 14px 16px; border-top: 1px solid var(--border); }
.entrega:first-child { border-top: 0; }
.entrega-l1 { display: flex; align-items: center; gap: 10px; min-height: 22px; }
.entrega .proyecto { min-width: 0; font-size: 14px; overflow-wrap: anywhere; }
.entrega-cuando { font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.entrega-l2 { margin-top: 2px; }
.entrega-titulo { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; overflow-wrap: anywhere; }
.entrega-nota { margin-top: 2px; font-size: 13px; color: var(--text-dim); line-height: 1.4; overflow-wrap: anywhere; }
/* Acciones de entrega: pequeñas (32 px, zona táctil de 44 px), abajo a la izquierda */
.entrega-acc { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.entrega-acc .pill-pequena .ic { width: 13px; height: 13px; }
.entrega-pend { margin-top: 4px; font-size: 13px; color: var(--text-dim); }
.btn-check {
  position: relative; display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 50%; background: transparent; color: var(--text); cursor: pointer;
  transition: transform .25s var(--ease);
}
.btn-check::after { content: ''; position: absolute; inset: -6px; }
.btn-check:active:not(:disabled) { transform: scale(0.94); }
.btn-check:disabled { opacity: 0.45; }
.btn-check .ic { width: 15px; height: 15px; }

/* Marcas: estado, Aviso, Entregada */
.t-marcas { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; margin-left: auto; flex: none; max-width: 100%; }
.estado-pill.en-curso, .estado-pill.devuelta { color: var(--text); }
.estado-pill.sin-empezar { color: var(--text-dim); }
.badge .ic { width: 12px; height: 12px; }
/* Aviso: pastilla neutra; solo el triángulo va en rojo (lo único rojo de la app) */
.badge-bloqueado { color: var(--text); border-color: var(--border-strong); background: none; }
.badge-bloqueado svg { color: var(--red); }

/* ---------- Tarea: tarjeta plegable (<details>) ---------- */

.tablero .tarea {
  position: relative; overflow: hidden; border: 1px solid var(--border); border-radius: 22px;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%);
  transition: transform .5s var(--ease);
}
.tablero .tarea::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(340px circle at 50% -20%, rgba(245,197,24,0.10), transparent 62%); transition: opacity .4s var(--ease);
}
@media (hover: hover) {
  .tablero .tarea:hover { transform: translateY(-2px); }
  .tablero .tarea:hover::after { opacity: 1; }
}
.tablero .tarea summary { position: relative; display: block; padding: 12px 16px; border-radius: 22px; list-style: none; cursor: pointer; }
.tablero .tarea summary::-webkit-details-marker { display: none; }
.tablero .tarea summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.t-l1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; }
.t-l1 .proyecto { min-width: 0; line-height: 1.2; overflow-wrap: anywhere; }
.t-l2 { margin-top: 3px; }
.tablero .tarea-titulo { font-size: 17px; font-weight: 800; letter-spacing: -0.02em; line-height: 1.25; overflow-wrap: anywhere; }
/* Escalas apiladas; en móvil el plazo va en línea propia debajo. Abajo a la derecha, el chevron. */
.t-l3 { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 8px; padding-right: 28px; }
.t-l3 .chevron { position: absolute; right: 16px; bottom: 13px; width: 18px; height: 18px; color: var(--text-dim); transition: transform .35s var(--ease); }
.tarea details[open] .chevron { transform: rotate(180deg); }
.t-escalas { display: grid; grid-template-columns: auto 46px; justify-content: start; align-items: center; column-gap: 10px; row-gap: 5px; }
.escala { display: contents; }
.escala-rot { font-size: 13px; font-weight: 400; line-height: 18px; color: var(--text); letter-spacing: -0.005em; white-space: nowrap; }
.plazo { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); white-space: nowrap; }
.plazo .ic { width: 16px; height: 16px; }
.plazo.hoy { color: var(--text); font-weight: 700; }
.plazo.fuera { padding: 2px 9px; border-radius: 999px; background: var(--accent); color: #000; font-size: 12px; font-weight: 700; line-height: 1.4; }

/* Cuerpo desplegado */
.tarea-cuerpo { padding: 0 16px 6px; }
.tarea-cuerpo > :first-child { margin-top: 0; padding-top: 10px; border-top: 1px solid var(--border); }
.tarea-nota { font-size: 15px; color: var(--text-dim); line-height: 1.5; }
.aviso-frase { margin-top: 8px; font-size: 14px; color: var(--text); line-height: 1.4; }
.devuelta-frase { margin-top: 8px; font-size: 14px; color: var(--text-dim); line-height: 1.4; }
.tarea-pie { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 12px; margin-top: 12px; }
.tarea-pie .pill { margin-left: auto; }
.quien { font-size: 13px; color: var(--text-dim); line-height: 1.4; }
.tarea-detalle {
  display: inline-flex; align-items: center; gap: 2px; min-height: 44px; color: var(--text-dim);
  font-size: 13px; font-weight: 600; text-decoration: none; border-radius: 8px;
}
.tarea-detalle .ico { width: 14px; height: 14px; }
@media (hover: hover) { .tarea-detalle:hover { color: var(--text); } }
/* Poner o quitar aviso: pastilla neutra con el triángulo en neutro */
.btn-aviso[aria-pressed] { background: none; border-color: var(--border-strong); }
.btn-aviso .ic { width: 15px; height: 15px; }

/* ---------- Dos tejados en dos columnas: el contenido mide 760 px o más ---------- */

@container vistas (min-width: 760px) {
  .tablero { padding: calc(32px + var(--seguro-arriba)) 24px 40px; }
  .tablero .cabecera { margin-bottom: 28px; }
  .tablero .titulo { font-size: 34px; }
  .tejados { gap: 20px; margin-bottom: 20px; }
  .tejado { padding: 22px 24px 20px; cursor: default; }
  .tejado:active { transform: none; }
  .tejado-nombre { font-size: 19px; }
  .tejado-num { font-size: 56px; }
  .tejado-res { font-size: 14px; }
  .res-p, .res-sep { display: inline; }
  .tablero .filtro { margin-bottom: 22px; }
  .tablero .columnas { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
  .tablero .col:not(.visible) { display: block; }
  .t-l3 { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 6px 14px; }
  .tablero .tarea summary { padding: 11px 20px; }
  .t-l3 .chevron { right: 20px; bottom: 12px; }
  .tarea-cuerpo { padding: 0 20px 8px; }
  .entrega { padding: 14px 20px; }
  .tablero .proyecto { font-size: 17px; }
  .entrega .proyecto { font-size: 15px; }
}
/* Con la barra lateral (≥ 1100 px) el contenido lleva el margen de la maqueta (.main: 44 48 64) */
@media (min-width: 1100px) {
  .tablero { padding: calc(44px + var(--seguro-arriba)) 48px 64px; }
}

/* ---------- Hojas «Pedir a …» y «Editar tarea» ---------- */

.form-pedir .opciones { gap: 8px; }
.form-pedir .opciones .pill { gap: 8px; }
.form-pedir .opciones .evidence-bar { width: 30px; gap: 3px; }
.form-pedir .opciones .evidence-seg { height: 6px; }
.pill-destino { align-self: flex-start; max-width: 100%; gap: 6px; }
.pill-destino span { overflow: hidden; text-overflow: ellipsis; }
.pill-destino .ico { width: 1rem; height: 1rem; }
.campo-fecha { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.campo-fecha input[type="date"] { flex: 1 1 12rem; width: auto; min-width: 0; }
/* Aviso al pedir: interruptor con el triángulo en neutro */
.interruptor {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 10px 14px;
  border: 1px solid var(--border-strong); border-radius: 18px; background: transparent; color: var(--text);
  font: inherit; font-size: 0.9375rem; font-weight: 600; text-align: left; cursor: pointer;
}
.interruptor .ic { color: var(--text-dim); }
.interruptor-texto { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.interruptor-pista { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: var(--bg-elevated); border: 1px solid var(--border-strong); transition: background .2s var(--ease); }
.interruptor-pista span { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: var(--text-dim); transition: transform .2s var(--ease), background .2s var(--ease); }
.interruptor[aria-checked="true"] { border-color: rgba(245,197,24,0.20); background: rgba(245,197,24,0.06); }
.interruptor[aria-checked="true"] .interruptor-pista { background: var(--gradient); border-color: transparent; }
.interruptor[aria-checked="true"] .interruptor-pista span { transform: translateX(18px); background: #000; }

/* ---------- Detalle de tarea ---------- */

.td-cab .cab-titulo { color: var(--accent); }
.td { padding: 18px var(--margen) 28px; }
.td-titulo { font-size: 22px; font-weight: 800; letter-spacing: -0.025em; line-height: 1.2; }
.td-marcas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.td-escalas { margin-top: 14px; }
.td .aviso-frase { margin-top: 12px; }
.td-datos {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 16px; align-items: center; margin-top: 18px; padding: 14px 18px;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-elevated) 100%); border: 1px solid var(--border); border-radius: 22px;
}
.td-datos dt { font-size: 13px; color: var(--text-faint); }
.td-datos dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }
.td-datos .enlace-boton { position: relative; min-height: 32px; font-size: 15px; text-align: left; }
/* Zona táctil de 44 px sin cambiar el aspecto (como .btn-check) */
.td-datos .enlace-boton::after { content: ''; position: absolute; inset: -6px 0; }
.td-bloque { margin-top: 22px; }
.td-bloque > h3, .td-plegable > summary { margin-bottom: 6px; font-size: 13px; font-weight: 400; color: var(--text-faint); }
.td-bloque > p { font-size: 15px; line-height: 1.5; }
.td-plegable > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-bottom: 0; cursor: pointer; list-style: none; }
.td-plegable > summary::-webkit-details-marker { display: none; }
/* Chevron dibujado con bordes: apunta abajo plegado y arriba desplegado */
.td-plegable > summary::after { content: ''; width: 7px; height: 7px; border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .3s var(--ease); }
.td-plegable[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
.td-comentarios { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.td-comentario { padding: 10px 14px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg-card); }
.td-comentario-cab { margin-bottom: 2px; font-size: 13px; }
.td-comentario .texto-largo { font-size: 15px; line-height: 1.45; }
.td-form { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; }
.td-form textarea { flex: 1 1 auto; min-width: 0; }
.td-historial { display: flex; flex-direction: column; gap: 8px; }
.td-historial li { display: flex; flex-direction: column; font-size: 14px; }
.td-historial-fecha { font-size: 12px; color: var(--text-faint); }
.td-avisos { display: flex; flex-direction: column; gap: 4px; margin-top: 12px; font-size: 13px; color: var(--text-dim); }
.td-avisos .fallido { color: var(--text); font-weight: 600; }
.td-botones { display: flex; flex-wrap: wrap; gap: 8px; }
.td-botones .boton { flex: 1 1 0; min-width: max-content; }

/* ---------- Histórico: cerradas y anuladas ---------- */

#v-historico .barra-busqueda { position: sticky; top: 0; z-index: 2; padding: 8px var(--margen) 4px; background: var(--bg); }
#v-historico .buscador { position: relative; display: flex; align-items: center; margin-bottom: 8px; }
#v-historico .buscador .ico { position: absolute; left: 14px; width: 1.125rem; height: 1.125rem; color: var(--text-dim); pointer-events: none; }
#v-historico .buscador input { padding-left: 40px; }
#v-historico .filtros-historico { padding-bottom: 6px; }
#v-historico .mes { display: flex; justify-content: space-between; padding: 14px var(--margen) 0; font-size: 0.8125rem; font-weight: 400; color: var(--text-faint); }
.hist { gap: 4px; }
.hist-abrir {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; width: 100%; padding: 0; border: 0; border-radius: 12px;
  background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.hist-abrir:focus-visible { outline-offset: 4px; }
.hist-l1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hist .proyecto { min-width: 0; font-size: 15px; overflow-wrap: anywhere; }
.hist-titulo { font-size: 16px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.3; overflow-wrap: anywhere; }
.hist-meta { font-size: 13px; color: var(--text-dim); line-height: 1.4; }
.hist-acc { display: flex; margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .tablero .tarea:hover, .btn-pedir:hover:not(:disabled), .tejado:active { transform: none; }
}

/* Acción en marcha: el botón conserva el foco y se ve apagado hasta la respuesta */
.pill[aria-disabled="true"], .btn-check[aria-disabled="true"], .boton[aria-disabled="true"] { opacity: 0.45; cursor: progress; }
