:root {
  /* Core Colors */
  --primary: #1B4F72;
  --primary-dark: #154360;
  --primary-light: #2980B9;
  --secondary: #2C3E50;
  --success: #27AE60;
  --warning: #F39C12;
  --danger: #E74C3C;
  --info: #3498DB;
  --light: #F8F9FA;
  --dark: #212529;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary-light));
  --gradient-success: linear-gradient(135deg, var(--success), #2ECC71);
  --gradient-warning: linear-gradient(135deg, var(--warning), #F1C40F);
  --gradient-danger: linear-gradient(135deg, var(--danger), #C0392B);
  --gradient-dark: linear-gradient(180deg, #0f1923 0%, #1a2940 50%, #0f1923 100%);
  
  /* Surfaces & Borders */
  --surface-1: #ffffff;
  --surface-2: #f8f9fc;
  --surface-3: #f1f3f7;
  --border-subtle: rgba(0, 0, 0, 0.04);
  --border-default: rgba(0, 0, 0, 0.08);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.03);
  --shadow-premium: 0 1px 3px rgba(0,0,0,0.04), 0 4px 12px rgba(0,0,0,0.03);
  --shadow-premium-hover: 0 8px 24px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);

  /* Typography */
  --font-family-base: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
}

html, body {
  /* removed overflow-x: hidden to allow scrolling/stickiness if needed */
}

body {
  font-family: var(--font-family-base);
  background-color: #F8FAFC;
  color: #0F172A;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
}

/* LAYOUT: Wrapper & Main Content */
#wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
  background: #F8FAFC;
  color: #0F172A;
}
#content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: calc(100% - 244px);
  margin-left: 244px;
  transition: all 0.3s;
}
.main-content {
  padding: 24px 28px 32px;
  flex: 1;
}

/* DC Dashboard Utility Classes */
.dc-card {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 14px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
}
.dc-card:hover {
  box-shadow: 0 8px 24px -12px rgba(15,23,42,0.18);
  transform: translateY(-2px);
}

.dc-hover-bg {
  transition: background 0.18s ease;
}
.dc-hover-bg:hover {
  background: #F8FAFC;
}

.dc-btn {
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease;
  height: 32px;
  padding: 0 14px;
}
.dc-btn:hover {
  border-color: #2563EB;
  color: #2563EB;
}

.dc-btn-primary {
  border: none;
  background: #2563EB;
  color: #FFFFFF;
  transition: background 0.18s ease;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
}
.dc-btn-primary:hover {
  background: #1D4ED8;
}

.dc-sidebar-item {
  transition: background 0.18s ease;
}
.dc-sidebar-item:hover {
  background: rgba(255,255,255,0.07);
}

.dc-header-icon {
  transition: background 0.18s ease;
}
.dc-header-icon:hover {
  background: #F1F5F9;
}

/* SIDEBAR: Premium Dark Gradient */
#sidebar {
  min-width: 244px;
  max-width: 244px;
  color: #fff;
  transition: all 0.3s ease;
  z-index: 1040;
  box-shadow: 4px 0 15px rgba(0,0,0,0.1);
  display: flex;
  flex-direction: column;
}

/* NAVBAR: Glassmorphic */
.navbar-premium {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.75rem 1.5rem;
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}
.navbar-premium::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-subtle), transparent);
}

/* User Avatar & Bell */
.avatar-ring {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 2px;
  background: var(--gradient-primary);
  display: inline-block;
}
.avatar-ring img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid #fff;
  object-fit: cover;
}

.bell-pulse {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--secondary);
  transition: all 0.2s;
}
.bell-pulse:hover {
  background: var(--surface-3);
  color: var(--primary);
}
.bell-pulse.unread::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid #fff;
  animation: pulse-glow 2s infinite;
}

/* CARDS */
.card-premium {
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-premium);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.card-premium:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-premium-hover);
  border-color: rgba(0,0,0,0.08);
}
.card-premium .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-subtle);
  padding: 1.25rem 1.5rem;
  position: relative;
}
.card-premium .card-header.accent-left {
  border-left: 4px solid var(--primary);
}
.card-premium .card-body {
  padding: 1.5rem;
}

