/* ============================================================
   CUBICEXP CMS — Custom Stylesheet  v1.1
   ============================================================ */

:root {
  --primary:    #4f46e5;
  --primary-lt: #eef2ff;
  --success:    #22c55e;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --info:       #0ea5e9;
  --purple:     #8b5cf6;
  --sidebar-bg: #0f172a;
  --sidebar-w:  260px;
  --sidebar-collapsed-w: 68px;
  --topbar-h:   64px;
  --body-bg:    #f1f5f9;
  --card-bg:    #ffffff;
  --text-main:  #1e293b;
  --text-muted: #64748b;
  --border:     #e2e8f0;
  --radius:     12px;
  --shadow:     0 1px 3px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --transition: .22s cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--body-bg);
  color: var(--text-main);
  font-size: 14px;
  margin: 0;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: width var(--transition), transform var(--transition);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}

.sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--topbar-h);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}
.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
  flex-shrink: 0;
}
.brand-name { color: white; font-weight: 700; font-size: 17px; line-height: 1.2; transition: opacity var(--transition), width var(--transition); }
.brand-sub  { color: rgba(255,255,255,.4); font-size: 11px; transition: opacity var(--transition); }
.sidebar-close { background: none; border: none; color: rgba(255,255,255,.5); font-size: 18px; padding: 4px; cursor: pointer; flex-shrink: 0; }

/* ── Sidebar Menu ─────────────────────────────────────────── */
.sidebar-menu { flex: 1; padding: 10px 0; overflow-y: auto; overflow-x: hidden; }

.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.25);
  padding: 16px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition), height var(--transition);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  transition: background var(--transition), color var(--transition), padding var(--transition);
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  white-space: nowrap;
}
.sidebar-link:hover { color: white; background: rgba(255,255,255,.06); }
.sidebar-link.active {
  color: white;
  background: rgba(79,70,229,.25);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 5px; bottom: 5px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.sidebar-link i { width: 20px; text-align: center; flex-shrink: 0; font-size: 14px; }
.sidebar-link > span { transition: opacity var(--transition); }
.sidebar-link.sub { padding-left: 46px; font-size: 13px; }

/* Group dropdown */
.sidebar-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  color: rgba(255,255,255,.6);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  user-select: none;
  white-space: nowrap;
}
.sidebar-group-toggle:hover { color: white; background: rgba(255,255,255,.06); }
.sidebar-group-toggle.active { color: white; }
.sidebar-group-toggle > span { display: flex; align-items: center; gap: 10px; overflow: hidden; }
.sidebar-group-toggle > span > span { transition: opacity var(--transition); }
.sidebar-group-toggle i { width: 20px; text-align: center; font-size: 14px; flex-shrink: 0; }
.toggle-arrow { transition: transform var(--transition); font-size: 11px; }
.sidebar-group.open .toggle-arrow { transform: rotate(90deg); }
.sidebar-group-items { display: none; }
.sidebar-group.open .sidebar-group-items { display: block; }

/* ── Sidebar Footer ───────────────────────────────────────── */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
  overflow: hidden;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; transition: opacity var(--transition); }
.user-name { color: white; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,.4); font-size: 11px; }
.logout-btn { color: rgba(255,255,255,.4); font-size: 16px; text-decoration: none; flex-shrink: 0; transition: color var(--transition); }
.logout-btn:hover { color: var(--danger); }

/* ── Sidebar Collapse (Desktop) ───────────────────────────── */
body.sidebar-collapsed .sidebar { width: var(--sidebar-collapsed-w); }
body.sidebar-collapsed .main-content { margin-left: var(--sidebar-collapsed-w); }

/* Hide text, keep icons */
body.sidebar-collapsed .brand-name,
body.sidebar-collapsed .brand-sub { opacity: 0; width: 0; overflow: hidden; }
body.sidebar-collapsed .sidebar-section { opacity: 0; height: 0; padding: 0; margin: 0; }
body.sidebar-collapsed .sidebar-link > span,
body.sidebar-collapsed .sidebar-group-toggle > span > span,
body.sidebar-collapsed .toggle-arrow,
body.sidebar-collapsed .user-info,
body.sidebar-collapsed .logout-btn { opacity: 0; width: 0; overflow: hidden; }

