/* ────────────────────────────────────────────────────────────────────────
   DelMax Air Cargo Portal — Custom CSS
   Theme : Blue & White | Minimalistic | Inspired by ia-Academy layout
   ──────────────────────────────────────────────────────────────────────── */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --sidebar-w:         240px;
  --topbar-h:          64px;

  /* Brand */
  --primary:           #1668dc;
  --primary-dark:      #0d4fa8;
  --primary-light:     rgba(22, 104, 220, 0.07);
  --primary-border:    rgba(22, 104, 220, 0.2);

  /* Semantic */
  --success:           #16a34a;
  --warning:           #d97706;
  --danger:            #dc2626;
  --info:              #0891b2;
  --purple:            #7c3aed;

  /* Surface */
  --bg:                #f5f6fa;
  --sidebar-bg:        #ffffff;
  --topbar-bg:         #ffffff;
  --card-bg:           #ffffff;
  --border:            #eef0f4;

  /* Text */
  --text:              #1a2030;
  --text-muted:        #64748b;
  --text-light:        #94a3b8;

  /* Design */
  --radius:            16px;
  --radius-sm:         10px;
  --radius-xs:         6px;
  --shadow:            0 1px 8px rgba(0, 0, 0, 0.06);
  --shadow-md:         0 4px 20px rgba(0, 0, 0, 0.09);
  --shadow-lg:         0 12px 40px rgba(0, 0, 0, 0.12);
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }

/* ══════════════════════════════════════════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════════════════════════════════════════ */
#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform .25s ease;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Logo */
.sidebar-logo {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; flex-shrink: 0;
}
.sidebar-logo .logo-text { color: var(--text); font-size: 15px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-sub  { color: var(--text-muted); font-size: 11px; }

/* User card inside sidebar */
.sidebar-user {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar-user .uname { color: var(--text);       font-size: 13px; font-weight: 600; }
.sidebar-user .urole  { color: var(--text-muted); font-size: 11px; }

/* Section label */
.sidebar-section-label {
  color: var(--text-light);
  font-size: 10px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase;
  padding: 16px 20px 6px;
}

/* Nav list */
.sidebar-nav { list-style: none; padding: 6px 10px; margin: 0; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted);
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  transition: all .15s;
  position: relative;
  margin-bottom: 2px;
}
.sidebar-nav li a i  { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-nav li a:hover { background: var(--bg); color: var(--text); }
.sidebar-nav li a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-nav li a.active::before {
  content: '';
  position: absolute; left: 0; top: 7px; bottom: 7px;
  width: 3px; background: var(--primary);
  border-radius: 0 3px 3px 0;
}

/* Badge on nav item */
.sidebar-badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

/* Logout footer */
.sidebar-footer {
  margin-top: auto;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-footer a {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  padding: 9px 13px; border-radius: var(--radius-sm);
  transition: all .15s;
}
.sidebar-footer a:hover { background: #fef2f2; color: var(--danger); }

/* Overlay (mobile) */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .4); z-index: 1035;
}

/* ══════════════════════════════════════════════════════════════════════════
   TOPBAR
   ══════════════════════════════════════════════════════════════════════════ */
#topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 14px;
  z-index: 1030;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}

.topbar-toggle {
  display: none;
  background: none; border: none; padding: 6px;
  color: var(--text); font-size: 20px; cursor: pointer; flex-shrink: 0;
}

.topbar-search {
  flex: 1; max-width: 380px; position: relative;
}
.topbar-search input {
  width: 100%; background: var(--bg);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 14px 9px 38px;
  font-size: 13px; color: var(--text); outline: none;
  transition: border-color .15s, background .15s;
}
.topbar-search input:focus  { border-color: var(--primary); background: #fff; }
.topbar-search input::placeholder { color: var(--text-light); }
.topbar-search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-light); font-size: 14px; pointer-events: none;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.topbar-divider { width: 1px; height: 28px; background: var(--border); flex-shrink: 0; }

/* Icon buttons */
.topbar-icon-btn {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1.5px solid var(--border);
  color: var(--text-muted); font-size: 18px;
  cursor: pointer; position: relative; transition: all .15s;
}
.topbar-icon-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary-border); }
.topbar-icon-btn .badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; border-radius: 9px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid #fff;
}

