/* Focused layout safeguards for COOGESP screens. Loaded after page-level CSS. */
.main,
.content,
.section,
.card,
.card-header,
.topbar,
.topbar-title,
.topbar-right,
.sidebar,
.table-wrap,
.live-sidebar,
.map-panel,
.modal,
.modal-header,
.modal-body {
  min-width: 0;
}

.content,
.section {
  max-width: 100%;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

.table-wrap > table {
  min-width: 640px;
}

.admin-page #section-attendance .table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border: 1px solid #b7c9c4;
  border-radius: 10px;
}

.admin-page #section-attendance #attendanceTable {
  width: 100%;
  min-width: 1200px;
  table-layout: fixed;
  border-collapse: collapse;
  background: #fbfcfa;
  font-size: 13px;
}

.admin-page #section-attendance #attendanceTable th,
.admin-page #section-attendance #attendanceTable td {
  min-width: 0;
  padding: 12px 11px;
  vertical-align: middle;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
  border-right: 1px solid #d2ded9 !important;
  border-bottom: 1px solid #ccd9d4 !important;
}

.admin-page #section-attendance #attendanceTable th {
  background: #164e63 !important;
  color: #fff !important;
  border-color: #426b78 !important;
  border-bottom: 3px solid #0d3948 !important;
  font-size: 11px;
  line-height: 1.35;
  font-weight: 750;
  letter-spacing: .035em;
}

.admin-page #section-attendance #attendanceTable th:nth-child(1) { width: 14%; }
.admin-page #section-attendance #attendanceTable th:nth-child(2) { width: 12%; }
.admin-page #section-attendance #attendanceTable th:nth-child(3) { width: 11%; }
.admin-page #section-attendance #attendanceTable th:nth-child(4) { width: 9%; }
.admin-page #section-attendance #attendanceTable th:nth-child(5) { width: 9%; }
.admin-page #section-attendance #attendanceTable th:nth-child(6) { width: 11%; }
.admin-page #section-attendance #attendanceTable th:nth-child(7) { width: 6%; }
.admin-page #section-attendance #attendanceTable th:nth-child(8) { width: 13%; }
.admin-page #section-attendance #attendanceTable th:nth-child(9) { width: 15%; }

.admin-page #section-attendance #attendanceTable td {
  line-height: 1.45;
}

.admin-page #section-attendance #attendanceTable tbody tr:nth-child(odd) {
  background: #fbfcfa;
}

.admin-page #section-attendance #attendanceTable tbody tr:nth-child(even) {
  background: #f0f5f2;
}

.admin-page #section-attendance #attendanceTable tbody td:first-child strong {
  display: inline-block;
  margin-bottom: 2px;
  color: #17323a;
  font-weight: 750;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.admin-page #section-attendance #attendanceTable td code,
.admin-page #section-attendance #attendanceTable td small {
  white-space: normal;
  overflow-wrap: anywhere;
}

.admin-page #section-attendance #attendanceTable td .badge {
  white-space: normal;
  line-height: 1.35;
}

.admin-page #section-attendance #attendanceTable td:last-child .btn {
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}

.modal-overlay {
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal {
  width: min(100%, 960px);
  max-height: calc(100dvh - 32px);
  overflow: auto;
  overscroll-behavior: contain;
}

/* Form controls and grid children must be allowed to shrink below intrinsic widths. */
.admin-page .service-form-grid {
  grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr));
}
@media (max-width: 1100px) {
  .admin-page .service-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 768px) {
  .admin-page .service-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.service-form-grid input:not([type="checkbox"]):not([type="radio"]),
.service-form-grid select,
.service-form-grid textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.modal .coren-registration {
  grid-column: 1 / -1;
  min-width: 0;
  max-width: 100%;
}

.modal .coren-registration-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  min-width: 0;
}

.modal,
.modal *,
.admin-page .form-grid,
.employee-page .form-grid,
.admin-page .service-form-grid,
.employee-page .service-form-grid {
  box-sizing: border-box;
}

.admin-page .form-grid,
.employee-page .form-grid,
.admin-page .service-form-grid,
.employee-page .service-form-grid,
.modal .form-grid {
  min-width: 0;
  max-width: 100%;
}

.admin-page .form-grid > *,
.employee-page .form-grid > *,
.admin-page .service-form-grid > *,
.employee-page .service-form-grid > *,
.modal .form-grid > *,
.form-group {
  min-width: 0;
  max-width: 100%;
}

