/* ============================================================
   HISTORIAL HOME V2
   Archivo: core/static/core/css/home_history_v2.css

   Objetivo:
   - Mantener desktop como está.
   - Mejorar experiencia móvil.
   - No tocar lógica, IDs, JS ni rutas.
   ============================================================ */

.card--history {
  margin-top: 2rem;
}

.card--history .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.history-toggle {
  background: transparent;
  border: 0;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
}

.history-hint {
  font-size: .95rem;
  color: #333;
}

.history-toggle .chevron {
  transition: transform .18s ease;
}

.history-toggle[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
}

/* ============================================================
   BUSCADOR DEL HISTORIAL
   ============================================================ */

.history-search {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
  margin-top: .85rem;
}

.history-search-input {
  flex: 1 1 260px;
  min-width: 0;
  height: 36px;
  padding: 0 .75rem;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  font-size: .9rem;
}

.history-search-input:focus {
  outline: none;
  border-color: #16BAC5;
  box-shadow: 0 0 0 3px rgba(22, 186, 197, .18);
}

.history-search-clear {
  font-size: .85rem;
  color: #6b7280;
  white-space: nowrap;
}

.history-sort-select {
  height: 36px;
  padding: 0 .6rem;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  font-size: .88rem;
  cursor: pointer;
}

.history-sort-select:focus {
  outline: none;
  border-color: #16BAC5;
  box-shadow: 0 0 0 3px rgba(22, 186, 197, .18);
}

/* ============================================================
   FILTRO POR ESTADO
   ============================================================ */

.history-filters {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  margin-top: .6rem;
}

.history-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: .3rem .75rem;
  border-radius: 999px;
  border: 1px solid #dbe3ef;
  background: #ffffff;
  color: #374151;
  font-size: .85rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}

.history-filter-chip:hover {
  border-color: #16BAC5;
  color: #0f5961;
  text-decoration: none;
}

.history-filter-chip.is-active {
  border-color: #16BAC5;
  background: #eef9fb;
  color: #0f5961;
}

/* ============================================================
   SELECCIÓN Y EXPORTACIÓN EN LOTE
   ============================================================ */

.doc-bulk-checkbox {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0;
  cursor: pointer;
}

.bulk-export-bar {
  display: flex;
  align-items: center;
  gap: .9rem;
  flex-wrap: wrap;
  margin-top: .85rem;
  padding: .65rem .9rem;
  border: 1px solid #16BAC5;
  border-radius: 10px;
  background: #eef9fb;
}

.bulk-export-count {
  font-size: .88rem;
  font-weight: 700;
  color: #0f5961;
  white-space: nowrap;
}

.bulk-export-actions {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  flex-wrap: wrap;
}

.bulk-export-group-label {
  font-size: .82rem;
  color: #6b7280;
  margin-right: .1rem;
  white-space: nowrap;
}

.bulk-export-clear {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: #6b7280;
  font-size: .85rem;
  text-decoration: underline;
  cursor: pointer;
}

/* ============================================================
   PAGINACIÓN DEL HISTORIAL
   ============================================================ */

.history-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
}

.history-pagination-counter {
  font-size: .85rem;
  color: #6b7280;
  white-space: nowrap;
}

.history-pagination .disabled {
  opacity: .45;
  pointer-events: none;
}

@media (max-width: 600px) {
  .history-search-input {
    flex-basis: 100%;
  }
}

#history-homepanel.td-history-v2-panel {
  margin-top: 1rem;
}

#history-homepanel.td-history-v2-panel .history-list {
  display: grid;
  gap: .85rem;
}

/* Resetea el grid viejo sin eliminar clases que puedan usar otros JS/CSS */
#history-homepanel.td-history-v2-panel .hrow.home-cols {
  display: block;
  grid-template-columns: unset;
  gap: unset;
}

#history-homepanel.td-history-v2-panel .hrow {
  position: relative;
  z-index: 1;
  padding: 1rem;
  border: 1px solid rgba(22, 186, 197, .18);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .04);
  transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}

