/* ============================================================
   ClearPort SaaS — site.css
   Select2 + Bootstrap 5 + Tabulator responsive layout
   ============================================================ */
/*html, body {
    overflow-x: hidden;
}*/

html {
  font-size: 14px;
  min-height: 100%;
}

@media (min-width: 768px) {
  html { font-size: 16px; }
}

body {
  background-color: #f0f4f8;
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #1e2d3d;
}

/* ===== Focus Styles ===== */
.btn:focus,
.btn:active:focus,
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem #1a73b8;
  border-color: #1a73b8;
  outline: none;
}

/* ===== App Shell ===== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: #0c4b6e;
  color: #b8cfe0;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0,0,0,0.18);
  z-index: 100;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.2rem 1.1rem 1rem;
  font-size: 1.1rem;
  font-weight: 800;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  letter-spacing: 0.03em;
}

.sidebar-brand a {
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-brand a i {
  color: #5bb8f5;
  font-size: 1.3rem;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0.5rem 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-menu-item a,
.submenu-toggle {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.6rem 1.1rem;
  color: #b8cfe0;
  text-decoration: none;
  font-size: 0.88rem;
  transition: background-color 0.15s, color 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
}

.sidebar-menu-item a:hover,
.submenu-toggle:hover {
  background-color: rgba(255,255,255,0.10);
  color: #fff;
}

/* Active sidebar item — highlights which section user is in */
.sidebar-menu-item a.active,
.sidebar-menu-item a[aria-current="page"] {
  background-color: #0a3e5c;
  color: #fff;
  font-weight: 600;
  border-left: 3px solid #3b9edd;
}

/* Parent item highlight when child is active */
.sidebar-menu-item.has-submenu.active-parent > .submenu-toggle {
  background-color: rgba(255,255,255,0.07);
  color: #fff;
  border-left: 3px solid rgba(59,158,221,0.5);
}

.sidebar-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  background-color: rgba(0,0,0,0.10);
}

.sidebar-submenu .sidebar-menu-item a {
  padding-left: 2.4rem;
  font-size: 0.84rem;
  color: #9dbdd8;
}

.sidebar-submenu .sidebar-menu-item a:hover {
  color: #fff;
  background-color: rgba(255,255,255,0.06);
}

.sidebar-submenu .sidebar-menu-item a.active,
.sidebar-submenu .sidebar-menu-item a[aria-current="page"] {
  color: #fff;
  background-color: #0a3e5c;
  border-left: 3px solid #3b9edd;
}

.sidebar-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6a8faa;
  padding: 0.8rem 1.1rem 0.3rem;
  font-weight: 700;
}

/* ===== App Main ===== */
.app-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    background-color: #f0f4f8;
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background-color: #fff;
  border-bottom: 1px solid #dde4ec;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 90;
}

.topbar-title {
  font-size: 1rem;
  font-weight: 700;
  color: #1e2d3d;
  white-space: nowrap;
}

.topbar-search {
  width: 280px;
  margin-left: auto;
}

.topbar-search .form-control {
  border-radius: 2rem;
  background-color: #f0f4f8;
  border: 1px solid #dde4ec;
  font-size: 0.88rem;
  padding-left: 2.2rem;
}

.topbar-search-wrapper {
  position: relative;
}

.topbar-search-wrapper .bi-search {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #8a9bb0;
  font-size: 0.85rem;
}

.topbar-user {
  font-size: 0.88rem;
  color: #6a8faa;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.topbar-user .btn-outline-secondary {
  border-color: #dde4ec;
  color: #6a8faa;
  border-radius: 0.5rem;
  font-size: 0.82rem;
}

.topbar-user .btn-outline-secondary:hover {
  background-color: #0a3e5c;
  border-color: #1a5fa8;
  color: #fff;
}

.topbar-user .badge {
  font-size: 0.75rem;
}

/* ===== Content ===== */
.content {
  flex: 1;
  padding: 1.4rem 1.5rem;
}

/* ===== Footer ===== */
.app-footer {
  padding: 0.65rem 1.5rem;
  background-color: #fff;
  border-top: 1px solid #dde4ec;
  font-size: 0.8rem;
  color: #8a9bb0;
}

.app-footer a {
  color: #1a73b8;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* ===== Page Header ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-header h4 {
  margin: 0;
  color: #1e2d3d;
  font-weight: 700;
}

