.table-box table {
  min-width: 1540px;
  table-layout: fixed;
}

.table-box th {
  padding: 13px 9px;
  font-size: 11px;
  letter-spacing: 0.025em;
}

.table-box td {
  padding: 13px 9px;
  overflow-wrap: anywhere;
}

.table-box th:nth-child(1) { width: 120px; }
.table-box th:nth-child(2) { width: 150px; }
.table-box th:nth-child(3) { width: 150px; }
.table-box th:nth-child(4) { width: 190px; }
.table-box th:nth-child(5) { width: 115px; }
.table-box th:nth-child(6) { width: 145px; }
.table-box th:nth-child(7) { width: 125px; }
.table-box th:nth-child(8) { width: 180px; }
.table-box th:nth-child(9) { width: 125px; }
.table-box th:nth-child(10) { width: 120px; }
.table-box th:nth-child(11) { width: 150px; }

@media (max-width: 900px) {
  .table-box table { min-width: 1480px; }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 20, 27, 0.68);
  backdrop-filter: blur(6px);
}

.modal-card {
  width: min(940px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 24px;
  border: 1px solid #fff8;
  border-radius: 22px;
  background: #f6f8f9;
  box-shadow: 0 30px 90px #0008;
}

.modal-title { display: flex; justify-content: space-between; gap: 20px; }
.modal-title h2 { margin: 0; font-size: 25px; }
.modal-title p { margin: 5px 0 0; color: #667680; }
.modal-close { border: 0; background: transparent; font-size: 34px; cursor: pointer; color: #53646e; }
.user-form { display: grid; grid-template-columns: 1.4fr 1fr .8fr 1fr 1.1fr auto; align-items: end; gap: 10px; margin: 22px 0; }
.user-form label { font-size: 12px; font-weight: 800; color: #576872; }
.user-form input, .user-form select { width: 100%; margin-top: 5px; padding: 11px; border: 1px solid #becbd2; border-radius: 9px; background: white; font-size: 14px; }
.form-error { grid-column: 1 / -1; min-height: 18px; color: #b83232; font-size: 13px; font-weight: 700; }
.users-list-wrap { overflow-x: auto; border: 1px solid #cad5da; border-radius: 13px; }
.users-table { width: 100%; min-width: 640px; table-layout: auto; }
.users-table th, .users-table td { padding: 12px; }
.users-table th { position: static; }
.users-table .disabled { opacity: .55; }
.role-pill { display: inline-block; padding: 5px 9px; border-radius: 999px; background: #dfe7eb; font-size: 12px; font-weight: 800; }
.access-button { border: 0; border-radius: 8px; padding: 8px 10px; cursor: pointer; font-weight: 800; }
.access-on { color: #176e51; background: #dff2e9; }
.access-off { color: #a83d3d; background: #f7dfdf; }

@media (max-width: 1100px) {
  .user-form { grid-template-columns: 1fr 1fr; }
  .user-form .button { width: 100%; }
}

/* Wide operational table: preserve readability instead of squeezing columns. */
.table-box table {
  min-width: 1980px;
  table-layout: fixed;
}

.table-box th {
  padding: 13px 11px;
  font-size: 11px;
  letter-spacing: 0.02em;
}

.table-box td {
  padding: 14px 11px;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: normal;
}

.table-box th:nth-child(1) { width: 145px; }
.table-box th:nth-child(2) { width: 185px; }
.table-box th:nth-child(3) { width: 180px; }
.table-box th:nth-child(4) { width: 235px; }
.table-box th:nth-child(5) { width: 145px; }
.table-box th:nth-child(6) { width: 180px; }
.table-box th:nth-child(7) { width: 155px; }
.table-box th:nth-child(8) { width: 270px; }
.table-box th:nth-child(9) { width: 150px; }
.table-box th:nth-child(10) { width: 155px; }
.table-box th:nth-child(11) { width: 180px; }

.table-box .controls { max-width: none; }
.table-box .control-item { overflow-wrap: anywhere; line-height: 1.35; }
.table-box .status { white-space: normal; max-width: 100%; line-height: 1.15; text-align: left; }

/* KBF standalone safe area */
@media (display-mode: standalone) {
  #app > header {
    height: auto;
    min-height: calc(102px + env(safe-area-inset-top, 0px));
    padding-top: calc(22px + env(safe-area-inset-top, 0px));
  }
  #login, #usersModal {
    padding-top: calc(22px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  }
}
@media (display-mode: standalone) and (max-width: 900px) {
  #app > header {
    min-height: 0;
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
  }
}

/* KBF mobile width containment */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}
#app, #app > main, .workspace {
  min-width: 0;
  max-width: 100%;
}
.table-box {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
@media (max-width: 900px) {
  #app > header {
    flex-wrap: wrap;
    gap: 14px;
  }
  .brand {
    flex: 1 1 100%;
    min-width: 0;
  }
  .brand strong, .brand span {
    overflow-wrap: anywhere;
  }
  .header-actions {
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
    gap: 10px;
  }
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .stats article {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .search-wrap, .search-wrap input {
    min-width: 0;
  }
  .toolbar > .button {
    flex: 1 1 calc(50% - 10px);
    min-width: 0;
    white-space: normal;
  }
}
