#User_Permit_Modal .modal-content {
  border: none;
  border-radius: .6rem;
  box-shadow: 0 24px 60px rgba(0,0,0,.22);
}

/* ── Header ── */
#User_Permit_Modal .perm-header-bg {
  background: linear-gradient(135deg, #0f2847 0%, #1a3f6f 60%, #1e4d8c 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
  padding: .9rem 1.25rem;
}
#User_Permit_Modal .perm-header-bg .modal-title {
  font-size: .9rem;
  font-weight: 600;
  letter-spacing: .01em;
}
#User_Permit_Modal .perm-header-bg .perm-username-badge {
  display: inline-block;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 1rem;
  padding: .1rem .65rem;
  font-size: .78rem;
  font-weight: 500;
  color: #bcd6f5;
  margin-left: .45rem;
  vertical-align: middle;
}

/* ── Table wrapper — horizontal scroll, never clips ── */
#User_Permit_Modal .perm-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Permission table ── */
#permTable {
  width: 100%;
  min-width: 560px;          /* prevents squish on narrow viewports */
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 0;
}

/* thead */
#permTable thead th {
  background: #f8fafc;
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #64748b;
  border-bottom: 2px solid #e2e8f0;
  border-right: 1px solid #e9edf2;
  padding: .65rem .4rem;
  white-space: nowrap;
  vertical-align: middle;
}
#permTable thead th:last-child { border-right: none; }

/* Module name col */
#permTable thead th.col-module {
  min-width: 160px;
  padding-left: 1rem;
  text-align: left;
}

/* Perm cols — fixed width so checkboxes always have room */
#permTable thead th.col-perm {
  width: 76px;
  min-width: 76px;
  text-align: center;
}

/* "All" col — slightly wider */
#permTable thead th.col-all {
  width: 68px;
  min-width: 68px;
  text-align: center;
}

/* ── Col-all / row-all header cell layout ── */
.perm-col-all-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.perm-col-label {
  font-size: .63rem;
  color: #64748b;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  line-height: 1.1;
}
.perm-col-label i { font-size: .62rem; }

/* ── tbody ── */
#permTable tbody td {
  vertical-align: middle;
  font-size: .84rem;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  border-right: 1px solid #f1f5f9;
  padding: .55rem .4rem;
}
#permTable tbody td:last-child { border-right: none; }
#permTable tbody tr:last-child td { border-bottom: none; }

#permTable tbody tr.perm-module-row:hover td { background: #f0f7ff; }

/* ── Group header rows ── */
#permTable .perm-group-row td {
  background: #f1f5f9;
  font-size: .72rem;
  font-weight: 700;
  color: #1e3a5f;
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 1px solid #e2e8f0;
  padding: .42rem 1rem;
}
.perm-group-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: #dbeafe;
  border-radius: 4px;
  margin-right: .4rem;
}
.perm-group-icon i { font-size: .6rem; color: #2563eb; }

/* ── Module name cell ── */
td.perm-module-name {
  padding-left: 1.25rem;
  font-size: .83rem;
  color: #334155;
  font-weight: 500;
}

/* ── Checkbox cells ── */
#permTable tbody td.perm-check-cell {
  text-align: center;
  /* ensure nothing clips the checkbox */
  overflow: visible;
  padding: .5rem .3rem;
}

/* ── Bootstrap checkbox refinements ──
   MUST reset float + margin that Bootstrap sets on .form-check-input
   when used outside a .form-check wrapper — otherwise it breaks flex layout
   and renders inline with the label text instead of above it.           ── */
#User_Permit_Modal .form-check-input {
  float: none;          /* ← kills Bootstrap default float:left            */
  margin: 0;            /* ← kills Bootstrap default margin-top:.25em      */
  display: block;       /* ← ensures it participates correctly in flex col  */
  width: 1.05rem;
  height: 1.05rem;
  cursor: pointer;
  border: 1.5px solid #cbd5e1;
  border-radius: .25rem;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
  flex-shrink: 0;
}
#User_Permit_Modal .form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(37,99,235,.18);
  border-color: #3b82f6;
}
#User_Permit_Modal .form-check-input:checked {
  background-color: #2563eb;
  border-color: #2563eb;
}
#User_Permit_Modal .form-check-input:hover:not(:disabled) {
  border-color: #3b82f6;
}

