* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  background: #f8f9fa;
}

img,
svg,
video,
canvas {
  max-width: 100%;
  height: auto;
}

.container,
.container-fluid {
  width: min(100%, 1440px);
}

.login-page .container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 4vw, 2rem);
}

.login-wrapper {
  width: 100%;
  min-height: auto;
}

.login-card {
  width: min(100%, 28rem);
  border: none;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.login-card .card-body {
  padding: clamp(1rem, 3vw, 1.5rem);
}

.version-text {
  font-size: 0.8rem;
  color: #6c757d;
}

.main-container {
  width: min(100%, 1180px);
  margin: clamp(0.75rem, 3vw, 2.5rem) auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: clamp(1rem, 3vw, 1.5rem);
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

#btnLogout {
  flex: 0 0 auto;
}

.top-actions {
  align-items: center;
  display: flex;
  flex: 0 1 auto;
  gap: 0.75rem;
  justify-content: flex-end;
  min-width: 0;
}

.logged-user-field {
  align-items: center;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  color: #212529;
  display: inline-flex;
  gap: 0.5rem;
  max-width: min(42vw, 22rem);
  min-height: 2.375rem;
  min-width: 0;
  padding: 0.35rem 0.85rem;
}

.logged-user-label {
  color: #6c757d;
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.logged-user-name {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tab-pane,
.card,
.alert,
.modal-content {
  min-width: 0;
}

.tab-pane p,
.tab-pane li,
.card,
.alert,
.form-text,
.text-muted {
  overflow-wrap: anywhere;
}

.tab-pane > .d-flex,
.card-body > .d-flex {
  min-width: 0;
}

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.nav-tabs {
  gap: 0.5rem;
  overflow-x: auto;
  overflow-y: hidden;
  flex-wrap: nowrap;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}

.nav-tabs .nav-link {
  white-space: nowrap;
}

.tab-content-box {
  padding: clamp(1rem, 3vw, 1.5rem) 0 clamp(0.75rem, 2vw, 1rem);
  min-height: 250px;
}

.group-list {
  max-height: min(320px, 55vh);
  overflow-y: auto;
  background-color: #fff;
}

.group-list.group-list-loading {
  overflow: hidden;
  pointer-events: none;
  opacity: 0.7;
}

.api-toggle-btn {
  min-width: 48px;
}

#jobConfigModal .modal-body {
  max-height: calc(100dvh - 220px);
  overflow-y: auto;
}

#tabelaRegrasJob td,
#tabelaRegrasJob th {
  white-space: nowrap;
}

.table {
  min-width: 680px;
}

.version-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: #eef4ff;
  color: #0d6efd;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
}


.membros-filter-bar .btn,
.membros-filter-bar .form-control {
  min-height: 2.5rem;
}

.membros-filter-toggle {
  align-items: center;
  display: inline-flex;
  gap: 0.45rem;
  justify-content: center;
  white-space: nowrap;
}

.membros-filter-toggle-icon {
  align-items: center;
  border: 1px solid currentColor;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 700;
  height: 1.15rem;
  justify-content: center;
  line-height: 1;
  opacity: 0.45;
  width: 1.15rem;
}

.btn-check:checked + .membros-filter-toggle .membros-filter-toggle-icon {
  background: #fff;
  border-color: #fff;
  color: #198754;
  opacity: 1;
}

.gestao-table-wrap,
.membros-table-wrap {
  max-height: min(520px, 64vh);
  overflow: auto;
}

.mk-turma-card {
  background: #fff;
  color: inherit;
  transition: transform .15s ease, box-shadow .15s ease;
}

.mk-turma-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 .75rem 1.5rem rgba(31, 45, 61, .12) !important;
}

.mk-search-results {
  max-height: 240px;
  overflow-y: auto;
  top: 100%;
  z-index: 1080;
}

.gestao-panel {
  border: 1px solid #dee2e6;
  border-radius: 10px;
  overflow: hidden;
}

.gestao-subnav {
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  gap: 0.25rem;
  padding: 0.5rem;
}

.gestao-subnav .nav-link {
  border-radius: 7px;
  font-size: 0.9rem;
  padding: 0.45rem 0.8rem;
}

.gestao-subcontent {
  padding: 0.75rem;
}

.gestao-section-bar {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  min-width: 0;
}

.gestao-section-bar h5 {
  font-size: 1rem;
  line-height: 1.2;
  margin: 0;
}

.gestao-section-bar small {
  color: #6c757d;
  display: block;
  font-size: 0.78rem;
}

.gestao-permission-controls {
  align-items: end;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(18rem, 1fr) auto;
  margin-bottom: 0.75rem;
}