/* Center icons */
body.sidebar-collapsed .sidebar-link { padding: 12px 0; justify-content: center; }
body.sidebar-collapsed .sidebar-link.active::before { top: 6px; bottom: 6px; }
body.sidebar-collapsed .sidebar-link.sub { padding-left: 0; justify-content: center; }
body.sidebar-collapsed .sidebar-group-toggle { padding: 12px 0; justify-content: center; }
body.sidebar-collapsed .sidebar-group-toggle > span { justify-content: center; gap: 0; }
body.sidebar-collapsed .sidebar-group-items { display: none !important; }
body.sidebar-collapsed .sidebar-footer .sidebar-user { justify-content: center; }
body.sidebar-collapsed .sidebar-header { justify-content: center; padding: 16px 0; }
body.sidebar-collapsed .sidebar-link i,
body.sidebar-collapsed .sidebar-group-toggle i { font-size: 16px; width: auto; }

/* Tooltip on hover when collapsed */
body.sidebar-collapsed .sidebar-link,
body.sidebar-collapsed .sidebar-group-toggle { position: relative; }
body.sidebar-collapsed .sidebar-link[data-label]:hover::after,
body.sidebar-collapsed .sidebar-group-toggle[data-label]:hover::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-collapsed-w) + 4px);
  top: 50%;
  transform: translateY(-50%);
  background: #1e293b;
  color: white;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  z-index: 9999;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin var(--transition);
}

/* ── Topbar ───────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.04);
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-toggle {
  background: none; border: none;
  font-size: 16px; color: var(--text-muted);
  cursor: pointer; padding: 8px;
  border-radius: 8px;
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  transition: background var(--transition), color var(--transition);
}
.topbar-toggle:hover { color: var(--primary); background: var(--primary-lt); }
.topbar-icon-btn {
  color: var(--text-muted); font-size: 15px;
  text-decoration: none; padding: 8px;
  border-radius: 8px; transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
}
.topbar-icon-btn:hover { color: var(--primary); background: var(--primary-lt); }
.topbar-date { color: var(--text-muted); font-size: 13px; }
.breadcrumb { font-size: 13px; margin-bottom: 0; }
.breadcrumb-item a { color: var(--primary); text-decoration: none; }
.breadcrumb-item.active { color: var(--text-muted); }

/* ── Page Body ────────────────────────────────────────────── */
.page-body { padding: 28px 28px 48px; }
.page-title-area {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-size: 22px; font-weight: 700; margin: 0; color: var(--text-main); }
.page-subtitle { color: var(--text-muted); margin: 4px 0 0; font-size: 13px; }
.page-actions { flex-shrink: 0; }