/* STAT CARDS */
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon-bg {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
  background: var(--gradient-primary);
  box-shadow: 0 4px 10px rgba(27, 79, 114, 0.2);
}
.stat-card.success .stat-icon-bg { background: var(--gradient-success); box-shadow: 0 4px 10px rgba(39, 174, 96, 0.2); }
.stat-card.warning .stat-icon-bg { background: var(--gradient-warning); box-shadow: 0 4px 10px rgba(243, 156, 18, 0.2); }
.stat-card.danger .stat-icon-bg { background: var(--gradient-danger); box-shadow: 0 4px 10px rgba(231, 76, 60, 0.2); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.2;
  margin-bottom: 0.25rem;
}
.stat-label {
  font-size: 0.875rem;
  color: #6c757d;
  font-weight: 500;
}

/* TABLES */
.table-premium {
  width: 100%;
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0;
}
.table-premium th {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  border-bottom: 1px solid var(--border-default);
  color: #6c757d;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.5px;
  padding: 1rem 1.25rem;
  z-index: 10;
}
.table-premium td {
  padding: 1rem 1.25rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-subtle);
  transition: all 0.2s ease;
}
.table-premium tbody tr {
  position: relative;
}
.table-premium tbody tr:nth-of-type(odd) {
  background-color: var(--surface-3);
}
.table-premium tbody tr:hover td {
  background-color: var(--surface-2);
}
.table-premium tbody tr::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.table-premium tbody tr:hover::before {
  opacity: 1;
}

/* BUTTONS */
.btn-premium {
  border-radius: 8px;
  font-weight: 500;
  padding: 0.5rem 1.25rem;
  transition: all 0.25s ease;
  border: none;
}
.btn-premium.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  box-shadow: 0 4px 6px rgba(27, 79, 114, 0.15);
}
.btn-premium.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 12px rgba(27, 79, 114, 0.2);
}
.btn-premium.btn-primary:active {
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

/* FORMS */
.form-control-premium, .form-select-premium {
  border-radius: 8px;
  border: 1px solid var(--border-default);
  padding: 0.6rem 1rem;
  transition: all 0.2s ease;
  background: var(--surface-2);
}
.form-control-premium:focus, .form-select-premium:focus {
  background: var(--surface-1);
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
  outline: none;
}
.form-label-premium {
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  color: var(--secondary);
}

/* BADGES */
.badge-soft {
  padding: 0.4em 0.8em;
  border-radius: 50rem;
  font-weight: 500;
  font-size: 0.75rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.badge-soft::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.badge-soft-success { background: rgba(39, 174, 96, 0.1); color: var(--success); }
.badge-soft-success::before { background: var(--success); }
.badge-soft-warning { background: rgba(243, 156, 18, 0.1); color: #d68910; }
.badge-soft-warning::before { background: var(--warning); }
.badge-soft-danger { background: rgba(231, 76, 60, 0.1); color: var(--danger); }
.badge-soft-danger::before { background: var(--danger); }
.badge-soft-primary { background: rgba(27, 79, 114, 0.1); color: var(--primary); }
.badge-soft-primary::before { background: var(--primary); }

/* MODALS */
.modal-content.premium {
  border-radius: 16px;
  border: none;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  overflow: hidden;
}
.modal-header.glass {
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}

/* UTILITIES & ANIMATIONS */
.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.glass {
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.3);
}

/* Keyframes */
@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(231, 76, 60, 0); }
  100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

.fade-in { animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; }
.slide-up { animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; transform: translateY(20px); }
.slide-in-left { animation: slideInLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; transform: translateX(-20px); }

.fade-in-delay-1 { animation-delay: 0.1s; }
.fade-in-delay-2 { animation-delay: 0.2s; }
.fade-in-delay-3 { animation-delay: 0.3s; }

@keyframes fadeIn { to { opacity: 1; } }
@keyframes slideUp { to { opacity: 1; transform: translateY(0); } }
@keyframes slideInLeft { to { opacity: 1; transform: translateX(0); } }

/* TYPOGRAPHY */
.page-title {
  font-weight: 700;
  letter-spacing: -0.5px;
  position: relative;
  display: inline-block;
  margin-bottom: 1.5rem;
}
.page-title::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 40px;
  height: 4px;
  background: var(--gradient-primary);
  border-radius: 2px;
}

