/* Facturación de ingresos: ajustes responsive del módulo */
/* Facturación de ingresos: ajustes responsive */

@media (max-width: 767px) {
  .modal.modal-factura {
    max-width: 100%;
  }
  .modal {
    padding: var(--space-5) var(--space-4);
  }
  .modal-close-x {
    top: var(--space-2);
    right: var(--space-2);
    width: 44px;
    height: 44px;
  }
  .modal-title {
    padding-right: 48px;
  }
  .modal-cobro .form-row.form-row-3 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .modal-cobro .form-row.form-row-3 .form-group:nth-child(3) {
    grid-column: 1 / -1;
  }
  .modal-cobro .modal-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: var(--space-3);
  }
  .modal-cobro .modal-actions .btn {
    justify-content: center;
    min-width: 0;
  }
  .factura-lineas-head {
    display: none;
  }
  .factura-lineas-box {
    gap: var(--space-3);
  }
  .factura-linea-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 72px 42px;
    gap: var(--space-2);
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface-offset);
  }
  .factura-linea-descripcion {
    grid-column: 1 / -1;
  }
  .factura-linea-uds,
  .factura-linea-precio,
  .factura-linea-dto {
    min-width: 0;
  }
  .factura-linea-precio {
    grid-column: 1 / 2;
  }
  .factura-linea-uds {
    grid-column: 2 / 3;
  }
  .factura-linea-dto {
    grid-column: 1 / 3;
  }
  .factura-linea-remove {
    grid-column: 3 / 4;
    grid-row: 2 / 4;
    align-self: stretch;
    height: auto;
    min-height: 34px;
  }

  .factura-row-cliente-total .factura-cliente-crm {
    grid-column: auto;
  }
  .factura-row-main,
  .factura-row-localidad {
    gap: var(--space-2);
  }

  .factura-modal-actions {
    display: grid;
    grid-template-columns: auto 1fr 1fr;
    gap: var(--space-2);
  }
  .factura-modal-actions .btn {
    min-width: 0;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
    justify-content: center;
    font-size: 12px;
    white-space: nowrap;
  }

  .factura-detail-actions {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-2) !important;
  }
  .factura-detail-actions .btn {
    min-width: 0;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
    justify-content: center;
    font-size: 12px;
    white-space: nowrap;
  }

  .factura-linea-row {
    grid-template-columns: 58px minmax(0,1fr) 58px 56px 34px;
    gap: var(--space-2);
    padding: var(--space-3);
    align-items: center;
  }
  .factura-linea-descripcion {
    grid-column: 1 / -1;
    grid-row: 1;
  }
  .factura-linea-uds {
    grid-column: 1 / 2;
    grid-row: 2;
  }
  .factura-linea-precio {
    grid-column: 2 / 3;
    grid-row: 2;
  }
  .factura-linea-dto {
    grid-column: 3 / 4;
    grid-row: 2;
  }
  .factura-linea-estilo {
    grid-column: 4 / 5;
    grid-row: 2;
    align-self: center;
  }
  .factura-linea-remove {
    grid-column: 5 / 6;
    grid-row: 2;
    align-self: stretch;
    height: auto;
    min-height: 34px;
  }
  .factura-linea-uds,
  .factura-linea-precio,
  .factura-linea-dto {
    text-align: right;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }
  /* Pulidos móviles de facturación */
  /* Listado de facturas: fecha y estado a la derecha, total abajo a la derecha */
  .facturas-table tr {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .facturas-table td:nth-child(1) {
    grid-column: 1 / 2;
    grid-row: 1;
  }
  .facturas-table td:nth-child(2) {
    grid-column: 2 / 3;
    grid-row: 1;
    text-align: right !important;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    white-space: nowrap;
  }
  .facturas-table td:nth-child(3) {
    grid-column: 1 / 2;
    grid-row: 2;
    min-width: 0;
  }
  .facturas-table td:nth-child(5) {
    grid-column: 2 / 3;
    grid-row: 2;
    text-align: right !important;
    align-self: start;
  }
  .facturas-table td:nth-child(4) {
    grid-column: 1 / 2;
    grid-row: 3;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
  }
  .facturas-table td:nth-child(6) {
    grid-column: 2 / 3;
    grid-row: 3;
    text-align: right !important;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    white-space: nowrap;
  }
  .facturas-table td:nth-child(7) {
    grid-column: 2 / 3;
    grid-row: 4;
    text-align: right !important;
    font-weight: 800;
    white-space: nowrap;
  }

  .facturas-table.facturas-table-admin td.factura-base-cell{
    display:none!important;
  }
  .facturas-table.facturas-table-admin td.factura-total-cell{
    grid-column:2 / 3;
    grid-row:3;
    text-align:right!important;
    color:var(--color-text-muted);
    font-size:var(--text-xs);
    white-space:nowrap;
  }
  .facturas-table.facturas-table-admin .factura-total-desktop{
    display:none;
  }
  .facturas-table.facturas-table-admin .factura-mobile-importes{
    display:inline;
  }


  /* Detalle de factura: cobros cómodos en móvil */
  .detail-panel.detail-panel-factura {
    padding: var(--space-4) var(--space-3);
  }
  .detail-panel-factura .factura-cobros-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }
  .detail-panel-factura .factura-cobros-table thead {
    display: none;
  }
  .detail-panel-factura .factura-cobros-table,
  .detail-panel-factura .factura-cobros-table tbody,
  .detail-panel-factura .factura-cobros-table tr,
  .detail-panel-factura .factura-cobros-table td {
    display: block;
    width: 100%;
  }
  .detail-panel-factura .factura-cobros-table tr {
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    margin-bottom: var(--space-3);
  }
  .detail-panel-factura .factura-cobros-table tr:last-child {
    margin-bottom: 0;
  }
  .detail-panel-factura .factura-cobros-table td {
    padding: 0;
    border: 0;
    text-align: left !important;
  }
  .detail-panel-factura .factura-cobros-table td + td {
    margin-top: var(--space-1);
  }
  .detail-panel-factura .factura-cobro-importe {
    font-size: var(--text-base);
    margin-top: var(--space-2) !important;
  }
  .detail-panel-factura .factura-cobro-actions-cell {
    margin-top: var(--space-3) !important;
  }
  .detail-panel-factura .factura-cobro-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    width: 100%;
  }
  .detail-panel-factura .factura-cobro-btn {
    min-height: 44px;
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
  }

  /* Modal factura: nº/fecha comparten línea; estado baja junto a provincia */
  .factura-row-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  }
  .factura-row-main .factura-estado-desktop {
    display: none !important;
  }
  .factura-row-localidad {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) !important;
  }
  .factura-row-localidad .form-group:nth-child(3),
  .factura-row-localidad .factura-estado-mobile {
    grid-row: 2;
  }
  .factura-estado-mobile {
    display: block !important;
  }

  /* Líneas de detalle: Uds./Importe/Dto. juntos e identificables */
  .factura-linea-row {
    grid-template-columns: 58px minmax(0,1fr) 58px 34px !important;
    gap: var(--space-2);
    padding: var(--space-3);
    align-items: center;
  }
  .factura-linea-descripcion {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
  }
  .factura-linea-uds {
    grid-column: 1 / 2 !important;
    grid-row: 2 !important;
  }
  .factura-linea-precio {
    grid-column: 2 / 3 !important;
    grid-row: 2 !important;
  }
  .factura-linea-dto {
    grid-column: 3 / 4 !important;
    grid-row: 2 !important;
  }
  .factura-linea-remove {
    grid-column: 4 / 5 !important;
    grid-row: 2 !important;
    align-self: stretch;
    height: auto;
    min-height: 34px;
  }
  .factura-linea-uds,
  .factura-linea-precio,
  .factura-linea-dto {
    text-align: right;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }
}