/* Row-all & col-all checkboxes — slightly larger + accent ring */
#User_Permit_Modal .perm-row-all,
#User_Permit_Modal .perm-col-all {
  width: 1.1rem;
  height: 1.1rem;
}
#User_Permit_Modal .perm-col-all:checked { background-color: #0f2847; border-color: #0f2847; }
#User_Permit_Modal .perm-row-all:checked { background-color: #0f6b3b; border-color: #0f6b3b; }

/* centering wrapper for every checkbox cell (row-all + individual perms) */
.perm-row-all-wrap,
.perm-cb-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Save message ── */
#perm_save_msg {
  border-radius: .4rem;
  font-size: .83rem;
  padding: .5rem .9rem;
}

/* ── Footer ── */
#User_Permit_Modal .modal-footer {
  background: #f8fafc;
  border-top: 1px solid #e9edf2;
  padding: .65rem 1rem;
}

/* ── Buttons ── */
#User_Permit_Modal #permSaveBtn {
  background: #2563eb;
  border-color: #2563eb;
  font-size: .82rem;
  font-weight: 600;
  padding: .4rem .9rem;
  border-radius: .375rem;
  transition: background .15s, box-shadow .15s;
}
#User_Permit_Modal #permSaveBtn:hover {
  background: #1d4ed8;
  box-shadow: 0 3px 10px rgba(37,99,235,.3);
}
#User_Permit_Modal .btn-secondary {
  font-size: .82rem;
  font-weight: 500;
  padding: .4rem .9rem;
  border-radius: .375rem;
}

/* ══════════════════════════════════════════
   DARK MODE
   ══════════════════════════════════════════ */
body.dark-mode #User_Permit_Modal .modal-content {
  background: #161e2e;
  color: #cbd5e1;
}
body.dark-mode #User_Permit_Modal .perm-header-bg {
  background: linear-gradient(135deg, #0a1628 0%, #0f2847 100%);
  border-bottom-color: rgba(255,255,255,.06);
}
body.dark-mode #User_Permit_Modal .modal-body { background: #161e2e; }
body.dark-mode #User_Permit_Modal .modal-footer {
  background: #111827;
  border-top-color: #1f2d40;
}

body.dark-mode #permTable thead th {
  background: #1c2740;
  color: #7c93b8;
  border-bottom-color: #1f2d40;
  border-right-color: #1f2d40;
}
body.dark-mode #permTable tbody td {
  color: #b8cce4;
  border-bottom-color: #1a2337;
  border-right-color: #1a2337;
}
body.dark-mode #permTable tbody tr.perm-module-row:hover td { background: #1c2d47; }
body.dark-mode #permTable .perm-group-row td {
  background: #19243a;
  color: #7dd3fc;
  border-bottom-color: #1f2d40;
}
body.dark-mode .perm-group-icon { background: #1e3a5f; }
body.dark-mode .perm-group-icon i { color: #60a5fa; }
body.dark-mode .perm-col-label { color: #7c93b8; }

body.dark-mode #User_Permit_Modal .form-check-input {
  background-color: #1c2740;
  border-color: #3a4f6b;
}
body.dark-mode #User_Permit_Modal .form-check-input:checked {
  background-color: #3b82f6;
  border-color: #3b82f6;
}
body.dark-mode #User_Permit_Modal .form-check-input:focus {
  box-shadow: 0 0 0 3px rgba(59,130,246,.25);
}
body.dark-mode #User_Permit_Modal .perm-col-all:checked {
  background-color: #1d4ed8; border-color: #1d4ed8;
}
body.dark-mode #User_Permit_Modal .perm-row-all:checked {
  background-color: #15803d; border-color: #15803d;
}

body.dark-mode #User_Permit_Modal #permSaveBtn {
  background: #1d4ed8; border-color: #1d4ed8;
}
body.dark-mode #User_Permit_Modal #permSaveBtn:hover {
  background: #2563eb;
}
body.dark-mode #User_Permit_Modal .btn-secondary {
  background: #1c2740; border-color: #3a4f6b; color: #94a3b8;
}
body.dark-mode #User_Permit_Modal .btn-secondary:hover {
  background: #253350; color: #e2e8f0;
}
body.dark-mode #User_Permit_Modal .alert-success {
  background: #052e16; color: #86efac; border-color: #14532d;
}
body.dark-mode #User_Permit_Modal .alert-danger {
  background: #450a0a; color: #fca5a5; border-color: #7f1d1d;
}