/* =========================================================
   Bizmax Admin — Design System v5
   Structure: tokens → base → layout → components → pages → utilities
   Token names from v4 are preserved so existing pages keep working.
   ========================================================= */

/* ---------- 1. Tokens ---------- */
:root {
  --sidebar-width: 264px;
  --topbar-height: 64px;

  /* Brand */
  --primary: #0b7a63;
  --primary-dark: #075a49;
  --primary-soft: #e8f4f0;
  --primary-ring: rgba(11, 122, 99, 0.18);
  --accent: #c6f06f;

  /* Status */
  --success: #12a075;
  --warning: #d97706;
  --danger: #d6455d;
  --info: #0d8bd1;

  /* Surfaces */
  --body-bg: #f4f6f8;
  --card-bg: #ffffff;
  --surface-2: #f8fafb;
  --border: #e3e9ed;
  --border-strong: #cfd8de;

  /* Text */
  --text: #14262f;
  --text-muted: #64808d;
  --text-faint: #94a8b2;

  /* Sidebar */
  --sidebar-bg: #0b1f2a;
  --sidebar-text: #9fb5bf;
  --sidebar-muted: #5f7885;
  --sidebar-active: #c6f06f;

  /* Shape & depth */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-xs: 0 1px 2px rgba(11, 31, 42, 0.05);
  --shadow: 0 1px 3px rgba(11, 31, 42, 0.06), 0 4px 14px rgba(11, 31, 42, 0.04);
  --shadow-md: 0 8px 28px rgba(11, 31, 42, 0.10);

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', Menlo, Consolas, monospace;

  /* Bootstrap bridge */
  --bs-primary: #0b7a63;
  --bs-primary-rgb: 11, 122, 99;
  --bs-link-color: #0b7a63;
  --bs-link-hover-color: #075a49;
  --bs-body-font-family: var(--font);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
}