/* Cuando el menú "Més" de esta fila está abierto, la subimos por encima de
   las filas siguientes: un z-index interno (.td-more-pop) no puede "escapar"
   por delante de una fila hermana posterior en el DOM si la propia fila
   (.hrow) no tiene también un z-index mayor. */
#history-homepanel.td-history-v2-panel .hrow.td-menu-open {
  z-index: 50;
}

#history-homepanel.td-history-v2-panel .hrow:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(15, 23, 42, .07);
  border-color: rgba(22, 186, 197, .32);
}

#history-homepanel.td-history-v2-panel .hrow.is-last {
  border-color: rgba(22, 186, 197, .55);
  box-shadow: 0 8px 24px rgba(22, 186, 197, .10);
}

#history-homepanel.td-history-v2-panel .hrow.row-ok {
  background: linear-gradient(180deg, #f0fdf4 0%, #ffffff 100%);
  border-color: rgba(22, 163, 74, .3);
}

#history-homepanel.td-history-v2-panel .hrow.row-partial {
  background: linear-gradient(180deg, #fffef5 0%, #ffffff 100%);
}

#history-homepanel.td-history-v2-panel .hrow.row-warn {
  background: linear-gradient(180deg, #fff7f7 0%, #ffffff 100%);
  border-color: rgba(245, 158, 11, .28);
}

#history-homepanel.td-history-v2-panel .td-history-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: flex-start;
}

#history-homepanel.td-history-v2-panel .td-doc-info {
  min-width: 0;
}

#history-homepanel.td-history-v2-panel .td-doc-titleline {
  display: flex;
  align-items: center;
  gap: .5rem;
  min-width: 0;
}

#history-homepanel.td-history-v2-panel .doc-title {
  display: inline-block;
  max-width: 100%;
  font-weight: 800;
  color: #1f2937;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

#history-homepanel.td-history-v2-panel .td-busy-dot {
  flex: 0 0 auto;
  width: .55rem;
  height: .55rem;
  border-radius: 999px;
  background: #16BAC5;
  box-shadow: 0 0 0 4px rgba(22, 186, 197, .14);
  animation: td-busy-pulse 1.8s ease-out infinite;
}

/* Anillo de pulso: mismo lenguaje visual que el pulso de .action--run */
@keyframes td-busy-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22, 186, 197, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(22, 186, 197, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 186, 197, 0); }
}

/* Respeta usuarios con reducción de movimiento */
@media (prefers-reduced-motion: reduce) {
  #history-homepanel.td-history-v2-panel .td-busy-dot {
    animation: none;
    box-shadow: 0 0 0 4px rgba(22, 186, 197, .14);
  }
}

#history-homepanel.td-history-v2-panel .td-doc-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem .65rem;
  margin-top: .35rem;
  color: #6b7280;
  font-size: .9rem;
  line-height: 1.35;
}

#history-homepanel.td-history-v2-panel .td-meta-item {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  white-space: nowrap;
}

#history-homepanel.td-history-v2-panel .td-meta-sep {
  color: #c4c4c4;
}

#history-homepanel.td-history-v2-panel .date-chip {
  display: inline-flex;
  align-items: center;
  padding: .12rem .45rem;
  border-radius: 999px;
  background: #f3f4f6;
  color: #4b5563;
  font-size: .82rem;
  font-weight: 700;
  line-height: 1.2;
}

#history-homepanel.td-history-v2-panel .date-chip[data-state="fresh"] {
  background: #EAF6FF;
  color: #1074a6;
}

#history-homepanel.td-history-v2-panel .date-chip[data-state="week"] {
  background: #F7F7F7;
  color: #4b5563;
}

#history-homepanel.td-history-v2-panel .date-chip[data-state="old"] {
  background: #F3F4F6;
  color: #6b7280;
}

/* =========================
   Acciones principales
   ========================= */

#history-homepanel.td-history-v2-panel .td-history-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .45rem;
  flex-wrap: wrap;
}

#history-homepanel.td-history-v2-panel .action {
  margin: 0;
}

#history-homepanel.td-history-v2-panel .td-action-btn,
#history-homepanel.td-history-v2-panel .td-more-summary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: 34px;
  padding: .42rem .72rem;
  border-radius: 999px;
  border: 1px solid transparent;
  background: #ffffff;
  color: #374151;
  font-size: .86rem;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}

