/* ==========================================================================
   CrestFlexi Design System v2 — tokens, components, themes
   Premium fintech/Web3 SaaS theme. Light by default, genuine dark theme.
   Pages should use ONLY the documented classes/tokens below.
   ========================================================================== */

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

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */

:root {
  /* Light theme (default) */
  --bg: #F4F5FA;
  --bg-soft: #ECEEF5;
  --surface: #FFFFFF;
  --surface-2: #F7F8FC;
  --sidebar-bg: #FFFFFF;
  --border: #E6E8F0;
  --border-soft: #EFF1F7;
  --text: #181A22;
  --text-2: #5A6072;
  --text-3: #9BA1B3;
  --primary: #2563EB;
  --primary-2: #3B82F6;
  --primary-soft: #EBF2FE;
  --primary-contrast: #FFFFFF;
  --accent: #60A5FA;
  --gradient: linear-gradient(135deg, #1D4ED8 0%, #2563EB 55%, #3B82F6 100%);
  --success: #16A34A;
  --success-soft: #E7F6EC;
  --warning: #D97706;
  --warning-soft: #FDF1E3;
  --danger: #DC2626;
  --danger-soft: #FCEBEB;
  --info: #2563EB;
  --info-soft: #E8F0FE;
  --shadow-sm: 0 1px 2px rgba(24, 26, 34, .05);
  --shadow: 0 4px 16px rgba(24, 26, 34, .07);
  --shadow-lg: 0 12px 32px rgba(24, 26, 34, .12);
}

[data-theme='dark'] {
  --bg: #0B0D14;
  --bg-soft: #10131D;
  --surface: #151824;
  --surface-2: #1B1F2E;
  --sidebar-bg: #10131D;
  --border: #242938;
  --border-soft: #1D2130;
  --text: #F1F2F8;
  --text-2: #A6ABC0;
  --text-3: #666D85;
  --primary: #3B82F6;
  --primary-2: #2563EB;
  --primary-soft: rgba(59, 130, 246, .16);
  --primary-contrast: #FFFFFF;
  --accent: #93C5FD;
  --gradient: linear-gradient(135deg, #2563EB 0%, #3B82F6 55%, #60A5FA 100%);
  --success: #34D399;
  --success-soft: rgba(52, 211, 153, .14);
  --warning: #FBBF24;
  --warning-soft: rgba(251, 191, 36, .14);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, .14);
  --info: #60A5FA;
  --info-soft: rgba(96, 165, 250, .14);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 6px 20px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .5);
}

:root {
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --sidebar-w: 260px;
  --sidebar-w-collapsed: 76px;
  --topbar-h: 68px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --font-display: 'Sora', var(--font);
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

html, body {
  overflow-x: hidden;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color .25s ease, color .25s ease;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-2);
}

button {
  font-family: inherit;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text);
}

h1 { font-size: 26px; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

::selection {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* --------------------------------------------------------------------------
   3. Layout — main content / page header / container
   -------------------------------------------------------------------------- */

.main-content {
  margin-left: var(--sidebar-w);
  padding: 28px;
  max-width: 1440px;
  min-height: calc(100vh - var(--topbar-h));
  transition: margin-left .25s ease;
}

body.sidebar-collapsed .main-content {
  margin-left: var(--sidebar-w-collapsed);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
}

.page-subtitle {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 2px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --------------------------------------------------------------------------
   4. App shell — sidebar / overlay / topbar
   -------------------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width .25s ease, transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 20px;
  min-height: var(--topbar-h);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
  overflow: hidden;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  background: var(--gradient);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  box-shadow: var(--shadow);
}

.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.01em;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 12px;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-3);
  padding: 14px 12px 6px;
  white-space: nowrap;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: background-color .2s ease, color .2s ease;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--gradient);
}

.nav-badge {
  margin-left: auto;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
}

.nav-item .badge-dot {
  margin-left: auto;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border-soft);
  white-space: nowrap;
  overflow: hidden;
}

