/**
 * Zenty Emite 2.0 · Resumen operativo de boletas
 * Versión 15.0.0
 */

body.zenty-boletas-page .zenty-payment-field select {
  width: 100%;
  min-width: 0;
  min-height: 41px;
  padding: 0.55rem 0.7rem;
  border: 1px solid #ccdde1;
  border-radius: 10px;
  background: #fff;
  color: #16343b;
  font: inherit;
}

body.zenty-boletas-page .zenty-payment-field select:focus {
  outline: none;
  border-color: #14b8a6;
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
}

body.zenty-boletas-page .zenty-summary-header-label {
  display: none;
}

body.zenty-boletas-page .zenty-sales-summary {
  display: grid;
  gap: 0.7rem;
  min-width: 0;
}

body.zenty-boletas-page .zenty-summary-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.62rem 0.75rem;
  border: 1px solid #dce8ea;
  border-radius: 12px;
  background: #f7fbfb;
}

body.zenty-boletas-page .zenty-summary-toolbar > div {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  color: #60757b;
  font-size: 0.75rem;
}

body.zenty-boletas-page .zenty-summary-toolbar strong {
  color: #0f766e;
  font-size: 1rem;
}

body.zenty-boletas-page .zenty-technical-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 34px;
  padding: 0.42rem 0.65rem;
  border: 1px solid #b9ced2;
  border-radius: 9px;
  background: #fff;
  color: #31545b;
  font-size: 0.72rem;
  font-weight: 650;
  cursor: pointer;
  transition: 0.18s ease;
}

body.zenty-boletas-page .zenty-technical-toggle:hover,
body.zenty-boletas-page .zenty-technical-toggle.is-active {
  border-color: #0f766e;
  background: #e8f8f6;
  color: #0f766e;
}

body.zenty-boletas-page .zenty-technical-history {
  display: none !important;
  margin-top: 0.8rem;
}

body.zenty-boletas-page .panel-card.zenty-show-technical .zenty-technical-history {
  display: block !important;
}

body.zenty-boletas-page .zenty-summary-table-wrap {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
  border: 1px solid #d7e4e7;
  border-radius: 14px;
  background: #fff;
}

body.zenty-boletas-page .zenty-summary-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
  color: #18363d;
  font-size: 0.75rem;
}

body.zenty-boletas-page .zenty-summary-table th {
  padding: 0.72rem 0.65rem;
  border-bottom: 1px solid #cedde0;
  background: #edf4f5;
  color: #35565d;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: left;
  white-space: nowrap;
}

body.zenty-boletas-page .zenty-summary-table td {
  padding: 0.62rem 0.65rem;
  border-bottom: 1px solid #e5edef;
  vertical-align: middle;
  white-space: nowrap;
}

body.zenty-boletas-page .zenty-summary-table tbody tr:nth-child(even) {
  background: #f7fafb;
}

body.zenty-boletas-page .zenty-summary-table tbody tr:hover {
  background: #edf9f7;
}

body.zenty-boletas-page .zenty-summary-table tbody tr:last-child td {
  border-bottom: 0;
}

body.zenty-boletas-page .zenty-summary-table td:nth-child(2) {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.zenty-boletas-page .zenty-doc-code {
  display: inline-grid;
  place-items: center;
  min-width: 25px;
  height: 25px;
  border-radius: 8px;
  background: #e9f3f4;
  color: #0f766e;
  font-weight: 800;
}

body.zenty-boletas-page .zenty-payment-badge,
body.zenty-boletas-page .zenty-status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  padding: 0.28rem 0.48rem;
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 700;
  white-space: nowrap;
}

body.zenty-boletas-page .zenty-payment-badge {
  border: 1px solid #d7e3e6;
  background: #f6f9fa;
  color: #45636a;
}

body.zenty-boletas-page .zenty-status-badge.is-approved {
  background: #dcfce7;
  color: #166534;
}

body.zenty-boletas-page .zenty-status-badge.is-process {
  background: #e0f2fe;
  color: #075985;
}

