/* Unified FIMS GUI Override - Uses Design System Colors */
:root {
  /* Light Mode - Mapped to Design System */
  --gui-bg: var(--color-bg-light);
  --gui-bg-soft: var(--color-bg-lighter);
  --gui-panel: var(--color-bg-white);
  --gui-panel-soft: #f4f1e8;
  --gui-line: var(--color-border);
  --gui-text: var(--color-text-dark);
  --gui-muted: var(--color-text-medium);

  --gui-sidebar-1: var(--color-primary);
  --gui-sidebar-2: var(--color-primary-dark);
  --gui-sidebar-line: rgba(44, 106, 162, 0.24);

  --gui-accent: var(--color-secondary);
  --gui-accent-2: #2da8bb;
  --gui-accent-deep: var(--color-secondary-dark);

  --gui-ok: var(--color-success);
  --gui-warn: var(--color-warning);
  --gui-bad: var(--color-danger);
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden !important;
  overscroll-behavior: none;
  /* Prevent mobile scroll bounce */
}

body {
  background: #f0f2f5 !important;
  color: var(--gui-text);
  font-family: "Poppins", "Manrope", sans-serif;
}

.app-shell {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  /* Use dynamic viewport height for mobile browsers */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.app-shell .canvas {
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: transparent !important;
  box-shadow: none;
  grid-template-columns: 255px minmax(0, 1fr) !important;
  flex: 1;
  display: grid;
  height: 100vh;
  /* Ensure canvas fills full viewport height */
}

/* Sidebar - Fixed/Locked */
.app-shell .sidebar {
  background: var(--color-primary) !important;
  border-right: none !important;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  height: 100%;
  /* Fill canvas height */
}

/* Main Panel - Scrollable content area */
.main-panel {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--gui-bg);
  position: relative;
}

.logo-block {
  padding: 12px 12px 10px;
  border-bottom: 1px solid rgba(182, 219, 239, 0.16);
  display: grid;
  justify-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.72);
  object-fit: cover;
  background: #fff;
}

#logoText {
  color: #ffffff;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.1;
}

#logoText .system-tag {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.8);
}

.nav-list {
  padding: 10px 8px;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.nav-list .nav-item {
  margin-bottom: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  background: rgba(255, 255, 255, 0.03) !important;
  color: #ffffff !important;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 11px;
}

.nav-list .nav-item:hover {
  background: rgba(255, 255, 255, 0.08) !important;
  transform: none;
}

.nav-list .nav-item.active {
  background: linear-gradient(90deg, rgba(44, 106, 162, 0.4), rgba(44, 106, 162, 0.2)) !important;
  border-color: rgba(74, 139, 194, 0.6) !important;
  color: #ffffff !important;
}

.nav-list .nav-item.active::before {
  background: var(--color-warning);
  width: 3px;
}

.nav-badge {
  background: #ef5858 !important;
  color: #fff !important;
  box-shadow: none !important;
}

/* Main area - Scrollable Content Only */
.main-panel {
  display: flex;
  flex-direction: column;
  padding: 0;
  min-width: 0;
  width: 100%;
  background: transparent !important;
  overflow: hidden;
  /* Prevent panel itself from scrolling */
  height: 100vh;
  /* Fill viewport height */
}

.content-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  /* Critical: allows scrolling to work with flex items */
}

.topbar {
  border: none !important;
  border-radius: 0;
  background: linear-gradient(90deg, var(--color-primary-dark), var(--color-primary)) !important;
  color: #ffffff !important;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: 48px;
  margin: 0;
  position: relative;
  z-index: 10;
}

.breadcrumbs,
.search-wrap,
.profile-wrap,
#searchWrap,
#profileWrap {
  color: #e9fbff !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.breadcrumbs .crumb,
.breadcrumbs .sep,
.breadcrumbs .crumb.current {
  color: #e9fbff !important;
  font-weight: 600;
}

.profile-avatar {
  background: rgba(10, 240, 255, 0.15) !important;
  color: #0af0ff !important;
  box-shadow: none;
}

#logoutButton {
  background: rgba(10, 240, 255, 0.1) !important;
  border: 1px solid rgba(10, 240, 255, 0.3) !important;
  color: #0af0ff !important;
}

#logoutButton:hover {
  background: rgba(10, 240, 255, 0.2) !important;
}

#dashboardHero,
#quickActions,
#kpiGrid {
  margin-top: 0;
  margin-bottom: 0;
}

#quickActions {
  gap: 8px !important;
}

#kpiGrid {
  gap: 10px !important;
}

.quick-action,
.portal-tab,
.tab-button {
  padding: 8px 12px !important;
  min-height: 36px !important;
  font-size: 13px !important;
}

.section-title {
  margin: 0;
  border: 0;
  padding: 0;
  font-size: 24px;
  color: #1d2a32 !important;
  font-family: "Poppins", "Manrope", sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

.note {
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--gui-muted) !important;
}

.content-grid {
  grid-template-columns: 1.3fr 1fr !important;
  gap: 24px !important;
  display: grid;
  width: 100%;
  padding: 16px;
  align-content: start;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.content-grid.directory-focus {
  grid-template-columns: 1.3fr 1fr !important;
}

.content-grid.single-panel {
  grid-template-columns: 1fr !important;
}

#dashboardHero {
  grid-column: 1 / -1 !important;
  order: 1;
}

#primaryPanel {
  grid-column: 1 !important;
  order: 2;
}

#secondaryPanel {
  grid-column: 2 !important;
  order: 3;
}

.content-grid.single-panel #primaryPanel {
  grid-column: 1 !important;
}

.content-grid.single-panel #secondaryPanel {
  display: none !important;
}

.content-grid {
  width: 100% !important;
  max-width: none !important;
}

.panel {
  border-radius: 6px;
  border: 1px solid rgba(53, 167, 184, 0.2) !important;
  background: linear-gradient(180deg, rgba(8, 33, 56, 0.94), rgba(5, 24, 43, 0.95)) !important;
  box-shadow: 0 10px 26px rgba(0, 8, 24, 0.42) !important;
}

.panel-head {
  background: linear-gradient(90deg, var(--color-primary-dark), var(--color-primary)) !important;
  border-bottom: none !important;
  color: #ffffff !important;
  font-family: "Poppins", "Manrope", sans-serif;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 12px;
}

.panel-body {
  color: #2c434f !important;
  background: transparent !important;
  padding: 16px;
}

/* Dashboard Hero - White background */
.dashboard-hero {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%) !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
  padding: 12px 14px !important;
  gap: 10px !important;
}

.dashboard-hero h2 {
  color: #ffffff !important;
  font-size: 18px !important;
  margin: 0 !important;
}

.dashboard-hero p {
  color: rgba(255, 255, 255, 0.88) !important;
  font-size: 13px !important;
  margin: 0 !important;
  line-height: 1.4 !important;
}

.dashboard-hero::after {
  display: none !important;
}