/* Collapsed (desktop) */
@media (min-width: 993px) {
  .sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
  }

  .sidebar.collapsed .brand-name,
  .sidebar.collapsed .nav-section-title,
  .sidebar.collapsed .nav-item .nav-label,
  .sidebar.collapsed .nav-item .nav-badge,
  .sidebar.collapsed .nav-item .badge-dot,
  .sidebar.collapsed .sidebar-footer .theme-label {
    display: none;
  }

  .sidebar.collapsed .sidebar-brand,
  .sidebar.collapsed .sidebar-footer {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
  }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 12, .55);
  backdrop-filter: blur(2px);
  z-index: 999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 500;
  height: var(--topbar-h);
  margin-left: var(--sidebar-w);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-soft);
  transition: margin-left .25s ease;
}

body.sidebar-collapsed .topbar {
  margin-left: var(--sidebar-w-collapsed);
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

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

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  position: relative;
  transition: background-color .2s ease, color .2s ease, border-color .2s ease, transform .2s ease;
}

.icon-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: scale(.96);
}

.menu-toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   5. Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform .25s ease, box-shadow .25s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stat-change {
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* --------------------------------------------------------------------------
   6. Charts
   -------------------------------------------------------------------------- */

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-container canvas {
  max-width: 100%;
}

.chart-tabs {
  display: flex;
  gap: 6px;
}

.chart-tabs .tab {
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .2s ease;
}

.chart-tabs .tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.chart-tabs .tab.active {
  background: var(--gradient);
  color: #fff;
}

/* --------------------------------------------------------------------------
   7. Tables
   -------------------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data-table thead th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-3);
  text-align: left;
  padding: 12px 16px;
  background: var(--surface-2);
  white-space: nowrap;
}

table.data-table tbody td {
  padding: 14px 16px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-2);
  vertical-align: middle;
}

table.data-table tbody td:first-child {
  color: var(--text);
  font-weight: 500;
}

table.data-table tbody tr {
  transition: background-color .15s ease;
}

table.data-table tbody tr:hover {
  background: var(--surface-2);
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 4px 0;
  font-size: 13px;
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   8. Badges
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-2); color: var(--text-2); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  display: inline-block;
  flex-shrink: 0;
  animation: pulse 2s ease-in-out infinite;
}

/* --------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .2s ease, box-shadow .2s ease, background-color .2s ease, color .2s ease, border-color .2s ease, filter .2s ease;
}

.btn:active {
  transform: scale(.98);
}

.btn:disabled,
.btn.disabled {
  opacity: .55;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-outline-primary {
  border: 1.5px solid var(--primary);
  color: var(--primary);
  background: transparent;
}

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

.stat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.btn-primary {
  background: var(--gradient);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(37, 99, 235, .45);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger-soft {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger-soft:hover {
  filter: brightness(.97);
  color: var(--danger);
}

.btn-success {
  background: var(--success);
  color: #fff;
}

.btn-success:hover {
  filter: brightness(1.08);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 10px;
}

.btn-lg {
  padding: 14px 26px;
  font-size: 15px;
  border-radius: 14px;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 12px;
  font-size: 15px;
}

/* --------------------------------------------------------------------------
   10. Forms
   -------------------------------------------------------------------------- */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color .2s ease, box-shadow .2s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.textarea {
  resize: vertical;
  min-height: 100px;
}

.input-error,
.input.error {
  border-color: var(--danger);
}

.input-error:focus,
.input.error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* Safety net: style bare form controls that have no class (legacy pages) */
input[type="text"]:not([class]),
input[type="number"]:not([class]),
input[type="email"]:not([class]),
input[type="password"]:not([class]),
input[type="tel"]:not([class]),
input[type="search"]:not([class]),
input[type="url"]:not([class]),
input[type="date"]:not([class]),
select:not([class]),
textarea:not([class]) {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color .2s ease, box-shadow .2s ease;
}

input[type="text"]:not([class]):focus,
input[type="number"]:not([class]):focus,
input[type="email"]:not([class]):focus,
input[type="password"]:not([class]):focus,
input[type="tel"]:not([class]):focus,
input[type="search"]:not([class]):focus,
input[type="url"]:not([class]):focus,
input[type="date"]:not([class]):focus,
select:not([class]):focus,
textarea:not([class]):focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

input[type="text"]:not([class])::placeholder,
input[type="number"]:not([class])::placeholder,
input[type="email"]:not([class])::placeholder,
input[type="password"]:not([class])::placeholder,
input[type="tel"]:not([class])::placeholder,
input[type="search"]:not([class])::placeholder,
textarea:not([class])::placeholder {
  color: var(--text-3);
}

.form-hint {
  font-size: 12px;
  color: var(--text-3);
  margin-top: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%239BA1B3' d='M8 11L2 5h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
  cursor: pointer;
}

.search-input {
  position: relative;
}

.search-input > i {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 14px;
  pointer-events: none;
}

.search-input .input {
  padding-left: 40px;
}

/* Checkbox / radio defaults keep theme accent */
input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   11. Tabs, filter bar, chips
   -------------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .2s ease;
}

.tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.tab.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s ease;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.chip.active {
  background: var(--primary-soft);
  border-color: transparent;
  color: var(--primary);
}

/* --------------------------------------------------------------------------
   12. Modal
   -------------------------------------------------------------------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 6, 12, .6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(.98);
  transition: transform .25s ease;
}

.modal-overlay.active .modal {
  transform: translateY(0) scale(1);
}

.modal-lg { width: 720px; }
.modal-sm { width: 400px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 0;
}

.modal-header .modal-title {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color .2s ease, color .2s ease;
}

.modal-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal-body {
  padding: 18px 24px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px 20px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   13. Toast
   -------------------------------------------------------------------------- */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--info);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  animation: toastIn .3s ease;
}

.toast.success { border-left-color: var(--success); }
.toast.success > span:first-child { color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.error > span:first-child { color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast.warning > span:first-child { color: var(--warning); }
.toast.info { border-left-color: var(--info); }
.toast.info > span:first-child { color: var(--info); }

.toast > span:first-child {
  font-weight: 700;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   14. Dropdown
   -------------------------------------------------------------------------- */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 1500;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}

.dropdown.active .dropdown-menu {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.dropdown-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: var(--danger-soft);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-soft);
  margin: 6px 4px;
}

.dropdown-header {
  padding: 10px 12px 6px;
}

/* --------------------------------------------------------------------------
   15. Pagination
   -------------------------------------------------------------------------- */

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s ease;
}

.page-btn:hover:not(:disabled):not(.active) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--gradient);
  border-color: transparent;
  color: #fff;
}

.page-btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.pagination > span {
  color: var(--text-3);
  padding: 0 2px;
}

/* --------------------------------------------------------------------------
   16. Avatar
   -------------------------------------------------------------------------- */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  letter-spacing: .02em;
  object-fit: cover;
  aspect-ratio: 1 / 1;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; }

/* Larger profile circle in the topbar */
.topbar-actions .avatar { width: 44px; height: 44px; font-size: 15px; }

/* --------------------------------------------------------------------------
   17. Utilities
   -------------------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }

.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-center { display: flex; align-items: center; justify-content: center; gap: 12px; }

.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-24 { gap: 24px; }

.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }

.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mb-32 { margin-bottom: 32px; }

.text-muted { color: var(--text-3); }
.text-small { font-size: 13px; }

.mono {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

.divider {
  height: 1px;
  background: var(--border-soft);
  border: none;
  margin: 16px 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  padding: 48px 24px;
  color: var(--text-3);
}

.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin-bottom: 6px;
}

.empty-state .empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-2);
}

.empty-state .empty-hint {
  font-size: 13px;
  max-width: 340px;
}

/* Skeleton & spinner */
.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  min-height: 14px;
}

