/* ============================================================
   FinFlow Admin Panel — Core Stylesheet
   Design: Clean financial SaaS, dark navy sidebar, blue accent
   ============================================================ */

/* --- Google Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* --- CSS Custom Properties (overridden by BrandingService) --- */
:root {
  --color-primary:        #1B4FD8;
  --color-primary-light:  #3B6EF0;
  --color-primary-dark:   #1340B0;
  --color-secondary:      #0EA5E9;
  --color-accent:         #10B981;
  --color-warning:        #F59E0B;
  --color-danger:         #EF4444;
  --color-text:           #1E293B;
  --color-text-muted:     #64748B;
  --color-text-light:     #94A3B8;
  --color-sidebar:        #0F172A;
  --color-sidebar-hover:  #1E293B;
  --color-sidebar-active: rgba(59,110,240,0.15);
  --color-bg:             #F1F5F9;
  --color-surface:        #FFFFFF;
  --color-border:         #E2E8F0;
  --color-border-light:   #F1F5F9;

  /* Shorthand variable aliases used across portal views */
  --text-primary:         var(--color-text);
  --text-muted:           var(--color-text-muted);
  --text-light:           var(--color-text-light);
  --border-color:         var(--color-border);
  --bg-card:              var(--color-surface);
  --bg-secondary:         var(--color-bg);
  --primary-color:        var(--color-primary);

  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   16px;
  --radius-xl:   24px;
  --radius-full: 9999px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 16px rgba(0,0,0,.08), 0 2px 6px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 32px rgba(0,0,0,.10), 0 4px 12px rgba(0,0,0,.06);
  --shadow-glow:0 0 0 3px rgba(27,79,216,.18);

  --sidebar-width:          260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height:           64px;

  --font-base: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: all .18s cubic-bezier(.4,0,.2,1);
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-base);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--color-primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--color-primary-light); }
img { max-width: 100%; display: block; }

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.admin-shell {
  display: flex;
  min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width .25s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

/* Logo area */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  min-height: var(--topbar-height);
  overflow: hidden;
}
.sidebar-brand-logo {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 15px;
  color: #fff;
  letter-spacing: -.5px;
}
.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.3px;
  white-space: nowrap;
  opacity: 1;
  transition: opacity .2s;
}
.sidebar.collapsed .sidebar-brand-name { opacity: 0; }

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 16px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s;
}
.sidebar.collapsed .nav-section-title { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: rgba(255,255,255,.6);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  border-left: 3px solid transparent;
  margin: 1px 0;
}
.nav-item:hover {
  color: #fff;
  background: var(--color-sidebar-hover);
}
.nav-item.active {
  color: #fff;
  background: var(--color-sidebar-active);
  border-left-color: var(--color-primary-light);
}
.nav-item.active .nav-icon { color: var(--color-primary-light); }

.nav-icon {
  width: 20px; height: 20px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: var(--transition);
}
.nav-label { flex: 1; transition: opacity .2s; }
.sidebar.collapsed .nav-label { opacity: 0; }

.nav-badge {
  background: var(--color-danger);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
  transition: opacity .2s;
}
.sidebar.collapsed .nav-badge { opacity: 0; }

/* Sidebar footer */
.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}
.sidebar-admin-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}
.sidebar-admin-info { overflow: hidden; flex: 1; }
.sidebar-admin-name {
  font-size: 13px; font-weight: 600; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: opacity .2s;
}
.sidebar-admin-role {
  font-size: 11px; color: rgba(255,255,255,.4);
  white-space: nowrap;
  transition: opacity .2s;
}
.sidebar.collapsed .sidebar-admin-name,
.sidebar.collapsed .sidebar-admin-role { opacity: 0; }

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .25s cubic-bezier(.4,0,.2,1);
}
.sidebar.collapsed ~ .main-wrapper { margin-left: var(--sidebar-collapsed-width); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-height);
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.topbar-toggle {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}
.topbar-toggle:hover { background: var(--color-bg); color: var(--color-text); }

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--color-text-muted);
  flex: 1;
}
.topbar-breadcrumb span { color: var(--color-text); font-weight: 600; }
.topbar-breadcrumb .sep { color: var(--color-border); }

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