#history-homepanel.td-history-v2-panel .td-action-btn:hover,
#history-homepanel.td-history-v2-panel .td-more-summary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, .08);
  text-decoration: none;
}

#history-homepanel.td-history-v2-panel .td-action-btn--tx {
  background: #EAF6FF;
  color: #1074a6;
  border-color: rgba(57, 169, 226, .24);
}

#history-homepanel.td-history-v2-panel .td-action-btn--ex {
  background: #F3E8FF;
  color: #6C3BAA;
  border-color: rgba(108, 59, 170, .22);
}

#history-homepanel.td-history-v2-panel .td-action-btn--chat {
  background: #ECFDF3;
  color: #15803D;
  border-color: rgba(34, 197, 94, .22);
}

#history-homepanel.td-history-v2-panel .td-action-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 900;
  line-height: 1;
}

#history-homepanel.td-history-v2-panel .td-action-dot--tx {
  background: #39A9E2;
  color: #fff;
}

#history-homepanel.td-history-v2-panel .td-action-dot--ex {
  background: #6C3BAA;
  color: #fff;
}

#history-homepanel.td-history-v2-panel .td-action-dot--chat {
  background: #22C55E;
  color: #fff;
}

/* =========================
   Menú Més
   ========================= */

#history-homepanel.td-history-v2-panel .td-more-menu {
  position: relative;
}

#history-homepanel.td-history-v2-panel .td-more-menu summary {
  list-style: none;
}

#history-homepanel.td-history-v2-panel .td-more-menu summary::-webkit-details-marker {
  display: none;
}

#history-homepanel.td-history-v2-panel .td-more-summary {
  background: #ffffff;
  border-color: #dbeafe;
  color: #374151;
}

#history-homepanel.td-history-v2-panel .td-more-summary::after {
  content: "▾";
  font-size: .75rem;
  color: #6b7280;
  margin-left: .1rem;
}

#history-homepanel.td-history-v2-panel .td-more-menu[open] .td-more-summary::after {
  content: "▴";
}

#history-homepanel.td-history-v2-panel .td-more-pop {
  position: absolute;
  top: calc(100% + .45rem);
  right: 0;
  z-index: 40;
  min-width: 235px;
  padding: .45rem;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: #fff;
  box-shadow: 0 18px 42px rgba(15, 23, 42, .16);
}

#history-homepanel.td-history-v2-panel .td-more-group {
  padding: .3rem 0;
  border-bottom: 1px solid #f1f5f9;
}

#history-homepanel.td-history-v2-panel .td-more-group:last-child {
  border-bottom: 0;
}

#history-homepanel.td-history-v2-panel .td-more-title {
  display: block;
  padding: .35rem .55rem .25rem;
  color: #9ca3af;
  font-size: .72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .04em;
}

#history-homepanel.td-history-v2-panel .td-more-item,
#history-homepanel.td-history-v2-panel .td-more-form button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .62rem .6rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #374151;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.1;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

#history-homepanel.td-history-v2-panel .td-more-item:hover,
#history-homepanel.td-history-v2-panel .td-more-form button:hover {
  background: #f8fafc;
  text-decoration: none;
}

#history-homepanel.td-history-v2-panel .td-more-danger {
  color: #b91c1c;
}

#history-homepanel.td-history-v2-panel .td-more-danger:hover {
  background: #fff1f2;
}

#history-homepanel.td-history-v2-panel .td-more-disabled {
  opacity: .45;
  cursor: not-allowed;
}

#history-homepanel.td-history-v2-panel .td-more-disabled:hover {
  background: transparent;
}

#history-homepanel.td-history-v2-panel .td-more-form {
  margin: 0;
}

/* =========================
   Estados
   ========================= */

#history-homepanel.td-history-v2-panel .td-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .65rem;
  margin-top: .85rem;
  /* Corta el text-align:center y el align-items:center heredados de la
     vieja regla "#history-homepanel .history-list .hh-estat" (diseño de
     tabla anterior): esa regla nunca se limpió y, como esta clase legacy
     sigue en el HTML, sus valores se cuelan en cualquier propiedad que
     esta regla nueva no redeclare explícitamente. */
  text-align: left;
  align-items: stretch;
}

