/* ==========================================================================
   AurumPulse Fintech Design System — Ultra-Grade Telegram Mini App & Admin UI
   Compliant with DESIGN.md | Zero Bloat | GPU-Accelerated | RTL Precision
   ========================================================================== */

@import url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/Vazirmatn-font-face.css');

:root {
  --bg-obsidian: #07090E;
  --bg-surface-1: #0D121C;
  --bg-surface-2: #131A29;
  --bg-surface-3: #1A2336;
  --bg-glass: rgba(16, 22, 35, 0.82);
  --bg-hero: linear-gradient(145deg, rgba(25, 34, 54, 0.94) 0%, rgba(11, 15, 24, 0.97) 58%, rgba(36, 27, 10, 0.94) 100%);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.15);
  --border-gold: rgba(245, 196, 81, 0.36);

  --gold-300: #FDE68A;
  --gold-400: #F7CE68;
  --gold-500: #EAB308;
  --gold-600: #CA8A04;
  --gold-grad: linear-gradient(135deg, #FDE68A 0%, #EAB308 55%, #B45309 100%);

  --profit: #10B981;
  --profit-bright: #34D399;
  --profit-bg: rgba(16, 185, 129, 0.13);
  --loss: #F43F5E;
  --loss-bright: #FB7185;
  --loss-bg: rgba(244, 63, 94, 0.13);
  --withdraw: #F59E0B;
  --withdraw-bg: rgba(245, 158, 11, 0.14);

  --text-primary: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 13px;
  --radius-pill: 999px;

  --shadow-elevated: 0 16px 38px -10px rgba(0, 0, 0, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --shadow-gold: 0 8px 24px -4px rgba(234, 179, 8, 0.28);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

html, body {
  background-color: var(--bg-obsidian);
  color: var(--text-primary);
  font-family: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 85% 8%, rgba(234, 179, 8, 0.10), transparent 42%),
    radial-gradient(circle at 12% 30%, rgba(16, 185, 129, 0.08), transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.num-ltr {
  direction: ltr;
  display: inline-block;
   unicode-bidi: isolate;
  font-variant-numeric: tabular-nums;
  font-family: 'Inter', 'Vazirmatn', system-ui, sans-serif;
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 15px 92px;
}

.admin-shell {
  max-width: 980px;
}

/* Brand Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 13px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  flex-shrink: 0;
  box-shadow: var(--shadow-gold);
}

.brand-titles h1 {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.25;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--gold-400);
  font-weight: 500;
}

.rate-pill {
  font-size: 0.72rem;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: rgba(234, 179, 8, 0.11);
  border: 1px solid var(--border-gold);
  color: var(--gold-300);
  white-space: nowrap;
}

/* Segmented Portfolio Switcher */
.account-tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 15px;
  margin-bottom: 14px;
}

.tab-btn {
  flex: 1;
  min-height: 40px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.2s ease, color 0.2s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tab-btn.active {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.22), rgba(234, 179, 8, 0.08));
  color: var(--gold-300);
  border: 1px solid var(--border-gold);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.tab-btn.admin-jump {
  background: rgba(16, 185, 129, 0.14);
  color: var(--profit-bright);
  border: 1px solid rgba(16, 185, 129, 0.3);
  flex: 0.85;
}

/* Hero Balance Card */
.hero-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-hero);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: 20px 18px 16px;
  box-shadow: var(--shadow-elevated);
  margin-bottom: 12px;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url('../assets/hero_banner.png') center/cover no-repeat;
  opacity: 0.13;
  mix-blend-mode: screen;
  pointer-events: none;
}

.hero-inner {
  position: relative;
  z-index: 1;
}

.hero-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.balance-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.balance-label small {
  font-size: 0.68rem;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--profit-bright);
  box-shadow: 0 0 10px var(--profit);
  display: inline-block;
}

.balance-amount-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 4px 0 2px;
}