.topbar-btn {
  width: 36px; height: 36px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--color-text-muted);
  font-size: 15px;
  transition: var(--transition);
  position: relative;
}
.topbar-btn:hover { background: var(--color-bg); color: var(--color-primary); border-color: var(--color-primary); }
.topbar-btn .dot {
  position: absolute;
  top: 7px; right: 7px;
  width: 7px; height: 7px;
  background: var(--color-danger);
  border-radius: 50%;
  border: 2px solid #fff;
}

.topbar-admin {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-surface);
  cursor: pointer;
  transition: var(--transition);
}
.topbar-admin:hover { border-color: var(--color-primary); box-shadow: var(--shadow-glow); }
.topbar-admin-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
}
.topbar-admin-name { font-size: 13px; font-weight: 600; color: var(--color-text); }

/* ============================================================
   PAGE CONTENT
   ============================================================ */
.page-content {
  flex: 1;
  padding: 28px 28px;
  max-width: 100%;
}

.page-header {
  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; color: var(--color-text); letter-spacing: -.3px; }
.page-subtitle { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }
.page-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   STAT CARDS
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: linear-gradient(180deg, #FFFFFF 0%, #FAFCFF 100%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 15px;
  transition: transform .28s cubic-bezier(.16,1,.3,1), box-shadow .28s cubic-bezier(.16,1,.3,1), border-color .28s ease;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.stat-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 110px; height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--card-accent, var(--color-primary)) 0%, transparent 70%);
  opacity: .06;
  pointer-events: none;
  transition: transform .4s ease, opacity .4s ease;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3.5px;
  background: linear-gradient(90deg, var(--card-accent, var(--color-primary)), var(--color-secondary));
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  opacity: .85;
  transition: var(--transition);
}
.stat-card:hover {
  box-shadow: 0 12px 28px -6px rgba(15, 23, 42, .10), 0 4px 10px -2px rgba(15, 23, 42, .05);
  transform: translateY(-4px);
  border-color: rgba(27, 79, 216, .25);
}
.stat-card:hover::before { transform: scale(1.35); opacity: .12; }
.stat-card:hover::after { opacity: 1; height: 4px; }

.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.stat-card:hover .stat-icon {
  transform: scale(1.08) rotate(-4deg);
}
.stat-icon.blue    { background: linear-gradient(135deg, rgba(27,79,216,.14), rgba(59,130,246,.06));  color: var(--color-primary); box-shadow: inset 0 0 0 1px rgba(27,79,216,.12); }
.stat-icon.teal    { background: linear-gradient(135deg, rgba(14,165,233,.14), rgba(6,182,212,.06));  color: var(--color-secondary); box-shadow: inset 0 0 0 1px rgba(14,165,233,.12); }
.stat-icon.green   { background: linear-gradient(135deg, rgba(16,185,129,.14), rgba(5,150,105,.06));  color: var(--color-accent); box-shadow: inset 0 0 0 1px rgba(16,185,129,.12); }
.stat-icon.amber   { background: linear-gradient(135deg, rgba(245,158,11,.15), rgba(217,119,6,.06));  color: var(--color-warning); box-shadow: inset 0 0 0 1px rgba(245,158,11,.14); }
.stat-icon.red     { background: linear-gradient(135deg, rgba(239,68,68,.14), rgba(220,38,38,.06));   color: var(--color-danger); box-shadow: inset 0 0 0 1px rgba(239,68,68,.12); }
.stat-icon.purple  { background: linear-gradient(135deg, rgba(139,92,246,.14), rgba(124,58,237,.06)); color: #8B5CF6; box-shadow: inset 0 0 0 1px rgba(139,92,246,.12); }
.stat-icon.indigo  { background: linear-gradient(135deg, rgba(99,102,241,.14), rgba(79,70,229,.06));  color: #6366F1; box-shadow: inset 0 0 0 1px rgba(99,102,241,.12); }
.stat-icon.orange  { background: linear-gradient(135deg, rgba(249,115,22,.14), rgba(234,88,12,.06));  color: #F97316; box-shadow: inset 0 0 0 1px rgba(249,115,22,.12); }

.stat-info { flex: 1; min-width: 0; }
.stat-value {
  font-size: clamp(18.5px, 1.5vw, 23px);
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -.4px;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.stat-label { font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); margin-top: 3px; }
.stat-meta  { font-size: 11.5px; color: var(--color-text-light); margin-top: 6px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stat-change { font-size: 12px; font-weight: 600; margin-top: 8px; display: flex; align-items: center; gap: 4px; }
.stat-change.up   { color: var(--color-accent); }
.stat-change.down { color: var(--color-danger); }
.stat-change.neutral { color: var(--color-text-muted); }

.stat-progress {
  margin-top: 10px;
  height: 5px;
  width: 100%;
  background: var(--color-bg);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}
.stat-progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--card-accent, var(--color-primary)), var(--color-secondary));
  width: 0%;
  transition: width 1.1s cubic-bezier(.16, 1, .3, 1);
  position: relative;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border-light);
  gap: 12px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--color-text); }