/* Maximize panel width for single-column views */
.app-shell .panel {
  width: 100% !important;
  max-width: none !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

.registry-table-wrap {
  width: 100% !important;
  margin: 0 !important;
}

.registry-table {
  width: 100% !important;
}

/* Registry table vibe */
.table-wrap {
  border: 1px solid rgba(45, 168, 187, 0.18);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(15, 37, 53, 0.96);
}

.table-row {
  border: 0 !important;
  border-bottom: 1px solid rgba(100, 130, 150, 0.28) !important;
  border-radius: 0;
  background: #1a3a48 !important;
  box-shadow: none !important;
  min-height: 40px;
  color: #e9f5fc !important;
}

.table-wrap .table-row:first-child {
  background: #0f2535 !important;
  font-weight: 600;
  color: #ffffff !important;
}

.table-wrap .table-row:last-child {
  border-bottom: 0 !important;
}

.table-row:hover {
  transform: none;
  background: #224556 !important;
}

/* Ensure table headers and native table elements follow the clean theme */
.registry-table thead,
.registry-table thead tr,
.registry-table thead th {
  background: #0f2535 !important;
  color: #e9f5fc !important;
  border-bottom: 1px solid rgba(100, 130, 150, 0.2) !important;
  font-weight: 600;
}

.registry-table th {
  padding: 12px !important;
  text-align: left !important;
}

.registry-table tbody tr {
  background: #1a3a48 !important;
  color: #e9f5fc !important;
}

.registry-table {
  width: 100% !important;
  border-collapse: collapse !important;
  font-size: 14px !important;
}

.registry-table td,
.registry-table th {
  padding: 10px 12px !important;
  text-align: left !important;
  vertical-align: top !important;
}

.registry-table tbody tr {
  border-bottom: 1px solid rgba(100, 130, 150, 0.28) !important;
  transition: background-color 0.2s ease !important;
}

.registry-table tbody tr:hover {
  background: #224556 !important;
}

.registry-table tbody tr.admin-record-row.selected {
  background: #2a5164 !important;
  outline: 1px solid rgba(130, 200, 230, 0.45);
}

.registry-table .row-actions {
  white-space: nowrap;
}

.registry-table .row-actions .btn+.btn {
  margin-left: 8px;
}

.registry-toolbar {
  grid-template-columns: 2fr 1.2fr 1.2fr 1.5fr !important;
  gap: 20px !important;
  align-items: end;
  padding: 24px !important;
  background: rgba(0, 30, 60, 0.2) !important;
  border-radius: 12px 12px 0 0 !important;
  /* Flat bottom */
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  margin: 0 12px 0 !important;
  /* Removed bottom margin */
  border-bottom: none !important;
}

.registry-toolbar .field-group {
  min-width: 0;
}

.registry-toolbar .input-field,
.registry-toolbar select {
  width: 100%;
  min-width: 0;
}

.registry-toolbar-chip {
  align-self: stretch;
}

.toolbar-pill {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid rgba(53, 167, 184, 0.3) !important;
  background: rgba(53, 167, 184, 0.1) !important;
  color: #0af0ff !important;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 14px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registry-table-wrap {
  overflow: auto;
  margin: 0 12px 0 !important;
  /* Match toolbar margin */
  width: auto !important;
  border: 1px solid rgba(45, 168, 187, 0.18);
  border-radius: 0 0 12px 12px !important;
  /* Flat top */
  background: rgba(15, 37, 53, 0.96);
  border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.registry-table {
  width: 100% !important;
  min-width: 0 !important;
  /* allow table to fill container without forcing horizontal scroll */
  border-collapse: collapse !important;
  font-size: 14px !important;
}

/* Remove horizontal padding only for the registry primary panel so the table reaches edges */
#primaryPanel>.panel-body {
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* When viewing dashboard (directory-focus), make primary panel span full width and hide secondary panel */
.content-grid.directory-focus #primaryPanel {
  grid-column: 1 / -1 !important;
}

.content-grid.directory-focus #secondaryPanel {
  display: none !important;
}

.content-grid.directory-focus #dashboardHero,
.content-grid.directory-focus #quickActions,
.content-grid.directory-focus #kpiGrid {
  display: none !important;
}

.content-grid.directory-focus #primaryPanel>.panel-body {
  padding-top: 0 !important;
}

.content-grid.directory-focus #primaryPanel.panel,
.content-grid.directory-focus #primaryPanel {
  background: linear-gradient(180deg, var(--color-primary-dark), #11324a) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
}

.content-grid.directory-focus #primaryPanel .panel-head,
.content-grid.directory-focus #primaryPanel .panel-body {
  background: transparent !important;
  color: #ffffff !important;
}

.content-grid.directory-focus #primaryPanel .registry-summary,
.content-grid.directory-focus #primaryPanel .registry-id-card-wrap {
  background: rgba(13, 39, 56, 0.42) !important;
  border-color: rgba(120, 175, 200, 0.32) !important;
}

.content-grid.directory-focus #primaryPanel .registry-toolbar,
.content-grid.directory-focus #primaryPanel .toolbar-pill {
  background: rgba(15, 37, 53, 0.92) !important;
  border-color: rgba(45, 168, 187, 0.18) !important;
}

/* Make registration panels scrollable in override stylesheet as well */
.admin-register-panel>.panel-body,
.admin-register-side-panel>.panel-body {
  max-height: calc(100vh - 220px) !important;
  overflow-y: auto !important;
  padding-left: 16px !important;
  padding-right: 16px !important;
  padding-bottom: 300px !important;
}

/* Add spacing inside form so content doesn't hug the edges */
.admin-register-panel .form-grid,
.admin-register-panel .record-list {
  padding: 0 12px !important;
}

/* Apply consistent horizontal padding to all admin panels to prevent cramping */
.admin-table-panel .record-list,
.admin-table-panel .registry-toolbar,
.admin-table-panel .table-wrap {
  padding-left: 12px !important;
  padding-right: 12px !important;
}

.admin-register-panel .form-grid,
.admin-register-panel .record-list,
.admin-register-side-panel .record-list {
  padding-left: 12px !important;
  padding-right: 12px !important;
}

/* General spacing for all panel content */
.panel .form-grid,
.panel .record-list {
  margin-left: 12px !important;
  margin-right: 12px !important;
}

.registry-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #0f2535 !important;
  color: #e9f5fc !important;
  text-align: left;
  padding: 10px 12px !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(100, 130, 150, 0.2) !important;
}

.registry-table td,
.registry-table th {
  padding: 10px 12px !important;
  text-align: left !important;
  vertical-align: top !important;
}

.registry-table tbody tr:nth-child(even) {
  background: #1a3a48 !important;
}

.registry-table tbody tr:hover {
  background: #224556 !important;
}

.registry-table tbody tr.admin-record-row.selected {
  background: #2a5164 !important;
  outline: 1px solid rgba(130, 200, 230, 0.45);
}

.registry-table .row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  white-space: nowrap;
}

.registry-table .row-actions .btn {
  min-width: 82px;
}

.registry-summary {
  margin-top: 8px;
  border: 1px solid rgba(45, 168, 187, 0.18);
  border-radius: 10px;
  background: rgba(15, 37, 53, 0.84);
  color: var(--read-muted) !important;
  padding: 10px 14px;
}

.registry-id-card-wrap {
  border: 1px solid rgba(120, 175, 200, 0.32) !important;
  padding: 10px !important;
  background: rgba(13, 39, 56, 0.42) !important;
  border-radius: 10px;
}

.registry-table thead th:first-child {
  border-top-left-radius: 8px;
}

.registry-table thead th:last-child {
  border-top-right-radius: 8px;
}

.admin-table-row {
  grid-template-columns: 96px 1.2fr 1fr 140px;
}

.input-field,
.admin-status-select,
.color-code-pill,
textarea.input-field,
select.input-field {
  border: 2px solid var(--color-border) !important;
  border-radius: 8px;
  background: transparent !important;
  color: var(--color-text-dark) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
  min-height: 40px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

.input-field:hover,
.admin-status-select:hover,
textarea.input-field:hover,
select.input-field:hover {
  border-color: var(--color-primary-light) !important;
  background: rgba(255, 255, 255, 0.05) !important;
  box-shadow: 0 0 0 4px rgba(44, 106, 162, 0.15), 0 6px 16px rgba(44, 106, 162, 0.15) !important;
}

.input-field:focus,
.admin-status-select:focus,
textarea.input-field:focus,
select.input-field:focus {
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 4px rgba(44, 106, 162, 0.15), 0 6px 16px rgba(44, 106, 162, 0.15) !important;
  background: rgba(255, 255, 255, 0.08) !important;
}

/* Master Detail Modal Expansion */
.modal-card.master-detail-modal-card {
  max-width: 960px !important;
  width: 92% !important;
  padding: 0 !important;
  /* Header and body handle padding */
  text-align: left !important;
}

.master-detail-modal-head {
  padding: 20px 24px !important;
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  border-bottom: 1px solid rgba(53, 167, 184, 0.3) !important;
}

#masterDetailModalBody {
  padding: 20px !important;
  max-height: 85vh !important;
  overflow-y: auto !important;
  background: linear-gradient(180deg, rgba(8, 33, 56, 0.96), rgba(5, 24, 43, 0.98)) !important;
}