@media (min-width: 768px) {
  .factura-estado-mobile {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .factura-row-localidad .form-group:nth-child(1) { grid-column: 1 / 2; grid-row: 1; }
  .factura-row-localidad .form-group:nth-child(2) { grid-column: 2 / 3; grid-row: 1; }
  .factura-row-localidad .form-group:nth-child(3) { grid-column: 1 / 2; grid-row: 2; }
  .factura-row-localidad .factura-estado-mobile { grid-column: 2 / 3; grid-row: 2; }
  .kpi-mini-grid{display:block;font-size:12px;line-height:1.28}

  .facturas-actions-bar{
    justify-content:stretch;
  }
  .facturas-actions-bar .btn{
    flex:1 1 140px;
    justify-content:center;
  }
  .factura-import-preview{
    max-height:55vh;
  }

  .factura-import-item-head{
    grid-template-columns:1fr auto;
    align-items:start;
    white-space: nowrap;
  }
  .facturas-table td:nth-child(3) {
    grid-column: 1 / 2;
    grid-row: 2;
    min-width: 0;
  }
  .facturas-table td:nth-child(5) {
    grid-column: 2 / 3;
    grid-row: 2;
    text-align: right !important;
    align-self: start;
  }
  .facturas-table td:nth-child(4) {
    grid-column: 1 / 2;
    grid-row: 3;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
  }
  .facturas-table td:nth-child(6) {
    grid-column: 2 / 3;
    grid-row: 3;
    text-align: right !important;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    white-space: nowrap;
  }
  .facturas-table td:nth-child(7) {
    grid-column: 2 / 3;
    grid-row: 4;
    text-align: right !important;
    font-weight: 800;
    white-space: nowrap;
  }

  .facturas-table.facturas-table-admin td.factura-base-cell{
    display:none!important;
  }
  .facturas-table.facturas-table-admin td.factura-total-cell{
    grid-column:2 / 3;
    grid-row:3;
    text-align:right!important;
    color:var(--color-text-muted);
    font-size:var(--text-xs);
    white-space:nowrap;
  }
  .facturas-table.facturas-table-admin .factura-total-desktop{
    display:none;
  }
  .facturas-table.facturas-table-admin .factura-mobile-importes{
    display:inline;
  }


  /* Detalle de factura: cobros cómodos en móvil */
  .detail-panel.detail-panel-factura {
    padding: var(--space-4) var(--space-3);
  }
  .detail-panel-factura .factura-cobros-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }
  .detail-panel-factura .factura-cobros-table thead {
    display: none;
  }
  .detail-panel-factura .factura-cobros-table,
  .detail-panel-factura .factura-cobros-table tbody,
  .detail-panel-factura .factura-cobros-table tr,
  .detail-panel-factura .factura-cobros-table td {
    display: block;
    width: 100%;
  }
  .detail-panel-factura .factura-cobros-table tr {
    padding: var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    margin-bottom: var(--space-3);
  }
  .detail-panel-factura .factura-cobros-table tr:last-child {
    margin-bottom: 0;
  }
  .detail-panel-factura .factura-cobros-table td {
    padding: 0;
    border: 0;
    text-align: left !important;
  }
  .detail-panel-factura .factura-cobros-table td + td {
    margin-top: var(--space-1);
  }
  .detail-panel-factura .factura-cobro-importe {
    font-size: var(--text-base);
    margin-top: var(--space-2) !important;
  }
  .detail-panel-factura .factura-cobro-actions-cell {
    margin-top: var(--space-3) !important;
  }
  .detail-panel-factura .factura-cobro-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
    width: 100%;
  }
  .detail-panel-factura .factura-cobro-btn {
    min-height: 44px;
    justify-content: center;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
  }

  /* Modal factura: nº/fecha comparten línea; estado baja junto a provincia */
  .factura-row-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
  }
  .factura-row-main .factura-estado-desktop {
    display: none !important;
  }
  .factura-row-localidad {
    grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr) !important;
  }
  .factura-row-localidad .form-group:nth-child(3),
  .factura-row-localidad .factura-estado-mobile {
    grid-row: 2;
  }
  .factura-estado-mobile {
    display: block !important;
  }

  /* Líneas de detalle: Uds./Importe/Dto. juntos e identificables */
  .factura-linea-row {
    grid-template-columns: 58px minmax(0,1fr) 58px 34px !important;
    gap: var(--space-2);
    padding: var(--space-3);
    align-items: center;
  }
  .factura-linea-descripcion {
    grid-column: 1 / -1 !important;
    grid-row: 1 !important;
  }
  .factura-linea-uds {
    grid-column: 1 / 2 !important;
    grid-row: 2 !important;
  }
  .factura-linea-precio {
    grid-column: 2 / 3 !important;
    grid-row: 2 !important;
  }
  .factura-linea-dto {
    grid-column: 3 / 4 !important;
    grid-row: 2 !important;
  }
  .factura-linea-remove {
    grid-column: 4 / 5 !important;
    grid-row: 2 !important;
    align-self: stretch;
    height: auto;
    min-height: 34px;
  }
  .factura-linea-uds,
  .factura-linea-precio,
  .factura-linea-dto {
    text-align: right;
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }
}