body.zenty-boletas-page .zenty-summary-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

body.zenty-boletas-page .zenty-summary-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  min-width: 31px;
  height: 31px;
  padding: 0 0.38rem;
  border: 1px solid transparent;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.61rem;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease;
}

body.zenty-boletas-page .zenty-summary-action:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 5px 13px rgba(29, 53, 59, 0.14);
}

body.zenty-boletas-page .zenty-summary-action:disabled {
  opacity: 0.34;
  cursor: not-allowed;
}

body.zenty-boletas-page .zenty-summary-action.is-view {
  border-color: #b9c9cd;
  background: #fff;
  color: #203f46;
  font-size: 0.9rem;
}

body.zenty-boletas-page .zenty-summary-action.is-pdf {
  background: #df2638;
  color: #fff;
}

body.zenty-boletas-page .zenty-summary-action.is-xml {
  background: #1f2937;
  color: #fff;
}

body.zenty-boletas-page .zenty-summary-action.is-nc {
  background: #fff4e6;
  color: #c55a05;
  font-size: 0.82rem;
}

body.zenty-boletas-page .zenty-summary-empty {
  padding: 1.5rem !important;
  color: #71868b;
  text-align: center;
}

/* Modal de contenido DTE */
.zenty-modal-open {
  overflow: hidden !important;
}

.zenty-dte-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
}

.zenty-dte-modal.is-open {
  display: grid;
  place-items: center;
}

.zenty-dte-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 34, 39, 0.62);
  backdrop-filter: blur(5px);
}

.zenty-dte-modal__dialog {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(920px, calc(100vw - 2rem));
  max-height: min(88vh, 820px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(5, 25, 31, 0.34);
}

.zenty-dte-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid #dce7e9;
  background: linear-gradient(135deg, #f1fbfa, #fff);
}

.zenty-dte-modal__header span {
  color: #0f766e;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.11em;
}

.zenty-dte-modal__header h3 {
  margin: 0.16rem 0 0;
  color: #17383f;
  font-size: 1.12rem;
}

.zenty-icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid #c9dadd;
  border-radius: 10px;
  background: #fff;
  color: #274950;
  cursor: pointer;
}

.zenty-dte-modal__body {
  overflow: auto;
  padding: 1rem 1.15rem 1.2rem;
}

.zenty-dte-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
}

.zenty-dte-summary-grid > div {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
  padding: 0.68rem;
  border: 1px solid #dfe9eb;
  border-radius: 12px;
  background: #f8fbfb;
}

.zenty-dte-summary-grid span,
.zenty-dte-totals span {
  color: #6d8186;
  font-size: 0.64rem;
}

.zenty-dte-summary-grid strong {
  overflow: hidden;
  color: #1a3d44;
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zenty-dte-detail-block {
  margin-top: 0.9rem;
}

.zenty-dte-detail-block h4 {
  margin: 0 0 0.55rem;
  color: #24484f;
  font-size: 0.82rem;
}

.zenty-dte-lines {
  overflow: hidden;
  border: 1px solid #dfe8ea;
  border-radius: 13px;
}

.zenty-dte-line {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 70px 100px;
  align-items: center;
  gap: 0.55rem;
  padding: 0.62rem 0.7rem;
  border-bottom: 1px solid #e6edef;
  font-size: 0.72rem;
}

.zenty-dte-line:last-child {
  border-bottom: 0;
}

.zenty-dte-line__number {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #e7f6f4;
  color: #0f766e;
  font-weight: 800;
}

.zenty-dte-line div {
  display: grid;
  min-width: 0;
}

.zenty-dte-line div strong,
.zenty-dte-line div small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zenty-dte-line div small {
  color: #789096;
}

.zenty-dte-totals {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin-top: 0.85rem;
}

.zenty-dte-totals > div {
  display: grid;
  gap: 0.15rem;
  padding: 0.62rem;
  border: 1px solid #dfe8ea;
  border-radius: 11px;
  background: #fff;
}

.zenty-dte-totals .is-total {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
}

.zenty-dte-totals .is-total span,
.zenty-dte-totals .is-total strong {
  color: #fff;
}

.zenty-dte-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.95rem;
}