.master-detail-modal-card {
  width: min(980px, 95vw) !important;
  max-height: 90vh !important;
}

/* Force 2-column layout for Master Detail content */
#masterDetailModalBody .registry-detail-body {
  display: grid !important;
  grid-template-columns: 1.2fr 1fr !important;
  grid-template-areas:
    "profile summary"
    "preview preview" !important;
  gap: 20px !important;
  align-items: start !important;
  padding: 0 !important;
}

#masterDetailModalBody .registry-profile-card {
  grid-area: profile !important;
  margin: 0 !important;
  height: auto !important;
  min-height: 160px !important;
  background: linear-gradient(135deg, rgba(44, 106, 162, 0.15), rgba(24, 124, 120, 0.1)) !important;
  border: 1px solid rgba(53, 167, 184, 0.2) !important;
}

#masterDetailModalBody .registry-summary-list {
  grid-area: summary !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  /* 2 columns for summary items in modal */
  gap: 12px !important;
  margin: 0 !important;
}

/* Ensure individual cards in summary list look good in 2-col */
#masterDetailModalBody .registry-summary-list .record-card {
  margin: 0 !important;
  padding: 12px !important;
  min-height: 70px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}

#masterDetailModalBody .registry-id-preview {
  grid-area: preview !important;
  margin-top: 10px !important;
  width: 100% !important;
  display: block !important;
}

#masterDetailModalBody .registry-id-card-wrap {
  display: flex !important;
  justify-content: center !important;
  padding: 24px !important;
  background: rgba(0, 0, 0, 0.3) !important;
  border-radius: 12px !important;
  border: 1px solid rgba(53, 167, 184, 0.1) !important;
}

/* Fallback for Dashboard Detail Panel (non-modal) */
.admin-detail-panel .registry-detail-body {
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
}

.admin-detail-panel .registry-summary-list {
  display: grid !important;
  grid-template-columns: 1fr !important;
  /* 1 column for dashboard sidebar */
  gap: 8px !important;
}

@media (max-width: 900px) {
  #masterDetailModalBody .registry-detail-body {
    grid-template-columns: 1fr !important;
    grid-template-areas:
      "profile"
      "summary"
      "preview" !important;
  }

  #masterDetailModalBody .registry-summary-list {
    grid-template-columns: 1fr 1fr !important;
  }
}

@media (max-width: 600px) {
  #masterDetailModalBody .registry-summary-list {
    grid-template-columns: 1fr !important;
  }
}

.field-label {
  color: rgba(180, 200, 220, 0.6) !important;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 4px;
}

.registry-toolbar .input-field,
.registry-toolbar select {
  height: 44px !important;
  padding: 0 14px !important;
  background: rgba(0, 0, 0, 0.25) !important;
  border: 1.5px solid rgba(255, 255, 255, 0.1) !important;
  color: #fff !important;
  font-size: 14px !important;
}

/* Buttons */
.btn,
.quick-action,
.link-button {
  border-radius: 9px;
  border: none !important;
  background: linear-gradient(135deg, var(--color-bg-white) 0%, #f2f6f8 100%) !important;
  color: var(--color-text-dark) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  text-transform: none;
  letter-spacing: 0.5px;
  font-weight: 600 !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  position: relative;
  overflow: hidden;
  min-height: 42px;
  padding: 10px 16px;
}

.btn::before,
.quick-action::before,
.link-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
  z-index: 1;
}

.btn:hover::before,
.quick-action:hover::before,
.link-button:hover::before {
  left: 100%;
}

.btn:hover,
.quick-action:hover,
.link-button:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15) !important;
  transform: translateY(-2px);
  border: none !important;
}

.btn.primary,
.quick-action:hover,
.portal-tab.active {
  border: none !important;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 20px rgba(44, 106, 162, 0.3) !important;
}

.btn.primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, #16385a 100%) !important;
  box-shadow: 0 10px 28px rgba(44, 106, 162, 0.4) !important;
  transform: translateY(-2px);
  border: none !important;
}

.status-badge.active {
  background: rgba(40, 167, 69, 0.16) !important;
  color: #1d7f37 !important;
  border-color: rgba(40, 167, 69, 0.3) !important;
}

.status-badge.pending {
  background: rgba(220, 53, 69, 0.16) !important;
  color: var(--color-danger) !important;
  border-color: rgba(220, 53, 69, 0.3) !important;
}

.status-badge.expired {
  background: rgba(220, 53, 69, 0.16) !important;
  color: #9f3737 !important;
  border-color: rgba(220, 53, 69, 0.3) !important;
}

.status-badge::before {
  display: none;
}

.id-photo-image-redesign {
  object-fit: cover !important;
  object-position: center !important;
}