.balance-amount {
  font-size: 2.25rem;
  font-weight: 900;
  letter-spacing: -0.025em;
  background: linear-gradient(180deg, #FFFFFF 20%, #FDE68A 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.balance-currency {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gold-400);
}

.balance-toman {
  font-size: 0.8rem;
  color: var(--gold-300);
  opacity: 0.9;
  margin-bottom: 14px;
}

/* SVG Equity Curve Container */
.sparkline-wrap {
  height: 58px;
  width: 100%;
  margin: 8px 0 14px;
  border-radius: 10px;
  background: rgba(7, 9, 14, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 4px;
  overflow: hidden;
}

.sparkline-wrap svg {
  width: 100%;
  height: 100%;
  display: block;
}

.profit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.profit-box {
  background: rgba(7, 9, 14, 0.56);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.profit-label {
  font-size: 0.73rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.profit-label small {
  display: block;
  font-size: 0.63rem;
  color: var(--text-muted);
}

.profit-value {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--text-primary);
}

.profit-value.positive { color: var(--profit-bright); }
.profit-value.negative { color: var(--loss-bright); }

/* Status Notice Banner */
.notice-banner {
  font-size: 0.8rem;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  background: rgba(56, 189, 248, 0.09);
  border: 1px solid rgba(56, 189, 248, 0.24);
  color: #BAE6FD;
  margin-bottom: 12px;
}

/* Metrics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 14px;
}

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

.stat-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 11px;
  text-align: center;
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.stat-label small {
  display: block;
  font-size: 0.6rem;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.08rem;
  font-weight: 800;
  color: var(--text-primary);
}

/* Referral Funnel Card */
.panel-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

.panel-card h2 {
  font-size: 0.96rem;
  font-weight: 800;
  color: var(--gold-300);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.panel-card p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Progress Bar & Milestones */
.milestone-track {
  margin: 12px 0 14px;
}

.progress-bar-bg {
  height: 9px;
  background: var(--bg-surface-3);
  border-radius: var(--radius-pill);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gold-grad);
  border-radius: var(--radius-pill);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.milestone-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.milestone-labels span.reached {
  color: var(--gold-400);
  font-weight: 700;
}

.input-copy-group {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.input-field, select.input-field, textarea.input-field {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-obsidian);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.84rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.input-field:focus {
  border-color: var(--gold-500);
}

.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.14s ease, opacity 0.2s ease, background-color 0.2s ease;
  text-decoration: none;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

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

.btn-gold {
  background: var(--gold-grad);
  color: #090C12;
  box-shadow: var(--shadow-gold);
}

.btn-emerald {
  background: linear-gradient(135deg, #10B981, #059669);
  color: #FFFFFF;
}

.btn-outline {
  background: var(--bg-surface-2);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--loss-bg);
  border-color: rgba(244, 63, 94, 0.35);
  color: var(--loss-bright);
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

/* Trades History List */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 10px;
}

.section-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-primary);
}

.trades-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.trade-card {
  background: var(--bg-surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: transform 0.18s ease, border-color 0.2s ease;
}

.trade-card.buy { border-right: 3px solid var(--profit); }
.trade-card.sell { border-right: 3px solid var(--loss); }
.trade-card.withdraw { border-right: 3px solid var(--withdraw); }

.trade-header, .trade-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.currency-name {
  font-weight: 800;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 7px;
}

.trade-badge {
  font-size: 0.71rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.trade-badge.buy { background: var(--profit-bg); color: var(--profit-bright); }
.trade-badge.sell { background: var(--loss-bg); color: var(--loss-bright); }
.trade-badge.withdraw { background: var(--withdraw-bg); color: var(--withdraw); }

.trade-date {
  font-size: 0.74rem;
  color: var(--text-muted);
}

.trade-profit-col {
  text-align: left;
}

.trade-profit {
  font-size: 0.98rem;
  font-weight: 800;
}

.trade-profit.positive { color: var(--profit-bright); }
.trade-profit.negative { color: var(--loss-bright); }
.trade-profit.withdraw { color: var(--withdraw); }

.trade-toman {
  font-size: 0.69rem;
  color: var(--text-secondary);
}

.empty-state {
  text-align: center;
  padding: 28px 14px;
  color: var(--text-muted);
  background: var(--bg-surface-1);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  font-size: 0.85rem;
}

/* Floating Refresh Button */
.refresh-fab {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid var(--border-gold);
  background: var(--bg-glass);
  color: var(--gold-400);
  backdrop-filter: blur(14px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-elevated);
  z-index: 30;
  transition: transform 0.25s ease;
}

.refresh-fab svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.refresh-fab.spinning svg {
  animation: spin360 0.75s linear infinite;
}

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

/* Modal Drawer (Withdrawal & Card Registration) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.78);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none !important;
}

.modal-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border-gold);
  border-radius: 22px;
  padding: 20px 18px;
  box-shadow: var(--shadow-elevated);
}

.modal-sheet h3 {
  font-size: 1rem;
  color: var(--gold-300);
  margin-bottom: 10px;
}

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

.form-group label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

/* Admin Specific Grids */
.admin-grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.admin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.data-table th, .data-table td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  background: var(--bg-surface-2);
  color: var(--gold-300);
  font-weight: 700;
  white-space: nowrap;
}

@media (max-width: 400px) {
  .balance-amount { font-size: 1.9rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