/* ===== Cards ===== */
.card {
  border: 1px solid #dde4ec;
  border-radius: 0.75rem;
  box-shadow: 0 1px 6px rgba(0,0,0,0.05);
  background-color: #fff;
}

.card-header {
  background-color: #f7f9fc;
  border-bottom: 1px solid #dde4ec;
  border-radius: 0.75rem 0.75rem 0 0 !important;
  font-weight: 600;
  color: #1e2d3d;
  padding: 0.85rem 1.1rem;
}

.card-body {
  padding: 1.1rem;
}

/* ===== Buttons ===== */
.btn-primary {
  background-color: #0a3e5c;
  border-color: #1a5fa8;
  border-radius: 0.5rem;
  font-weight: 600;
  /*font-size: 0.88rem;*/
}

.btn-primary:hover {
  background-color: #155090;
  border-color: #155090;
}

.btn-outline-primary {
  color: #1a5fa8;
  border-color: #1a5fa8;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-outline-primary:hover {
  background-color: #0a3e5c;
  border-color: #1a5fa8;
  color: #fff;
}

.btn-danger {
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-secondary {
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.88rem;
  background-color: #e2e8f0;
  border-color: #e2e8f0;
  color: #1e2d3d;
}

.btn-secondary:hover {
  background-color: #cbd5e1;
  border-color: #cbd5e1;
  color: #1e2d3d;
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.25rem 0.65rem;
}

/* ===== Form Controls ===== */
.form-control,
.form-select {
  border-radius: 0.5rem;
  border: 1px solid #dde4ec;
  background-color: #f7f9fc;
  font-size: 0.88rem;
  transition: border-color 0.15s, background-color 0.15s;
}

.form-control:focus,
.form-select:focus {
  background-color: #fff;
  border-color: #1a73b8;
}

.form-label {
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.01em;
  color: #6a8faa;
  margin-bottom: 0.3rem;
}

/* ===== Alerts ===== */
.alert {
  border-radius: 0.65rem;
  font-size: 0.88rem;
}

.alert-success {
  background-color: #e8f5e9;
  border-color: #4caf50;
  color: #1b5e20;
}

.alert-danger {
  background-color: #fdecea;
  border-color: #f44336;
  color: #7f1d1d;
}

.alert-info {
  background-color: #e3f2fd;
  border-color: #2196f3;
  color: #0d47a1;
}

/* ===== Badges ===== */
.badge.bg-primary {
  background-color: #1a5fa8 !important;
}

.badge.bg-secondary {
  background-color: #4a6580 !important;
}

.badge.bg-info {
  background-color: #3b9edd !important;
}

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0c4b6e 0%, #0a3e5c 60%, #3b9edd 100%);
}

.login-shell {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 1rem;
  box-shadow: 0 8px 40px rgba(0,0,0,0.25);
  padding: 2.5rem 2rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand .brand-mark {
  font-size: 2.5rem;
  color: #0c4b6e;
  margin-bottom: 0.5rem;
}

.login-brand h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: #0c4b6e;
  margin-bottom: 0.25rem;
}

.login-brand p {
  color: #4a6580;
  font-size: 0.9rem;
  margin: 0;
}

.login-form .form-label {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #4a6580;
}

.input-with-icon {
  position: relative;
}

.input-with-icon i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #8a9bb0;
  font-size: 0.9rem;
  z-index: 5;
}

.input-with-icon .form-control {
  padding-left: 2.2rem;
}

.password-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.password-toggle {
  background: none;
  border: 1px solid #dde4ec;
  border-radius: 0.5rem;
  padding: 0.45rem 0.65rem;
  color: #4a6580;
  cursor: pointer;
  flex-shrink: 0;
}

.password-toggle:hover {
  background-color: #f0f4f8;
}

.btn-login {
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 0.6rem;
  background-color: #0c4b6e;
  border-color: #0c4b6e;
}

.btn-login:hover {
  background-color: #0a3e5c;
  border-color: #0a3e5c;
}

.login-card .card-header {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 800;
  color: #1e2d3d;
  border-radius: 1rem 1rem 0 0 !important;
  background-color: #fff;
  border-bottom: 1px solid #dde4ec;
  padding: 1.5rem;
}

/* ===== Error Pages ===== */
.error-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0c4b6e 0%, #0a3e5c 60%, #3b9edd 100%);
  padding: 1rem;
}

.error-card {
  background-color: #fff;
  border-radius: 1rem;
  padding: 3rem 2.5rem;
  max-width: 560px;
  width: 100%;
  box-shadow: 0 1rem 3rem rgba(0,0,0,0.25);
}