@media (max-width: 820px) {

  body,
  html {
    overflow-y: auto !important;
    height: auto !important;
    overscroll-behavior: auto !important;
  }

  .app-shell {
    height: auto !important;
    min-height: 100vh !important;
    overflow: visible !important;
    display: block !important;
  }

  .app-shell .canvas {
    grid-template-columns: 1fr !important;
    display: block !important;
    position: relative !important;
    transform: none !important;
    will-change: auto !important;
  }

  .app-shell .sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0 !important;
    /* Force full height */
    height: 100vh !important;
    z-index: 99999 !important;
    width: 252px !important;
    min-width: 252px !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3) !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    will-change: transform;
    transform: translate3d(0, 0, 0);
    contain: layout;
    overflow-y: auto !important;
    /* Enable internal scrolling */
  }

  .app-shell .sidebar.collapsed {
    transform: translate3d(-100%, 0, 0) !important;
    width: 252px !important;
    min-width: 252px !important;
  }

  .canvas.sidebar-collapsed {
    grid-template-columns: 1fr !important;
  }

  .logo-block {
    padding: 10px 8px !important;
  }

  .nav-list {
    padding: 5px 6px !important;
  }

  .nav-list .nav-item {
    padding: 3px 10px !important;
    margin-bottom: 2px !important;
    font-size: 11px !important;
    min-height: auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .main-panel {
    padding: 10px;
    width: 100% !important;
    min-width: 100% !important;
    margin: 0 !important;
    height: auto !important;
    /* Allow panel to grow naturally */
    overflow: visible !important;
    display: block !important;
  }

  .topbar {
    flex-direction: column !important;
    padding: 25px 15px !important;
    gap: 20px !important;
    height: auto !important;
    align-items: center !important;
    text-align: center !important;
    background: linear-gradient(180deg, rgba(13, 49, 71, 0.98), rgba(10, 30, 43, 0.98)) !important;
    border-bottom: 2px solid rgba(10, 240, 255, 0.2) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
  }

  .breadcrumbs {
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 1px !important;
    margin-bottom: 5px !important;
    color: #0af0ff !important;
    opacity: 0.8 !important;
    display: block !important;
    width: 100% !important;
  }

  .profile-wrap {
    width: 100% !important;
    padding: 0 !important;
  }

  .profile-wrap .meta-row {
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    justify-content: center !important;
  }

  .profile-avatar {
    width: 56px !important;
    height: 56px !important;
    font-size: 1.3rem !important;
    margin-bottom: 5px !important;
    box-shadow: 0 0 15px rgba(10, 240, 255, 0.3) !important;
    border: 2px solid #0af0ff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  .profile-meta {
    text-align: center !important;
    margin: 0 !important;
  }

  .profile-meta strong {
    font-size: 1.15rem !important;
    display: block !important;
    margin-bottom: 2px !important;
    color: #ffffff !important;
  }

  .profile-meta span {
    font-size: 0.8rem !important;
    opacity: 0.6 !important;
    display: block !important;
  }

  .link-button#logoutButton {
    background: linear-gradient(135deg, #0d3147, #1a4a64) !important;
    border: 1.5px solid rgba(10, 240, 255, 0.4) !important;
    color: #0af0ff !important;
    padding: 10px 30px !important;
    border-radius: 30px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    font-size: 0.75rem !important;
    letter-spacing: 1px !important;
    margin-top: 10px !important;
    width: auto !important;
    min-width: 140px !important;
  }

  .content-grid {
    grid-template-columns: 1fr !important;
    padding: 10px !important;
    gap: 15px !important;
    display: flex !important;
    flex-direction: column !important;
  }

  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
  }

  .form-grid .field-group.full {
    grid-column: span 1 !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    display: grid !important;
  }

  .hero-copy h2 {
    font-size: 1.25rem !important;
    line-height: 1.3 !important;
    margin-top: 8px !important;
  }

  .hero-copy p {
    font-size: 0.9rem !important;
    opacity: 0.8 !important;
  }

  /* Trend / KPI Cards on mobile */
  .trend-summary {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 20px !important;
  }

  .trend-card {
    padding: 10px !important;
    min-height: auto !important;
  }

  .trend-label {
    font-size: 0.7rem !important;
    text-transform: uppercase !important;
  }

  .trend-value {
    font-size: 1.1rem !important;
    font-weight: 800 !important;
  }

  /* Analytics Chart on mobile */
  .performance-chart {
    padding: 12px !important;
    overflow: hidden !important;
  }

  .chart-title {
    font-size: 0.9rem !important;
    margin-bottom: 15px !important;
  }

  .chart-legend {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
    margin-top: 20px !important;
    padding: 10px !important;
    background: rgba(0, 0, 0, 0.03) !important;
    border-radius: 8px !important;
  }

  .chart-legend span {
    font-size: 0.75rem !important;
    white-space: nowrap !important;
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
  }

  .panel-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 15px !important;
  }

  .actions {
    display: flex !important;
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .actions input,
  .actions select {
    width: 100% !important;
    margin: 0 !important;
    min-height: 42px !important;
  }

  .table-container {
    overflow-x: auto !important;
    display: block !important;
    width: 100% !important;
    -webkit-overflow-scrolling: touch !important;
    margin-top: 10px !important;
  }

  .registry-table {
    min-width: 700px !important;
    /* Force width for horizontal scroll */
  }

  .registry-table th,
  .registry-table td {
    padding: 12px 10px !important;
    font-size: 13px !important;
  }

  .registry-toolbar {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding: 10px !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    margin-bottom: 20px !important;
  }

  .bulk-action-bar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 15px !important;
    padding: 15px !important;
    margin: 10px !important;
  }

  .bulk-action-bar .button-row {
    flex-direction: column !important;
    width: 100% !important;
  }

  .bulk-action-bar .btn {
    width: 100% !important;
    text-align: center !important;
  }

  .table-wrap {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin-top: 10px !important;
    border-radius: 8px !important;
  }

  .registry-table {
    min-width: 800px !important;
    /* Force min-width to trigger horizontal scroll instead of squishing */
  }

  .admin-record-row td {
    white-space: nowrap !important;
  }

  #secondaryPanel {
    margin-top: 20px !important;
    width: 100% !important;
  }

  .button-row {
    flex-direction: column !important;
    gap: 10px !important;
    width: 100% !important;
  }

  .button-row .btn {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Form spacing for mobile */
  .field-group label {
    font-size: 11px !important;
    margin-bottom: 4px !important;
  }

  .input-field,
  select,
  textarea {
    min-height: 44px !important;
    font-size: 16px !important;
    /* Prevent iOS zoom on focus */
  }

  /* Modal & Master Detail Responsiveness */
  .modal-content {
    width: 95% !important;
    max-width: 98% !important;
    padding: 12px !important;
    margin: auto !important;
    max-height: 95vh !important;
  }

  .registry-detail-body {
    display: flex !important;
    flex-direction: column !important;
    padding: 10px !important;
    gap: 15px !important;
  }

  .registry-profile-card {
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    gap: 12px !important;
    padding: 15px !important;
  }

  .registry-avatar-large {
    width: 100px !important;
    height: 100px !important;
    margin: 0 auto !important;
  }

  .registry-summary-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .registry-summary-list .record-card {
    width: 100% !important;
    margin: 0 !important;
  }

  /* ID Card Preview Scaling for Mobile */
  .id-card-realistic {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    overflow: visible !important;
    margin: 15px 0 !important;
    /* Scale down for mobile if needed, though 90mm ~ 340px fits most */
  }

  @media (max-width: 400px) {
    .id-card-redesign {
      transform: scale(0.85) !important;
      transform-origin: center center !important;
    }

    .id-card-realistic {
      height: 180px !important;
      /* Adjust height to match scale */
    }
  }

  .registry-id-preview .panel-head {
    flex-direction: row !important;
    /* Keep the flip button row horizontal */
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px !important;
  }

  .registry-id-preview .panel-head span:first-child {
    font-size: 0.85rem !important;
  }
}

/* Final readability lock: keep text contrast stable on all surfaces */
:root {
  --read-dark: #1b2f39;
  --read-body: #274552;
  --read-muted: #4f6975;
  --read-light: #f4fbff;
}

.app-shell,
.app-shell * {
  text-shadow: none !important;
}

.app-shell .panel,
.app-shell .panel-body,
.app-shell .record-card,
.app-shell .table-row,
.app-shell .notice,
.app-shell .timeline-content,
.app-shell .kpi,
.app-shell .hero-metric,
.app-shell .activity-card,
.app-shell .chart,
.app-shell .thumb,
.app-shell .map {
  color: var(--read-body) !important;
}

.app-shell .panel-head,
.app-shell .panel-head span,
.app-shell .section-title,
.app-shell .dashboard-hero h2,
.app-shell .record-card strong,
.app-shell .timeline-content strong,
.app-shell .kpi .value,
.app-shell .hero-metric .metric-value,
.app-shell .activity-card .large-value,
.app-shell .profile-meta strong,
.app-shell #sectionTitle {
  color: var(--read-dark) !important;
  font-weight: 700 !important;
}

.app-shell p,
.app-shell span,
.app-shell label,
.app-shell .helper-text,
.app-shell .field-help,
.app-shell .kpi .label,
.app-shell .hero-metric .metric-label,
.app-shell .activity-card .small-label,
.app-shell .note,
.app-shell .record-card span,
.app-shell .timeline-content span {
  color: var(--read-muted) !important;
}

.app-shell .table-wrap .table-row,
.app-shell .table-wrap .table-row span,
.app-shell .table-wrap .table-row strong {
  color: #243e4a !important;
}

.app-shell .table-wrap .table-row:first-child,
.app-shell .table-wrap .table-row:first-child strong {
  color: #1f3642 !important;
}

/* Full-size workspace tuning: maximize content area on desktop/tablet widths */
.app-shell,
.app-shell .canvas {
  width: 100% !important;
  max-width: none !important;
}

.app-shell .canvas {
  grid-template-columns: 252px minmax(0, 1fr) !important;
}

.app-shell .content-grid,
.app-shell .content-grid.directory-focus {
  display: grid !important;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 1fr) !important;
  gap: 24px !important;
}

/* Single column expansion logic */
.app-shell .content-grid>#secondaryPanel.hidden {
  display: none !important;
}

.app-shell .content-grid:has(#secondaryPanel.hidden) {
  grid-template-columns: 1fr !important;
}

/* Fallback for browsers that don't support :has() - forcing wide views */
.app-shell .primary-column {
  width: 100% !important;
  max-width: none !important;
}

.app-shell .content-grid>* {
  width: 100% !important;
  min-width: 0 !important;
}

#dashboardHero,
#quickActions,
#kpiGrid {
  width: 100% !important;
  min-width: 0 !important;
}