.card-subtitle { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.card-body { padding: 24px; }
.card-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--color-border-light);
  background: var(--color-bg);
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}

/* ============================================================
   DATA TABLE
   ============================================================ */
.table-wrap,
.table-responsive {
  overflow-x: auto;
  width: 100%;
}
.data-table,
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead tr,
.table thead tr {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.data-table th,
.table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: .4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.data-table td,
.table td {
  padding: 13px 16px;
  color: var(--color-text);
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}
.data-table tbody tr,
.table tbody tr {
  transition: background .12s;
}
.data-table tbody tr:hover,
.table tbody tr:hover {
  background: rgba(241,245,249,.7);
}
.data-table tbody tr:last-child td,
.table tbody tr:last-child td {
  border-bottom: none;
}

.table-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.table-user { display: flex; align-items: center; gap: 10px; }
.table-user-name { font-weight: 600; font-size: 13.5px; }
.table-user-sub  { font-size: 12px; color: var(--color-text-muted); }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .2px;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; }

.badge-success { background: rgba(16,185,129,.1);  color: #059669; }
.badge-success .badge-dot { background: #10B981; }
.badge-warning { background: rgba(245,158,11,.12); color: #D97706; }
.badge-warning .badge-dot { background: #F59E0B; }
.badge-danger  { background: rgba(239,68,68,.1);  color: #DC2626; }
.badge-danger .badge-dot  { background: #EF4444; }
.badge-info    { background: rgba(14,165,233,.1);  color: #0284C7; }
.badge-info .badge-dot    { background: #0EA5E9; }
.badge-primary { background: rgba(27,79,216,.1);   color: var(--color-primary); }
.badge-primary .badge-dot { background: var(--color-primary); }
.badge-secondary { background: var(--color-bg);     color: var(--color-text-muted); border: 1px solid var(--color-border); }
.badge-secondary .badge-dot { background: var(--color-text-muted); }
.badge-muted   { background: var(--color-bg);       color: var(--color-text-muted); }
.badge-muted .badge-dot   { background: var(--color-text-light); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 7px 13px; font-size: 12.5px; }
.btn-lg { padding: 12px 24px; font-size: 14.5px; }
.btn-icon { padding: 9px; }
.btn-icon.btn-sm { padding: 7px; }

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover { background: var(--color-primary-light); border-color: var(--color-primary-light); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}
.btn-secondary:hover { background: var(--color-bg); border-color: var(--color-text-muted); }

.btn-success {
  background: var(--color-accent);
  color: #fff; border-color: var(--color-accent);
}
.btn-success:hover { background: #059669; border-color: #059669; }

.btn-danger { background: var(--color-danger); color: #fff; border-color: var(--color-danger); }
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }

.btn-warning { background: var(--color-warning); color: #fff; border-color: var(--color-warning); }
.btn-warning:hover { background: #D97706; }

.btn-outline-primary {
  background: transparent; color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline-primary:hover { background: var(--color-primary); color: #fff; }

.btn-outline-danger {
  background: transparent; color: var(--color-danger);
  border-color: var(--color-danger);
}
.btn-outline-danger:hover { background: var(--color-danger); color: #fff; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}
.form-label .required { color: var(--color-danger); margin-left: 2px; }

.form-control {
  display: block; width: 100%;
  padding: 9px 13px;
  font-size: 13.5px;
  font-family: var(--font-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
  outline: none;
  line-height: 1.5;
}
.form-control::placeholder { color: var(--color-text-light); }
.form-control:focus { border-color: var(--color-primary); box-shadow: var(--shadow-glow); }
.form-control:disabled { background: var(--color-bg); cursor: not-allowed; opacity: .7; }
.form-control.is-invalid { border-color: var(--color-danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 5px; }
.form-error { font-size: 12px; color: var(--color-danger); margin-top: 5px; }

.form-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }

/* ============================================================
   MODALS
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.modal-backdrop.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  transform: scale(.95) translateY(10px);
  transition: transform .2s, opacity .2s;
}
.modal-backdrop.open .modal { transform: scale(1) translateY(0); }
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 980px; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--color-text); }
.modal-close {
  width: 32px; height: 32px;
  border: none; background: var(--color-bg);
  border-radius: var(--radius-sm);
  cursor: pointer; color: var(--color-text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: var(--transition);
}
.modal-close:hover { background: var(--color-danger); color: #fff; }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex; justify-content: flex-end; gap: 10px;
  flex-shrink: 0;
}

/* ============================================================
   ALERTS / FLASH
   ============================================================ */
.alert {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-success { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.2); color: #065F46; }
.alert-warning { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.2); color: #92400E; }
.alert-danger  { background: rgba(239,68,68,.08);  border-color: rgba(239,68,68,.2);  color: #991B1B; }
.alert-info    { background: rgba(14,165,233,.08); border-color: rgba(14,165,233,.2); color: #075985; }
.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}
.page-link {
  display: flex; align-items: center; justify-content: center;
  min-width: 34px; height: 34px;
  padding: 0 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--color-text-muted);
  background: var(--color-surface);
  cursor: pointer; transition: var(--transition);
  text-decoration: none;
}
.page-link:hover { border-color: var(--color-primary); color: var(--color-primary); }
.page-link.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; font-weight: 700; }
.page-link.disabled { opacity: .4; cursor: not-allowed; }

/* ============================================================
   FILTER BAR
   ============================================================ */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-bottom: 1px solid var(--color-border-light);
  background: var(--color-bg);
}
.filter-search {
  position: relative; flex: 1; min-width: 200px; max-width: 340px;
}
.filter-search input {
  padding-left: 36px;
  width: 100%;
}
.filter-search-icon {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted); font-size: 14px;
  pointer-events: none;
}
.filter-select { min-width: 140px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--color-text-muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; opacity: .5; }
.empty-state-title { font-size: 16px; font-weight: 700; color: var(--color-text); margin-bottom: 6px; }
.empty-state-text  { font-size: 13.5px; max-width: 320px; margin: 0 auto 20px; }

/* ============================================================
   DASHBOARD WIDGETS
   ============================================================ */
.widgets-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.widget-full { grid-column: 1 / -1; }

/* Activity list */
.activity-list { list-style: none; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--color-border-light);
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-content { flex: 1; min-width: 0; }
.activity-title { font-size: 13.5px; font-weight: 500; color: var(--color-text); }
.activity-time { font-size: 12px; color: var(--color-text-light); margin-top: 2px; }

/* ============================================================
   LOADER / SPINNER
   ============================================================ */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  position: fixed; inset: 0;
  background: rgba(255,255,255,.8);
  z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}

/* ============================================================
   TOOLTIPS
   ============================================================ */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%; transform: translateX(-50%);
  background: #1E293B;
  color: #fff;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
  z-index: 999;
}
[data-tooltip]:hover::after { opacity: 1; }

/* ============================================================
   KYC & STATUS-SPECIFIC STYLING
   ============================================================ */
.kyc-doc-preview {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-bg);
}
.kyc-doc-thumb {
  height: 140px; object-fit: cover; width: 100%;
}
.kyc-doc-footer {
  padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
}

/* ============================================================
   AUTH LAYOUT
   ============================================================ */
.auth-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--color-sidebar) 0%, #1E3A8A 100%);
}
.auth-left {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  padding: 60px 48px;
  position: relative;
}
.auth-right {
  width: 480px;
  background: var(--color-surface);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 56px;
}
.auth-logo {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 48px;
}
.auth-logo-icon {
  width: 52px; height: 52px;
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 22px; font-weight: 800;
}
.auth-logo-name { font-size: 20px; font-weight: 800; color: #fff; }
.auth-tagline { color: rgba(255,255,255,.7); font-size: 16px; max-width: 400px; line-height: 1.7; }
.auth-features { list-style: none; margin-top: 36px; }
.auth-features li {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,.8); font-size: 14px; font-weight: 500;
  margin-bottom: 14px;
}
.auth-features li::before {
  content: '✓';
  width: 22px; height: 22px;
  background: rgba(16,185,129,.25);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #10B981;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}

.auth-form-wrap { width: 100%; }
.auth-form-title { font-size: 24px; font-weight: 800; color: var(--color-text); margin-bottom: 6px; letter-spacing: -.4px; }
.auth-form-sub { font-size: 13.5px; color: var(--color-text-muted); margin-bottom: 36px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1200px) {
  .widgets-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width) !important; }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-wrapper { margin-left: 0 !important; }
  .page-content { padding: 18px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .auth-page { flex-direction: column; }
  .auth-right { width: 100%; padding: 36px 24px; }
  .auth-left { display: none; }
  .topbar { padding: 0 16px; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   MICRO-ANIMATIONS & MOTION GRAPHICS ENGINE
   ============================================================ */
.fade-in {
  animation: fadeIn .35s cubic-bezier(.16, 1, .3, 1) forwards;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.slide-in {
  animation: slideIn .35s cubic-bezier(.16, 1, .3, 1) forwards;
}
@keyframes slideIn { from { transform: translateX(-20px); opacity: 0; } to { transform: none; opacity: 1; } }

@keyframes shimmerSweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(220%); }
}

@keyframes pulseRing {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

@keyframes flowDash {
  to { stroke-dashoffset: -28; }
}

@keyframes floatSlow {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

/* Stagger children */
.stagger > *,
.stats-grid > .stat-card {
  animation: fadeIn .45s cubic-bezier(.16, 1, .3, 1) both;
}
.stagger > *:nth-child(1), .stats-grid > .stat-card:nth-child(1) { animation-delay: .04s; }
.stagger > *:nth-child(2), .stats-grid > .stat-card:nth-child(2) { animation-delay: .09s; }
.stagger > *:nth-child(3), .stats-grid > .stat-card:nth-child(3) { animation-delay: .14s; }
.stagger > *:nth-child(4), .stats-grid > .stat-card:nth-child(4) { animation-delay: .19s; }
.stagger > *:nth-child(5) { animation-delay: .24s; }
.stagger > *:nth-child(6) { animation-delay: .29s; }
.stagger > *:nth-child(7) { animation-delay: .34s; }
.stagger > *:nth-child(8) { animation-delay: .39s; }

/* Module Sub-Navigation Pill Bar */
.subnav-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  margin-bottom: 22px;
  overflow-x: auto;
  box-shadow: var(--shadow-sm);
}
.subnav-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: all .2s cubic-bezier(.16, 1, .3, 1);
}
.subnav-pill:hover {
  color: var(--color-text);
  background: var(--color-bg);
}
.subnav-pill.active {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-light));
  color: #fff;
  box-shadow: 0 4px 12px rgba(27, 79, 216, .25);
}

/* Live Status Pulse Indicator */
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, .1);
  border: 1px solid rgba(16, 185, 129, .22);
  color: #059669;
  font-size: 12px;
  font-weight: 600;
}
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #10B981;
  animation: pulseRing 2s infinite;
}

/* Motion Graphics Flow Banner */
.motion-banner {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 55%, #1E3A8A 100%);
  border-radius: var(--radius-lg);
  padding: 22px 26px;
  color: #fff;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.motion-banner::before {
  content: '';
  position: absolute;
  top: -80px; right: -60px;
  width: 280px; height: 280px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(59, 130, 246, .28) 0%, transparent 70%);
  pointer-events: none;
}
.motion-banner::after {
  content: '';
  position: absolute;
  bottom: -90px; left: 25%;
  width: 240px; height: 240px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16, 185, 129, .18) 0%, transparent 70%);
  pointer-events: none;
}

/* Multi-Segment Animated Progress Bar */
.segmented-bar {
  height: 12px;
  width: 100%;
  background: rgba(255, 255, 255, .1);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
  gap: 2px;
  padding: 2px;
}
.segmented-bar.light {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}
.segment-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width 1.2s cubic-bezier(.16, 1, .3, 1);
  position: relative;
  overflow: hidden;
}
.segment-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent);
  animation: shimmerSweep 2.6s infinite;
}

