:host {
  display: block;
  min-width: 0;
}

.table-card {
  border: 1px solid var(--pg-border, #dbe3ef);
  border-radius: var(--pg-radius-md, 14px);
  overflow: hidden;
  background: #fff;
  box-shadow: var(--pg-shadow-sm, 0 8px 18px rgba(15, 23, 42, 0.08));
}

.table-head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--pg-border, #dbe3ef);
  background: linear-gradient(180deg, #f8fbff, #ffffff 75%);
  display: grid;
  gap: 12px;
}

.table-head-left {
  display: grid;
  gap: 4px;

  h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--pg-text, #0f172a);
  }

  small {
    color: var(--pg-text-soft, #64748b);
    font-size: 12px;
    font-weight: 600;
  }
}

.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.segment-btn {
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  border-radius: 999px;
  background: #fff;
  color: var(--pg-text-muted, #475569);
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all 0.2s ease;

  &:focus-visible {
    outline: none;
    box-shadow: var(--pg-focus-ring, 0 0 0 3px rgba(31, 79, 214, 0.22));
  }
}

.segment-btn:hover {
  border-color: var(--pg-primary, #1f4fd6);
  color: var(--pg-primary-strong, #153caa);
}

.segment-btn.active {
  background: rgba(31, 79, 214, 0.12);
  border-color: rgba(31, 79, 214, 0.3);
  color: var(--pg-primary-strong, #153caa);
}

.segment-btn .count {
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 800;
  background: rgba(15, 23, 42, 0.08);
  color: var(--pg-text-muted, #475569);
}

.table-state {
  padding: 24px 16px;
  display: grid;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.state-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--pg-border, #dbe3ef);
  background: var(--pg-surface-alt, #f8fafc);
  color: var(--pg-text-muted, #475569);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

.state-copy {
  display: grid;
  gap: 4px;

  strong {
    color: var(--pg-text, #0f172a);
    font-size: 0.92rem;
    font-weight: 800;
  }

  span {
    color: var(--pg-text-soft, #64748b);
    font-size: 0.82rem;
    font-weight: 600;
  }
}

.table-state.error .state-icon {
  color: var(--pg-danger, #c52929);
  border-color: rgba(197, 41, 41, 0.32);
  background: rgba(197, 41, 41, 0.08);
}

.table-state.empty .state-icon {
  color: var(--pg-warning, #b4690e);
  border-color: rgba(180, 105, 14, 0.32);
  background: rgba(180, 105, 14, 0.1);
}

.skeleton-group {
  width: min(760px, 100%);
  display: grid;
  gap: 8px;
}

.skeleton-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr 1fr;
}

.skeleton-line {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e6edf8, #dbe6f3, #e6edf8);
  background-size: 240px 100%;
  animation: shimmer 1.3s infinite linear;
}

.parcelamentos-table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
}

.table-modern {
  width: max-content;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;

  thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 11px 10px;
    border-bottom: 1px solid var(--pg-border-strong, #c8d4e4);
    background: #f5f9ff;
    color: var(--pg-text-soft, #64748b);
    font-size: 0.67rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-weight: 800;
    white-space: nowrap;
    text-align: left;
  }

  tbody tr {
    transition: background 0.18s ease;
  }

  tbody tr:nth-child(even) {
    background: #f9fbff;
  }

  tbody tr:hover {
    background: rgba(31, 79, 214, 0.08);
  }

  td {
    padding: 11px 10px;
    border-bottom: 1px solid #e9eef6;
    font-size: 0.84rem;
    color: var(--pg-text, #0f172a);
    white-space: nowrap;
    text-align: left;
    vertical-align: middle;
  }
}

.table-row {
  cursor: default;
}

.nowrap {
  white-space: nowrap;
}

.col-ano {
  width: 90px;
}

.col-linha {
  width: 138px;
}

.col-cliente {
  width: 260px;
  max-width: 260px;
}

.col-status {
  width: 110px;
}

.col-parcela {
  width: 130px;
}

.col-valor {
  width: 150px;
  text-align: right;
}

.col-acoes {
  width: 152px;
  min-width: 152px;
  text-align: center;
}

.table-modern thead .col-ano,
.table-modern thead .col-linha,
.table-modern thead .col-cliente,
.table-modern thead .col-status,
.table-modern thead .col-parcela,
.table-modern thead .col-acoes,
.table-modern tbody .col-ano,
.table-modern tbody .col-linha,
.table-modern tbody .col-cliente,
.table-modern tbody .col-status,
.table-modern tbody .col-parcela,
.table-modern tbody .col-acoes {
  text-align: center;
}

.text-end {
  text-align: right;
}

.text-center {
  text-align: center;
}

.text-blue {
  color: var(--pg-primary-strong, #153caa);
}

.text-danger {
  color: var(--pg-danger, #c52929);
}

.text-muted {
  color: var(--pg-text-muted, #475569);
}

.fw-bold {
  font-weight: 700;
}

.fw-black {
  font-weight: 800;
}

.money-strong {
  color: var(--pg-primary, #1f4fd6);
  font-weight: 800;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid #d5dfef;
  background: #f2f6fc;
  color: #334155;
  font-size: 11px;
  font-weight: 800;
}

.status-ativos {
  background: rgba(28, 122, 62, 0.14);
  color: #1c7a3e;
  border-color: rgba(28, 122, 62, 0.28);
}

.status-futuros {
  background: rgba(31, 79, 214, 0.12);
  color: #1f4fd6;
  border-color: rgba(31, 79, 214, 0.28);
}

.status-finalizados {
  background: rgba(197, 41, 41, 0.12);
  color: #b42323;
  border-color: rgba(197, 41, 41, 0.25);
}

.action-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border: 1px solid #cfd9e9;
  border-radius: 10px;
  background: #eff4ff;
  color: var(--pg-primary-strong, #153caa);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s ease;

  &:hover {
    transform: translateY(-1px);
    border-color: var(--pg-primary, #1f4fd6);
    background: #e3edff;
  }

  &:focus-visible {
    outline: none;
    box-shadow: var(--pg-focus-ring, 0 0 0 3px rgba(31, 79, 214, 0.22));
  }
}

.btn-icon.ghost {
  background: #f4f6fb;
  color: #475569;
}

.btn-icon.danger {
  background: rgba(197, 41, 41, 0.12);
  color: #b42323;
  border-color: rgba(197, 41, 41, 0.22);
}

.table-footer {
  border-top: 1px solid var(--pg-border, #dbe3ef);
  background: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.page-info {
  color: var(--pg-text-muted, #475569);
  font-size: 12px;
  font-weight: 700;
}

.pagination {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-ghost.icon-only,
.btn-page {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  background: #fff;
  color: var(--pg-text, #0f172a);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;

  &:focus-visible {
    outline: none;
    box-shadow: var(--pg-focus-ring, 0 0 0 3px rgba(31, 79, 214, 0.22));
  }

  &:disabled {
    opacity: 0.55;
    cursor: not-allowed;
  }
}

.btn-page.active {
  color: #fff;
  border-color: var(--pg-primary-strong, #153caa);
  background: linear-gradient(140deg, var(--pg-primary, #1f4fd6), var(--pg-primary-strong, #153caa));
}

.page-size {
  display: inline-flex;
  align-items: center;
  gap: 8px;

  span {
    color: var(--pg-text-soft, #64748b);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 800;
  }
}

.select-glass {
  min-width: 76px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--pg-border-strong, #c8d4e4);
  background: #fff;
  color: var(--pg-text, #0f172a);
  font-weight: 700;
  padding: 0 8px;
}

@keyframes shimmer {
  0% {
    background-position: -120px 0;
  }

  100% {
    background-position: 120px 0;
  }
}

@media (max-width: 1180px) {
  .table-modern {
    min-width: 1020px;
  }

  .col-cliente {
    width: 210px;
    max-width: 210px;
  }
}

@media (max-width: 760px) {
  .table-head,
  .table-footer {
    padding-left: 12px;
    padding-right: 12px;
  }

  .segmented {
    width: 100%;
  }

  .segment-btn {
    flex: 1;
    justify-content: space-between;
    min-width: 0;
  }

  .table-footer {
    justify-content: center;
  }

  .page-size {
    width: 100%;
    justify-content: center;
  }
}