/* User pill */
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: #fff;
  cursor: pointer; transition: all .15s;
}
.topbar-user:hover { background: var(--bg); }
.topbar-user .t-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.topbar-user .t-uname { font-size: 13px; font-weight: 600; color: var(--text); }
.topbar-user .t-role  { font-size: 11px; color: var(--text-muted); }

/* User dropdown menu */
.user-dropdown-menu {
  min-width: 240px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-sm);
  padding: 0;
  overflow: hidden;
}
.user-dd-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  padding: 16px;
  text-align: center;
  color: #fff;
}
.user-dd-avatar {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: rgba(255,255,255,0.25);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 20px;
  margin: 0 auto 8px;
  border: 2.5px solid rgba(255,255,255,0.5);
  position: relative; overflow: hidden;
}
.user-dd-avatar img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border-radius: 50%;
  z-index: 2;
}
.user-dd-avatar span {
  position: relative; z-index: 1;
}
.user-dd-name  { font-size: 15px; font-weight: 700; color: #fff; line-height: 1.2; }
.user-dd-email { font-size: 11px; color: rgba(255,255,255,0.75); margin: 2px 0 6px; }
.user-dd-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 10px; font-weight: 700;
  letter-spacing: .05em;
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.35);
}
.user-dropdown-menu .dropdown-item {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  display: flex; align-items: center;
  transition: background .12s;
}
.user-dropdown-menu .dropdown-item:hover { background: var(--primary-light); }
.user-dropdown-menu .dropdown-item.text-danger { color: var(--danger) !important; }
.user-dropdown-menu .dropdown-item.text-danger:hover { background: rgba(220,38,38,.07); }
.user-dropdown-menu .dropdown-divider { margin: 0; border-color: var(--border); }

/* ══════════════════════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════════════════════ */
#main-content {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-h));
}