#dashboardHero,
#primaryPanel,
#secondaryPanel {
  width: 100% !important;
  min-width: 0 !important;
}

@media (max-width: 1500px) {

  .app-shell .content-grid,
  .app-shell .content-grid.directory-focus {
    grid-template-columns: 1fr !important;
  }

  #dashboardHero,
  #primaryPanel,
  #secondaryPanel {
    grid-column: 1 !important;
  }

  .content-grid.directory-focus #dashboardHero,
  .content-grid.directory-focus #quickActions,
  .content-grid.directory-focus #kpiGrid {
    display: none !important;
  }
}

.app-shell .field-label,
.app-shell .breadcrumbs .crumb,
.app-shell .breadcrumbs .sep,
.app-shell .breadcrumbs .crumb.current {
  color: #e9fbff !important;
}

.app-shell .input-field,
.app-shell .admin-status-select,
.app-shell textarea.input-field,
.app-shell select.input-field,
.app-shell .color-code-pill {
  color: #163746 !important;
  font-weight: 500 !important;
}

.app-shell .input-field::placeholder,
.app-shell textarea.input-field::placeholder {
  color: #6f8895 !important;
  opacity: 1 !important;
}

.app-shell .btn,
.app-shell .quick-action,
.app-shell .link-button {
  background: linear-gradient(135deg, #f0f4f8 0%, #e8ecf0 100%) !important;
  color: #204859 !important;
  font-weight: 600 !important;
  border: none !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  min-height: 42px !important;
}

.app-shell .btn:hover,
.app-shell .quick-action:hover,
.app-shell .link-button:hover {
  background: linear-gradient(135deg, #e8ecf0 0%, #dce2e8 100%) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15) !important;
  transform: translateY(-2px) !important;
  color: #163746 !important;
}

.app-shell .btn.primary,
.app-shell .quick-action:hover,
.app-shell .portal-tab.active,
.app-shell #logoutButton,
.app-shell .nav-list .nav-item.active,
.app-shell .nav-badge {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
  color: var(--read-light) !important;
  box-shadow: 0 6px 20px rgba(44, 106, 162, 0.35) !important;
  border: none !important;
}

.app-shell .btn.primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, #16385a 100%) !important;
  box-shadow: 0 10px 28px rgba(44, 106, 162, 0.45) !important;
  transform: translateY(-2px) !important;
}

.app-shell .topbar,
.app-shell .topbar * {
  color: #ecfbff !important;
}

.app-shell .status-badge.active {
  color: #155f2b !important;
}

.app-shell .status-badge.pending {
  color: #dc3545 !important;
}

.app-shell .status-badge.expired {
  color: #8e3232 !important;
}

#masterDetailModal {
  z-index: 80 !important;
}

.master-detail-modal-card {
  width: min(960px, 96vw) !important;
  max-height: 90vh;
  overflow: hidden;
}

.master-detail-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#masterDetailModalBody {
  overflow-y: auto;
  max-height: calc(90vh - 88px);
  padding-right: 4px;
}

#masterDetailModal .panel-head {
  background: linear-gradient(90deg, rgba(44, 106, 162, 0.36), rgba(30, 77, 115, 0.6)) !important;
  border: 1px solid rgba(44, 106, 162, 0.26) !important;
  border-radius: 10px;
  color: #f3fbff !important;
}

#masterDetailModal .panel-head span,
#masterDetailModal .panel-head strong,
#masterDetailModal .panel-head h3 {
  color: #eaf7ff !important;
}

#masterDetailModal .btn {
  border: none !important;
  background: linear-gradient(135deg, #3a6b8a 0%, #2a5570 100%) !important;
  color: #ddf6ff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  min-height: 42px !important;
}

#masterDetailModal .btn:hover {
  background: linear-gradient(135deg, #4a7b9a 0%, #3a6580 100%) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3) !important;
  transform: translateY(-2px) !important;
}

#masterDetailModal .btn.primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 20px rgba(44, 106, 162, 0.35) !important;
  border: none !important;
}

#masterDetailModal .btn.primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, #16385a 100%) !important;
  box-shadow: 0 10px 28px rgba(44, 106, 162, 0.45) !important;
  transform: translateY(-2px) !important;
}

@media (max-width: 900px) {
  .master-detail-modal-card {
    width: 96vw !important;
  }
}

/* Login readability (when logging out) */
.login-wireframe,
.login-wireframe * {
  text-shadow: none !important;
}

.login-wireframe .auth-title,
.login-wireframe .system-title,
.login-wireframe .neon-label,
.login-wireframe .portal-jump,
.login-wireframe .portal-jump-btn,
.login-wireframe .form-kicker {
  color: #effbff !important;
}

.login-wireframe .neon-input {
  color: #f3fcff !important;
}

.login-wireframe .neon-input::placeholder {
  color: #a6c7d4 !important;
  opacity: 1 !important;
}

/* Low-glare dark override */
:root {
  --lg-bg-1: #0b1a24;
  --lg-bg-2: #102433;
  --lg-surface-1: #132a39;
  --lg-surface-2: #173447;
  --lg-panel: #112733;
  --lg-panel-soft: #173241;
  --lg-line: rgba(44, 106, 162, 0.26);
  --lg-text: #f3fbff;
  --lg-muted: #b7cfde;
  --lg-accent: var(--color-secondary);
  --lg-accent-2: #3aaec0;
}

body.dark-mode {
  background:
    radial-gradient(1100px 600px at -10% -18%, rgba(53, 167, 184, 0.14) 0%, rgba(53, 167, 184, 0) 64%),
    radial-gradient(900px 520px at 110% -16%, rgba(44, 106, 162, 0.16) 0%, rgba(44, 106, 162, 0) 66%),
    linear-gradient(180deg, var(--lg-bg-1) 0%, var(--lg-bg-2) 100%) !important;
  color: var(--lg-text) !important;
}