/* ==========================================================================
   RESPONSIVE DESIGN SYSTEM (Mobile, iPad, Tablet, Desktop)
   ========================================================================== */

/* Backdrop for Mobile & iPad Sidebar Drawer */
.sidebar-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.sidebar-backdrop.show {
  opacity: 1;
  visibility: visible;
}

/* Hamburger Button Styling */
.dc-hamburger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 1px solid #CBD5E1;
  background: #FFFFFF;
  color: #334155;
  transition: all 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.dc-hamburger-btn:hover, .dc-hamburger-btn:focus {
  background: #F1F5F9;
  border-color: #2563EB;
  color: #2563EB;
}

/* Responsive Grid Utility Classes for Dashboard */
.dc-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) minmax(0, 268px);
  gap: 16px;
}
.dc-stats-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) minmax(0, 268px);
  gap: 16px;
}
.dc-grid-2-col {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr);
  gap: 16px;
}
.dc-grid-2-col-equal {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 16px;
}
.dc-grid-3-col {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

/* Desktop Sidebar Collapsing (>= 1200px) */
@media (min-width: 1200px) {
  #sidebar.collapsed {
    transform: translateX(-244px);
    visibility: hidden;
  }
  #content.expanded {
    width: 100% !important;
    margin-left: 0 !important;
  }
}

/* iPad / Tablet & Mobile (< 1200px) Breakpoints */
@media (max-width: 1199.98px) {
  #wrapper {
    overflow-x: hidden !important;
  }
  #sidebar {
    position: fixed !important;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1050 !important;
    transform: translateX(-100%) !important;
    visibility: hidden !important;
    box-shadow: none !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s ease !important;
  }
  #sidebar.show, #sidebar.active {
    transform: translateX(0) !important;
    visibility: visible !important;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.45) !important;
  }
  #content {
    width: 100% !important;
    margin-left: 0 !important;
  }
  .dc-stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .dc-stats-grid-3 {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  .dc-grid-2-col, .dc-grid-2-col-equal, .dc-grid-3-col {
    grid-template-columns: 1fr !important;
  }
  .main-content {
    padding: 20px 18px 28px;
  }
}