/* Flow Pipeline Nodes */
.flow-pipeline {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  position: relative;
  z-index: 1;
}
.flow-node {
  background: rgba(255, 255, 255, .06);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 12px;
  padding: 14px 16px;
  transition: transform .25s ease, background .25s ease, border-color .25s ease;
}
.flow-node:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .25);
}
.flow-node-title {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: rgba(255, 255, 255, .65);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.flow-node-value {
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}
.flow-node-sub {
  font-size: 11.5px;
  color: rgba(255, 255, 255, .6);
  margin-top: 3px;
}

@media (max-width: 960px) {
  .flow-pipeline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 540px) {
  .flow-pipeline { grid-template-columns: 1fr; }
}

/* Tabular Numbers & Compact Ref Pills */
.num-tabular {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ref-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  text-decoration: none;
  transition: var(--transition);
}
.ref-pill.purple { background: rgba(109, 40, 217, .09); color: #6D28D9; border: 1px solid rgba(109, 40, 217, .16); }
.ref-pill.blue   { background: rgba(27, 79, 216, .09);  color: var(--color-primary); border: 1px solid rgba(27, 79, 216, .16); }
.ref-pill.slate  { background: #F1F5F9; color: #0F172A; border: 1px solid #CBD5E1; }
.ref-pill.teal   { background: rgba(14, 165, 233, .1); color: #0369A1; border: 1px solid rgba(14, 165, 233, .2); }
.ref-pill:hover  { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary   { color: var(--color-primary) !important; }
.text-success   { color: var(--color-accent) !important; }
.text-warning   { color: var(--color-warning) !important; }
.text-danger    { color: var(--color-danger) !important; }
.text-muted     { color: var(--color-text-muted) !important; }
.text-sm        { font-size: 12px !important; }
.text-xs        { font-size: 11px !important; }
.fw-600         { font-weight: 600 !important; }
.fw-700         { font-weight: 700 !important; }
.d-flex         { display: flex !important; }
.align-center   { align-items: center !important; }
.gap-2          { gap: 8px !important; }
.gap-3          { gap: 12px !important; }
.mt-1           { margin-top: 4px !important; }
.mt-2           { margin-top: 8px !important; }
.mt-3           { margin-top: 16px !important; }
.mb-0           { margin-bottom: 0 !important; }
.mb-2           { margin-bottom: 8px !important; }
.mb-3           { margin-bottom: 16px !important; }
.mb-4           { margin-bottom: 24px !important; }
.w-100          { width: 100% !important; }
.truncate       { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