.app-shell .canvas {
  background: linear-gradient(180deg, #0f2431, #132b3b) !important;
  border-color: var(--lg-line) !important;
  box-shadow: 0 24px 52px rgba(2, 10, 16, 0.5) !important;
}

.app-shell .sidebar {
  background: linear-gradient(180deg, #0d3147, #102b3f) !important;
  border-right-color: rgba(44, 106, 162, 0.26) !important;
}

.app-shell .topbar,
.app-shell .panel,
.app-shell .record-card,
.app-shell .table-row,
.app-shell .notice,
.app-shell .timeline-content,
.app-shell .hero-metric,
.app-shell .kpi,
.app-shell .activity-card,
.app-shell .input-field,
.app-shell .admin-status-select,
.app-shell .color-code-pill,
.app-shell .panel-body {
  background: linear-gradient(180deg, var(--lg-surface-1), var(--lg-surface-2)) !important;
  border-color: var(--lg-line) !important;
  color: var(--lg-text) !important;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28) !important;
}

.app-shell .panel-head {
  background: linear-gradient(90deg, rgba(58, 174, 192, 0.28), rgba(47, 149, 166, 0.2)) !important;
  border-bottom-color: var(--lg-line) !important;
  color: #f3fbff !important;
}

.app-shell .table-wrap .table-row:first-child {
  background: linear-gradient(180deg, #1b3b4f, #1a384b) !important;
}

.app-shell .table-wrap .table-row,
.app-shell .table-wrap .table-row span,
.app-shell .table-wrap .table-row strong {
  color: #e9f5fc !important;
}

.app-shell p,
.app-shell span,
.app-shell label,
.app-shell .helper-text,
.app-shell .field-help,
.app-shell .note,
.app-shell .kpi .label,
.app-shell .hero-metric .metric-label,
.app-shell .activity-card .small-label,
.app-shell .record-card span,
.app-shell .timeline-content span {
  color: var(--lg-muted) !important;
}

.app-shell .section-title,
.app-shell .panel-head,
.app-shell .record-card strong,
.app-shell .timeline-content strong,
.app-shell .kpi .value,
.app-shell .hero-metric .metric-value,
.app-shell .activity-card .large-value,
.app-shell .profile-meta strong {
  color: #f3fbff !important;
}

.app-shell .input-field,
.app-shell .admin-status-select,
.app-shell textarea.input-field,
.app-shell select.input-field {
  color: #ecf8ff !important;
}

.app-shell .input-field::placeholder,
.app-shell textarea.input-field::placeholder {
  color: #a7c3d2 !important;
}

.app-shell .btn,
.app-shell .quick-action,
.app-shell .link-button {
  background: linear-gradient(135deg, #1a3a4d 0%, #173344 100%) !important;
  border: none !important;
  color: #eaf7ff !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
  min-height: 42px !important;
}

.app-shell .btn:hover,
.app-shell .quick-action:hover,
.app-shell .link-button:hover {
  background: linear-gradient(135deg, #254a5a 0%, #223847 100%) !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4) !important;
  transform: translateY(-2px) !important;
  color: #ffffff !important;
  border: none !important;
}

.app-shell .btn.primary,
.app-shell .quick-action:hover,
.app-shell .portal-tab.active,
.app-shell #logoutButton,
.app-shell .nav-list .nav-item.active,
.app-shell .nav-badge {
  background: linear-gradient(135deg, var(--lg-accent-2), var(--lg-accent)) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 6px 20px rgba(53, 167, 184, 0.35) !important;
}

.app-shell .btn.primary:hover {
  background: linear-gradient(135deg, var(--lg-accent), #2a7f8d) !important;
  box-shadow: 0 10px 28px rgba(53, 167, 184, 0.45) !important;
  transform: translateY(-2px) !important;
}

.app-shell .nav-list .nav-item {
  background: rgba(255, 255, 255, 0.03) !important;
  border-color: rgba(176, 215, 236, 0.2) !important;
  color: #e8f5fc !important;
}

.app-shell .nav-list .nav-item:hover {
  background: rgba(255, 255, 255, 0.09) !important;
}

.app-shell .status-badge.active {
  color: #baf7cd !important;
  background: rgba(35, 140, 70, 0.24) !important;
}

.app-shell .status-badge.pending {
  color: #ff6b7a !important;
  background: rgba(220, 53, 69, 0.28) !important;
}

.app-shell .status-badge.expired {
  color: #ffc5c5 !important;
  background: rgba(158, 58, 58, 0.28) !important;
}

/* Logout modal visibility and clickability */
.modal.hidden {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 10, 16, 0.62) !important;
  z-index: 9999 !important;
}

.modal-card {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid rgba(170, 214, 230, 0.28) !important;
  background: linear-gradient(180deg, #132a39, #0f2431) !important;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5) !important;
  padding: 18px;
  position: relative !important;
}

.fims-modal-close-x {
  position: absolute !important;
  top: 15px !important;
  right: 15px !important;
  width: 34px !important;
  height: 34px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: rgba(255, 255, 255, 0.15) !important;
  border: 1px solid rgba(255, 255, 255, 0.3) !important;
  color: #ffffff !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  font-size: 24px !important;
  line-height: 1 !important;
  z-index: 1000 !important;
  transition: all 0.2s ease !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
  padding: 0 !important;
  margin: 0 !important;
  min-width: 0 !important;
  min-height: 0 !important;
  font-family: Arial, sans-serif !important;
  text-align: center !important;
}

.fims-modal-close-x:hover {
  background: rgba(255, 255, 255, 0.3) !important;
  border-color: #ffffff !important;
  transform: scale(1.1) !important;
  color: #ffffff !important;
}

.modal-card h3,
.modal-card p {
  color: #eef9ff !important;
}

.modal-card .button-row {
  justify-content: flex-end;
}

.modal-card .btn {
  min-width: 92px;
}

/* ============ DARK MODE STYLES ============ */
body.dark-mode {
  --gui-bg: #1a1a1a;
  --gui-bg-soft: #242424;
  --gui-panel: #2a2a2a;
  --gui-panel-soft: #333333;
  --gui-line: #404040;
  --gui-text: #e0e0e0;
  --gui-muted: #a0a0a0;

  --gui-sidebar-1: #1a2a3a;
  --gui-sidebar-2: #141f2f;
  --gui-sidebar-line: rgba(100, 150, 180, 0.24);

  background: radial-gradient(1000px 520px at -10% -16%, rgba(30, 60, 100, 0.16) 0%, rgba(30, 60, 100, 0) 62%),
    radial-gradient(860px 480px at 110% -14%, rgba(10, 20, 40, 0.14) 0%, rgba(10, 20, 40, 0) 65%),
    linear-gradient(180deg, #1a1a1a 0%, #242424 100%) !important;
}

body.dark-mode .app-shell .canvas {
  background: linear-gradient(180deg, #1f1f1f, #2a2a2a) !important;
  border-color: #404040 !important;
  box-shadow: 0 22px 54px rgba(0, 0, 0, 0.5) !important;
}

body.dark-mode .app-shell .sidebar {
  background-color: #1a2a3a !important;
  border-right-color: #404040 !important;
}

body.dark-mode .app-shell .topbar {
  background-color: #242424 !important;
  border-bottom-color: #404040 !important;
  color: #e0e0e0 !important;
}

body.dark-mode .app-shell .panel {
  background-color: #2a2a2a !important;
  border-color: #404040 !important;
  color: #e0e0e0 !important;
}

body.dark-mode .panel-header {
  border-bottom-color: #404040 !important;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
  background-color: #333333 !important;
  color: #e0e0e0 !important;
  border-color: #404040 !important;
}

body.dark-mode input:focus,
body.dark-mode textarea:focus,
body.dark-mode select:focus {
  border-color: #2c6aa2 !important;
  box-shadow: 0 0 0 3px rgba(44, 106, 162, 0.2) !important;
}

body.dark-mode .table-container {
  background-color: #2a2a2a !important;
}

body.dark-mode .registry-table {
  background-color: #2a2a2a !important;
  color: #e0e0e0 !important;
}

body.dark-mode .registry-table thead {
  background-color: #333333 !important;
  color: #e0e0e0 !important;
}

body.dark-mode .registry-table tbody tr:hover {
  background-color: #404040 !important;
}

body.dark-mode .registry-table td,
body.dark-mode .registry-table th {
  border-color: #404040 !important;
  color: #e0e0e0 !important;
}

body.dark-mode .modal-overlay {
  background-color: rgba(0, 0, 0, 0.8) !important;
}

body.dark-mode .modal-card {
  background-color: #2a2a2a !important;
  border-color: #404040 !important;
  color: #e0e0e0 !important;
}

body.dark-mode .btn {
  background-color: #2c6aa2 !important;
  color: #fff !important;
}

body.dark-mode .btn:hover {
  background-color: #1e4a74 !important;
}

body.dark-mode .btn.secondary {
  background-color: #505050 !important;
}

body.dark-mode .btn.secondary:hover {
  background-color: #606060 !important;
}

body.dark-mode .nav-item {
  color: #e0e0e0 !important;
}

body.dark-mode .nav-item:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

body.dark-mode .nav-item.active {
  background-color: rgba(44, 106, 162, 0.3) !important;
}

body.dark-mode .kpi-card {
  background-color: #333333 !important;
  border-color: #404040 !important;
  color: #e0e0e0 !important;
}

/* ============ FIX: NAVIGATION LIST SCROLLABILITY ============ */
/* Ensure nav-list has proper height and scrolling for bottom items */
.nav-list {
  padding: 10px 8px 80px 8px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.08);
  flex: 1;
  min-height: 0;
  max-height: none !important;
}

.nav-list::-webkit-scrollbar {
  width: 6px;
}

.nav-list::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

.nav-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.nav-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* Highlight bottom nav items (theme colors and activity logs) */
.nav-list .nav-item[data-view="theme-settings"],
.nav-list .nav-item[data-view="activity-logs"] {
  margin-top: 12px !important;
  border: 1px solid rgba(255, 255, 255, 0.2) !important;
  background: rgba(255, 255, 255, 0.06) !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0;
}

.nav-list .nav-item[data-view="theme-settings"]:first-of-type,
.nav-list .nav-item[data-view="settings-users"]+.nav-item {
  border-top: 2px solid rgba(255, 255, 255, 0.15) !important;
  padding-top: 12px !important;
}

.nav-list .nav-item[data-view="theme-settings"]:hover,
.nav-list .nav-item[data-view="activity-logs"]:hover {
  background: rgba(255, 255, 255, 0.12) !important;
  border-color: rgba(255, 255, 255, 0.3) !important;
  transform: translateX(2px);
}

body.dark-mode .breadcrumbs {
  color: #e0e0e0 !important;
}

body.dark-mode .breadcrumbs a {
  color: #2c6aa2 !important;
}

/* Sidebar blue lock for normal dashboard view */
body:not(.dark-mode) .app-shell .topbar,
body:not(.dark-mode) .app-shell .panel-head,
body:not(.dark-mode) .app-shell .dashboard-hero,
body:not(.dark-mode) .app-shell .registry-table-wrap {
  background: linear-gradient(180deg, var(--color-primary-dark), var(--color-primary)) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: #ffffff !important;
}

body:not(.dark-mode) .app-shell .panel-head span,
body:not(.dark-mode) .app-shell .panel-head strong,
body:not(.dark-mode) .app-shell .panel-head h3,
body:not(.dark-mode) .app-shell .dashboard-hero h2,
body:not(.dark-mode) .app-shell .dashboard-hero p,
body:not(.dark-mode) .app-shell .section-title {
  color: #ffffff !important;
}

body:not(.dark-mode) .app-shell .registry-table thead th,
body:not(.dark-mode) .app-shell .registry-table thead,
body:not(.dark-mode) .app-shell .registry-table thead tr {
  background: linear-gradient(180deg, var(--color-primary-dark), var(--color-primary)) !important;
  color: #ffffff !important;
}

/* Dashboard button palette lock - all buttons match sidebar blue */
.content-grid.directory-focus .btn,
.content-grid.directory-focus button,
.registry-table .btn,
.registry-table button,
.registry-toolbar .btn,
.registry-toolbar button {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 4px 12px rgba(44, 106, 162, 0.2) !important;
}

.content-grid.directory-focus .btn:hover,
.content-grid.directory-focus button:hover,
.registry-table .btn:hover,
.registry-table button:hover,
.registry-toolbar .btn:hover,
.registry-toolbar button:hover {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, #1a3f5a 100%) !important;
  box-shadow: 0 6px 18px rgba(44, 106, 162, 0.35) !important;
  transform: translateY(-1px) !important;
}

#barangayResidentsBody {
  max-height: 500px;
  overflow-y: auto;
  padding-right: 5px;
}

#barangayResidentsBody::-webkit-scrollbar {
  width: 6px;
}

#barangayResidentsBody::-webkit-scrollbar-track {
  background: rgba(0, 212, 255, 0.05);
  border-radius: 10px;
}

#barangayResidentsBody::-webkit-scrollbar-thumb {
  background: rgba(0, 212, 255, 0.3);
  border-radius: 10px;
}

#barangayResidentsBody::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 212, 255, 0.5);
}

/* Modal Expansion Override */
#barangayResidentsModal .modal-card {
  max-width: 1200px !important;
  width: 95% !important;
}