/* Mobile Devices (< 768px) */
@media (max-width: 767.98px) {
  .dc-header {
    padding: 0 14px;
    gap: 10px;
  }
  .dc-stats-grid, .dc-stats-grid-3 {
    grid-template-columns: 1fr !important;
  }
  .main-content {
    padding: 14px 12px 24px;
  }
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ==========================================================================
   GLOBAL MULTI-PAGE RESPONSIVE UTILITIES & TABLE CONTAINERS
   ========================================================================== */

/* Universal Table & Custom List-Table Overflow Handler */
.table-responsive,
.dataTables_wrapper {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* Ensure custom list-tables (Daily Console, Employee Directory, Exceptions, Audit, etc.) scroll horizontally on small viewports */
section.dc-table-card,
.dc-table-responsive {
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

section.dc-table-card > div[style*="grid-template-columns:"],
.dc-table-responsive > div[style*="grid-template-columns:"] {
  min-width: 760px;
}

@media (max-width: 1199.98px) {
  /* Match ALL inline grid sections with 4 or 3 repeat columns across all views (Daily Console, Employees, Exceptions, Config, Users, Audit, Integration, Reports) */
  section[style*="grid-template-columns: repeat(4"],
  section[style*="grid-template-columns:repeat(4"],
  section[style*="grid-template-columns: repeat(3"],
  section[style*="grid-template-columns:repeat(3"],
  div[style*="grid-template-columns: repeat(4"],
  div[style*="grid-template-columns:repeat(4"],
  div[style*="grid-template-columns: repeat(3"],
  div[style*="grid-template-columns:repeat(3"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Make filter toolbars and action bars wrap nicely on iPad / Tablet */
  div[style*="display: flex"][style*="align-items: center"][style*="flex-wrap: wrap"] {
    gap: 10px !important;
  }
}

@media (max-width: 767.98px) {
  /* Collapse ALL multi-column grids to 1 column on Mobile */
  section[style*="grid-template-columns: repeat(4"],
  section[style*="grid-template-columns:repeat(4"],
  section[style*="grid-template-columns: repeat(3"],
  section[style*="grid-template-columns:repeat(3"],
  section[style*="grid-template-columns: repeat(2"],
  section[style*="grid-template-columns:repeat(2"],
  div[style*="grid-template-columns: repeat(4"],
  div[style*="grid-template-columns:repeat(4"],
  div[style*="grid-template-columns: repeat(3"],
  div[style*="grid-template-columns:repeat(3"],
  div[style*="grid-template-columns: repeat(2"],
  div[style*="grid-template-columns:repeat(2"] {
    grid-template-columns: 1fr !important;
  }

  /* Stack header action buttons and filter pills on Mobile */
  .console-toolbar-btn, .console-toolbar-btn-primary, .exc-clear-btn {
    padding: 6px 10px !important;
    font-size: 11.5px !important;
  }

  /* Ensure page titles don't overflow */
  span[style*="font-size: 26px"] {
    font-size: 20px !important;
  }
}

/* ==========================================================================
   GLOBAL RESPONSIVE SYSTEM: POPUPS, MODALS, FORMS & DETAIL VIEWS
   ========================================================================== */

/* Universal Modal / Popup Responsiveness */
.modal-dialog {
  max-width: 600px;
  margin: 1.75rem auto;
}
.modal-dialog-lg, .modal-lg {
  max-width: 840px;
}

@media (max-width: 767.98px) {
  .modal-dialog {
    margin: 10px !important;
    max-width: calc(100vw - 20px) !important;
    width: auto !important;
  }
  .modal-content {
    border-radius: 12px !important;
    max-height: calc(100vh - 20px) !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .modal-header {
    padding: 12px 16px !important;
    flex-shrink: 0 !important;
  }
  .modal-body {
    padding: 16px !important;
    overflow-y: auto !important;
    flex: 1 1 auto !important;
  }
  .modal-footer {
    padding: 12px 16px !important;
    flex-shrink: 0 !important;
    flex-direction: column-reverse !important;
    gap: 8px !important;
  }
  .modal-footer .btn {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Grid layout inside modals stacks in 1 column on Mobile */
  .modal-body div[style*="grid-template-columns"],
  .modal-body .row {
    grid-template-columns: 1fr !important;
  }
}

/* Universal Profile & Detail Views Responsiveness */
@media (max-width: 991.98px) {
  /* Profile header card layout */
  div[style*="background: linear-gradient"][style*="padding: 28px 30px"],
  div[style*="background: linear-gradient"][style*="padding: 24px 20px"] {
    flex-direction: column !important;
    text-align: center !important;
    align-items: center !important;
    padding: 20px 16px !important;
  }
  div[style*="background: linear-gradient"] div[style*="display: flex"][style*="flex-wrap: wrap"] {
    justify-content: center !important;
  }
}

@media (max-width: 767.98px) {
  /* 2-column detail sections stack into 1 column on Mobile */
  section[style*="grid-template-columns: 1fr 1fr"],
  section[style*="grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr)"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }

  .profile-field-label {
    font-size: 11px !important;
  }
  .profile-field-value {
    font-size: 13px !important;
  }
}

/* Universal Form Responsiveness */
@media (max-width: 767.98px) {
  .form-control, .form-select, input[type="text"], input[type="email"], input[type="password"], select {
    font-size: 13.5px !important;
  }
  form label {
    font-size: 12px !important;
  }
  form div[style*="display: flex"][style*="justify-content: flex-end"],
  form div[style*="display: flex"][style*="gap:"] {
    flex-wrap: wrap !important;
    gap: 10px !important;
  }
}