[data-bs-theme="dark"] {
  --body-bg: #09161e;
  --card-bg: #11242f;
  --surface-2: #0e1f29;
  --border: #213643;
  --border-strong: #2d4756;
  --text: #e6f0f3;
  --text-muted: #8da6b2;
  --text-faint: #5f7885;
  --primary: #2cc29e;
  --primary-dark: #4fd8b6;
  --primary-soft: #12362f;
  --primary-ring: rgba(44, 194, 158, 0.25);
  --sidebar-bg: #07131a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.4);
  --bs-body-bg: #09161e;
  --bs-body-color: #e6f0f3;
  --bs-border-color: #213643;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font) !important;
  background: var(--body-bg) !important;
  color: var(--text) !important;
  font-size: 14px;
  line-height: 1.55;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
h1, h2, h3, h4, h5, h6 { color: var(--text); letter-spacing: -0.01em; }
::selection { background: var(--primary-ring); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.text-muted { color: var(--text-muted) !important; }
.num, .stat-card h3, .table td.num { font-variant-numeric: tabular-nums; }

.skip-link {
  position: absolute; left: -999px; top: 8px; z-index: 3000;
  background: var(--primary); color: #fff; padding: 8px 14px; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { left: 8px; color: #fff; }

/* ---------- 3. Layout shell ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg) !important;
  color: #fff;
  z-index: 1040;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  transition: transform 0.25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  height: var(--topbar-height);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
  color: #fff;
}
.sidebar-brand:hover { color: #fff; }
.brand-mark {
  width: 34px; height: 34px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #0b1f2a;
  border-radius: 10px; font-weight: 800; font-size: 16px;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; color: #fff; }
.brand-sub { font-size: 10px; font-weight: 600; letter-spacing: 0.9px; text-transform: uppercase; color: var(--sidebar-muted); margin-top: 3px; }

.sidebar-nav { padding: 8px 12px 16px; flex: 1; }
.nav-section {
  font-size: 10.5px; font-weight: 700; letter-spacing: 1.1px; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 18px 12px 6px;
}
.sidebar .nav-link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px !important; margin: 2px 0 !important;
  border-radius: 9px !important;
  color: var(--sidebar-text) !important;
  font-size: 13.5px !important; font-weight: 500 !important;
  transition: background 0.15s, color 0.15s;
}
.sidebar .nav-link i { width: 18px; text-align: center; font-size: 14px; opacity: 0.8; }
.sidebar .nav-link:hover { background: rgba(255, 255, 255, 0.06) !important; color: #fff !important; }
.sidebar .nav-link.active { background: rgba(198, 240, 111, 0.12) !important; color: #fff !important; font-weight: 600 !important; }
.sidebar .nav-link.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--sidebar-active); border-radius: 0 3px 3px 0;
}
.sidebar .nav-link.active i { color: var(--sidebar-active); opacity: 1; }
.sidebar .nav-link .badge {
  margin-left: auto; min-width: 22px; text-align: center;
  font-size: 10.5px !important; font-weight: 700; padding: 3px 7px !important; border-radius: 20px;
  background: rgba(255, 255, 255, 0.12) !important; color: #fff !important;
}
.sidebar .nav-link .badge.badge-warn { background: #f59e0b !important; color: #1d1400 !important; }
.sidebar .nav-link .badge.badge-danger { background: #ef4444 !important; color: #fff !important; }
.sidebar-footer {
  padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.sidebar-footer .avatar { width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,0.08); color: var(--sidebar-active); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.sidebar-footer .who { flex: 1; min-width: 0; line-height: 1.25; }
.sidebar-footer .who strong { display: block; color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .who span { font-size: 11px; color: var(--sidebar-muted); }
.sidebar-footer .logout { color: var(--sidebar-text); padding: 8px; border-radius: 8px; }
.sidebar-footer .logout:hover { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 4px; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(5, 15, 22, 0.55); backdrop-filter: blur(2px); z-index: 1035; }
.sidebar-overlay.show { display: block; }

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--body-bg);
}
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-height);
  padding: 0 clamp(16px, 3vw, 36px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: color-mix(in srgb, var(--card-bg) 88%, transparent) !important;
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border) !important;
}
.topbar-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); min-width: 0; }
.crumbs a { color: var(--text-muted); font-weight: 500; }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { font-size: 9px; opacity: 0.6; }
.crumbs .current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon {
  position: relative;
  width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: all 0.15s;
}
.btn-icon:hover { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.btn-icon .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--card-bg); }
.topbar .avatar {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.user-chip { display: flex; align-items: center; gap: 10px; padding: 3px 10px 3px 3px; border: 1px solid var(--border); border-radius: 12px; background: var(--card-bg); color: var(--text); }
.user-chip:hover { border-color: var(--primary); color: var(--text); }
.user-chip .meta { line-height: 1.2; text-align: left; }
.user-chip .meta strong { display: block; font-size: 12.5px; font-weight: 600; }
.user-chip .meta span { font-size: 11px; color: var(--text-muted); }

.page-content { flex: 1; width: 100%; max-width: 1480px; padding: 28px clamp(16px, 3vw, 36px) 40px; }
.app-footer { padding: 18px clamp(16px, 3vw, 36px); border-top: 1px solid var(--border); font-size: 12px; color: var(--text-muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; }

/* ---------- 4. Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-title { font-weight: 700; font-size: 1.5rem; letter-spacing: -0.02em; color: var(--text); margin: 0 0 4px; }
.page-subtitle { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }
.page-head .page-subtitle { margin: 0; }
.section-title { font-weight: 700; font-size: 1rem; color: var(--text); margin: 0 0 12px; }
.eyebrow { letter-spacing: 0.12em; text-transform: uppercase; font-size: 11px; font-weight: 700; color: var(--text-muted); }

/* ---------- 5. Cards ---------- */
.card {
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: var(--shadow);
  color: var(--text);
}
.card-header {
  background: transparent !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 14px 20px !important;
  font-weight: 650; font-size: 14px; color: var(--text);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-body { padding: 20px !important; }
.card-body.p-0 { padding: 0 !important; }
.card-footer { background: transparent !important; border-top: 1px solid var(--border) !important; padding: 12px 20px !important; }

.stat-card {
  display: flex; align-items: center; gap: 14px; height: 100%;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  color: inherit;
}
a.stat-card:hover, .stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.stat-icon {
  width: 46px; height: 46px; flex-shrink: 0; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  background: var(--primary-soft); color: var(--primary);
}
.stat-icon.bg-primary { background: var(--primary-soft) !important; color: var(--primary); }
.stat-icon.bg-success { background: rgba(18, 160, 117, 0.14) !important; color: var(--success); }
.stat-icon.bg-warning { background: rgba(217, 119, 6, 0.14) !important; color: var(--warning); }
.stat-icon.bg-danger  { background: rgba(214, 69, 93, 0.14) !important; color: var(--danger); }
.stat-icon.bg-info    { background: rgba(13, 139, 209, 0.14) !important; color: var(--info); }
.stat-card h3 { margin: 0; font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.stat-card small { display: block; margin-top: 2px; color: var(--text-muted); font-size: 12px; font-weight: 500; }

/* Attention banner (pending work) */
.attention {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 14px 18px; margin-bottom: 20px;
  background: color-mix(in srgb, var(--warning) 9%, var(--card-bg));
  border: 1px solid color-mix(in srgb, var(--warning) 30%, var(--border));
  border-radius: var(--radius);
}
.attention i.lead { color: var(--warning); font-size: 18px; }
.attention .msg { flex: 1; min-width: 200px; font-weight: 500; }
.attention .msg small { display: block; color: var(--text-muted); font-weight: 400; }

/* ---------- 6. Tables ---------- */
.table-responsive { -webkit-overflow-scrolling: touch; }
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-hover-bg: var(--surface-2);
  --bs-table-hover-color: var(--text);
  --bs-table-striped-bg: transparent;
  margin-bottom: 0; font-size: 13px;
}
.table thead th {
  font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted) !important; background: var(--surface-2) !important;
  border-bottom: 1px solid var(--border); padding: 11px 16px; white-space: nowrap;
}
.table tbody td { padding: 13px 16px; vertical-align: middle; color: var(--text); border-color: var(--border); }
.table-hover tbody tr:hover > * { background: var(--surface-2) !important; }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- 7. Badges, buttons, forms, alerts ---------- */
.badge { font-weight: 600; font-size: 11px; padding: 4px 9px; border-radius: 999px; letter-spacing: 0.1px; }
.badge-soft-success { background: #d8f5e9; color: #0a6b4b; }
.badge-soft-warning { background: #fdecc8; color: #8a4b05; }
.badge-soft-danger  { background: #fde0e5; color: #9d2438; }
.badge-soft-info    { background: #dbeefb; color: #0b5d8f; }
.badge-soft-primary { background: #d8f0ea; color: #075a49; }
.badge-soft-secondary { background: #e8edf0; color: #40555f; }
[data-bs-theme="dark"] .badge-soft-success { background: #0d3d2f; color: #7be0b8; }
[data-bs-theme="dark"] .badge-soft-warning { background: #4a3009; color: #f6c76c; }
[data-bs-theme="dark"] .badge-soft-danger  { background: #4a1822; color: #f4a3b0; }
[data-bs-theme="dark"] .badge-soft-info    { background: #0c3550; color: #8fd0f5; }
[data-bs-theme="dark"] .badge-soft-primary { background: #0f3a31; color: #7be0cc; }
[data-bs-theme="dark"] .badge-soft-secondary { background: #243845; color: #bccdd5; }

.btn { font-weight: 600; font-size: 13px; border-radius: var(--radius-sm); padding: 8px 16px; transition: all 0.15s; }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn-primary { --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary); --bs-btn-hover-bg: var(--primary-dark); --bs-btn-hover-border-color: var(--primary-dark); --bs-btn-active-bg: var(--primary-dark); --bs-btn-color: #fff; --bs-btn-hover-color: #fff; background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }
.btn-primary:hover, .btn-primary:focus { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; }
[data-bs-theme="dark"] .btn-primary { color: #04231c !important; }
.btn-success { background: var(--success) !important; border-color: var(--success) !important; color: #fff !important; }
.btn-danger { background: var(--danger) !important; border-color: var(--danger) !important; color: #fff !important; }
.btn-warning { background: var(--warning) !important; border-color: var(--warning) !important; color: #fff !important; }
.btn-outline-secondary { border-color: var(--border-strong); color: var(--text); background: var(--card-bg); }
.btn-outline-secondary:hover { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); }
.btn-outline-primary { border-color: var(--primary); color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-outline-danger:hover { color: #fff; }

.form-control, .form-select {
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  font-size: 13.5px; padding: 9px 12px; background-color: var(--card-bg); color: var(--text);
}
.form-control::placeholder { color: var(--text-faint); }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); background-color: var(--card-bg); color: var(--text); }
.form-control:disabled, .form-control[readonly], .readonly-field { background-color: var(--surface-2); }
.form-label { font-weight: 600; font-size: 12.5px; color: var(--text); margin-bottom: 6px; }
.form-text { color: var(--text-muted); font-size: 12px; }
.input-group-text { background: var(--surface-2); border-color: var(--border-strong); color: var(--text-muted); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

.alert { border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 13px; font-weight: 500; padding: 12px 16px; }
.alert-success { background: #e1f6ec; color: #0a6b4b; border-color: #bfe9d6; }
.alert-danger  { background: #fde8ec; color: #9d2438; border-color: #f7c6cf; }
.alert-warning { background: #fef3d9; color: #8a4b05; border-color: #f7dea6; }
.alert-info    { background: #e3f1fb; color: #0b5d8f; border-color: #bfdff4; }
[data-bs-theme="dark"] .alert-success { background: #0d3d2f; color: #7be0b8; border-color: #14573f; }
[data-bs-theme="dark"] .alert-danger  { background: #4a1822; color: #f4a3b0; border-color: #6b2432; }
[data-bs-theme="dark"] .alert-warning { background: #4a3009; color: #f6c76c; border-color: #6b4710; }
[data-bs-theme="dark"] .alert-info    { background: #0c3550; color: #8fd0f5; border-color: #134c70; }

.nav-pills .nav-link { border-radius: 8px; font-weight: 600; font-size: 13px; color: var(--text-muted); padding: 7px 14px; }
.nav-pills .nav-link:hover { color: var(--primary); background: var(--primary-soft); }
.nav-pills .nav-link.active { background: var(--primary); color: #fff; }
.nav-tabs { border-bottom: 1px solid var(--border); }
.nav-tabs .nav-link { color: var(--text-muted); font-weight: 600; font-size: 13px; border: 0; border-bottom: 2px solid transparent; padding: 10px 16px; }
.nav-tabs .nav-link:hover { color: var(--primary); }
.nav-tabs .nav-link.active { color: var(--primary); background: transparent; border-bottom-color: var(--primary); }

.dropdown-menu { border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-md); font-size: 13px; background: var(--card-bg); padding: 6px; min-width: 200px; }
.dropdown-item { color: var(--text); padding: 8px 12px; border-radius: 6px; font-weight: 500; }
.dropdown-item:hover { background: var(--primary-soft); color: var(--primary); }
.dropdown-item i { width: 18px; color: var(--text-muted); }
.dropdown-divider { border-color: var(--border); }
.dropdown-header { padding: 8px 12px 6px; }

.modal-content { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); color: var(--text); }
.modal-header, .modal-footer { border-color: var(--border); }
.modal-title { font-weight: 700; font-size: 1.05rem; }
.modal-backdrop.show { opacity: 0.55; }
.pagination .page-link { color: var(--text); border-color: var(--border); background: var(--card-bg); font-size: 13px; }
.pagination .active .page-link { background: var(--primary); border-color: var(--primary); color: #fff; }
.progress { background: var(--border); border-radius: 999px; height: 8px; }
.progress-bar { background: var(--primary); }

code, .mono {
  font-family: var(--mono); font-size: 12px;
  background: var(--primary-soft); color: var(--primary-dark);
  padding: 2px 7px; border-radius: 6px;
}

/* ---------- 8. Reusable page patterns ---------- */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; opacity: 0.35; margin-bottom: 12px; display: block; }
.empty-state p { margin: 0; font-size: 14px; }

.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.quick-action {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-weight: 600; font-size: 12.5px; box-shadow: var(--shadow-xs); transition: all 0.15s;
}
.quick-action:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 13px; }
.toolbar .search input { padding-left: 34px; }

.plan-card { border-left: 4px solid var(--primary); padding: 14px 16px; margin-bottom: 12px; background: var(--primary-soft); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.plan-card.matured { border-left-color: var(--warning); }
.plan-card.credited { border-left-color: var(--success); }

/* Confirm deposit / withdrawal screens */
.deposit-hero, .withdrawal-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.mini-stat { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; display: flex; align-items: center; gap: 12px; }
.mini-stat .icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--primary-soft); color: var(--primary); font-size: 16px; }
.mini-stat .label { display: block; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 650; }
.mini-stat .value { display: block; margin-top: 4px; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.mini-stat.success .icon { background: rgba(18, 160, 117, 0.14); color: var(--success); }
.mini-stat.warning .icon { background: rgba(217, 119, 6, 0.14); color: var(--warning); }
.summary-box { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 18px; display: grid; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.summary-row:last-child { border-bottom: 0; }
.summary-row .label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em; font-weight: 650; }
.summary-row .value { font-weight: 700; color: var(--text); }
.amount-highlight { background: linear-gradient(135deg, var(--success), #2db786) !important; color: #fff; border-radius: var(--radius); padding: 16px 18px; font-size: 1.3rem; font-weight: 700; }
.action-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.action-row .btn { min-width: 170px; }
.info-pill { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 650; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- 9. Auth & status pages ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); background: var(--card-bg); }
.auth-aside {
  position: relative; overflow: hidden; color: #fff; padding: 48px clamp(28px, 5vw, 72px);
  background: radial-gradient(1200px 600px at 0% 0%, #0f4f44 0%, transparent 60%), linear-gradient(160deg, #0b1f2a 0%, #0a3a33 100%);
  display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside::after { content: ''; position: absolute; width: 520px; height: 520px; right: -200px; bottom: -220px; border-radius: 50%; border: 90px solid rgba(198, 240, 111, 0.07); }
.auth-aside h2 { color: #fff; font-size: clamp(1.6rem, 2.6vw, 2.3rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.2; max-width: 460px; }
.auth-aside p { color: #a9c1c9; max-width: 440px; }
.auth-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; position: relative; z-index: 1; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #cfe0e5; font-size: 14px; }
.auth-points i { color: var(--accent); margin-top: 3px; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 24px; background: var(--body-bg); }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.03em; margin: 0 0 6px; }
.auth-card .lead { color: var(--text-muted); font-size: 14px; margin-bottom: 26px; }
.auth-card .form-control { padding: 11px 14px; }
.pw-wrap { position: relative; }
.pw-wrap .toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--text-muted); padding: 8px 10px; border-radius: 8px; }
.pw-wrap .toggle:hover { color: var(--primary); }
.status-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--body-bg); }
.status-card { width: 100%; max-width: 460px; text-align: center; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 44px 32px; }
.status-code { font-size: 4.2rem; font-weight: 800; letter-spacing: -0.05em; line-height: 1; color: var(--primary); margin-bottom: 8px; }
.status-card h1 { font-size: 1.35rem; font-weight: 700; margin: 0 0 8px; }
.status-card p { color: var(--text-muted); margin-bottom: 24px; }

/* ---------- 10. Responsive ---------- */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); box-shadow: 10px 0 40px rgba(0, 0, 0, 0.3); }
  .main-content { margin-left: 0; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
}
@media (max-width: 767px) {
  .summary-grid { grid-template-columns: 1fr; }
  .action-row .btn { width: 100%; }
  .user-chip .meta { display: none; }
  .user-chip { padding: 3px; border-radius: 10px; }
}
@media (max-width: 600px) {
  .page-title { font-size: 1.3rem; }
  .stat-card { padding: 14px; }
  .stat-card h3 { font-size: 1.2rem; }
  .card-body { padding: 16px !important; }
  .table thead th, .table tbody td { padding: 10px 12px; }
}
@media print {
  .sidebar, .topbar, .app-footer, .sidebar-overlay, .quick-actions { display: none !important; }
  .main-content { margin: 0; }
  .card { box-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ---------- 11. Shared helpers for plan tracking / migration / chat ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stats-grid > .stat-card { display: block; }
.stat-label { color: var(--text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.stat-label i { margin-right: 6px; color: var(--primary); }
.stat-value { margin-top: 6px; font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-card.warning .stat-value { color: var(--warning); }
.stat-card.success .stat-value { color: var(--success); }
.user-info { display: flex; flex-direction: column; line-height: 1.35; }
.user-name { font-weight: 600; color: var(--text); }
.user-email { font-size: 12px; color: var(--text-muted); }
.amount { color: var(--text); }
.profit { color: var(--success); }

.callout {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center; justify-content: space-between;
  padding: 18px 22px; margin-bottom: 22px; border-radius: var(--radius);
  background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
}
.callout h5 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.callout p { margin: 0; color: var(--text-muted); font-size: 13px; }
.callout .figures { display: flex; gap: 28px; }
.callout .figures strong { display: block; font-size: 1.4rem; line-height: 1.1; }
.callout .figures span { font-size: 12px; color: var(--text-muted); }

/* Lightweight modal used by plan tracking (no Bootstrap JS needed) */
.mx-modal { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(5, 15, 22, 0.6); backdrop-filter: blur(2px); align-items: center; justify-content: center; padding: 16px; }
.mx-modal.show { display: flex; }
.mx-modal .modal-content { position: relative; width: 100%; max-width: 520px; max-height: 92vh; overflow: auto; }
.mx-modal .modal-header { padding: 16px 22px; }
.mx-modal .modal-header h5 { margin: 0; font-size: 1rem; font-weight: 700; }
.mx-modal .modal-body { padding: 20px 22px; }
.mx-modal .modal-footer { padding: 14px 22px; display: flex; justify-content: flex-end; gap: 10px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.info-label { color: var(--text-muted); }
.info-value { font-weight: 600; text-align: right; }
.highlight { background: linear-gradient(135deg, var(--success), #2db786); color: #fff; border-radius: var(--radius); padding: 14px 18px; font-size: 1.4rem; font-weight: 700; text-align: center; }

/* Migration page */
.page-container .card { padding: 22px; margin-bottom: 20px; }
.page-container .section-header { margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.page-container .section-header h2 { margin: 0; font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.page-container .section-header h2 i { color: var(--primary); }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat-item { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-item.complete { border-left: 4px solid var(--success); }
.stat-item.pending { border-left: 4px solid var(--warning); }
.stat-item p { margin: 6px 0 0; font-size: 12px; }
.progress-box { margin-top: 22px; }
.progress-header { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.progress-box .progress-bar { display: block; width: 100%; height: 12px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), var(--success)); color: #fff; font-size: 10px; font-weight: 700; line-height: 12px; text-align: center; border-radius: 999px; min-width: 2px; }
.step-box { padding: 14px 16px; margin-bottom: 10px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.step-box h4 { font-size: 14px; font-weight: 650; margin: 0 0 6px; }
.step-box h4 i { color: var(--success); margin-right: 6px; }
.step-box p { margin: 0; color: var(--text-muted); font-size: 13px; }
.info-box { padding: 14px 16px; margin-top: 14px; background: var(--primary-soft); border-left: 4px solid var(--primary); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 13px; }
.info-box p { margin: 0; }
.complete-badge { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: rgba(18, 160, 117, 0.14); color: var(--success); font-weight: 650; }
.migration-results { padding: 16px; margin-bottom: 16px; background: rgba(18, 160, 117, 0.08); border: 1px solid rgba(18, 160, 117, 0.25); border-radius: var(--radius); }
.migration-results h4 { font-size: 15px; font-weight: 700; color: var(--success); }
.result-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 13.5px; }
.result-item i { color: var(--success); width: 18px; }

a.stat-card, a.stat-card:hover { color: inherit; }
.email-partner-banner {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: center; justify-content: space-between;
  padding: 18px 22px; margin-bottom: 22px; border-radius: var(--radius);
  background: linear-gradient(135deg, #0b1f2a 0%, #0a4a3f 100%); color: #fff;
}
.email-partner-banner strong { font-size: 16px; font-weight: 700; color: #fff; }
.email-partner-banner span { color: #a9c1c9; font-size: 13px; }

/* Legacy badge aliases (Bootstrap 4 names still used in some pages) */
.badge-primary { background: #d8f0ea; color: #075a49; }
.badge-success { background: #d8f5e9; color: #0a6b4b; }
.badge-warning { background: #fdecc8; color: #8a4b05; }
.badge-danger  { background: #fde0e5; color: #9d2438; }
.badge-info    { background: #dbeefb; color: #0b5d8f; }
.badge-secondary { background: #e8edf0; color: #40555f; }
[data-bs-theme="dark"] .badge-primary { background: #0f3a31; color: #7be0cc; }
[data-bs-theme="dark"] .badge-success { background: #0d3d2f; color: #7be0b8; }
[data-bs-theme="dark"] .badge-warning { background: #4a3009; color: #f6c76c; }
[data-bs-theme="dark"] .badge-danger  { background: #4a1822; color: #f4a3b0; }
[data-bs-theme="dark"] .badge-info    { background: #0c3550; color: #8fd0f5; }
[data-bs-theme="dark"] .badge-secondary { background: #243845; color: #bccdd5; }

/* =========================================================
   12. v6 — Mobile-first enhancements & navigation upgrades
   ========================================================= */
body { padding-bottom: 0; min-height: 100vh; min-height: 100dvh; }
.row:not([class*="g-"]):not([class*="gy-"]) { --bs-gutter-y: 0.75rem; }
.bg-light { background-color: var(--surface-2) !important; color: var(--text) !important; }
.border-bottom, .border-top, .border { border-color: var(--border) !important; }
.shadow-sm { box-shadow: var(--shadow) !important; }
pre, code { white-space: pre-wrap; word-break: break-word; }
img, svg, video { max-width: 100%; height: auto; }
.btn-close { filter: none; }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(1); }

/* Desktop: collapsible sidebar */
.btn-icon.collapse-btn { display: none; }
@media (min-width: 992px) {
  .btn-icon.collapse-btn { display: inline-flex; }
  body.sidebar-collapsed { --sidebar-width: 76px; }
  body.sidebar-collapsed .brand-text,
  body.sidebar-collapsed .nav-section,
  body.sidebar-collapsed .sidebar-footer .who,
  body.sidebar-collapsed .sidebar .nav-link .badge { display: none; }
  body.sidebar-collapsed .sidebar-brand { justify-content: center; padding: 0; }
  body.sidebar-collapsed .sidebar .nav-link { font-size: 0 !important; justify-content: center; padding: 11px 0 !important; }
  body.sidebar-collapsed .sidebar .nav-link i { font-size: 16px; width: auto; }
  body.sidebar-collapsed .sidebar .nav-link.active::before { left: -12px; }
  body.sidebar-collapsed .sidebar-nav { padding: 8px; }
  body.sidebar-collapsed .sidebar-nav .nav-link + .nav-link { margin-top: 2px; }
  body.sidebar-collapsed .sidebar-footer { flex-direction: column; padding: 12px 0; }
  .sidebar, .main-content { transition: width .2s ease, margin .2s ease, transform .25s ease; }
}
.sidebar-close { display: none; position: absolute; top: 15px; right: 14px; z-index: 2; background: rgba(255,255,255,.08); border: 0; color: #cfe0e5; width: 34px; height: 34px; border-radius: 9px; }
.search-trigger { display: inline-flex; align-items: center; gap: 10px; height: 38px; padding: 0 12px; min-width: 220px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); border-radius: 10px; font-size: 13px; cursor: pointer; transition: border-color .15s; }
.search-trigger:hover { border-color: var(--primary); color: var(--text); }
.search-trigger kbd { margin-left: auto; font-size: 10.5px; background: var(--card-bg); border: 1px solid var(--border); color: var(--text-muted); padding: 1px 6px; border-radius: 5px; font-family: var(--font); }

/* Command palette */
.palette { position: fixed; inset: 0; z-index: 3000; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(5,15,22,.55); backdrop-filter: blur(3px); }
.palette.show { display: flex; }
.palette-box { width: 100%; max-width: 560px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-md); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.palette-input i { color: var(--text-faint); }
.palette-input input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 16px; font-family: inherit; }
.palette-list { max-height: min(52vh, 420px); overflow-y: auto; padding: 8px; }
.palette-item { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
.palette-item i { width: 20px; text-align: center; color: var(--text-muted); }
.palette-item small { margin-left: auto; color: var(--text-faint); font-size: 11px; }
.palette-item.sel, .palette-item:hover { background: var(--primary-soft); color: var(--primary); }
.palette-item.sel i, .palette-item:hover i { color: var(--primary); }
.palette-empty { padding: 28px; text-align: center; color: var(--text-muted); }

/* Mobile bottom navigation */
.bottom-nav { display: none; }

/* Stackable tables (cards on phones) — labels added by JS */
.table-stack .cell { min-width: 0; }

/* ---------- Tablet & below ---------- */
@media (max-width: 991.98px) {
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom, 0px)); }
  .sidebar { width: min(86vw, 310px); }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }
  .search-trigger { min-width: 0; width: 38px; padding: 0; justify-content: center; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .topbar { padding-top: env(safe-area-inset-top, 0px); height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px)); }
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: grid; grid-template-columns: repeat(5, 1fr);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--card-bg) 94%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(11,31,42,.06);
  }
  .bottom-nav a, .bottom-nav button {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 52px; border: 0; background: none; color: var(--text-muted);
    font-size: 10.5px; font-weight: 600; border-radius: 12px; font-family: inherit;
  }
  .bottom-nav i { font-size: 18px; }
  .bottom-nav a.active { color: var(--primary); background: var(--primary-soft); }
  .bottom-nav .pill {
    position: absolute; top: 4px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px;
    border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
  }
  .bottom-nav .pill.warn { background: var(--warning); }
  .app-footer { display: none; }
}

/* ---------- Phones ---------- */
@media (max-width: 767.98px) {
  .page-content { padding: 16px 14px 24px; }
  .page-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 16px; }
  .page-head > div:last-child:not(:first-child) { display: flex; gap: 8px; }
  .page-head > div:last-child:not(:first-child) .btn, .page-head > .btn { flex: 1; }
  .page-title { font-size: 1.25rem; }
  .page-subtitle { font-size: 13px; }
  .crumbs .sep:first-of-type { display: inline; }
  .btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; }
  .btn-sm { min-height: 36px; }
  .form-control, .form-select, .palette-input input { font-size: 16px; padding: 11px 12px; }
  .toolbar { padding: 12px 14px; }
  .toolbar .search { max-width: none; min-width: 100%; }
  .card-header { flex-wrap: wrap; padding: 12px 14px !important; }
  .card-body { padding: 14px !important; }
  .quick-actions { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px 16px; padding: 2px 14px 6px; scrollbar-width: none; }
  .quick-actions::-webkit-scrollbar { display: none; }
  .quick-action { white-space: nowrap; flex-shrink: 0; min-height: 40px; }
  .attention { padding: 12px 14px; }
  .attention .btn { flex: 1; }
  .attention > .d-flex { width: 100%; }

  /* KPI cards: 2 per row, stacked content */
  .row > [class*="col-xl-3"].col-md-6 { flex: 0 0 auto; width: 50%; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .stat-icon { width: 38px; height: 38px; font-size: .95rem; border-radius: 10px; }
  .stat-card h3 { font-size: 1.15rem; word-break: break-word; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-value { font-size: 1.25rem; }
  .callout { padding: 14px; }
  .callout .figures { gap: 20px; }
  .action-row .btn, .callout .btn { width: 100%; }

  /* Tables → cards */
  .has-stack { padding: 12px; overflow: visible; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack thead { display: none; }
  .table-stack tr { margin: 0 0 12px; padding: 4px 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-xs); }
  .table-stack tr:last-child { margin-bottom: 0; }
  .table-hover.table-stack tbody tr:hover > * { background: transparent !important; }
  .table-stack td { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 10px 0 !important; border: 0 !important; border-bottom: 1px dashed var(--border) !important; text-align: right !important; font-size: 13px; }
  .table-stack td:last-child { border-bottom: 0 !important; }
  .table-stack td::before { content: attr(data-label); flex: 0 0 38%; max-width: 38%; text-align: left; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); padding-top: 2px; }
  .table-stack td.no-label::before { display: none; }
  .table-stack td .cell { flex: 1; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; word-break: break-word; }
  .table-stack td.td-actions .cell, .table-stack td.no-label .cell { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  .table-stack td.td-actions { padding-top: 12px !important; }
  .table-stack td.td-actions .btn, .table-stack td.td-actions form { flex: 1 1 auto; }
  .table-stack td.td-actions form .btn { width: 100%; }
  .table-stack td[colspan] { display: block; text-align: center !important; }
  .table-stack td[colspan]::before { display: none; }

  /* Tabs & pills scroll sideways */
  .nav-tabs, .nav-pills { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; white-space: nowrap; scrollbar-width: none; }
  .nav-tabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar { display: none; }
  .nav-tabs .nav-link, .nav-pills .nav-link { flex-shrink: 0; }

  /* Modals: bottom sheets */
  .modal-dialog { margin: 0; min-height: 100%; display: flex; align-items: flex-end; max-width: none; }
  .modal-content { border-radius: 18px 18px 0 0; width: 100%; max-height: 92vh; overflow-y: auto; }
  .mx-modal { align-items: flex-end; padding: 0; }
  .mx-modal .modal-content { max-width: none; border-radius: 18px 18px 0 0; }
  .mx-modal .modal-footer { flex-direction: column-reverse; }
  .mx-modal .modal-footer .btn, .mx-modal .modal-footer form { width: 100%; }

  /* Chat */
  .chat-container { height: calc(100dvh - 330px) !important; min-height: 320px; }
  .message { max-width: 94% !important; gap: .6rem !important; }
  .message-avatar { width: 32px !important; height: 32px !important; }

  /* Auth */
  .auth-main { align-items: flex-start; padding: 36px 20px 24px; }
  .status-card { padding: 32px 22px; }
  .palette { padding-top: 8vh; }
}
@media (max-width: 380px) {
  .row > [class*="col-xl-3"].col-md-6 { width: 100%; }
  .stat-card { flex-direction: row; align-items: center; }
}