.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 75%, transparent), transparent);
  animation: shimmer 1.5s infinite;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  width: 100%;
  animation: ccFadeIn .35s ease;
}

/* Page + content fade-in: no blank flashes, content gently fades in */
@keyframes ccFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
body { animation: ccFadeIn .3s ease; }
.main-content { animation: ccFadeIn .35s ease; }
.card, .stat-card { content-visibility: auto; }

/* --------------------------------------------------------------------------
   19. Landing (theme-aware namespace)
   -------------------------------------------------------------------------- */

.landing-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  padding: 18px 0;
  transition: background-color .25s ease, border-color .25s ease, padding .25s ease;
  border-bottom: 1px solid transparent;
}

.landing-nav.scrolled {
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom-color: var(--border-soft);
  padding: 12px 0;
}

.landing-nav .container {
  display: flex;
  align-items: center;
  gap: 24px;
}

.landing-nav .nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
}

.landing-nav .nav-links a {
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  transition: color .2s ease;
}

.landing-nav .nav-links a:hover {
  color: var(--text);
}

.hero {
  /* Vertical rhythm only — the horizontal padding must come from the
     .container class (24px), otherwise this shorthand zeroes it and the
     hero text sits flush against the screen edge on phones. */
  padding-top: 160px;
  padding-bottom: 90px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 48px;
  align-items: center;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(34px, 5vw, 56px);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -.02em;
}

.hero-title .gradient-text,
.gradient-text {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

.hero-sub {
  font-size: 17px;
  color: var(--text-2);
  margin: 18px 0 28px;
  max-width: 480px;
}

.hero-cta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.hero-visual {
  position: relative;
}

.hero-visual .mockup-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  animation: float 6s ease-in-out infinite;
}

.float-chip {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: float 5s ease-in-out infinite;
}

.float-chip .stat-icon {
  width: 34px;
  height: 34px;
  font-size: 14px;
  border-radius: 10px;
}

.section {
  padding: 80px 0;
}

.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 14px;
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 800;
  letter-spacing: -.01em;
  margin-bottom: 12px;
}

.section-sub {
  font-size: 16px;
  color: var(--text-2);
  max-width: 560px;
}

.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
  transition: transform .25s ease, box-shadow .25s ease;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
}

.feature-card .feature-title {
  font-size: 17px;
  font-weight: 700;
  margin: 16px 0 8px;
}

.feature-card p {
  font-size: 14px;
  color: var(--text-2);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-lg);
}

.stats-strip .stat-number {
  font-family: var(--font-display);
  font-size: clamp(24px, 3vw, 36px);
  font-weight: 800;
  color: #fff;
}

.stats-strip .stat-caption {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, .8);
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  position: relative;
}

.step-card .step-number {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
  font-family: var(--font-display);
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.step-card .step-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 8px;
}

.step-card p {
  font-size: 14px;
  color: var(--text-2);
}

.testimonial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.testimonial-card .testimonial-text {
  font-size: 15px;
  color: var(--text-2);
  margin-bottom: 18px;
}

.testimonial-card .testimonial-author {
  display: flex;
  align-items: center;
  gap: 12px;
}

.testimonial-card .author-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.testimonial-card .author-role {
  font-size: 12px;
  color: var(--text-3);
}

.cta-band {
  background: var(--gradient);
  border-radius: var(--radius-lg);
  padding: 56px 40px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.cta-band .cta-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 3.4vw, 36px);
  font-weight: 800;
  color: #fff;
  margin-bottom: 12px;
}

.cta-band .cta-sub {
  color: rgba(255, 255, 255, .85);
  font-size: 16px;
  margin-bottom: 26px;
}

.footer {
  background: var(--surface-2);
  border-top: 1px solid var(--border-soft);
  padding: 56px 0 0;
  margin-top: 80px;
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 32px;
}

.footer .footer-brand p {
  font-size: 14px;
  color: var(--text-2);
  margin-top: 14px;
  max-width: 280px;
}