#history-homepanel.td-history-v2-panel .td-status-card {
  min-width: 0;
  padding: .75rem;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #eef2f7;
}

#history-homepanel.td-history-v2-panel .td-status-card--tx {
  border-color: rgba(57, 169, 226, .18);
}

#history-homepanel.td-history-v2-panel .td-status-card--ex {
  border-color: rgba(108, 59, 170, .18);
}

#history-homepanel.td-history-v2-panel .td-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .55rem;
}

#history-homepanel.td-history-v2-panel .td-status-name {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  min-width: 0;
  color: #374151;
  font-size: .82rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .035em;
}

#history-homepanel.td-history-v2-panel .td-status-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  line-height: 1;
}

#history-homepanel.td-history-v2-panel .td-status-tag--tx {
  background: #39A9E2;
}

#history-homepanel.td-history-v2-panel .td-status-tag--ex {
  background: #6C3BAA;
}

#history-homepanel.td-history-v2-panel .td-status-count {
  color: #111827;
  font-size: .9rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

#history-homepanel.td-history-v2-panel .td-status-bottom {
  display: flex;
  align-items: center;
  gap: .55rem;
}

#history-homepanel.td-history-v2-panel .td-progressbar {
  flex: 1;
  min-width: 50px;
  height: 6px;
  border-radius: 999px;
  background: #e5e7eb;
  overflow: hidden;
}

#history-homepanel.td-history-v2-panel .td-progressbar__bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  transition: width .25s ease;
}

#history-homepanel.td-history-v2-panel .td-progressbar__bar--tx {
  background: #39A9E2;
}

#history-homepanel.td-history-v2-panel .td-progressbar__bar--ex {
  background: #6C3BAA;
}

#history-homepanel.td-history-v2-panel .td-status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .22rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

#history-homepanel.td-history-v2-panel .td-status-pill--empty {
  background: #f3f4f6;
  color: #6b7280;
}

#history-homepanel.td-history-v2-panel .td-status-pill--process {
  background: #EAF6FF;
  color: #1074a6;
}

#history-homepanel.td-history-v2-panel .td-status-pill--ok {
  background: #ECFDF3;
  color: #166534;
}

#history-homepanel.td-history-v2-panel .td-status-pill--warn {
  background: #FFF7E6;
  color: #a25e00;
}

#history-homepanel.td-history-v2-panel .td-status-pill--partial {
  background: #fefce8;
  color: #854d0e;
}

/* =========================
   Historial de intentos
   ========================= */

#history-homepanel.td-history-v2-panel .hh-subhist {
  padding: 0;
  margin-top: .75rem;
  font-size: .9rem;
  color: #555;
}

#history-homepanel.td-history-v2-panel .td-attempts {
  border-top: 1px dashed #e5e7eb;
  padding-top: .65rem;
}

#history-homepanel.td-history-v2-panel .td-attempts summary {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  cursor: pointer;
  color: #4b5563;
  font-weight: 800;
  list-style: none;
}

#history-homepanel.td-history-v2-panel .td-attempts summary::-webkit-details-marker {
  display: none;
}

#history-homepanel.td-history-v2-panel .td-attempts summary::after {
  content: "▾";
  font-size: .75rem;
  color: #9ca3af;
}

#history-homepanel.td-history-v2-panel .td-attempts[open] summary::after {
  content: "▴";
}

#history-homepanel.td-history-v2-panel .td-attempts ul {
  margin: .55rem 0 0 0;
  padding: 0;
  list-style: none;
}

#history-homepanel.td-history-v2-panel .att {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .45rem .75rem;
  padding: .45rem 0;
  border-bottom: 1px dashed #edf2f7;
}

#history-homepanel.td-history-v2-panel .att:last-child {
  border-bottom: 0;
}

#history-homepanel.td-history-v2-panel .att-date time {
  color: #374151;
  font-weight: 800;
}

#history-homepanel.td-history-v2-panel .att-sent {
  color: #6b7280;
  font-variant-numeric: tabular-nums;
}