/* Additional button overrides for accent/secondary variations */
.content-grid.directory-focus .btn.btn-accent,
.content-grid.directory-focus .btn.accent,
.registry-table .btn.btn-accent,
.registry-table .btn.accent,
.registry-table .btn.btn-secondary,
.registry-table .btn.secondary,
.btn[class*="secondary"],
.btn[class*="accent"] {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
  color: #ffffff !important;
}

/* Force all .btn.primary to use sidebar blue - override cyan gradient from styles.css */
.btn.primary,
button.primary,
.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 20px rgba(44, 106, 162, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1) inset !important;
  border-color: transparent !important;
}

.btn.primary:hover,
button.primary:hover,
.btn-primary:hover {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, #16385a 100%) !important;
  box-shadow: 0 10px 30px rgba(44, 106, 162, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.15) inset !important;
  transform: translateY(-2px) !important;
}

/* --- ID Card Back Preview Styles --- */
.id-card-back {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  background: #fff !important;
}

.id-card-back {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
  background: #ffffff !important;
  color: #000000 !important;
}

.id-card-back * {
  opacity: 1 !important;
  visibility: visible !important;
}

.id-card-body-back {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
  padding: 5mm 5.5mm !important;
  background: #fff !important;
  color: #000000 !important;
}

.id-back-emergency {
  display: grid !important;
  gap: 1.2mm !important;
  width: 100% !important;
}

.id-back-heading {
  font-size: 2.35mm !important;
  font-weight: 900 !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  line-height: 1.1 !important;
  letter-spacing: 0.03mm !important;
  text-transform: uppercase !important;
  margin-bottom: 0.5mm !important;
  display: block !important;
}

.id-back-line {
  display: grid !important;
  grid-template-columns: 32mm 1fr !important;
  /* Wider stable width */
  align-items: end !important;
  gap: 1.5mm !important;
  color: #000000 !important;
}

.id-back-line>span:first-child {
  font-size: 2.3mm !important;
  font-weight: 900 !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  line-height: 1.05 !important;
  text-transform: uppercase !important;
  display: block !important;
}

.id-back-line>span:last-child {
  display: block !important;
  border-bottom: 0.3mm solid #000000 !important;
  min-height: 3.8mm !important;
  font-size: 2.3mm !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  font-weight: 700 !important;
  padding-left: 1.2mm !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.id-back-cert-title {
  margin-top: 2.5mm !important;
  background: var(--id-accent, #2176c7) !important;
  color: #ffffff !important;
  -webkit-text-fill-color: #ffffff !important;
  text-align: center !important;
  font-size: 7.2mm !important;
  font-weight: 900 !important;
  letter-spacing: 0.1mm !important;
  line-height: 1 !important;
  padding: 1.4mm !important;
  text-transform: uppercase !important;
}

.id-back-cert-copy {
  margin-top: 2.5mm !important;
  text-align: center !important;
  font-size: 2.3mm !important;
  line-height: 1.35 !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  font-weight: 500 !important;
  padding: 0 4mm !important;
  display: block !important;
}

.id-back-footer {
  margin-top: auto !important;
  position: relative !important;
  width: 100% !important;
  min-height: 16mm !important;
  padding-bottom: 3mm !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-end !important;
  align-items: center !important;
}

.id-back-logo-wrap {
  position: absolute !important;
  left: 4mm !important;
  bottom: 3mm !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  z-index: 1 !important;
}

.id-back-logo {
  height: 14mm !important;
  width: 14mm !important;
  border-radius: 50% !important;
  border: 0.3mm solid #333 !important;
  object-fit: cover !important;
  background: #fff !important;
}

.id-back-sign-area {
  width: 75% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  position: relative !important;
  z-index: 2 !important;
}

.id-back-sign {
  font-size: 2.8mm !important;
  line-height: 1.1 !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  font-weight: 600 !important;
  margin-bottom: 0.5mm !important;
  text-align: center !important;
}

.id-back-name {
  margin: 0 auto !important;
  width: 70% !important;
  display: flex !important;
  justify-content: center !important;
  align-items: flex-end !important;
  border-bottom: 0.3mm solid #000000 !important;
  min-height: 4.8mm !important;
  padding-bottom: 0.2mm !important;
  color: #000000 !important;
}

.id-back-name>span:first-child {
  font-size: 2.5mm !important;
  line-height: 1.1 !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  font-weight: 800 !important;
  margin-right: 2mm !important;
  text-transform: uppercase !important;
}

.id-back-name>span:last-child {
  display: block !important;
  font-size: 2.8mm !important;
  color: #000000 !important;
  -webkit-text-fill-color: #000000 !important;
  font-weight: 700 !important;
  text-align: center !important;
}

/* ========== DASHBOARD RESPONSIVENESS ========== */
@media (max-width: 1024px) {

  .app-shell,
  .canvas {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    border-radius: 0 !important;
    margin: 0 !important;
    grid-template-columns: 1fr !important;
  }

  .sidebar {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    width: 252px !important;
    min-width: 252px !important;
    height: 100vh !important;
    z-index: 99999 !important;
    overflow-y: auto !important;
    padding: 1rem !important;
    border-right: none !important;
    border-bottom: none !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.3) !important;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    will-change: transform;
    transform: translate3d(0, 0, 0);
  }

  .sidebar.collapsed {
    transform: translate3d(-100%, 0, 0) !important;
  }

  .logo-block {
    margin-bottom: 1.5rem !important;
    justify-content: center !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
  }

  .nav-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.25rem !important;
    padding: 0.5rem 0.4rem !important;
  }

  .nav-item {
    width: 100% !important;
    padding: 0.5rem 0.8rem !important;
    margin: 0 !important;
    justify-content: center !important;
    font-size: 12px !important;
  }

  .main-panel {
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
  }

  .topbar {
    padding: 1rem !important;
    flex-direction: column !important;
    gap: 0.8rem !important;
    align-items: center !important;
    text-align: center !important;
  }

  .profile-wrap {
    width: 100% !important;
    justify-content: center !important;
  }

  .content-grid {
    display: flex !important;
    flex-direction: column !important;
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
    padding: 1rem !important;
  }

  .kpi-grid {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)) !important;
  }

  .actions {
    flex-direction: column !important;
    gap: 0.8rem !important;
    align-items: stretch !important;
  }

  .actions input,
  .actions select {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .nav-item {
    flex: 1 1 100% !important;
  }

  .panel-header h2 {
    font-size: 1.2rem !important;
  }

  .modal-card {
    width: 95% !important;
    padding: 1.5rem !important;
  }
}