.footer .footer-col h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-2);
  margin-bottom: 16px;
}

.footer .footer-col a {
  display: block;
  font-size: 14px;
  color: var(--text-3);
  padding: 5px 0;
  transition: color .2s ease;
}

.footer .footer-col a:hover {
  color: var(--primary);
}

.footer-bottom {
  margin-top: 44px;
  border-top: 1px solid var(--border-soft);
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   20. Auth pages
   -------------------------------------------------------------------------- */

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-visual {
  background: var(--gradient);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-visual::after {
  content: '';
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  bottom: -160px;
  right: -160px;
}

.auth-visual .brand-mark {
  background: rgba(255, 255, 255, .18);
  box-shadow: none;
}

.auth-visual h2 {
  color: #fff;
  font-size: clamp(26px, 3vw, 38px);
  font-weight: 800;
  margin-bottom: 14px;
}

.auth-visual p {
  color: rgba(255, 255, 255, .85);
  font-size: 16px;
  max-width: 420px;
}

.auth-testimonial {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  padding: 22px 24px;
  backdrop-filter: blur(8px);
  max-width: 420px;
}

.auth-testimonial p {
  font-size: 14px;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  background: var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 36px 32px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 5px;
  margin-bottom: 26px;
}

.auth-tabs .auth-tab {
  border: none;
  background: transparent;
  padding: 10px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: all .2s ease;
}

.auth-tabs .auth-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* --------------------------------------------------------------------------
   21. Animations & reveal
   -------------------------------------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .45s ease, transform .45s ease;
  transition-delay: var(--reveal-delay, 0ms);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes shimmer {
  100% { transform: translateX(100%); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.85); }
}

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .reveal {
    opacity: 1;
    transform: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* --------------------------------------------------------------------------
   22. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }

  .sidebar.active {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content,
  body.sidebar-collapsed .main-content {
    margin-left: 0;
  }

  .topbar,
  body.sidebar-collapsed .topbar {
    margin-left: 0;
  }

  .menu-toggle {
    display: inline-flex;
  }

  .auth-page {
    grid-template-columns: 1fr;
  }

  .auth-visual {
    display: none;
  }

  .hero {
    grid-template-columns: 1fr;
    padding-top: 110px;
  }

  /* Text + Get Started first; the portfolio mockup follows below */
  .hero-visual {
    order: 0;
  }

  .stats-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .main-content {
    padding: 20px 16px;
  }

  .topbar {
    padding: 0 16px;
    gap: 10px;
  }

  .topbar-title {
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  .steps {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 18px;
  }

  /* iOS Safari auto-zooms on focus when input text is under 16px —
     keep mobile form controls at 16px so the page stays put. */
  .input,
  .select,
  .textarea,
  .form-control,
  .lang-search,
  input[type="text"]:not([class]),
  input[type="number"]:not([class]),
  input[type="email"]:not([class]),
  input[type="password"]:not([class]),
  input[type="tel"]:not([class]),
  input[type="search"]:not([class]),
  input[type="url"]:not([class]),
  input[type="date"]:not([class]),
  select:not([class]),
  textarea:not([class]) {
    font-size: 16px;
  }

  /* specific enough to beat the later base .lang-search rule */
  .lang-menu .lang-search {
    font-size: 16px;
  }

  .page-title {
    font-size: 22px;
  }
}

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

  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .page-title {
    font-size: 20px;
  }

  table.data-table {
    min-width: 640px;
  }

  .hero {
    /* longhand: keep .container's horizontal padding intact */
    padding-top: 92px;
    padding-bottom: 44px;
  }

  .hero-sub {
    font-size: 15px;
    margin: 14px 0 20px;
  }

  .hero-cta .btn-lg {
    padding: 12px 20px;
    font-size: 14px;
  }

  .hero-visual .mockup-card {
    padding: 18px;
  }

  .stats-strip {
    grid-template-columns: 1fr;
    padding: 32px 24px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
  }

  .modal-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .modal-footer .btn {
    width: 100%;
  }
}

/* ---------------------------------------------------------------------------
   Mobile bottom navigation bar (user pages, injected by js/main.js)
--------------------------------------------------------------------------- */
.bottom-nav {
  display: none;
}

@media (max-width: 992px) {
  /* Never let the page scroll sideways on phones — inner strips
     (table-wrap, crypto-strip) keep their own horizontal scroll */
  html, body {
    overflow-x: hidden;
    max-width: 100%;
  }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)) 14px;
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .06);
    gap: 16px;
  }

  /* Narrow gap under the chat widget bubble (bottom-right corner) so the
     Transactions item sits right next to the support chat icon. */
  .bottom-nav-spacer {
    flex: 0 0 24px;
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 4px 0;
    color: var(--text-3);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
  }

  .bottom-nav-item i {
    font-size: 17px;
  }

  .bottom-nav-item.active {
    color: var(--primary);
  }

  /* Keep page content clear of the fixed bar (nav height + safe area) */
  .main-content,
  body.sidebar-collapsed .main-content {
    padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------------------------------------------------------------------------
   Advert carousel (SoFi-style promo card — auto-rotates and supports swiping)
   --------------------------------------------------------------------------- */

.advert-viewport {
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.advert-track {
  display: flex;
  transition: transform .5s ease;
  touch-action: pan-y;
}

.advert-slide {
  flex: 0 0 100%;
  min-width: 0;
}

.advert-card {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px 26px;
  min-height: 190px;
}

.advert-body {
  flex: 1 1 auto;
  min-width: 0;
}

.advert-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 10px;
}

.advert-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.advert-text {
  font-size: 13px;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0 0 14px;
}

/* Admin-picked banner color: flip text to white so it stays readable on any
   custom background (the inline background is set in the carousel markup). */
.advert-card--tinted .advert-badge {
  background: rgba(255, 255, 255, .16);
  border-color: rgba(255, 255, 255, .35);
  color: #fff;
}

.advert-card--tinted .advert-title,
.advert-card--tinted .advert-text {
  color: #fff;
}

/* Small color swatch shown next to the title in the admin adverts list. */
.adv-color-dot {
  display: inline-block;
  width: 26px;
  height: 16px;
  border-radius: 5px;
  border: 1px solid var(--border);
  margin-right: 8px;
  vertical-align: -3px;
}

/* Live preview strip for the picked banner color in the admin form. */
.adv-color-preview {
  flex-basis: 100%;
  height: 46px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--surface);
  margin-top: 4px;
}