#history-homepanel.td-history-v2-panel .att-chips {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .3rem;
}

#history-homepanel.td-history-v2-panel .att-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .16rem .45rem;
  border-radius: 999px;
  font-weight: 900;
  font-size: .82rem;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  background: #EAF6FF;
  color: #1074a6;
}

#history-homepanel.td-history-v2-panel .att-chip.err {
  background: #FFF7E6;
  color: #a25e00;
}

/* "Sin datos": no es un error, se distingue en gris neutro (no ámbar/rojo) */
#history-homepanel.td-history-v2-panel .att-chip.empty {
  background: #F1F3F5;
  color: #495159;
}

#history-homepanel.td-history-v2-panel .att-chip.cancel {
  background: #FFEEEF;
  color: #9a0e0e;
}

#history-homepanel.td-history-v2-panel .badge {
  display: inline-flex;
  align-items: center;
  padding: .18rem .5rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 900;
  line-height: 1;
  margin-left: 0;
}

#history-homepanel.td-history-v2-panel .badge-ok {
  background: #ECFDF3;
  color: #166534;
}

#history-homepanel.td-history-v2-panel .badge-warn {
  background: #FFF7E6;
  color: #a25e00;
}

#history-homepanel.td-history-v2-panel .badge-cancel {
  background: #FFEEEF;
  color: #9a0e0e;
}

#history-homepanel.td-history-v2-panel .badge-progress {
  background: #EAF6FF;
  color: #1074a6;
}

#history-homepanel.td-history-v2-panel .row-empty {
  padding: 1.2rem;
  border-radius: 16px;
  background: #fff;
  color: #6b7280;
  text-align: center;
  font-weight: 700;
}

/* ============================================================
   RESPONSIVE MÓVIL
   Se mejora solo móvil, sin alterar desktop.
   ============================================================ */