/* ── Cards ────────────────────────────────────────────────── */
.card-custom {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header-custom {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  background: transparent;
}
.card-title-custom {
  font-weight: 600;
  font-size: 14px;
  margin: 0;
  color: var(--text-main);
}
.card-custom .card-body { padding: 22px; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.stat-icon {
  width: 54px; height: 54px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-primary .stat-icon { background: var(--primary-lt); color: var(--primary); }
.stat-success .stat-icon { background: #f0fdf4; color: var(--success); }
.stat-warning .stat-icon { background: #fffbeb; color: var(--warning); }
.stat-danger  .stat-icon { background: #fef2f2; color: var(--danger);  }
.stat-info    .stat-icon { background: #f0f9ff; color: var(--info);    }
.stat-purple  .stat-icon { background: #f5f3ff; color: var(--purple);  }
.stat-value { font-size: 22px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-top: 3px; }

/* ── Mini Stats ───────────────────────────────────────────── */
.mini-stat {
  background: white;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}
.mini-stat-label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.mini-stat-val   { font-size: 18px; font-weight: 700; margin-top: 4px; }

/* ── Tables ───────────────────────────────────────────────── */
.table { margin-bottom: 0; }
.table thead th {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  padding: 13px 18px;
  white-space: nowrap;
  vertical-align: middle;
}
.table tbody td {
  padding: 13px 18px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13.5px;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #fafbfc; }
.table tfoot td { padding: 13px 18px; background: #f8fafc; border-top: 2px solid var(--border); font-size: 13.5px; }
/* First & last column breathing room */
.card-custom .table thead th:first-child,
.card-custom .table tbody td:first-child,
.card-custom .table tfoot td:first-child { padding-left: 24px; }
.card-custom .table thead th:last-child,
.card-custom .table tbody td:last-child,
.card-custom .table tfoot td:last-child  { padding-right: 24px; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn { font-weight: 500; border-radius: 8px; font-size: 13.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: #4338ca; border-color: #4338ca; }
.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 6px; line-height: 1.4; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }

/* ── Badges ───────────────────────────────────────────────── */
.badge { font-weight: 600; font-size: 11px; border-radius: 6px; padding: 4px 9px; letter-spacing: .2px; }
.bg-success-subtle { background: #f0fdf4 !important; }
.bg-primary-subtle { background: var(--primary-lt) !important; }

/* ── Avatar ───────────────────────────────────────────────── */
.avatar-sm {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

/* ── Top Student ──────────────────────────────────────────── */
.top-student-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f5f9;
}
.top-student-item:last-child { border-bottom: none; }
.top-rank {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}
.rank-1 { background: #fef3c7; color: #92400e; }
.rank-2 { background: #f1f5f9; color: #475569; }
.rank-3 { background: #fef2f2; color: #991b1b; }
.rank-4, .rank-5 { background: #f8fafc; color: var(--text-muted); }
.top-student-info { flex: 1; }
.top-student-name { font-weight: 600; font-size: 13px; }
.top-student-sub  { font-size: 11px; color: var(--text-muted); }
.top-student-rev  { font-weight: 700; color: var(--success); font-size: 14px; }

/* ── Earnings / Calc Breakdown ────────────────────────────── */
.earnings-breakdown, .calc-breakdown { display: flex; flex-direction: column; gap: 10px; }
.earnings-row, .calc-row {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; padding: 4px 0;
}
.calc-divider { border-top: 1px dashed var(--border); margin: 6px 0; }
.calc-total { margin-top: 8px; padding-top: 8px; border-top: 2px solid var(--border); }
.text-purple { color: var(--purple) !important; }

/* ── Export Type Cards ────────────────────────────────────── */
.export-type-card {
  display: block;
  background: #f8fafc;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 18px 14px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.export-type-card:hover { border-color: var(--primary); background: var(--primary-lt); }
.export-type-card.active { border-color: var(--primary); background: var(--primary-lt); }

/* ── Forms ────────────────────────────────────────────────── */
.form-control, .form-select {
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13.5px;
  padding: 9px 14px;
  color: var(--text-main);
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-label { font-size: 13px; color: var(--text-main); margin-bottom: 6px; font-weight: 500; }
.input-group-text {
  border-radius: 8px;
  background: #f8fafc;
  border-color: var(--border);
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 9px 14px;
}
/* Seamless input groups */
.input-group > .form-control:not(:first-child),
.input-group > .form-select:not(:first-child) { border-left: none; border-radius: 0 8px 8px 0; }
.input-group > .input-group-text:not(:last-child) { border-right: none; border-radius: 8px 0 0 8px; }
.input-group > .form-control:not(:last-child),
.input-group > .form-select:not(:last-child) { border-right: none; border-radius: 8px 0 0 8px; }
.input-group > .input-group-text:not(:first-child) { border-left: none; border-radius: 0 8px 8px 0; }
.input-group > .btn { border-radius: 0 8px 8px 0; }
.form-text { font-size: 12px; color: var(--text-muted); }

/* ── Status Select in Table ───────────────────────────────── */
.status-select {
  font-size: 12px;
  padding: 5px 10px;
  height: auto;
  min-width: 115px;
  border-radius: 7px;
}

/* ── DataTables overrides ─────────────────────────────────── */
div.dataTables_wrapper div.dataTables_filter {
  text-align: right;
}
div.dataTables_wrapper div.dataTables_filter input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  margin-left: 6px;
  color: var(--text-main);
}
div.dataTables_wrapper div.dataTables_length {
  font-size: 13px;
  color: var(--text-muted);
}
div.dataTables_wrapper div.dataTables_length select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text-main);
  margin: 0 5px;
  min-width: 70px;
}
div.dataTables_wrapper div.dataTables_info {
  font-size: 12.5px;
  color: var(--text-muted);
  padding-top: 10px;
  margin-left: 15px;
}
div.dataTables_wrapper div.dataTables_paginate {
  padding-top: 8px;
}
div.dataTables_wrapper div.dataTables_paginate .paginate_button {
  border-radius: 6px !important;
  font-size: 13px !important;
  padding: 4px 10px !important;
  border: 1px solid transparent !important;
}
div.dataTables_wrapper div.dataTables_paginate .paginate_button.current,
div.dataTables_wrapper div.dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: white !important;
}
div.dataTables_wrapper div.dataTables_paginate .paginate_button:hover:not(.current) {
  background: var(--primary-lt) !important;
  border-color: var(--border) !important;
  color: var(--primary) !important;
}

/* ── Login Page ───────────────────────────────────────────── */
.login-body { background: #f8fafc; }
.login-wrapper { min-height: 100vh; display: flex; }
.login-left {
  flex: 1;
  background: linear-gradient(145deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 60px 48px;
  position: relative;
  overflow: hidden;
}
.login-left-content { position: relative; z-index: 2; text-align: center; }
.login-brand-logo {
  margin: 0 auto 24px;
  display: flex; align-items: center; justify-content: center;
}
.login-brand-logo img {
  max-height: 110px; max-width: 240px;
  object-fit: contain;
  background: #fff;
  padding: 14px 28px;
  border-radius: 20px;
  box-shadow: 0 4px 28px rgba(0,0,0,.22);
  /* no filter — show logo in its actual colours */
}
.login-brand-icon-fallback,
.login-brand-icon {
  width: 72px; height: 72px;
  background: rgba(255,255,255,.1);
  border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; color: white;
  margin: 0 auto 20px;
  backdrop-filter: blur(10px);
}
.login-brand-logo .login-brand-icon-fallback { margin: 0; }
.login-mobile-img {
  max-height: 36px; max-width: 120px;
  object-fit: contain;
}
.login-brand { color: white; font-size: 36px; font-weight: 800; margin: 0; }
.login-tagline { color: rgba(255,255,255,.6); font-size: 15px; margin: 8px 0 40px; }
.login-features { text-align: left; display: inline-block; }
.login-feature-item { display: flex; align-items: center; gap: 12px; color: rgba(255,255,255,.8); margin-bottom: 12px; font-size: 14px; }
.login-feature-item i { color: #a5f3fc; }
.login-left-deco { position: absolute; inset: 0; z-index: 1; }
.deco-circle { position: absolute; border-radius: 50%; background: rgba(255,255,255,.04); }
.deco-1 { width: 400px; height: 400px; top: -100px; right: -100px; }
.deco-2 { width: 250px; height: 250px; bottom: -60px; left: -60px; }
.deco-3 { width: 150px; height: 150px; top: 50%; right: 80px; transform: translateY(-50%); }

.login-right {
  flex: 1;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 48px;
  background: #f8fafc;
}
.login-form-box { width: 100%; max-width: 400px; }
.login-title { font-size: 26px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { color: var(--text-muted); margin-bottom: 28px; }
.login-btn { background: var(--primary); border-color: var(--primary); font-weight: 600; }
.login-btn:hover { background: #4338ca; }
.login-footer-text { color: var(--text-muted); font-size: 12px; text-align: center; }
.login-logo-mobile { display: flex; align-items: center; gap: 10px; }
.brand-icon-sm {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 16px;
}
.brand-name-sm { font-weight: 700; font-size: 18px; }

/* ── Sidebar Overlay ──────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1040;
  backdrop-filter: blur(2px);
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(calc(-1 * var(--sidebar-w))); width: var(--sidebar-w) !important; }
  .sidebar.sidebar-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .topbar-toggle { display: flex !important; }
  #collapseBtn { display: none !important; }
  .sidebar-overlay.active { display: block; }
  .page-body { padding: 20px 16px 36px; }
  /* Reset collapse on mobile */
  body.sidebar-collapsed .brand-name,
  body.sidebar-collapsed .brand-sub,
  body.sidebar-collapsed .sidebar-section,
  body.sidebar-collapsed .sidebar-link > span,
  body.sidebar-collapsed .sidebar-group-toggle > span > span,
  body.sidebar-collapsed .toggle-arrow,
  body.sidebar-collapsed .user-info,
  body.sidebar-collapsed .logout-btn { opacity: 1; width: auto; overflow: visible; }
  body.sidebar-collapsed .sidebar-link { padding: 10px 20px; justify-content: flex-start; }
  body.sidebar-collapsed .sidebar-link.sub { padding-left: 46px; }
  body.sidebar-collapsed .sidebar-group-toggle { padding: 10px 20px; justify-content: space-between; }
  body.sidebar-collapsed .sidebar-section { padding: 16px 20px 6px; height: auto; }
  body.sidebar-collapsed .sidebar-header { justify-content: space-between; padding: 16px 18px; }
  body.sidebar-collapsed .sidebar-footer .sidebar-user { justify-content: flex-start; }
}

@media (min-width: 992px) {
  .topbar-toggle:not(#collapseBtn) { display: none; }
  #collapseBtn { display: flex; }
}

@media (max-width: 575.98px) {
  .stat-value { font-size: 18px; }
  .page-title { font-size: 18px; }
  .card-custom .card-body { padding: 16px; }
  .table thead th,
  .table tbody td { padding: 11px 14px; }
}

/* ── Alerts ──────────────────────────────────────────────── */
.alert { border-radius: 10px; border: none; font-size: 13.5px; padding: 14px 16px; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-info    { background: #f0f9ff; color: #075985; }

/* ============================================================
   Mobile Polish v1.2 — site-wide responsive tightening
   ============================================================ */

/* Prevent iOS Safari from zooming form inputs on focus */
@media (max-width: 768px) {
  input.form-control,
  select.form-select,
  textarea.form-control,
  .dataTables_filter input,
  .select2-container--bootstrap-5 .select2-selection,
  .select2-search__field { font-size: 16px !important; }
}

/* Tablet & below — tighter chrome */
@media (max-width: 991.98px) {
  .topbar { padding: 0 14px; }
  .topbar-icon-btn { width: 36px; height: 36px; font-size: 14px; }
  .topbar-toggle { width: 36px; height: 36px; }

  .page-body { padding: 16px 12px 32px; }
  .page-title-area { margin-bottom: 16px; gap: 10px; }
  .page-title { font-size: 19px; }
  .page-actions { width: 100%; }
  .page-actions .btn { width: 100%; justify-content: center; }
  .page-actions .btn + .btn { margin-top: 6px; }

  .card-custom .card-body { padding: 16px; }
  .card-header-custom { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
  .card-header-custom .btn { flex-shrink: 0; }

  .stat-card { padding: 14px; gap: 12px; }
  .stat-icon { width: 44px; height: 44px; font-size: 18px; border-radius: 10px; }
  .stat-value { font-size: 18px; }
  .mini-stat { padding: 12px 14px; }
  .mini-stat-val { font-size: 17px; }

  .table thead th, .table tbody td, .table tfoot td { padding: 9px 12px; font-size: 12.5px; }
  .table thead th { font-size: 10.5px; }
  .card-custom .table thead th:first-child,
  .card-custom .table tbody td:first-child,
  .card-custom .table tfoot td:first-child { padding-left: 14px; }
  .card-custom .table thead th:last-child,
  .card-custom .table tbody td:last-child,
  .card-custom .table tfoot td:last-child  { padding-right: 14px; }

  /* DataTables controls stack cleanly */
  div.dataTables_wrapper div.dataTables_filter,
  div.dataTables_wrapper div.dataTables_length { text-align: left; padding: 4px 0; }
  div.dataTables_wrapper div.dataTables_filter input { width: 100%; margin-left: 0; margin-top: 4px; box-sizing: border-box; }
  div.dataTables_wrapper > .row { margin: 0 !important; }
  div.dataTables_wrapper > .row > [class^="col"] { padding-left: 6px !important; padding-right: 6px !important; }

  /* Statement letterhead — stack on tablet */
  .statement-head .lh-company,
  .statement-head [style*="font-size:20px"] { font-size: 17px !important; }
}

/* Phone — extra tight */
@media (max-width: 575.98px) {
  :root { --topbar-h: 56px; }
  .topbar { padding: 0 8px; }
  .breadcrumb { font-size: 11px; }
  .topbar-date { display: none !important; }

  .page-body { padding: 12px 10px 28px; }
  .page-title { font-size: 16px; }
  .page-subtitle { font-size: 12px; }

  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 15px; border-radius: 9px; }
  .stat-value { font-size: 16px; line-height: 1.15; }
  .stat-label { font-size: 11px; }
  .mini-stat { padding: 10px 12px; }
  .mini-stat-val { font-size: 15px; }
  .mini-stat-label { font-size: 10px; }

  .card-custom { border-radius: 10px; }
  .card-custom .card-body { padding: 12px; }
  .card-header-custom { padding: 10px 12px; }
  .card-title-custom { font-size: 13px; }

  .table thead th, .table tbody td, .table tfoot td { padding: 7px 9px; font-size: 12px; }
  .table thead th { font-size: 10px; }
  .card-custom .table thead th:first-child,
  .card-custom .table tbody td:first-child,
  .card-custom .table tfoot td:first-child { padding-left: 9px; }
  .card-custom .table thead th:last-child,
  .card-custom .table tbody td:last-child,
  .card-custom .table tfoot td:last-child  { padding-right: 9px; }

  .btn { font-size: 13px; padding: 7px 12px; }
  .btn-lg { font-size: 14px; padding: 10px 14px; }
  .btn-sm { font-size: 11.5px; padding: 5px 10px; }
  .btn-xs { font-size: 11px; padding: 3px 7px; }

  .alert { padding: 10px 12px; font-size: 12.5px; }

  /* Quick actions row — share the row 50/50 */
  .card-body > .d-flex.flex-wrap.gap-2 .btn,
  .card-body > .d-flex.flex-wrap.gap-3 .btn { flex: 1 1 calc(50% - 4px); }

  /* Calc breakdown: keep amounts aligned */
  .calc-row, .earnings-row { font-size: 13px; }

  /* Export type cards — 1 column each */
  .export-type-card { padding: 14px 10px; }
}

/* Horizontal scroll cue for overflowing tables */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* Touch-friendly minimum target on touch devices */
@media (hover: none) and (max-width: 991.98px) {
  .btn, .topbar-icon-btn, .topbar-toggle { min-height: 38px; }
  .sidebar-link, .sidebar-group-toggle { min-height: 42px; }
  .btn-xs { min-height: 28px; }
}

/* DataTables Responsive plugin: child-row "+" button styling */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  box-shadow: 0 0 2px rgba(79,70,229,.4) !important;
}
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before {
  background-color: var(--danger) !important;
  border-color: var(--danger) !important;
}
ul.dtr-details { font-size: 13px; }
ul.dtr-details li { border-bottom: 1px solid var(--border) !important; padding: 6px 0 !important; }
ul.dtr-details .dtr-title { font-weight: 600; color: var(--text-main); min-width: 100px; }

/* ── Print Header (screen: hidden) ───────────────────────── */
#print-header { display: none; }

/* ── Print ────────────────────────────────────────────────── */
@media print {
  @page { margin: 1.5cm; }

  /* Force colour rendering */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  /* ── Hide all screen chrome ── */
  .sidebar, .sidebar-overlay,
  .topbar,
  .page-title-area,
  nav[aria-label="breadcrumb"],
  .page-actions,
  .card-header-custom .btn,
  .card-header-custom button,
  .card-header-custom a.btn,
  .card-custom:has(> .card-body > form.row),
  div.dataTables_wrapper div.dataTables_filter,
  div.dataTables_wrapper div.dataTables_length,
  div.dataTables_wrapper div.dataTables_paginate,
  div.dataTables_wrapper div.dataTables_info,
  .confirm-delete, .send-email-btn, .status-select,
  .btn-group,
  #collapseBtn, #sidebarToggle,
  .alert,
  canvas { display: none !important; }

  /* Hide action buttons inside table cells */
  td .btn-xs, td .d-flex.gap-1 { display: none !important; }

  /* ── Show print header ── */
  #print-header           { display: block !important; margin-bottom: 24px; }
  .print-hdr-inner        { display: flex !important; align-items: center;
                            justify-content: space-between;
                            padding-bottom: 16px;
                            border-bottom: 3px solid #4f46e5; }
  .print-hdr-left         { display: flex !important; align-items: center; gap: 16px; }
  .print-hdr-logo         { max-height: 60px; max-width: 160px; object-fit: contain; }
  .print-hdr-company-name { font-size: 20px; font-weight: 800; color: #0f172a; line-height: 1.2; }
  .print-hdr-company-sub  { font-size: 11px; color: #64748b; margin-top: 3px; }
  .print-hdr-right        { text-align: right; }
  .print-hdr-title        { font-size: 17px; font-weight: 700; color: #4f46e5; }
  .print-hdr-period       { font-size: 11px; color: #374151; font-weight: 600; margin-top: 4px; }
  .print-hdr-date         { font-size: 10px; color: #94a3b8; margin-top: 3px; }

  /* ── Layout ── */
  body        { background: #fff !important; font-size: 10pt; color: #000; }
  .main-content           { margin-left: 0 !important; }
  .page-body              { padding: 0 !important; }
  body.sidebar-collapsed .main-content { margin-left: 0 !important; }

  /* ── Cards ── */
  .card-custom {
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
    break-inside: avoid;
    margin-bottom: 16px !important;
  }
  .card-header-custom {
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 10px 16px !important;
  }
  .card-body { padding: 12px 16px !important; }

  /* ── Tables ── */
  .table                  { font-size: 9pt !important; border-collapse: collapse !important; width: 100% !important; }
  .table th,
  .table td               { border: 1px solid #d1d5db !important; padding: 5px 8px !important;
                            vertical-align: middle !important; white-space: normal !important; }
  .table thead th         { background: #f1f5f9 !important; font-weight: 700 !important;
                            font-size: 8pt !important; text-transform: uppercase !important;
                            letter-spacing: .4px !important; color: #374151 !important; }
  .table tfoot td,
  .table tfoot th         { background: #f8fafc !important; font-weight: 700 !important;
                            border-top: 2px solid #9ca3af !important; }
  .table-hover tbody tr:hover { background: transparent !important; }

  /* ── Badges ── */
  .badge { border: 1.5px solid currentColor !important; background: transparent !important;
           font-size: 7.5pt !important; padding: 2px 6px !important; }
  .badge.bg-success  { color: #16a34a !important; border-color: #16a34a !important; }
  .badge.bg-warning  { color: #d97706 !important; border-color: #d97706 !important; }
  .badge.bg-danger   { color: #dc2626 !important; border-color: #dc2626 !important; }
  .badge.bg-secondary{ color: #6b7280 !important; border-color: #6b7280 !important; }
  .badge.bg-primary  { color: #4f46e5 !important; border-color: #4f46e5 !important; }
  .badge.bg-primary-subtle { color: #4f46e5 !important; border-color: #c7d2fe !important; background: #eef2ff !important; }
  .badge.bg-light.text-dark { color: #374151 !important; border-color: #9ca3af !important; }

  /* ── Mini-stat cards ── */
  .mini-stat { border: 1px solid #e2e8f0 !important; box-shadow: none !important;
               break-inside: avoid; padding: 10px 14px !important; }

  /* ── Links ── */
  a { color: #1e293b !important; text-decoration: none !important; }
  a.text-primary, .fw-semibold.text-primary { color: #4f46e5 !important; }
}

/* ── Select2 integration ──────────────────────────────────── */
.select2-container--bootstrap-5 .select2-selection {
  border-color: var(--border) !important;
  border-radius: 8px !important;
  font-size: 13.5px !important;
  min-height: 40px !important;
}
.select2-container--bootstrap-5 .select2-selection--single { padding: 6px 14px !important; }
.select2-container--bootstrap-5 .select2-dropdown { border-color: var(--border) !important; border-radius: 8px !important; }

/* Sidebar pending badge */
.sb-badge {
  display: inline-block;
  min-width: 18px;
  padding: 1px 6px;
  margin-left: 6px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.4;
  color: #fff;
  background: #ef4444;
  border-radius: 999px;
  text-align: center;
  vertical-align: middle;
}