.advert-media {
  flex: 0 0 340px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.advert-media img {
  width: 100%;
  height: 100%;
  max-height: 210px;
  object-fit: cover;
  object-position: center;
  border-radius: var(--radius-sm);
}

.advert-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.advert-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border);
  transition: background .15s ease;
}

.advert-dots span.on {
  background: var(--primary);
}

@media (max-width: 640px) {
  .advert-card {
    flex-direction: row;
    align-items: center;
    padding: 18px;
    gap: 14px;
    min-height: 170px;
  }

  .advert-body {
    flex: 1 1 52%;
  }

  .advert-media {
    flex: 0 0 44%;
    align-self: stretch;
  }

  .advert-media img {
    max-height: 170px;
    border-radius: var(--radius-sm);
  }
}

/* Smartsupp widget: intentionally NOT repositioned — the mobile bottom nav
   keeps an empty fifth slot (see .bottom-nav-spacer), so the bubble stays at
   Smartsupp's own default bottom-right position without covering any nav
   item. */


/* ==========================================================================
   Language selector (translator) + avatar zoom overlay
   ========================================================================== */

.lang-select-slot,
.lang-select {
  position: relative;
  display: inline-flex;
}

.lang-select-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

.lang-select-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.lang-select-btn .fa-globe {
  font-size: 14px;
}