@media (max-width: 760px) {
  .card--history {
    margin-top: 1.4rem;
  }

  .card--history .card-head {
    align-items: flex-start;
    gap: .75rem;
  }

  .card--history .card-title {
    font-size: 1.05rem;
    line-height: 1.15;
  }

  .history-toggle {
    flex: 0 0 auto;
    padding-top: .1rem;
  }

  .history-hint {
    font-size: .88rem;
  }

  #history-homepanel.td-history-v2-panel {
    margin-top: .75rem;
  }

  #history-homepanel.td-history-v2-panel .history-list {
    gap: .75rem;
  }

  #history-homepanel.td-history-v2-panel .hrow {
    padding: .85rem;
    border-radius: 16px;
    box-shadow: 0 5px 16px rgba(15, 23, 42, .055);
  }

  #history-homepanel.td-history-v2-panel .hrow:hover {
    transform: none;
    box-shadow: 0 5px 16px rgba(15, 23, 42, .055);
  }

  #history-homepanel.td-history-v2-panel .td-history-top {
    display: block;
  }

  #history-homepanel.td-history-v2-panel .td-doc-titleline {
    align-items: flex-start;
  }

  #history-homepanel.td-history-v2-panel .doc-title {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-size: .98rem;
    line-height: 1.25;
    word-break: break-word;
  }

  #history-homepanel.td-history-v2-panel .td-busy-dot {
    margin-top: .32rem;
  }

  #history-homepanel.td-history-v2-panel .td-doc-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: .35rem;
    margin-top: .55rem;
    font-size: .82rem;
  }

  #history-homepanel.td-history-v2-panel .td-meta-sep {
    display: none;
  }

  #history-homepanel.td-history-v2-panel .td-meta-item {
    width: 100%;
    min-width: 0;
    white-space: normal;
    color: #6b7280;
  }

  #history-homepanel.td-history-v2-panel .date-cell {
    min-width: 0;
  }

  #history-homepanel.td-history-v2-panel .date-chip {
    max-width: 100%;
    font-size: .78rem;
  }

  /* Acciones en móvil: grilla 2x2 clara */
  #history-homepanel.td-history-v2-panel .td-history-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
    width: 100%;
    margin-top: .8rem;
  }

  #history-homepanel.td-history-v2-panel .td-action-btn,
  #history-homepanel.td-history-v2-panel .td-more-summary {
    width: 100%;
    min-height: 40px;
    padding: .62rem .65rem;
    border-radius: 13px;
    font-size: .84rem;
  }

  #history-homepanel.td-history-v2-panel .td-action-dot {
    width: 1.25rem;
    height: 1.25rem;
    font-size: .72rem;
  }

  #history-homepanel.td-history-v2-panel .td-more-menu {
    width: 100%;
    min-width: 0;
  }

  #history-homepanel.td-history-v2-panel .td-more-menu[open] {
    grid-column: 1 / -1;
  }

  #history-homepanel.td-history-v2-panel .td-more-pop {
    position: static;
    width: 100%;
    min-width: 0;
    margin-top: .5rem;
    padding: .45rem;
    border-radius: 14px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, .10);
  }

  #history-homepanel.td-history-v2-panel .td-more-title {
    padding: .45rem .55rem .25rem;
    font-size: .7rem;
  }

  #history-homepanel.td-history-v2-panel .td-more-item,
  #history-homepanel.td-history-v2-panel .td-more-form button {
    min-height: 40px;
    padding: .68rem .65rem;
    font-size: .88rem;
  }

  /* Estados en móvil: una columna, compacta y legible */
  #history-homepanel.td-history-v2-panel .td-status-grid {
    grid-template-columns: 1fr;
    gap: .55rem;
    margin-top: .75rem;
  }

  #history-homepanel.td-history-v2-panel .td-status-card {
    padding: .68rem;
    border-radius: 13px;
  }

  #history-homepanel.td-history-v2-panel .td-status-head {
    margin-bottom: .48rem;
  }

  #history-homepanel.td-history-v2-panel .td-status-name {
    font-size: .76rem;
    letter-spacing: .025em;
  }

  #history-homepanel.td-history-v2-panel .td-status-count {
    font-size: .86rem;
  }

  #history-homepanel.td-history-v2-panel .td-status-tag {
    width: 1.12rem;
    height: 1.12rem;
    font-size: .66rem;
  }

  #history-homepanel.td-history-v2-panel .td-status-bottom {
    gap: .45rem;
  }

  #history-homepanel.td-history-v2-panel .td-progressbar {
    height: 5px;
    min-width: 44px;
  }

  #history-homepanel.td-history-v2-panel .td-status-pill {
    padding: .22rem .48rem;
    font-size: .72rem;
  }

  #history-homepanel.td-history-v2-panel .hh-subhist {
    margin-top: .65rem;
    font-size: .84rem;
  }

  #history-homepanel.td-history-v2-panel .td-attempts {
    padding-top: .58rem;
  }

  #history-homepanel.td-history-v2-panel .td-attempts summary {
    font-size: .84rem;
  }

  #history-homepanel.td-history-v2-panel .att {
    display: grid;
    grid-template-columns: 1fr;
    gap: .35rem;
    padding: .55rem 0;
  }

  #history-homepanel.td-history-v2-panel .att-chips {
    gap: .35rem;
  }

  #history-homepanel.td-history-v2-panel .att-chip,
  #history-homepanel.td-history-v2-panel .badge {
    font-size: .78rem;
  }
}

@media (max-width: 420px) {
  #history-homepanel.td-history-v2-panel .hrow {
    padding: .75rem;
    border-radius: 14px;
  }

  #history-homepanel.td-history-v2-panel .td-history-actions {
    grid-template-columns: 1fr;
  }

  #history-homepanel.td-history-v2-panel .td-action-btn,
  #history-homepanel.td-history-v2-panel .td-more-summary {
    justify-content: flex-start;
    min-height: 42px;
    padding-left: .75rem;
    padding-right: .75rem;
  }

  #history-homepanel.td-history-v2-panel .td-more-menu[open] {
    grid-column: auto;
  }

  #history-homepanel.td-history-v2-panel .td-status-bottom {
    align-items: flex-start;
  }

  #history-homepanel.td-history-v2-panel .td-status-pill {
    max-width: 42%;
    text-align: center;
  }
}