@media (min-width: 768px) {
  .factura-estado-mobile {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .factura-row-localidad .form-group:nth-child(1) { grid-column: 1 / 2; grid-row: 1; }
  .factura-row-localidad .form-group:nth-child(2) { grid-column: 2 / 3; grid-row: 1; }
  .factura-row-localidad .form-group:nth-child(3) { grid-column: 1 / 2; grid-row: 2; }
  .factura-row-localidad .factura-estado-mobile { grid-column: 2 / 3; grid-row: 2; }
  .kpi-mini-grid{display:block;font-size:12px;line-height:1.28}

  .facturas-actions-bar{
    justify-content:stretch;
  }
  .facturas-actions-bar .btn{
    flex:1 1 140px;
    justify-content:center;
  }
  .factura-import-preview{
    max-height:55vh;
  }

  .factura-import-item-head{
    grid-template-columns:1fr auto;
    align-items:start;
  }
  .factura-import-check{
    grid-column:1 / 3;
  }
  .factura-import-numero{
    grid-column:1;
  }
  .factura-import-meta{
    grid-template-columns:1fr 1fr;
  }
  .factura-import-meta div:nth-child(2){
    grid-column:1 / 3;
  }
}

@media (max-width: 768px){
  .facturas-filter-stack{gap:var(--space-2);margin-bottom:var(--space-4)}
  /* El botón Año ahora está en la fila del ejercicio: se alinea automáticamente */
  #facturasYearFilterBar{width:100%;justify-content:center}
  .facturas-year-bar .filter-label{width:auto;padding-left:0}
  .facturas-year-bar{flex-wrap:nowrap;align-items:center}
  .facturas-year-select{min-width:88px;max-width:110px}
}

/* Facturación: resumen y tarjetas móviles para gestoría */
@media (max-width: 767px){
  .facturas-period-summary{
    padding:var(--space-3) var(--space-4);
  }
  .facturas-period-summary-title{
    text-align:center;
  }
  .facturas-period-summary-grid{
    grid-template-columns:1fr;
    gap:var(--space-2);
  }
  .facturas-period-summary-grid div{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap:var(--space-3);
  }
  .facturas-period-summary-grid span{margin-bottom:0}
  html[data-crm-role="gestoria"] .facturas-table tr,
  .facturas-table.facturas-table-gestoria tr{
    grid-template-columns:minmax(0,1fr) auto;
  }
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(1),
  .facturas-table.facturas-table-gestoria td:nth-child(1){grid-column:1/2;grid-row:1}
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(2),
  .facturas-table.facturas-table-gestoria td:nth-child(2){grid-column:2/3;grid-row:1;text-align:right!important;color:var(--color-text-muted);font-size:var(--text-xs);white-space:nowrap}
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(3),
  .facturas-table.facturas-table-gestoria td:nth-child(3){grid-column:1/2;grid-row:2;min-width:0}
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(4),
  .facturas-table.facturas-table-gestoria td:nth-child(4){grid-column:1/2;grid-row:3;color:var(--color-text-muted);font-size:var(--text-xs);text-align:left!important}
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(5),
  .facturas-table.facturas-table-gestoria td:nth-child(5){grid-column:2/3;grid-row:2;text-align:right!important;color:var(--color-text-muted);font-size:var(--text-xs);white-space:nowrap}
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(6),
  .facturas-table.facturas-table-gestoria td:nth-child(6){grid-column:2/3;grid-row:3;text-align:right!important;color:var(--color-text-muted);font-size:var(--text-xs);white-space:nowrap}
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(7),
  .facturas-table.facturas-table-gestoria td:nth-child(7){grid-column:2/3;grid-row:4;text-align:right!important;font-weight:800;white-space:nowrap}
  html[data-crm-role="gestoria"] .facturas-table td:nth-child(8),
  .facturas-table.facturas-table-gestoria td:nth-child(8){grid-column:1/2;grid-row:4;text-align:left!important;align-self:end}
  /* Facturación: filtros móviles en una línea */
  .filter-label-mobile{display:inline}
  .filter-label-desktop{display:none}
  #facturasFilterBar{
    flex-wrap:nowrap;
    gap:4px;
    width:100%;
  }
  .facturas-combined-filter-bar{display:grid;grid-template-columns:1fr;gap:var(--space-2)}
  /* Fila de trimestres en móvil: ancho completo centrado (incluye el botón Año) */
  .facturas-quarter-options,.facturas-top-actions{width:100%;justify-content:center}
  .facturas-filter-separator{display:none}
  .facturas-delete-imported-btn{width:auto;max-width:max-content;margin:var(--space-2) auto 0;justify-content:center}
  #facturasFilterBar .filter-btn{
    text-align:center;
    white-space:nowrap;
    text-align:center;
    white-space:nowrap;
  }
  .facturas-period-summary-grid .facturas-summary-status{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--space-1)}
    gap:var(--space-2);
  }
  .factura-import-summary span{
    white-space:normal;
  }
  .factura-import-loading{
    grid-column:1 / -1;
  }
}