.error-code { color: #1a5fa8; }
.error-icon { color: #f59e0b; }

/* ===== Page Loader ===== */
.page-loader {
  position: fixed;
  inset: 0;
  background-color: rgba(12, 75, 110, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
}

.page-loader-content {
  text-align: center;
  color: #fff;
}

.spinner-loader {
  width: 3.5rem;
  height: 3.5rem;
  border: 5px solid rgba(255,255,255,0.2);
  border-top-color: #5bb8f5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Table ===== */
.table-responsive { overflow-x: auto; }

.table thead th {
  background-color: #f0f4f8;
  color: #1e2d3d;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid #dde4ec;
}

/* ===== Grid Toolbar ===== */
.grid-toolbar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.grid-toolbar-section {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.grid-toolbar-global {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}

.grid-toolbar-global .input-group .form-control {
  min-height: 31px;
}

.grid-toolbar-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* Role filter pill */
.grid-toolbar-filter {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background-color: #e3f0fa;
  border: 1px solid #b3d3f0;
  color: #1a5fa8;
  border-radius: 2rem;
  padding: 0.2rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.filter-badge:hover,
.filter-badge.active {
  background-color: #1a5fa8;
  color: #fff;
  border-color: #1a5fa8;
}

.filter-badge .bi {
  font-size: 0.7rem;
}

.grid-toolbar-selection-info {
  font-size: 0.82rem;
  color: #6a8faa;
  margin-right: 0.5rem;
  white-space: nowrap;
}

.grid-toolbar-dropdown {
  position: relative;
  display: inline-block;
}

.grid-toolbar-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 1080;
  min-width: 200px;
  max-height: 420px;
  overflow-y: auto;
  background-color: #fff;
  border: 1px solid #dde4ec;
  border-radius: 0.6rem;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.12);
  padding: 0.25rem 0;
  list-style: none;
  margin: 0;
}

.grid-toolbar-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.grid-toolbar-menu .dropdown-item:hover {
  background-color: #f0f4f8;
  color: #1e2d3d;
}

.grid-toolbar-menu .dropdown-item input[type="checkbox"] {
  flex-shrink: 0;
  accent-color: #1a5fa8;
}

/* ===== Tabulator — Responsive, No Horizontal Scroll ===== */

/* Make the tabulator fill its container width fully */
#userTable,
.tabulator {
  width: 100% !important;
  max-width: 100% !important;
}

/* Prevent outer card/container from generating horizontal scroll.
   Scoped to grid cards only — plain .card-body still needs to overflow
   visibly so position:sticky footers (page-footer.freeze-footer) work
   on regular form pages. */
.grid-panel .card-body,
.card-body:has(.tabulator) {
    overflow: hidden;
}

.tabulator {
  border: none;
  border-radius: 0.5rem;
  overflow: hidden;
  font-size: 0.875rem;
}

/* Header */
.tabulator .tabulator-header {
  background-color: #d0dbe8 !important;
  border-bottom: 2px solid #b8c6d4 !important;
}

.tabulator .tabulator-header .tabulator-col {
  background-color: #d0dbe8 !important;
  border-right: 1px solid #bcc9d6 !important;
  box-sizing: border-box !important;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #1e2d3d;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Rows */
.tabulator .tabulator-row {
  border-bottom: 1px solid #eef1f5;
  transition: background-color 0.12s;
}

.tabulator .tabulator-row:hover {
  background-color: #f0f6fc !important;
}

.tabulator .tabulator-row.tabulator-selected {
  background-color: #dbeeff !important;
}

.tabulator .tabulator-row .tabulator-cell {
  vertical-align: middle;
  padding: 0.55rem 0.75rem;
  border-right: 1px solid #eef1f5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tabulator .tabulator-row .tabulator-cell[title] {
  cursor: help;
}

/* Column search inputs */
.tabulator .tabulator-header input[type="text"],
.tabulator .tabulator-header input[type="number"],
.tabulator .tabulator-header input[type="search"],
.tabulator .tabulator-header select {
  width: 100%;
  box-sizing: border-box;
  min-height: 26px;
  font-size: 0.78rem;
  border-radius: 0.3rem;
  border: 1px solid #dde4ec;
  background: #fff;
  padding: 0.15rem 0.4rem;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tabulator .tabulator-col-header {
  overflow: hidden;
}

.tabulator .tabulator-col-header .tabulator-col-sorter {
  display: inline-block;
  margin-left: 4px;
  flex-shrink: 0;
}

/* Footer/Pagination */
.tabulator-footer {
  background-color: #f7f9fc;
  border-top: 1px solid #dde4ec;
  padding: 0.5rem 0.75rem;
}

.tabulator-footer .tabulator-page {
  border-radius: 0.35rem;
  border: 1px solid #dde4ec;
  background: #fff;
  color: #1e2d3d;
  font-size: 0.82rem;
  padding: 0.2rem 0.55rem;
  margin: 0 0.1rem;
  transition: background 0.12s;
}

.tabulator-footer .tabulator-page.active {
  background-color: #1a5fa8;
  color: #fff;
  border-color: #1a5fa8;
}

.tabulator-footer .tabulator-page:hover:not(.active):not([disabled]) {
  background-color: #e3f0fa;
}

.tabulator-footer .tabulator-page[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Responsive: stack columns vertically on mobile */
@media (max-width: 640px) {
  /* Hide horizontal scroll — use card layout instead */
  .tabulator .tabulator-header {
    display: none;
  }

  .tabulator .tabulator-row {
    display: flex;
    flex-direction: column;
    padding: 0.75rem 1rem;
    border: 1px solid #dde4ec;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    background: #fff;
  }

  .tabulator .tabulator-row .tabulator-cell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: none;
    border-bottom: 1px solid #f0f4f8;
    padding: 0.35rem 0;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .tabulator .tabulator-row .tabulator-cell:last-child {
    border-bottom: none;
  }

  /* Show data-label as field name on mobile */
  .tabulator .tabulator-row .tabulator-cell::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6a8faa;
    min-width: 90px;
    flex-shrink: 0;
  }

  .tabulator-tableholder {
    overflow: visible !important;
  }
}

/* Desktop — no horizontal scroll; columns shrink to fit */
@media (min-width: 641px) {
  .tabulator-tableholder {
    overflow-x: hidden !important;
    overflow-y: auto;
  }

  .tabulator-table {
    width: 100% !important;
    table-layout: fixed;
  }
}

/* Action buttons inside cells */
.tabulator .tabulator-row .tabulator-cell button,
.tabulator .tabulator-row .tabulator-cell a.btn {
  white-space: nowrap;
  display: inline-block;
  margin: 2px;
  padding: 0.18rem 0.5rem;
  font-size: 0.78rem;
  opacity: 0.8;
}

.tabulator .tabulator-row .tabulator-cell button:hover,
.tabulator .tabulator-row .tabulator-cell a.btn:hover {
  opacity: 1;
}

.tabulator .tabulator-row .tabulator-cell .btn-info {
  background-color: #b6d4fe;
  border-color: #b6d4fe;
  color: #084298;
}

.tabulator .tabulator-row .tabulator-cell .btn-warning {
  background-color: #ffeeba;
  border-color: #ffeeba;
  color: #664d03;
}

.tabulator .tabulator-row .tabulator-cell .btn-danger {
  background-color: #f8d7da;
  border-color: #f8d7da;
  color: #842029;
}

.tabulator .tabulator-row .tabulator-cell .btn-success {
  background-color: #d1e7dd;
  border-color: #d1e7dd;
  color: #0f5132;
}

.tabulator .tabulator-row .tabulator-cell .btn-primary {
  background-color: #c2d4f0;
  border-color: #c2d4f0;
  color: #0a3e5c;
}

.tabulator .tabulator-row .tabulator-cell .btn-group,
.tabulator .tabulator-row .tabulator-cell .btn-container {
  display: flex;
  gap: 3px;
  white-space: nowrap;
}

/* ===== Select2 Overrides ===== */

/* Make select2 match Bootstrap form-select appearance */
.select2-container--classic .select2-selection--single,
.select2-container--classic .select2-selection--multiple {
  min-height: 38px !important;
  border: 1px solid #dde4ec !important;
  border-radius: 0.5rem !important;
  background-color: #f7f9fc !important;
  background-image: none !important;
  box-shadow: none !important;
  font-size: 0.88rem;
}

.select2-container--classic .select2-selection--single .select2-selection__rendered {
  line-height: 36px !important;
  color: #1e2d3d;
  padding-left: 12px;
  padding-right: 52px !important; /* reserve space for clear (×) + arrow (▼) */
}

/* Dropdown arrow (▼) — pushed slightly farther right and vertically centered */
.select2-container--classic .select2-selection--single .select2-selection__arrow {
  height: auto !important;
  top: 50% !important;
  transform: translateY(-50%);
  right: 12px !important;
  border: none !important;
  background: transparent !important;
}

.select2-container--classic .select2-selection--single .select2-selection__arrow b {
  border-color: #6a8faa transparent transparent transparent !important;
}

/* Clear (×) — own area, lighter weight, smaller, vertically centered,
   sits left of the arrow with a consistent gap */
.select2-container--classic .select2-selection--single .select2-selection__clear {
  position: absolute !important;
  right: 34px !important;          /* leaves a clear gap before the arrow at 12px */
  top: 50% !important;
  transform: translateY(-50%);
  margin: 0 !important;
  padding: 0 4px !important;        /* gives the × its own clickable area */
  font-size: 15px !important;
  line-height: 1 !important;
  font-weight: 500 !important;
  color: #2f3e4e !important;        /* deeper, more visible cross */
  opacity: 1;
  cursor: pointer;
}

.select2-container--classic .select2-selection--single .select2-selection__clear:hover {
  color: #c0392b !important;
}

/* Dropdown panel */
.select2-container--classic .select2-dropdown {
  border: 1px solid #dde4ec !important;
  border-radius: 0.5rem !important;
  box-shadow: 0 0.5rem 1.5rem rgba(0,0,0,0.12) !important;
  margin-top: 2px;
  font-size: 0.88rem;
}

.select2-container--classic .select2-search--dropdown .select2-search__field {
  border: 1px solid #dde4ec !important;
  border-radius: 0.35rem !important;
  padding: 0.35rem 0.6rem;
  font-size: 0.85rem;
}

.select2-container--classic .select2-results__option {
  padding: 0.45rem 0.75rem;
}

.select2-container--classic .select2-results__option--highlighted {
  background-color: #1a5fa8 !important;
  color: #fff !important;
}

/* Width fix — must inherit from parent */
/*.select2-container {
  width: 100% !important;
}*/

/* Focus ring */
.select2-container--classic.select2-container--open .select2-selection--single {
  border-color: #1a73b8 !important;
  background-color: #fff !important;
}

/* Required-field highlighting for dynamic add-items rows */
.add-items-table .form-control.is-invalid,
.add-items-table .form-select.is-invalid {
    border-color: #dc3545 !important;
    background-color: #fff5f5;
}

/* Select2's own box needs its own target — the real <select> is hidden */
.select2-container .select2-selection.is-invalid {
    border-color: #dc3545 !important;
}

/* ===== Responsive Dynamic Assignment Tables =====
   - Card width is fixed; height grows with rows.
   - Table uses 100% of the card width, no horizontal scroll.
   - Inputs/selects shrink to fit the column (min-width:0).
   - On small screens the table stacks each row as a block card
     (labels come from each <td data-label="...">). */
.table.dynamic-table {
  width: 100% !important;
  table-layout: fixed;
}

.table.dynamic-table th,
.table.dynamic-table td {
  word-break: break-word;
}

/* Lighter, consistent header hierarchy (no heavy table-light background) */
.table.dynamic-table thead th {
  background-color: #f4f7fb !important;
  border-bottom: 2px solid #dde4ec !important;
  font-weight: 600;
  color: #44566c;
  font-size: 0.78rem;
  white-space: nowrap;
}

/* Compact, horizontal action cell */
.table.dynamic-table .row-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.25rem;
}

.table.dynamic-table .row-actions .btn {
  padding: 0.1rem 0.4rem;
  line-height: 1.2;
}

.table.dynamic-table input,
.table.dynamic-table select,
.table.dynamic-table .form-control,
.table.dynamic-table .form-select,
.table.dynamic-table .form-control-sm,
.table.dynamic-table .form-select-sm {
  min-width: 0 !important;
  width: 100% !important;
}



@media (max-width: 768px) {
  .table.dynamic-table,
  .table.dynamic-table tbody,
  .table.dynamic-table tr,
  .table.dynamic-table td {
    display: block;
    width: 100% !important;
  }

  .table.dynamic-table thead {
    display: none;
  }

  .table.dynamic-table tr {
    margin-bottom: 1rem;
    border: 1px solid #dde4ec;
    border-radius: 0.5rem;
    padding: 0.35rem 0.6rem;
  }

  .table.dynamic-table td {
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-align: right;
    padding: 0.3rem 0.25rem;
  }

  .table.dynamic-table td::before {
    content: attr(data-label);
    font-weight: 600;
    text-align: left;
    flex: 0 0 38%;
    color: #44566c;
  }

  .table.dynamic-table td > input,
  .table.dynamic-table td > select,
  .table.dynamic-table td > .form-control,
  .table.dynamic-table td > .form-select {
    flex: 1 1 auto;
  }
}

/* ===== Tabulator column headers (custom, scoped) =====
   Small, bold, wrapped header titles — applied ONLY to grids that opt in
   via the .compact-header class (CustomerBankAccount, VendorBankAccount,
   UserWiseMenuAccess). All other grids keep the default header style. */
.compact-header .tabulator-header .tabulator-col-title {
  font-size: 0.55rem !important;
  font-weight: 700 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: unset !important;
  line-height: 1.2 !important;
  word-wrap: break-word !important;
  word-break: break-word !important;
}

.compact-header .tabulator-header .tabulator-col,
.compact-header .tabulator-header {
  overflow: visible !important;
}

/* ===== Responsive Tabulator (no horizontal scroll) =====
   Desktop (>=1200px): normal column table.
   Tablet / Mobile (<=1199px): header hidden, every row becomes a
   vertical card; each cell shows its column name (data-label) on the
   left and the value on the right, so data flows top-to-bottom. */
@media (max-width: 1199.98px) {
  .tabulator .tabulator-header {
    display: none !important;
  }

  .tabulator .tabulator-tableholder {
    height: auto !important;
    overflow: visible !important;
    border: none !important;
    background: transparent !important;
  }

  .tabulator .tabulator-table {
    display: block !important;
    min-width: 0 !important;
  }

  .tabulator .tabulator-row {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin-bottom: 0.5rem;
    border: 1px solid #dde4ec !important;
    border-radius: 0.5rem;
    background: #fff !important;
    padding: 0.1rem 0.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0,0,0,0.04);
  }

  .tabulator .tabulator-row.tabulator-calcs,
  .tabulator .tabulator-row.tabulator-group {
    display: none !important;
  }

  .tabulator .tabulator-cell {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    border: none !important;
    border-bottom: 1px solid #eef2f6 !important;
    text-align: right !important;
    padding: 0.22rem 0.2rem !important;
    line-height: 1.25 !important;
    white-space: normal !important;
  }

  .tabulator .tabulator-cell:last-child {
    border-bottom: none !important;
  }

  .tabulator .tabulator-cell[data-label]::before {
    content: attr(data-label);
    flex: 0 0 38%;
    text-align: left !important;
    font-weight: 600;
    color: #44566c;
  }

  /* Wrapped value: consistent right-aligned, content-sized column. */
  .tabulator .tabulator-cell .cp-cell-value {
    flex: 1 1 auto;
    min-width: 0;
    text-align: right;
  }

  /* Status / state badges keep a natural, slightly more prominent,
     content-sized appearance (not stretched, not too faint). */
  .tabulator .tabulator-cell .cp-cell-value .badge {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.3em 0.55em;
  }

  /* Action cells: compact, wrapping, right-aligned button group next to
     the ACTIONS label. */
  .tabulator .tabulator-cell[data-label="Actions"] .cp-cell-value {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.25rem;
    row-gap: 0.25rem;
  }

  /* ===== Responsive pagination (tablet + mobile): EXACTLY TWO rows.
     clearportGrid rewrites the Tabulator footer DOM into:
         .tabulator-footer-contents          (pagination-footer)
         ├── .tabulator-page-counter         (pagination-summary)
         ├── .pagination-page-size           (pagination-page-size: label + select)
         └── .tabulator-paginator            ({display:contents} exposes its child)
               └── .tabulator-pages          (pagination-controls: all buttons)
     The paginator holds ONLY .tabulator-pages after the JS restructure, so
     display:contents makes .tabulator-pages the single "controls" grid item.
     The grid then lays out exactly two rows:
         Row 1: summary (left)  + page size (right)
         Row 2: .tabulator-pages (ALL buttons in ONE horizontal row)
     Desktop (>=1200px) is untouched (scoped to <=1199.98px). */
  .tabulator .tabulator-footer-contents {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "summary size"
      "controls controls";
    align-items: center;
    row-gap: 8px;
    column-gap: 8px;
    padding: 0.5rem 0.5rem !important;
  }

  /* The paginator is reduced to a single child (.tabulator-pages) by the JS
     restructure, so collapsing it makes .tabulator-pages a direct grid item. */
  .tabulator .tabulator-paginator {
    display: contents !important;
  }

  .tabulator .tabulator-page-counter {
    grid-area: summary;
    min-width: 0;
    margin: 0 !important;
    text-align: left;
    white-space: nowrap;
    font-size: 0.82rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Page-size lives on Row 1 only; it must never steal width from the
     pagination controls on Row 2. */
  .tabulator .pagination-page-size {
    grid-area: size;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0 !important;
    padding: 0 4px;
    white-space: nowrap;
  }

  .tabulator .pagination-page-size label {
    margin: 0 !important;
    font-size: 12px;
    line-height: 1.2;
    white-space: nowrap;
    color: #6a8faa;
  }

  .tabulator .pagination-page-size .tabulator-page-size {
    display: inline-block;
    width: auto;
    height: 30px;
    padding: 0 4px;
    font-size: 12px;
    line-height: 1.2;
    border: 1px solid #dde4ec;
    border-radius: 0.35rem;
    background: #fff;
    color: #1e2d3d;
  }

  /* Row 2: ALL pagination buttons in ONE non-wrapping horizontal row. */
  .tabulator .tabulator-pages {
    grid-area: controls;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: 100%;
    min-width: 0;
    margin: 0 !important;
    overflow-x: auto;
  }

  .tabulator .tabulator-page {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto !important;
    height: 30px;
    min-width: 28px;
    width: auto;
    margin: 0 !important;
    padding: 0 6px !important;
    font-size: 12px !important;
    line-height: 1.2;
  }

  /* Toolbar: stack search full-width, then wrap action controls below so
     nothing is crowded at narrow widths. */
  .grid-toolbar-section {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .grid-toolbar-global {
    flex: 1 1 100%;
    max-width: 100%;
  }

  .grid-toolbar-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 0.35rem;
  }

  .grid-toolbar-selection-info {
    width: 100%;
    margin-right: 0;
  }
}

/* ===== Mobile pagination (<=767px): compact icon-only nav buttons and a
   single non-wrapping controls row. ===== */
@media (max-width: 767.98px) {
  .tabulator .tabulator-pages {
    flex-wrap: nowrap !important;
  }

  .tabulator .tabulator-page-counter {
    font-size: 12px !important;
  }

  /* Icon-only First / Prev / Next / Last so all controls fit one row. */
  .tabulator .tabulator-page[data-page="first"],
  .tabulator .tabulator-page[data-page="prev"],
  .tabulator .tabulator-page[data-page="next"],
  .tabulator .tabulator-page[data-page="last"] {
    font-size: 0 !important;
    width: 28px !important;
    min-width: 28px !important;
    padding: 0 !important;
    line-height: 1;
  }

  .tabulator .tabulator-page[data-page="first"]::before {
    content: "\00AB";
    font-size: 13px;
  }

  .tabulator .tabulator-page[data-page="prev"]::before {
    content: "\2039";
    font-size: 13px;
  }

  .tabulator .tabulator-page[data-page="next"]::before {
    content: "\203A";
    font-size: 13px;
  }

  .tabulator .tabulator-page[data-page="last"]::before {
    content: "\00BB";
    font-size: 13px;
  }
}

/* Create/Edit page: 1 column (mobile) / 2 columns (tablet) /
   3 columns (desktop) — handled via Bootstrap col classes in markup.
   Ensure the centered card never imposes a fixed height and grows
   naturally with dynamic rows. */
.card-body {
  height: auto;
}

/* ===== Details view (responsive field-card grid) =====
   Each "<strong>Label:</strong> value" line becomes a clean field card
   laid out in a 1 / 2 / 3 column responsive grid
   (mobile / tablet / desktop). Applies to all Details pages. */
.detail-card .card-header {
  background: linear-gradient(90deg, #f7fafc, #eef3f8);
  border-bottom: 1px solid #e3e9f0;
}

.detail-card .card-header h5 {
  font-weight: 600;
  color: #1e2d3d;
  margin: 0;
}

.detail-card .card-body strong {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7b93a7;
}

/* Responsive field grid: override Bootstrap row/col gutters so the grid
   controls layout consistently at every breakpoint. */
.detail-card .card-body .row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  margin: 0;
}

@media (min-width: 768px) {
  .detail-card .card-body .row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1200px) {
  .detail-card .card-body .row {
    grid-template-columns: repeat(3, 1fr);
  }
}

.detail-card .card-body .row .col-12 {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  width: auto;
  max-width: none;
  padding: 0.7rem 0.9rem !important;
  background: #fbfdff;
  border: 1px solid #e6edf4;
  border-radius: 0.5rem;
  color: #1e2d3d;
  font-size: 0.95rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* Standalone (non-grid) fields such as Address. */
.detail-card .card-body > .mb-2:not(.row) {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.7rem 0.9rem;
  margin-top: 0.75rem;
  background: #fbfdff;
  border: 1px solid #e6edf4;
  border-radius: 0.5rem;
  color: #1e2d3d;
  font-size: 0.95rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.detail-card .card-body img {
  align-self: flex-start;
  max-height: 64px;
  border: 1px solid #e3e9f0;
  border-radius: 0.4rem;
}

.detail-card .card-footer {
  background: #f7fafc;
  border-top: 1px solid #e3e9f0;
}

/* ===== Global overflow guard =====
   Prevents accidental horizontal page scroll (off-canvas sidebar,
   tables, etc.). clip (not hidden) so position:sticky keeps working. */
.app-shell {
  overflow-x: clip;
}

/* ===== Responsive Sidebar / Shell (3 breakpoints) ===== */
.sidebar-toggle {
  display: none;
}

/* Tablet 768–1199px: compact icon-only navigation rail */
@media (min-width: 768px) and (max-width: 1199.98px) {
  .sidebar {
    width: 72px;
    min-width: 72px;
    overflow-x: hidden;
  }

  .sidebar-brand {
    padding: 1rem 0;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  }

  .sidebar-brand a {
    justify-content: center;
    gap: 0;
    font-size: 0; /* hide brand text, keep the icon */
  }

  .sidebar-brand a i {
    font-size: 1.4rem;
  }

  .sidebar-section-label {
    display: none;
  }

  .sidebar-menu-item a,
  .submenu-toggle {
    justify-content: center;
    padding: 0.72rem 0;
  }

  /* Hide labels + submenu chevron → icon-only rail */
  .sidebar-menu-item a span,
  .submenu-toggle span,
  .bi-chevron-down {
    display: none;
  }

  .sidebar-submenu .sidebar-menu-item a {
    padding-left: 0;
    justify-content: center;
    font-size: 0;
  }

  .sidebar-submenu .sidebar-menu-item a i {
    font-size: 0.95rem;
  }

  .content {
    padding: 1.2rem 1.1rem;
  }
}

/* Mobile <=767px: off-canvas sidebar + hamburger */
@media (max-width: 767.98px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 240px;
    max-width: 82vw;
    min-width: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1050;
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1040;
  }

  .app-shell.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.5rem;
  }

  .topbar {
    padding: 0.5rem 0.75rem;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    row-gap: 0.4rem;
    column-gap: 0.5rem;
    height: auto;
    min-height: 56px;
  }

  /* Row 1: hamburger + title. The title shrinks instead of wrapping or
     pushing the user block onto an unintended line. */
  .sidebar-toggle {
    order: 1;
    flex: 0 0 auto;
  }

  .topbar-title {
    order: 2;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-search {
    display: none; /* non-functional placeholder; avoid clutter on mobile */
  }

  /* Row 2: the ENTIRE user block (badge / name / Logout) on its own full-width
     line, forced to stay on ONE row. Only the user's name is allowed to
     truncate so the badge and Logout are never pushed to a separate line. */
  .topbar-user {
    order: 3;
    flex: 1 1 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    min-width: 0;
    white-space: nowrap;
  }

  .topbar-user .badge {
    flex: 0 0 auto;
    max-width: 40vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .topbar-user > span {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 32vw;
  }

  .topbar-user form {
    flex: 0 0 auto;
  }

  .content {
    padding: 1rem 0.75rem;
  }
}

/* Mobile: stack form action buttons (Save / Back To List) */
@media (max-width: 767.98px) {
  #sidebarToggle {
    order: -1;
  }

  form > .d-flex.gap-2.mt-3 {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  form > .d-flex.gap-2.mt-3 > .btn {
    width: 100%;
  }
}

/* Grid toolbar / action groups wrap gracefully on small screens */
.grid-toolbar,
.grid-toolbar-actions {
  flex-wrap: wrap;
  row-gap: 0.5rem;
}