/* ========== FLUID AUTO-SIZING ID PREVIEW ========== */
.id-preview {
  width: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  overflow: visible !important;
  padding: 1.5rem 0 !important;
}

.id-card-print-wrap {
  /* Use a more conservative scale (80vw) to account for panel padding */
  /* 402px is the base width. Scale = (Screen Width - Padding) / 402 */
  --fluid-scale: clamp(0.3, (80vw) / 402, 1);

  transform: scale(var(--fluid-scale)) !important;
  transform-origin: top center !important;

  width: 402px !important;
  margin: 0 auto !important;
  display: block !important;
  padding: 0 !important;
  overflow: visible !important;

  /* Use a slightly larger height multiplier to ensure signature isn't cut at bottom */
  height: calc(280px * var(--fluid-scale)) !important;
  transition: transform 0.1s ease-out !important;
  position: relative !important;
}

.id-card-print-wrap .id-card-redesign,
.id-card-print-wrap .id-card-realistic {
  transform: none !important;
  position: relative !important;
  margin: 0 !important;
  left: 0 !important;
  right: 0 !important;
  width: 106mm !important;
  height: 68mm !important;
}

/* Tablet refinement */
@media (min-width: 1025px) {
  .id-card-print-wrap {
    --fluid-scale: 1;
    /* Keep full size on large desktops */
  }
}

@media (max-width: 600px) {
  .id-preview {
    margin-bottom: 2rem !important;
  }
}

/* ========== COLLAPSIBLE SIDEBAR SYSTEM ========== */

/* Performance Chart Premium Styling */
.chart-svg {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.1));
}

.chart-bar {
  fill: url(#barGradient);
  /* Fallback to solid if gradient not found */
  fill: #00d2ff !important;
  opacity: 0.85;
  transition: all 0.3s ease;
}

.chart-bar:hover {
  opacity: 1;
  fill: #0af0ff !important;
}

.chart-line {
  stroke-width: 3px !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.chart-grid {
  stroke: rgba(255, 255, 255, 0.05) !important;
  stroke-dasharray: 4, 4;
}

.chart-axis-label {
  fill: rgba(255, 255, 255, 0.5) !important;
  font-size: 11px !important;
  font-weight: 500;
}

.chart-dot {
  stroke-width: 2px;
  stroke: #1a2a3a;
  transition: r 0.2s ease;
}

.chart-dot:hover {
  r: 5;
}

/* When sidebar is collapsed, shrink its grid column to 0 so main-panel fills 100% */
.canvas.sidebar-collapsed {
  grid-template-columns: 0px minmax(0, 1fr) !important;
}

@media (min-width: 821px) {

  /* Sidebar base transition */
  .sidebar {
    position: relative !important;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
      min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
      padding 0.25s cubic-bezier(0.4, 0, 0.2, 1) !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    min-width: 252px !important;
    will-change: width, min-width;
    contain: layout;
  }

  /* ---- Collapsed State ---- */
  .sidebar.collapsed {
    width: 0px !important;
    min-width: 0px !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
  }

  /* Sidebar inner content fade transitions */
  .sidebar .nav-item span,
  .sidebar #logoText,
  .sidebar .system-tag,
  .sidebar .logo-block,
  .sidebar .nav-list,
  .sidebar .sidebar-logo {
    transition: opacity 0.2s ease !important;
    opacity: 1 !important;
  }

  /* Hide all sidebar content when collapsed */
  .sidebar.collapsed .logo-block,
  .sidebar.collapsed .nav-list,
  .sidebar.collapsed .sidebar-logo,
  .sidebar.collapsed #logoText,
  .sidebar.collapsed .system-tag,
  .sidebar.collapsed .nav-item span {
    opacity: 0 !important;
    pointer-events: none !important;
  }
}

/* ---- Toggle Button (sibling of sidebar inside .canvas) ---- */
.sidebar-collapse-btn {
  position: fixed !important;
  /* Change to fixed to prevent scrolling away */
  left: 240px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 32px !important;
  height: 32px !important;
  background: linear-gradient(135deg, #0d3147, #1a4a64) !important;
  border: 1.5px solid rgba(53, 167, 184, 0.4) !important;
  border-radius: 50% !important;
  color: #0af0ff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  z-index: 100000 !important;
  /* Extremely high to stay above sidebar overlay */
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(53, 167, 184, 0.1) !important;
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275),
    background 0.3s ease,
    box-shadow 0.3s ease !important;
  font-size: 1.1rem !important;
  padding: 0 !important;
  line-height: 1 !important;
  min-height: 32px !important;
  max-height: 32px !important;
  max-width: 32px !important;
}

.sidebar-collapse-btn:hover {
  transform: translateY(-50%) scale(1.15) !important;
  background: linear-gradient(135deg, #2c6aa2, #1a4a64) !important;
  color: #ffffff !important;
  box-shadow: 0 6px 24px rgba(44, 106, 162, 0.5), 0 0 0 3px rgba(53, 167, 184, 0.2) !important;
}

.sidebar-collapse-btn:active {
  transform: translateY(-50%) scale(0.92) !important;
}

/* When sidebar is collapsed, move button to the far left edge */
.app-shell.is-collapsed .sidebar-collapse-btn {
  left: 8px !important;
}

/* Main Panel smooth transition */
.main-panel {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

@media (max-width: 1024px) {
  .sidebar-collapse-btn {
    display: flex !important;
    /* Keep button visible on tablet/mobile */
    left: 240px !important;
    z-index: 100001 !important;
  }
}

@media (max-width: 820px) {
  .sidebar-collapse-btn {
    left: 232px !important;
    /* Move to the perfect edge of the 252px sidebar */
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 200000 !important;
    /* Maximum priority */
    background: #0af0ff !important;
    color: #0d3147 !important;
    border: 2px solid #ffffff !important;
    box-shadow: 0 0 20px rgba(10, 240, 255, 0.6) !important;
  }

  .app-shell.is-collapsed .sidebar-collapse-btn {
    left: 10px !important;
  }
}