.zenty-modal-action {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 35px;
  padding: 0.46rem 0.68rem;
  border: 1px solid #c7d6d9;
  border-radius: 9px;
  background: #fff;
  color: #294a51;
  font-family: inherit;
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
}

.zenty-modal-action.is-pdf {
  border-color: #e33243;
  background: #e33243;
  color: #fff;
}

.zenty-modal-action.is-sii {
  border-color: #0f766e;
  background: #0f766e;
  color: #fff;
}

.zenty-modal-action.is-nc {
  border-color: #ed7900;
  background: #ed7900;
  color: #fff;
}

.zenty-modal-action:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.zenty-modal-loading,
.zenty-modal-error {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 180px;
  color: #5d747a;
}

.zenty-modal-error {
  color: #b42333;
}

.zenty-spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: zenty-spin 0.7s linear infinite;
}

@keyframes zenty-spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1100px) {
  .zenty-dte-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body.zenty-boletas-page .zenty-summary-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  body.zenty-boletas-page .zenty-technical-toggle {
    justify-content: center;
  }

  body.zenty-boletas-page .zenty-summary-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  body.zenty-boletas-page .zenty-summary-table {
    min-width: 0;
  }

  body.zenty-boletas-page .zenty-summary-table thead {
    display: none;
  }

  body.zenty-boletas-page .zenty-summary-table,
  body.zenty-boletas-page .zenty-summary-table tbody,
  body.zenty-boletas-page .zenty-summary-table tr,
  body.zenty-boletas-page .zenty-summary-table td {
    display: block;
    width: 100%;
  }

  body.zenty-boletas-page .zenty-summary-table tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 0.7rem;
    overflow: hidden;
    border: 1px solid #d7e4e7;
    border-radius: 14px;
    background: #fff !important;
  }

  body.zenty-boletas-page .zenty-summary-table td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    align-items: center;
    gap: 0.35rem;
    min-height: 43px;
    padding: 0.52rem 0.62rem;
    border-bottom: 1px solid #e6edef;
    white-space: normal;
  }

  body.zenty-boletas-page .zenty-summary-table td::before {
    content: attr(data-label);
    color: #72868b;
    font-size: 0.61rem;
    font-weight: 700;
  }

  body.zenty-boletas-page .zenty-summary-table td:nth-child(2),
  body.zenty-boletas-page .zenty-summary-table td:nth-child(7),
  body.zenty-boletas-page .zenty-summary-table td:last-child {
    grid-column: 1 / -1;
  }

  body.zenty-boletas-page .zenty-summary-table td:last-child {
    border-bottom: 0;
  }

  body.zenty-boletas-page .zenty-summary-actions {
    justify-content: flex-end;
  }

  .zenty-dte-modal__dialog {
    width: calc(100vw - 1rem);
    max-height: calc(100vh - 1rem);
    border-radius: 15px;
  }

  .zenty-dte-summary-grid,
  .zenty-dte-totals {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .zenty-dte-line {
    grid-template-columns: 28px minmax(0, 1fr) 65px;
  }

  .zenty-dte-line > strong:last-child {
    grid-column: 2 / -1;
    text-align: right;
  }
}

@media (max-width: 480px) {
  body.zenty-boletas-page .zenty-summary-table tr {
    grid-template-columns: 1fr;
  }

  body.zenty-boletas-page .zenty-summary-table td,
  body.zenty-boletas-page .zenty-summary-table td:nth-child(2),
  body.zenty-boletas-page .zenty-summary-table td:nth-child(7),
  body.zenty-boletas-page .zenty-summary-table td:last-child {
    grid-column: 1;
  }

  .zenty-dte-summary-grid,
  .zenty-dte-totals {
    grid-template-columns: 1fr;
  }

  .zenty-dte-modal-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .zenty-modal-action {
    justify-content: center;
  }
}