.gestao-panel .gestao-table-wrap {
  max-height: min(58vh, 470px);
}

.gestao-panel .table {
  font-size: 0.875rem;
  min-width: 760px;
}

.gestao-panel .table > :not(caption) > * > * {
  padding: 0.42rem 0.55rem;
}

.gestao-panel thead th {
  background: #fff;
  box-shadow: inset 0 -1px 0 #dee2e6;
  position: sticky;
  top: 0;
  z-index: 1;
}

.changelog-card {
  border-left: 4px solid #0d6efd !important;
}

.membro-row {
  cursor: pointer;
}

.membro-row:focus {
  outline: 2px solid #0d6efd;
  outline-offset: -2px;
}

.pessoa-results {
  position: absolute;
  z-index: 1080;
  width: calc(100% - 1.5rem);
  max-height: min(240px, 45vh);
  overflow-y: auto;
}

#membroModal .modal-content {
  max-height: calc(100dvh - 2rem);
}

#membroForm {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

#membroModal .modal-body {
  flex: 1 1 auto;
  max-height: none;
  min-height: 0;
  overflow-y: auto;
}

.membro-modal-tabs {
  border-bottom: 1px solid #dee2e6;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.75rem;
  scrollbar-width: thin;
}

.membro-modal-tabs .nav-link {
  border-radius: 7px;
  min-width: max-content;
  padding: 0.45rem 0.8rem;
}

.membro-modal-tab-content {
  min-height: 24rem;
}

.membro-form-section {
  min-height: 23rem;
}

.membro-classificacao-box {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  min-height: 100%;
  padding: 0.8rem 0.9rem;
}

.membro-section-label {
  color: #495057;
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.membro-vinculos-inline {
  justify-content: flex-start;
  margin-top: 0.55rem;
}

.membro-list-card,
.membro-detail-card {
  min-height: 30rem;
}

#listaFilhos .border-bottom:last-child {
  border-bottom: 0 !important;
}

#appVersionFooter {
  margin-block: 0.75rem 1.25rem;
}

@media (max-width: 991.98px) {
  .main-container {
    border-radius: 14px;
  }

  .top-bar {
    align-items: flex-start;
  }
}

@media (max-width: 767.98px) {
  .container-fluid {
    padding-inline: 0.65rem;
  }

  .main-container {
    margin-block: 0.65rem;
    border-radius: 14px;
  }

  .top-bar {
    flex-direction: column;
  }

  .top-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .logged-user-field {
    border-radius: 14px;
    justify-content: space-between;
    max-width: none;
    width: 100%;
  }

  #btnLogout {
    width: 100%;
  }

  .tab-pane > .d-flex,
  .card-body > .d-flex {
    align-items: stretch !important;
  }

  .tab-pane > .d-flex .btn,
  .card-body > .d-flex .btn,
  .tab-pane > .d-flex .d-flex,
  .card-body > .d-flex .d-flex {
    width: 100%;
  }

  .nav-tabs .nav-link {
    padding: 0.65rem 0.9rem;
  }

  .card-body,
  .modal-body {
    padding: 1rem !important;
  }

  .modal-dialog {
    margin: 0.65rem;
  }

  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-footer > * {
    width: 100%;
    margin: 0 !important;
  }

  .d-grid.gap-2,
  .card .d-grid {
    gap: 0.75rem !important;
  }

  .membros-filter-bar .col-sm-auto {
    width: 100%;
  }

  #membroModal .modal-content {
    max-height: calc(100dvh - 1.3rem);
  }

  .membro-modal-tabs {
    margin-inline: -0.25rem;
  }

  .membro-modal-tab-content,
  .membro-form-section {
    min-height: 0;
  }

  .membro-classificacao-box {
    min-height: auto;
  }

  .membro-vinculos-checks {
    display: grid;
    grid-template-columns: 1fr;
  }

  .membro-vinculos-checks .form-check-label {
    white-space: normal;
  }

  .table {
    font-size: 0.9rem;
  }

  .gestao-table-wrap,
  .membros-table-wrap,
  .table-responsive {
    margin-inline: -0.25rem;
    -webkit-overflow-scrolling: touch;
  }

  .gestao-subcontent {
    padding: 0.65rem;
  }

  .gestao-section-bar,
  .gestao-permission-controls {
    align-items: stretch;
    display: flex;
    flex-direction: column;
  }

  .gestao-section-bar .btn,
  .gestao-permission-controls .btn {
    width: 100%;
  }

  .gestao-panel .gestao-table-wrap {
    max-height: 60vh;
  }

  #filtrosPdfModal .modal-content {
    max-height: calc(100dvh - 1.3rem);
  }

  #filtrosPdfModal .modal-body {
    padding: 1rem !important;
  }

  #filtrosPdfModal .filtros-pdf-preview-box {
    max-height: 12rem;
  }

  .table-responsive::after,
  .gestao-table-wrap::after,
  .membros-table-wrap::after {
    color: #6c757d;
    content: "Deslize a tabela para ver mais colunas";
    display: block;
    font-size: 0.75rem;
    padding: 0.35rem 0.25rem 0;
  }
}