@media (max-width: 767px){
  #view-facturacion.view.active{
    display:flex;
    flex-direction:column;
  }
  #view-facturacion .facturas-filter-stack{order:1}
  #view-facturacion #facturasDuplicadasAviso{order:2}
  #view-facturacion #facturasResumenPeriodo{order:3}
  #view-facturacion .table-card{order:4}

  .factura-action-desktop{display:none!important}
  .factura-action-mobile{display:inline-flex!important}
  /* Facturación móvil: detalle completo en tarjetas cómodas */
  .detail-panel-factura .factura-detail-data-lines{
    display:none;
  }
  .detail-panel-factura .factura-detail-data-grid{
    display:grid;
    grid-template-columns:1fr;
    gap:var(--space-2);
  }
  .detail-panel-factura .factura-detail-data-item{
    padding:var(--space-3);
  }
  .detail-panel-factura .factura-detail-data-item-pair{
    display:grid !important;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important;
    column-gap:var(--space-3);
  }
  .detail-panel-factura .factura-detail-actions-top{
    grid-template-columns:repeat(2,minmax(0,1fr)) !important;
  }
  .detail-panel-factura .factura-detail-actions-top .factura-action-mobile{
    order:-1;
    grid-column:1 / -1;
  }
  .detail-panel-factura .factura-detail-actions .btn{
    min-height:44px;
  }

  .detail-panel-factura .factura-lineas-detalle-table{
    min-width:0;
    border-collapse:separate;
    border-spacing:0;
  }
  .detail-panel-factura .factura-lineas-detalle-table thead{
    display:none;
  }
  .detail-panel-factura .factura-lineas-detalle-table,
  .detail-panel-factura .factura-lineas-detalle-table tbody,
  .detail-panel-factura .factura-lineas-detalle-table tr,
  .detail-panel-factura .factura-lineas-detalle-table td{
    display:block;
    width:100%;
  }
  .detail-panel-factura .factura-lineas-detalle-table tr{
    padding:var(--space-3);
    border:1px solid var(--color-border);
    border-radius:var(--radius-md);
    background:var(--color-surface);
    margin-bottom:var(--space-3);
  }
  .detail-panel-factura .factura-lineas-detalle-table tr:last-child{
    margin-bottom:0;
  }
  .detail-panel-factura .factura-lineas-detalle-table td{
    display:flex;
    justify-content:space-between;
    gap:var(--space-3);
    padding:0;
    border:0;
    text-align:right !important;
  }
  .detail-panel-factura .factura-lineas-detalle-table td:first-child{
    display:block;
    margin-bottom:var(--space-2);
    text-align:left !important;
    font-weight:650;
    overflow-wrap:anywhere;
  }
  .detail-panel-factura .factura-lineas-detalle-table td:first-child::before{
    display:none;
  }
  .detail-panel-factura .factura-lineas-detalle-table td + td{
    margin-top:var(--space-1);
  }
  .detail-panel-factura .factura-lineas-detalle-table td::before{
    content:attr(data-label);
    color:var(--color-text-muted);
    font-size:var(--text-xs);
    font-weight:700;
    text-transform:uppercase;
    letter-spacing:.06em;
  }
  .detail-panel-factura .factura-detalle-total{
    text-align:left;
    line-height:1.4;
  }
}