/* Page header */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text); margin: 0; }
.page-header .breadcrumb { margin: 4px 0 0; font-size: 12px; }
.page-header .breadcrumb-item + .breadcrumb-item::before { content: "/"; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════════════════
   CARDS
   ══════════════════════════════════════════════════════════════════════════ */
.card {
  background: var(--card-bg);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  background: none;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h5 { font-size: 15px; font-weight: 700; margin: 0; color: var(--text); }
.card-body { padding: 20px; }

/* ══════════════════════════════════════════════════════════════════════════
   STAT CARDS  — icon on right, label on top, value below
   ══════════════════════════════════════════════════════════════════════════ */
.stat-card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: transform .2s, box-shadow .2s;
  background: #fff;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }

/* Icon — pushed to the right */
.stat-icon {
  order: 2;
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}

/* Text block — on the left, label first then value */
.stat-card > div:not(.stat-icon) {
  order: 1;
  display: flex;
  flex-direction: column;
}
.stat-card .stat-label {
  font-size: 12px; font-weight: 500;
  color: var(--text-muted);
  order: -1;
  margin-bottom: 8px;
}
.stat-card .stat-val {
  font-size: 28px; font-weight: 800; line-height: 1;
  color: var(--text);
  order: 1;
}

/* Card background variants — driven by icon class */
.stat-card:has(.stat-icon.blue)   { background: #eff6ff; }
.stat-card:has(.stat-icon.green)  { background: #f0fdf4; }
.stat-card:has(.stat-icon.red)    { background: #fef2f2; }
.stat-card:has(.stat-icon.cyan)   { background: #ecfeff; }
.stat-card:has(.stat-icon.yellow) { background: #fffbeb; }
.stat-card:has(.stat-icon.purple) { background: #faf5ff; }

/* Icon colors */
.stat-icon.blue   { background: rgba(22,104,220,.12); color: var(--primary); }
.stat-icon.green  { background: rgba(22,163,74,.12);  color: var(--success); }
.stat-icon.red    { background: rgba(220,38,38,.12);  color: var(--danger);  }
.stat-icon.cyan   { background: rgba(8,145,178,.12);  color: var(--info);    }
.stat-icon.yellow { background: rgba(217,119,6,.12);  color: var(--warning); }
.stat-icon.purple { background: rgba(124,58,237,.12); color: var(--purple);  }

/* ══════════════════════════════════════════════════════════════════════════
   TABLES
   ══════════════════════════════════════════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
.table { font-size: 13px; margin: 0; }
.table thead th {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-light); background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap; padding: 11px 16px;
}
.table tbody td { padding: 13px 16px; vertical-align: middle; border-color: var(--border); }
.table tbody tr:hover { background: var(--primary-light); }

/* ══════════════════════════════════════════════════════════════════════════
   STATUS PILLS
   ══════════════════════════════════════════════════════════════════════════ */
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 20px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.status-pill::before {
  content: ''; display: inline-block;
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: .7;
}
.status-pill.active, .status-pill.delivered, .status-pill.paid, .status-pill.completed {
  background: #dcfce7; color: #15803d;
}
.status-pill.pending, .status-pill.booked, .status-pill.draft {
  background: #fef9c3; color: #854d0e;
}
.status-pill.in-transit, .status-pill.dispatched { background: #dbeafe; color: #1d4ed8; }
.status-pill.out-for-delivery                    { background: #ede9fe; color: #6d28d9; }
.status-pill.overdue, .status-pill.cancelled     { background: #fee2e2; color: #b91c1c; }
.status-pill.inactive, .status-pill.returned     { background: #f1f5f9; color: #475569; }
.status-pill.unpaid                              { background: #fef9c3; color: #854d0e; }
.status-pill.partial                             { background: #ffedd5; color: #c2410c; }
.status-pill.active-mawb                         { background: #dbeafe; color: #1d4ed8; }

/* ══════════════════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════════════════ */
.btn { border-radius: var(--radius-sm); font-weight: 500; transition: all .15s; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: #fff; }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border); }
.btn-outline-secondary:hover { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-sm  { padding: 6px 14px;  font-size: 12px; border-radius: 8px; }
.btn-xs  { padding: 4px 10px;  font-size: 11px; border-radius: 6px; }
.btn-lg  { padding: 11px 22px; font-size: 15px; border-radius: 12px; }

/* ══════════════════════════════════════════════════════════════════════════
   FORMS
   ══════════════════════════════════════════════════════════════════════════ */
.form-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.form-control, .form-select {
  font-size: 13px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); padding: 9px 14px;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,104,220,.1);
  background: #fff;
}
.form-control-lg { padding: 12px 16px; font-size: 14px; }

/* ══════════════════════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════════════════════ */
.modal-content { border-radius: var(--radius); border: none; box-shadow: var(--shadow-lg); }
.modal-header  { border-bottom: 1px solid var(--border); padding: 18px 24px; }
.modal-footer  { border-top: 1px solid var(--border); padding: 14px 24px; }
.modal-body    { padding: 24px; }
.modal-header .modal-title { font-size: 16px; font-weight: 700; }

/* ══════════════════════════════════════════════════════════════════════════
   DROPDOWN
   ══════════════════════════════════════════════════════════════════════════ */
.dropdown-menu {
  border: none;
  box-shadow: var(--shadow-lg);
  border-radius: 14px;
  padding: 8px;
  min-width: 180px;
}
.dropdown-item { font-size: 13px; padding: 8px 12px; border-radius: 8px; color: var(--text); }
.dropdown-item:hover { background: var(--primary-light); color: var(--primary); }
.dropdown-item.text-danger:hover { background: #fef2f2; }

/* ══════════════════════════════════════════════════════════════════════════
   FLASH / ALERTS
   ══════════════════════════════════════════════════════════════════════════ */
.flash-area {
  position: fixed; top: 74px; right: 20px;
  z-index: 9999; min-width: 300px; max-width: 400px;
}
.flash-area .alert { border-radius: 12px; font-size: 13px; box-shadow: var(--shadow-md); border: none; }

/* ══════════════════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════════════════ */
.toast-container { position: fixed; top: 74px; right: 20px; z-index: 9999; }
.toast { min-width: 280px; font-size: 13px; border-radius: 12px; border: none; box-shadow: var(--shadow-md); }

/* ══════════════════════════════════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════════════════════════════════ */
.pagination .page-link {
  font-size: 13px; padding: 6px 12px;
  color: var(--primary); border-color: var(--border); border-radius: 8px !important;
}
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ══════════════════════════════════════════════════════════════════════════
   PROGRESS
   ══════════════════════════════════════════════════════════════════════════ */
.progress { height: 6px; border-radius: 4px; background: var(--border); }
.progress-bar { border-radius: 4px; }

/* ══════════════════════════════════════════════════════════════════════════
   TIMELINE
   ══════════════════════════════════════════════════════════════════════════ */
.timeline { list-style: none; padding: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline li { position: relative; padding: 0 0 20px 36px; }
.timeline li .tl-dot {
  position: absolute; left: 6px; top: 4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--primary-light); border: 2px solid var(--primary);
}
.tl-time  { font-size: 11px; color: var(--text-muted); }
.tl-title { font-size: 13px; font-weight: 600; }
.tl-sub   { font-size: 12px; color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════════════════ */
.login-page { min-height: 100vh; display: flex; align-items: stretch; background: #fff; }
.login-left {
  flex: 1;
  background: linear-gradient(140deg, #0d4fa8 0%, #1668dc 55%, #3b82f6 100%);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px; color: #fff;
}
.login-right {
  width: 480px; flex-shrink: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 48px; background: #fff;
}
.login-logo {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 20px;
}
.login-logo-circle {
  width: 100px; height: 100px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; border: 3px solid rgba(255,255,255,.4);
}
.login-logo-circle img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.login-tagline { font-size: 32px; font-weight: 800; text-align: center; line-height: 1.2; }
.login-sub { font-size: 14px; opacity: .75; text-align: center; margin-top: 10px; }
.login-features { margin-top: 40px; width: 100%; max-width: 340px; }
.login-features li { display: flex; align-items: center; gap: 12px; font-size: 14px; margin-bottom: 14px; opacity: .9; }
.login-features li i { font-size: 20px; }
.login-form-box { width: 100%; max-width: 360px; }
.login-form-box h2 { font-size: 28px; font-weight: 800; color: var(--text); }

/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 992px) {
  #sidebar { transform: translateX(-100%); box-shadow: none; }
  #sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  #sidebar-overlay { display: none; }
  #topbar { left: 0; }
  #main-content { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .topbar-divider { display: none; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 32px 24px; }
}

@media (max-width: 576px) {
  #main-content { padding: 16px; }
  .stat-val   { font-size: 22px; }
  .stat-icon  { width: 48px; height: 48px; font-size: 20px; }
  .page-header h1 { font-size: 18px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   UTILITIES
   ══════════════════════════════════════════════════════════════════════════ */
.text-primary     { color: var(--primary)  !important; }
.text-success     { color: var(--success)  !important; }
.text-danger      { color: var(--danger)   !important; }
.text-muted       { color: var(--text-muted) !important; }
.bg-primary-light { background: var(--primary-light) !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.fs-11  { font-size: 11px !important; }
.fs-12  { font-size: 12px !important; }
.fs-13  { font-size: 13px !important; }
.fs-14  { font-size: 14px !important; }

/* ── Loading spinner ─────────────────────────────────────────────────── */
.btn-loading { position: relative; pointer-events: none; opacity: .75; }
.btn-loading::after {
  content: '';
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .6s linear infinite;
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
}
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

/* ── Input group — fix border-radius overrides ───────────────────────── */
.input-group-text {
  border-color: var(--border);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 14px;
}
/* Restore Bootstrap input-group corner logic that our global radius overrides */
.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}
.input-group > .form-control:not(:last-child),
.input-group > .form-select:not(:last-child) {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}
.input-group > .btn:not(:first-child) {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}
.input-group > .input-group-text:first-child {
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.input-group > .input-group-text:last-child {
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ══════════════════════════════════════════════════════════════════════════
   SIDEBAR COLLAPSE — floating tab on right edge (desktop only)
   ══════════════════════════════════════════════════════════════════════════ */

/* The button lives OUTSIDE #sidebar at body level */
#sidebarCollapseBtn {
  position: fixed;
  /* sits exactly at the right edge of the sidebar */
  left: calc(var(--sidebar-w) - 14px);
  top: 68px;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 1.5px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 14px;
  z-index: 1045;
  transition: left .25s ease, background .15s, color .15s;
  padding: 0;
}
#sidebarCollapseBtn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 12px rgba(22,104,220,.35);
}

/* Collapsed state — CSS custom property cascades to topbar + main-content */
body.sidebar-collapsed { --sidebar-w: 68px; }

body.sidebar-collapsed .sidebar-brand,
body.sidebar-collapsed .sidebar-section-label,
body.sidebar-collapsed .sidebar-user .uname,
body.sidebar-collapsed .sidebar-user .urole,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-badge { display: none !important; }

body.sidebar-collapsed .sidebar-logo { padding: 14px 10px; justify-content: center; gap: 0; }
body.sidebar-collapsed .sidebar-user  { padding: 8px 10px; justify-content: center; }
body.sidebar-collapsed .sidebar-nav   { padding: 6px; }
body.sidebar-collapsed .sidebar-nav li a { justify-content: center; padding: 11px; gap: 0; }
body.sidebar-collapsed .sidebar-nav li a.active::before { display: none; }
body.sidebar-collapsed .sidebar-footer { padding: 8px 6px; }
body.sidebar-collapsed .sidebar-footer a { justify-content: center; padding: 11px; gap: 0; }

/* CSS tooltip on hover in collapsed mode */
body.sidebar-collapsed .sidebar-nav li a,
body.sidebar-collapsed .sidebar-footer a { position: relative; overflow: visible; }
body.sidebar-collapsed .sidebar-nav li a::after,
body.sidebar-collapsed .sidebar-footer a::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 12px);
  top: 50%; transform: translateY(-50%);
  background: #1a2030; color: #fff;
  padding: 5px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .15s;
  z-index: 2000;
}
body.sidebar-collapsed .sidebar-nav li a:hover::after,
body.sidebar-collapsed .sidebar-footer a:hover::after { opacity: 1; }

/* On mobile: hide the floating button; sidebar is a full-width drawer */
@media (max-width: 992px) {
  #sidebarCollapseBtn { display: none; }
  body.sidebar-collapsed { --sidebar-w: 240px; }
  body.sidebar-collapsed .sidebar-brand,
  body.sidebar-collapsed .sidebar-section-label,
  body.sidebar-collapsed .sidebar-user .uname,
  body.sidebar-collapsed .sidebar-user .urole,
  body.sidebar-collapsed .nav-label,
  body.sidebar-collapsed .sidebar-badge { display: unset !important; }
  body.sidebar-collapsed .sidebar-logo { padding: 18px 20px 16px; justify-content: flex-start; gap: 12px; }
  body.sidebar-collapsed .sidebar-user  { padding: 12px 16px; justify-content: flex-start; }
  body.sidebar-collapsed .sidebar-nav   { padding: 6px 10px; }
  body.sidebar-collapsed .sidebar-nav li a { justify-content: flex-start; padding: 9px 13px; gap: 10px; }
  body.sidebar-collapsed .sidebar-nav li a.active::before { display: block; }
  body.sidebar-collapsed .sidebar-footer { padding: 12px 20px; }
  body.sidebar-collapsed .sidebar-footer a { justify-content: flex-start; padding: 9px 13px; gap: 10px; }
}

/* ── Avatar with photo ──────────────────────────────────────────────────────── */
.avatar-with-photo {
  position: relative;
  overflow: hidden;
}
.avatar-with-photo img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; border-radius: inherit;
  z-index: 2;
}

/* ══════════════════════════════════════════════════════════════════════════
   CHAT / SUPPORT CONVERSATION
   ══════════════════════════════════════════════════════════════════════════ */
.chat-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}
.chat-bubble.customer {
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  margin-left: auto;
}
.chat-bubble.staff {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

/* ══════════════════════════════════════════════════════════════════════════
   INVOICE DETAIL
   ══════════════════════════════════════════════════════════════════════════ */
.invoice-header-box {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px;
}
.invoice-total-row {
  background: var(--primary-light);
  border-radius: var(--radius-sm);
  padding: 16px;
}

/* ══════════════════════════════════════════════════════════════════════════
   CONTACT CARDS
   ══════════════════════════════════════════════════════════════════════════ */
.contact-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  text-align: center;
  transition: transform .2s, box-shadow .2s;
}
.contact-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.contact-card .cc-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; margin: 0 auto 12px;
}
.contact-card .cc-label { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.contact-card .cc-value { font-size: 13px; color: var(--text-muted); margin-bottom: 14px; }

/* ══════════════════════════════════════════════════════════════════════════
   PROFILE MODAL
   ══════════════════════════════════════════════════════════════════════════ */
.profile-photo-circle {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 700;
  overflow: hidden; position: relative;
  border: 3px solid var(--border);
  box-shadow: var(--shadow-md);
}
.profile-photo-circle img {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  z-index: 2;
}
.profile-photo-circle span { position: relative; z-index: 1; pointer-events: none; }

.section-label-sm {
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  text-transform: uppercase; color: var(--text-muted);
  border-bottom: 1px solid var(--border); padding-bottom: 6px;
}

/* ══════════════════════════════════════════════════════════════════════════
   REPORT CARDS (Reports & Analytics page)
   ══════════════════════════════════════════════════════════════════════════ */
.rpt-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-top: 3px solid var(--rc, var(--primary));
  box-shadow: var(--shadow);
  padding: 18px 16px 14px;
  display: flex; flex-direction: column;
  height: 100%; min-height: 200px;
}
.rpt-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: color-mix(in srgb, var(--rc, var(--primary)) 12%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: var(--rc, var(--primary));
  margin-bottom: 10px; flex-shrink: 0;
}
/* Fallback for browsers without color-mix (use a fixed light bg) */
@supports not (color: color-mix(in srgb, red 10%, transparent)) {
  .rpt-icon { background: var(--primary-light); }
}
.rpt-title {
  font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.3;
  margin-bottom: 4px;
}
.rpt-sub {
  font-size: 11px; color: var(--text-muted); line-height: 1.4;
  flex: 1; margin-bottom: 12px;
}
.btn-rpt-pdf,
.btn-rpt-excel {
  width: 100%; border: none; border-radius: 8px;
  padding: 8px 0; font-size: 12px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center;
  justify-content: center; gap: 4px; transition: opacity .15s, transform .1s;
}
.btn-rpt-pdf   { background: #ef4444; color: #fff; margin-bottom: 7px; }
.btn-rpt-excel { background: #16a34a; color: #fff; }
.btn-rpt-pdf:hover,
.btn-rpt-excel:hover { opacity: .88; }
.btn-rpt-pdf:active,
.btn-rpt-excel:active { transform: scale(.97); }
.btn-rpt-pdf:disabled,
.btn-rpt-excel:disabled { opacity: .55; cursor: not-allowed; }

/* ══════════════════════════════════════════════════════════════════════════
   SIDEBAR LOGO — image
   ══════════════════════════════════════════════════════════════════════════ */
.sidebar-logo-img {
  width: 36px; height: 36px;
  object-fit: contain; border-radius: 50%;
  flex-shrink: 0;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
}
/* When sidebar collapses, hide brand text, center the image */
body.sidebar-collapsed .sidebar-logo-img { width: 38px; height: 38px; }

/* ══════════════════════════════════════════════════════════════════════════
   PORTAL FOOTER
   ══════════════════════════════════════════════════════════════════════════ */
.portal-footer {
  margin-top: 48px;
  padding: 24px 32px 20px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
  align-items: center; gap: 6px;
  text-align: center;
}
.portal-footer-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 4px;
}
.portal-footer-logo img {
  width: 36px; height: 36px; object-fit: contain;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--border);
  background: #fff;
}
.portal-footer-logo span {
  font-weight: 700; font-size: 14px; color: var(--text);
}
.portal-footer-text {
  font-size: 12px; color: var(--text-muted);
}
.portal-footer-dev {
  font-size: 12px; color: var(--text-muted);
}
.portal-footer-dev a {
  color: var(--primary); font-weight: 600; text-decoration: none;
}
.portal-footer-dev a:hover { text-decoration: underline; }