@media (max-width: 575.98px) {
  .login-page .container {
    padding: 0.75rem;
  }

  .login-card {
    border-radius: 14px;
  }

  .btn,
  .form-control,
  .form-select {
    min-height: 2.85rem;
  }

  .logged-user-field {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.15rem;
  }

  .logged-user-name {
    max-width: 100%;
  }

  .tab-content-box {
    padding-top: 1rem;
  }

  .row.g-4 {
    --bs-gutter-y: 1rem;
  }

  .pessoa-results {
    width: calc(100% - 1rem);
  }
}

.filtros-card .form-control,
.filtros-card .form-select,
.filtros-card .btn {
  min-height: 2.5rem;
}

.filtros-section {
  background: #f8faff;
  border: 1px solid #e7eefc;
  border-radius: 1rem;
  padding: 1rem;
}

.filtros-subtitle {
  color: #495057;
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.filtros-chip-group {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
}

.filtros-chip-group .btn {
  align-items: center;
  border-radius: 0.8rem;
  display: flex;
  justify-content: center;
  min-width: 0;
  text-align: center;
}

.filtros-chip-group-departamentos .btn {
  justify-content: flex-start;
  min-height: 3.75rem;
  padding: 0.75rem 0.9rem;
  text-align: left;
}

.filtros-chip-group-compact {
  grid-template-columns: repeat(auto-fit, minmax(7.75rem, 1fr));
}

.filtros-chip-group-compact .btn {
  min-width: 0;
}

.membro-vinculos-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.9rem;
  justify-content: flex-start;
  line-height: 1.2;
}

.membro-vinculos-checks .form-check {
  margin-right: 0;
  min-width: 0;
}

.membro-vinculos-checks .form-check-label {
  font-size: 0.86rem;
  white-space: nowrap;
}

.filtros-result-card {
  background: linear-gradient(135deg, #f8f9fa, #eef4ff);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 4.25rem;
}

.filtros-table-wrap {
  max-height: min(560px, 66vh);
  overflow: auto;
}

.filtros-pdf-fields {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}

#filtrosPdfModal .modal-content {
  max-height: calc(100dvh - 3.5rem);
}

#filtrosPdfForm {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
}

#filtrosPdfModal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#filtrosPdfModal .modal-footer {
  flex: 0 0 auto;
}

.filtros-pdf-field {
  align-items: center;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.85rem;
  display: flex;
  gap: 0.55rem;
  min-height: 2.75rem;
  padding: 0.65rem 0.8rem;
}

.filtros-pdf-field .form-check-input {
  flex: 0 0 auto;
  margin: 0;
}

.filtros-pdf-field .form-check-label {
  cursor: pointer;
  font-weight: 600;
  margin: 0;
}

.filtros-pdf-numbering {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 999px;
  padding: 0.45rem 0.85rem 0.45rem 2.75rem;
}

.filtros-pdf-numbering .form-check-input {
  margin-top: 0.15rem;
}

.filtros-pdf-preview-box {
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.85rem;
  max-height: 18rem;
  overflow: auto;
}

.filtros-pdf-preview-table {
  font-size: 0.8rem;
  min-width: 42rem;
}

.filtros-pdf-preview-table th {
  background: #f1f3f5;
  white-space: nowrap;
}

.filtros-pdf-preview-table th,
.filtros-pdf-preview-table td {
  vertical-align: top;
}

.observacao-pessoa-preview {
  height: 2.75rem;
  min-width: 9rem;
}

.whatsapp-job-card .form-control,
.whatsapp-job-card .form-select,
.whatsapp-job-card .btn {
  min-height: 2.5rem;
}

.whatsapp-job-selection-summary {
  background: #f8f9fa;
  min-width: 150px;
}

.whatsapp-job-people-wrap,
.whatsapp-job-list-wrap,
.whatsapp-job-detail-wrap {
  max-height: min(480px, 62vh);
  overflow: auto;
}

.whatsapp-job-message-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whatsapp-upload-preview {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.75rem;
  margin-top: 0.75rem;
  padding: 0.75rem;
}

.whatsapp-upload-preview-media {
  background: #fff;
  border-radius: 0.5rem;
  display: block;
  max-height: 260px;
  width: 100%;
}

img.whatsapp-upload-preview-media {
  object-fit: contain;
}