@media (max-width: 320px) {
  .modal-cobro .form-row.form-row-3,
  .modal-cobro .modal-actions {
    grid-template-columns: 1fr;
  }
  .modal-cobro .modal-actions .btn-primary {
    order: -1;
  }
}


/* Refuerzo final: mantener las tarjetas dobles del detalle de factura en dos columnas también en móvil. */
@media (max-width: 767px){
  .detail-panel-factura .factura-detail-data-item-pair,
  .detail-panel-factura .factura-detail-data-item-pair-force{
    display:grid !important;
    grid-template-columns:minmax(0,1fr) minmax(0,1fr) !important;
    column-gap:var(--space-3);
    row-gap:var(--space-2);
  }
  .detail-panel-factura .factura-detail-data-item-pair > .factura-detail-data-field,
  .detail-panel-factura .factura-detail-data-item-pair-force > .factura-detail-data-field{
    display:block !important;
    min-width:0;
  }
  .detail-panel-factura .factura-detail-data-field-right{
    text-align:right !important;
  }
  .detail-panel-factura .factura-detail-data-field-right .badge{
    justify-content:flex-end !important;
  }
  /* Detalle y edición de facturas en móvil */
  .detail-panel-factura .factura-lineas-detalle-table td.factura-linea-detalle-empty-mobile{
    display:none !important;
  }
  .detail-panel-factura .factura-detalle-total{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:var(--space-2);
    text-align:left;
    padding:var(--space-2) var(--space-3);
  }
  .detail-panel-factura .factura-detalle-total span,
  .detail-panel-factura .factura-detalle-total strong{
    min-width:0;
    white-space:normal;
  }
  .factura-linea-row{
    grid-template-columns:58px minmax(0,1fr) 58px 68px 34px;
  }
  .factura-linea-estilo{
    min-height:44px;
    padding:0 var(--space-1);
  }
}