.lang-flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}

.lang-option-name {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.lang-select-btn .lang-caret {
  font-size: 10px;
  opacity: .65;
}

.lang-menu {
  /* Absolute overlay inside the position:relative .lang-select wrapper:
     opening it never reflows the topbar/nav, and it stays right-aligned
     under the button. Only the wrapper participates in layout. */
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: min(320px, 90vw);
  max-height: 60vh;
  overflow: hidden;
  display: none;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 2000;
}

.lang-select.open .lang-menu {
  display: flex;
}

/* On phones the menu can't hang right:0 under the button (the 320px panel
   runs off the left edge of small screens) — anchor it to the bar itself so
   it drops down just under the dropdown. Absolute (not fixed) positioning
   keeps it glued to the bar when the on-screen keyboard opens. */
@media (max-width: 768px) {
  .topbar .lang-select,
  .landing-page .nav-actions .lang-select {
    position: static;
  }

  .topbar .lang-menu,
  .landing-page .nav-actions .lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 12px;
    left: auto;
    transform: none;
    width: min(320px, calc(100vw - 32px));
    max-height: 70vh;
  }
}

.lang-list {
  overflow-y: auto;
  max-height: min(340px, calc(60vh - 52px));
}

.lang-search {
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
}

.lang-search:focus {
  border-color: var(--primary);
}

.lang-option-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
  overflow: hidden;
}

.lang-native {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-en {
  color: var(--text-3);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}

.lang-option:hover {
  background: var(--surface-2);
}

.lang-option.active {
  color: var(--primary);
  font-weight: 700;
}

/* Google Translate widget chrome cleanup (we drive it with our own menu) */
.goog-te-banner-frame.skiptranslate,
.VIpgJd-ZVi9od-ORHb-OEVmcd.skiptranslate {
  display: none !important;
}

body {
  top: 0 !important;
}

#goog-gt-tt,
.goog-te-balloon-frame,
.goog-te-gadget {
  display: none !important;
}

.goog-text-highlight {
  background: none !important;
  box-shadow: none !important;
}

/* ---------- Avatar zoom lightbox ---------- */

#ccAvatarZoom {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 10, 16, .88);
  cursor: zoom-out;
  padding: 24px;
}

#ccAvatarZoom.active {
  display: flex;
}

#ccAvatarZoom img {
  max-width: min(92vw, 700px);
  max-height: 92vh;
  width: auto;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .55);
  object-fit: contain;
}

/* --------------------------------------------------------------------------
   23. Rendering perf — skip offscreen layout/paint
   -------------------------------------------------------------------------- */

/* Landing page: sections + founder cards render on demand.
   Reveal-on-scroll uses IntersectionObserver, which stays compatible:
   entries only compute once the browser lays the section out. */
.landing-page section,
.landing-page .founder-card {
  content-visibility: auto;
  contain-intrinsic-size: auto 480px;
}

/* App/dashboard pages: stat cards and content cards render on demand. */
.stat-card,
.card {
  content-visibility: auto;
  contain-intrinsic-size: auto 220px;
}

/* ---------------------------------------------------------------------------
   Mobile grid blowout guard (max-width 992px)
   Pages collapse two-column grids (e.g. 1.25fr .75fr) to a single 1fr track
   on phones. Grid items default to min-width: auto, so wide form controls
   (inputs/buttons with intrinsic widths) force the 1fr track wider than the
   screen and the whole page overflows sideways. Allowing these items to
   shrink below their content's intrinsic minimum keeps every page within the
   viewport on all mobile screens. */
@media (max-width: 992px) {
  .dep-grid > *, .wd-grid > *, .kyc-grid > *, .loans-grid > *, .support-grid > *,
  .cart-grid > *, .ws-grid > *, .spot-grid > *, .proj-grid > *, .advisor-card > *,
  .musk-banner > *, .grid-2 > *, .stat-grid > *, .model-grid > * {
    min-width: 0;
  }
}