.modal input:not([type="checkbox"]):not([type="radio"]),
.modal select,
.modal textarea,
.admin-page .form-group input:not([type="checkbox"]):not([type="radio"]),
.admin-page .form-group select,
.admin-page .form-group textarea,
.employee-page .form-group input:not([type="checkbox"]):not([type="radio"]),
.employee-page .form-group select,
.employee-page .form-group textarea {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.modal textarea,
.admin-page .form-group textarea,
.employee-page .form-group textarea {
  resize: vertical;
}

.modal .form-group label,
.modal .form-group small,
.admin-page .form-group label,
.admin-page .form-group small,
.employee-page .form-group label,
.employee-page .form-group small {
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}

.modal,
.modal-header,
.modal-body,
.modal-footer {
  min-width: 0;
}

.modal-footer .btn {
  min-width: 0;
  max-width: 100%;
}

/* Normalize inline 1fr tracks; their implicit auto minimum can exceed the modal. */
.modal .form-grid[style*="grid-template-columns:1fr 1fr 1fr"],
.modal .form-grid[style*="grid-template-columns: 1fr 1fr 1fr"] {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.modal .form-grid[style*="grid-template-columns:1fr 1fr"]:not([style*="1fr 1fr 1fr"]),
.modal .form-grid[style*="grid-template-columns: 1fr 1fr"]:not([style*="1fr 1fr 1fr"]) {
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.modal-close {
  flex: 0 0 auto;
  min-width: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-header,
.modal-footer {
  flex-wrap: wrap;
  gap: 10px;
}

.modal-header > :first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal-header > div {
  min-width: 0;
  max-width: 100%;
  flex-wrap: wrap;
}

@media (min-width: 769px) {
  .admin-page .sidebar-logo {
    padding: 18px 16px 14px;
  }

  .admin-page .sidebar-logo img,
  .employee-page .sidebar-logo img {
    display: block;
    width: min(100%, 184px);
    height: auto;
    padding: 7px;
    border: 1px solid rgba(14, 116, 144, 0.24);
    border-radius: 14px;
    background: #f5fbfc;
    box-shadow: 0 3px 12px rgba(15, 74, 91, 0.14), inset 0 0 0 3px rgba(255,255,255,.82);
    object-fit: contain;
  }
}

@media (max-width: 1024px) {
  .admin-page .content,
  .employee-page .content {
    padding-right: 22px;
    padding-left: 22px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  }

  .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  }
}

@media (max-width: 768px) {
  .admin-page .main {
    width: calc(100% - 70px);
    margin-left: 70px;
  }

  .employee-page .main {
    width: calc(100% - 60px);
    margin-left: 60px;
  }

  .admin-page .sidebar,
  .employee-page .sidebar {
    overflow: hidden;
    height: 100dvh;
  }

  .sidebar-footer {
    display: block;
    padding: 8px;
  }

  .sidebar-footer .btn-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    font-size: 0;
  }

  .sidebar-footer .btn-logout i {
    font-size: 16px;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
  }

  .admin-page .sidebar-logo,
  .employee-page .sidebar-logo {
    padding: 12px 8px;
    display: flex;
    justify-content: center;
  }

  .admin-page .sidebar-logo img,
  .employee-page .sidebar-logo img {
    display: block;
    width: 46px;
    max-width: 100%;
    height: auto;
    padding: 3px;
    border: 1px solid rgba(14, 116, 144, 0.24);
    border-radius: 9px;
    background: #f5fbfc;
    box-shadow: 0 2px 7px rgba(15, 74, 91, 0.12);
    object-fit: contain;
  }

  .admin-page .topbar,
  .employee-page .topbar {
    min-height: 58px;
    height: auto;
    padding: 10px 16px;
    gap: 10px;
    flex-wrap: wrap;
  }

  .admin-page .topbar-title,
  .employee-page .topbar-title {
    font-size: clamp(14px, 3vw, 17px);
    overflow-wrap: anywhere;
  }

  .admin-page .topbar-right,
  .employee-page .topbar-right {
    margin-left: auto;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .admin-page .content,
  .employee-page .content {
    padding: 16px;
  }

  .admin-page .stats-grid,
  .employee-page .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  }

  .card,
  .checkin-panel,
  .profile-card {
    padding: 18px;
  }

  .filter-bar,
  .report-filter,
  .checkin-actions {
    flex-wrap: wrap;
  }

  .filter-bar > *,
  .report-filter > * {
    min-width: 0;
    max-width: 100%;
  }

  .modal-overlay {
    align-items: flex-start;
    padding: 10px;
  }

  .modal {
    width: 100% !important;
    max-width: none !important;
    max-height: calc(100dvh - 20px);
    border-radius: 14px;
  }

  .modal-header {
    padding: 14px 16px;
    border-radius: 14px 14px 0 0;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    justify-content: flex-start;
  }

  .modal-footer .btn {
    flex: 1 1 auto;
    justify-content: center;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .modal .form-grid[style*="grid-template-columns:1fr 1fr 1fr"],
  .modal .form-grid[style*="grid-template-columns: 1fr 1fr 1fr"],
  .modal .form-grid[style*="grid-template-columns:1fr 1fr"]:not([style*="1fr 1fr 1fr"]),
  .modal .form-grid[style*="grid-template-columns: 1fr 1fr"]:not([style*="1fr 1fr 1fr"]) {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .lgpd-box {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .lgpd-header,
  .lgpd-scroll-area,
  .lgpd-footer {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (max-width: 560px) {
  .admin-page .topbar,
  .employee-page .topbar {
    align-items: flex-start;
  }

  .admin-page .topbar-title,
  .employee-page .topbar-title {
    flex: 1 1 100%;
  }

  .admin-page .topbar-right,
  .employee-page .topbar-right {
    margin-left: 0;
  }

  .admin-page .content,
  .employee-page .content {
    padding: 12px;
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .card,
  .checkin-panel,
  .profile-card {
    padding: 15px;
    border-radius: 13px;
  }

  .card-header {
    align-items: flex-start;
  }

  .tabs {
    overflow-x: auto;
    overscroll-behavior-x: contain;
  }

  .tab {
    flex: 0 0 auto;
    padding-right: 12px;
    padding-left: 12px;
  }

  .modal-overlay {
    padding: 6px;
  }

  .modal {
    max-height: calc(100dvh - 12px);
  }

  .modal-body {
    padding: 12px;
  }

  .modal-footer .btn {
    flex-basis: 100%;
  }

  .toast,
  #toast {
    right: 10px;
    bottom: 10px;
    left: 10px;
    min-width: 0;
    width: auto;
  }
}

@media (max-width: 860px) {
  .login-page {
    overflow-y: auto;
  }

  .login-page .topbar {
    min-height: 56px;
    height: auto;
    padding: 8px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .login-page .tb-left {
    min-width: 0;
    flex: 1 1 auto;
    gap: 8px;
  }

  .login-page .tb-logo {
    height: 30px;
    flex: 0 0 auto;
  }

  .login-page .tb-name {
    font-size: 11px;
    line-height: 1.2;
  }

  .login-page .tb-right {
    gap: 6px;
    flex: 0 1 auto;
  }

  .login-page .tb-clock {
    padding: 4px 7px;
    font-size: 10px;
    white-space: nowrap;
  }

  .login-page .tb-badge {
    padding: 4px 8px;
    font-size: 10px;
  }

  .login-page .center-stage {
    position: absolute;
    top: 90px;
    bottom: 90px;
    min-height: 0;
    padding: 12px 0;
    overflow-y: auto;
    align-items: center;
    align-items: safe center;
  }

  .login-page .glass-wrap {
    width: min(470px, calc(100vw - 24px));
    flex: 0 0 auto;
  }

  .login-page .glass-card {
    padding: 26px 22px 24px;
  }

  .login-page .feat-strip {
    height: auto;
    min-height: 76px;
    padding: 8px 10px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .login-page .feat-chip {
    min-width: 0;
    justify-content: center;
    padding: 5px 6px;
    gap: 5px;
  }

  .login-page .chip-r {
    min-width: 0;
  }

  .login-page .chip-txt {
    font-size: 9px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 360px) {
  .login-page .tb-clock {
    display: none;
  }

  .login-page .center-stage {
    top: 62px;
    bottom: 88px;
  }

  .login-page .glass-card {
    padding: 22px 16px 22px;
  }

  .login-page .card-title {
    font-size: 25px;
  }

  .login-page .feat-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-height: 92px;
  }
}