@media (max-width: 360px){
  .detail-panel-factura .factura-detalle-total{
    grid-template-columns:1fr;
  }
  .factura-linea-row{
    grid-template-columns:54px minmax(0,1fr) 54px 62px 34px;
  }
}

/* 20260620v: detalle de factura más compacto en móvil */
@media (max-width: 767px){
  .detail-panel-factura .factura-detail-header h2{
    margin-bottom:var(--space-1);
    line-height:1.2;
  }
  .detail-panel-factura .factura-detail-header-date{
    font-size:var(--text-sm);
  }
  .detail-panel-factura .factura-detail-header-client,
  .detail-panel-factura .factura-detail-header-address{
    margin:0;
    line-height:1.3;
  }
  .detail-panel-factura .factura-detail-header-address{
    margin-top:2px;
    font-size:var(--text-xs);
  }

  .detail-panel-factura .factura-lineas-detalle-table tr{
    display:grid;
    grid-template-columns:repeat(3,minmax(0,1fr));
    gap:var(--space-2);
  }
  .detail-panel-factura .factura-lineas-detalle-table td{
    min-width:0;
  }
  .detail-panel-factura .factura-lineas-detalle-table td:first-child{
    grid-column:1 / -1;
    margin-bottom:0;
  }
  .detail-panel-factura .factura-lineas-detalle-table td:not(:first-child){
    display:block;
    margin-top:0;
    padding:var(--space-1) var(--space-2);
    border:1px solid var(--color-border);
    border-radius:var(--radius-sm);
    background:var(--color-surface-offset);
    text-align:center!important;
    white-space:nowrap;
  }
  .detail-panel-factura .factura-lineas-detalle-table td:not(:first-child)::before{
    display:inline;
    margin-right:4px;
  }
  .detail-panel-factura .factura-lineas-detalle-table td.factura-linea-detalle-empty-mobile{
    display:none!important;
  }

  .detail-panel-factura .factura-cobros-table tr{
    display:grid;
    grid-template-columns:minmax(0,1fr) auto;
    gap:var(--space-2) var(--space-3);
  }
  .detail-panel-factura .factura-cobros-table td{
    min-width:0;
  }
  .detail-panel-factura .factura-cobros-table td + td{
    margin-top:0;
  }
  .detail-panel-factura .factura-cobros-table td:nth-child(1){
    grid-column:1 / 2;
    grid-row:1;
    align-self:baseline;
  }
  .detail-panel-factura .factura-cobro-importe{
    grid-column:2 / 3;
    grid-row:1;
    align-self:baseline;
    margin-top:0!important;
    text-align:right!important;
    white-space:nowrap;
  }
  .detail-panel-factura .factura-cobros-table td:nth-child(2){
    grid-column:1 / -1;
    grid-row:2;
  }
  .detail-panel-factura .factura-cobro-actions-cell{
    grid-column:1 / -1;
    grid-row:3;
    margin-top:var(--space-1)!important;
  }
  .detail-panel-factura .factura-cobro-actions{
    gap:var(--space-2);
  }
  .detail-panel-factura .factura-cobro-btn{
    min-height:40px;
    justify-content:center;
    padding:var(--space-2) var(--space-3);
    font-size:var(--text-sm);
  }
}

