:root {
  --bg: #111014;
  --surface: #17171c;
  --surface-2: #1d1b24;
  --surface-3: #252330;
  --line: rgba(200, 184, 255, .16);
  --line-soft: rgba(255, 255, 255, .07);
  --text: #fff;
  --text-2: #d6d1e4;
  --muted: #878393;
  --muted-2: #575360;
  --accent: #7b5ef0;
  --accent-2: #c8b8ff;
  --accent-soft: rgba(123, 94, 240, .14);
  --success: #34d399;
  --success-soft: rgba(16, 185, 129, .13);
  --danger: #fb7185;
  --warning: #f59e0b;
  --blue: #8a68ff;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow: 0 40px 90px rgba(0, 0, 0, .62);
  --header-height: 56px;
  --nav-height: calc(68px + env(safe-area-inset-bottom));
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body, #root {
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

html {
  background: #0a0a0d;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at 42% -12%, rgba(123, 94, 240, .18) 0, rgba(123, 94, 240, .06) 34%, transparent 58%),
    linear-gradient(180deg, #211b29 0%, #151318 48%, #101011 100%);
}

#root {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }

/* ---- App Shell ---- */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(circle at 70% -12%, rgba(123, 94, 240, .09), transparent 36%),
    linear-gradient(180deg, #101013 0%, #101013 100%);
  position: relative;
}

/* ---- Icons (inline SVG) ---- */
.icon {
  width: 20px; height: 20px;
  display: inline-block;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  flex: 0 0 auto;
}

/* ---- Nav ---- */
.nav {
  z-index: 55;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  min-height: var(--nav-height);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  background: rgba(14, 14, 16, .96);
  backdrop-filter: blur(16px);
  flex: 0 0 auto;
}

.nav-btn {
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted-2);
  min-height: 52px;
  display: grid;
  place-items: center;
  gap: 2px;
  cursor: pointer;
  font-size: 9.5px;
  font-weight: 560;
  transition: color .16s ease, background .16s ease, transform .16s ease;
}

.nav-btn .icon { width: 20px; height: 20px; stroke-width: 1.75; }
.nav-btn.active { background: #1a1a20; color: var(--accent-2); }
.nav-btn:active { transform: translateY(1px); }

/* ---- Pages Container ---- */
.pages {
  z-index: 0;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.pages::-webkit-scrollbar { display: none; }
.page { display: none; padding: 28px 14px calc(22px + env(safe-area-inset-bottom)); }
.page.active { display: block; }

/* ---- Eyeline / Greeting ---- */
.eyeline {
  display: flex; justify-content: space-between; gap: 12px;
  align-items: flex-start; margin-bottom: 16px;
}
.greeting { color: var(--muted-2); font-size: 12px; line-height: 1.3; margin: 0 0 3px; }
.user-name, .order-header {
  color: #fff; font-size: 20px; line-height: 1.15;
  font-weight: 720; margin: 0; letter-spacing: -.2px;
}
.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 30px;
  background: #17171c; font-size: 11px; font-weight: 580; color: var(--muted);
}
.dot-active {
  width: 7px; height: 7px; border-radius: 50%; background: var(--success);
  box-shadow: 0 0 5px var(--success);
}

/* ---- Balance Card ---- */
.balance-card {
  display: block; width: 100%;
  background:
    radial-gradient(circle at 60% 12%, rgba(123, 94, 240, .24), transparent 48%),
    linear-gradient(180deg, #1e1932, #191527 58%, #121017 100%);
  border: 1.5px solid rgba(200, 184, 255, .2);
  border-radius: var(--radius-lg);
  padding: 18px 18px 14px;
  margin-bottom: 16px;
  text-align: left;
  color: #fff;
  transition: transform .14s ease;
}
.balance-card:active { transform: scale(.99); }
.balance-label { font-size: 11px; color: var(--muted-2); margin: 0 0 4px; font-weight: 500; }
.balance-amount { font-size: 34px; font-weight: 760; margin: 0 0 11px; letter-spacing: -.3px; }
.card-row { display: flex; align-items: center; gap: 8px; }
.card-num { font-size: 12px; color: var(--text-2); letter-spacing: .8px; }
.card-status { font-size: 10px; color: var(--success); display: flex; align-items: center; gap: 4px; }

/* ---- Quick Actions ---- */
.quick-actions {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px;
}
.qa {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-md); padding: 13px 6px 10px;
  display: grid; place-items: center; gap: 5px;
  color: var(--text-2); cursor: pointer; transition: background .18s ease;
}
.qa:active { background: #25212e; }
.qa-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; }
.qa-label { font-size: 10px; font-weight: 520; }

/* ---- Section Head ---- */
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-title { color: var(--muted-2); font-size: 11px; margin: 0; font-weight: 580; }
.link-btn { background: transparent; border: 0; color: var(--accent-2); font-size: 10px; cursor: pointer; padding: 0; }

/* ---- Transaction List ---- */
.tx-list { display: flex; flex-direction: column; gap: 6px; }
.tx-item {
  display: flex; align-items: center; gap: 11px;
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-md); padding: 11px 12px;
  cursor: pointer; color: inherit; text-align: left; width: 100%;
  transition: background .14s ease;
}
.tx-item:active { background: #1f1d28; }
.tx-icon {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex: 0 0 auto;
}
.tx-icon.in { background: var(--success-soft); color: var(--success); }
.tx-icon.out { background: rgba(255,255,255,.06); color: var(--muted); }
.tx-icon.warn { background: rgba(245,158,11,.15); color: var(--warning); }
.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 13px; color: #e8e4f6; margin: 0 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: 11px; color: var(--muted-2); margin: 0; }
.tx-amt { font-size: 14px; font-weight: 650; white-space: nowrap; }
.tx-amt.in { color: var(--success); }
.tx-amt.out { color: var(--text-2); }

/* ---- Card Options (Order) ---- */
.card-option {
  display: block; width: 100%; text-align: left;
  background: var(--surface-2); border: 1.5px solid var(--line);
  border-radius: var(--radius-md); padding: 15px 15px 12px;
  margin-bottom: 12px; color: var(--text); cursor: pointer;
  transition: border-color .18s ease, background .18s ease, transform .16s ease;
}
.card-option.selected { border-color: var(--accent); background: rgba(123,94,240,.08); }
.card-option:active { transform: scale(.99); }
.co-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 10px; }
.co-left { display: flex; align-items: center; gap: 12px; }
.card-flag { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); font-size: 11px; font-weight: 700; color: #fff; flex: 0 0 auto; }
.co-name { font-size: 14px; font-weight: 650; color: #e8e4f6; margin: 0 0 2px; }
.co-bank { font-size: 11px; color: var(--muted-2); margin: 0; }
.price-badge { background: var(--accent-soft); color: var(--accent-2); font-size: 11px; font-weight: 660; padding: 4px 10px; border-radius: 30px; white-space: nowrap; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: rgba(255,255,255,.07); color: var(--muted); font-size: 10px; padding: 3px 9px; border-radius: 20px; display: inline-flex; align-items: center; gap: 3px; }
.chip.good { background: var(--success-soft); color: var(--success); }

/* ---- Tariff meta ---- */
.tariff-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.tariff-meta div { font-size: 10px; }
.tariff-meta div span { color: var(--muted-2); display: block; margin-bottom: 1px; }
.tariff-meta div strong { color: var(--text-2); font-weight: 600; }

/* ---- Order Button ---- */
.order-btn {
  width: 100%;
  background: var(--accent);
  border: 0;
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-size: 15px;
  font-weight: 680;
  cursor: pointer;
  transition: background .18s ease, transform .14s ease;
}
.order-btn:active { background: #6948d4; transform: scale(.98); }

/* ---- Details Rollout ---- */
.details-rollout {
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-md);
  margin-top: -4px;
}
.home-details-rollout { margin-bottom: 16px; }

/* ---- Mini Card ---- */
.mini-card {
  background:
    radial-gradient(circle at 70% 10%, rgba(123,94,240,.21), transparent 45%),
    linear-gradient(135deg, #161229, #13101f 52%, #0f0d18 100%);
  border: 1.5px solid rgba(200,184,255,.15);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
  margin: 14px;
  position: relative;
}
.mini-card::after {
  content: attr(data-brand-mark);
  position: absolute;
  right: 14px; top: 14px;
  font-size: 9px; font-weight: 700;
  color: rgba(255,255,255,.5);
}
.mc-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.mc-type { font-size: 13px; color: #e8e4f6; margin: 0; font-weight: 650; }
.mc-status { font-size: 10px; color: var(--muted-2); }
.mc-bottom { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mc-fl { font-size: 9px; color: var(--muted-2); margin: 0 0 2px; }
.mc-fv { font-size: 13px; color: #fff; margin: 0; font-weight: 620; }

/* ---- Detail Grid ---- */
.detail-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  padding: 0 14px 14px;
}
.detail-cell { background: var(--surface-3); border-radius: var(--radius-sm); padding: 10px 12px; }
.dc-label { font-size: 10px; color: var(--muted-2); margin: 0 0 3px; }
.dc-value { font-size: 12px; color: var(--text); margin: 0; font-weight: 600; }
.card-number { letter-spacing: 1.2px; }

/* ---- Copy Row ---- */
.copy-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; gap: 10px;
  border-top: 1px solid var(--line-soft);
}
.copy-meta { font-size: 10px; color: var(--muted-2); margin: 0 0 2px; }
.copy-val { font-size: 12px; color: var(--text-2); margin: 0; font-weight: 520; }
.copy-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--accent-soft); border: 0;
  border-radius: 20px; padding: 7px 14px; color: var(--accent-2);
  font-size: 11px; font-weight: 580; cursor: pointer; white-space: nowrap;
  transition: background .16s ease;
}
.copy-btn:active { background: rgba(123,94,240,.22); }

/* ---- Detail Actions ---- */
.detail-actions {
  display: flex; gap: 8px; padding: 14px;
  border-top: 1px solid var(--line-soft);
}
.topup-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface-3); border: 0; border-radius: var(--radius-sm);
  padding: 12px 8px; color: var(--accent-2); font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background .16s ease;
}
.topup-btn:active { background: #2d2838; }
.topup-btn.danger { color: var(--danger); }
.topup-btn.danger:active { background: #2a1418; }

/* ---- Profile ---- */
.profile-card {
  text-align: center; padding: 12px 0 18px;
}
.profile-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background:
    radial-gradient(circle at 30% 28%, rgba(255,255,255,.35), transparent 24%),
    linear-gradient(135deg, #2a1280, #7b5ef0);
  display: grid; place-items: center;
  margin: 0 auto 10px;
  font-size: 20px; font-weight: 750; color: #fff;
}
.profile-name { font-size: 18px; font-weight: 680; color: #fff; margin: 0 0 4px; }
.profile-tag { font-size: 11px; color: var(--muted-2); margin: 0; }

/* ---- Stat Row ---- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat-cell {
  background: var(--surface-2); border: 1px solid var(--line-soft); border-radius: var(--radius-md);
  padding: 14px 8px; text-align: center; cursor: pointer; color: inherit; width: 100%;
  transition: background .16s ease;
}
.stat-cell:active { background: #1f1d28; }
.stat-num { font-size: 22px; font-weight: 740; color: #fff; margin: 0 0 4px; }
.stat-lab { font-size: 11px; color: var(--muted-2); margin: 0; }

/* ---- Menu Items ---- */
.menu-item {
  display: flex; align-items: center; gap: 12px;
  width: 100%; background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-md); padding: 14px 14px;
  color: var(--text); cursor: pointer; font-size: 14px; text-align: left;
  margin-bottom: 7px;
  transition: background .16s ease, transform .14s ease;
}
.menu-item:active { background: #1f1d28; transform: scale(.99); }
.menu-icon {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-3); display: grid; place-items: center;
  color: var(--muted); flex: 0 0 auto;
}
.menu-text { flex: 1; color: #e8e4f6; }
.menu-chevron { color: var(--muted-2); margin-left: auto; }
.badge {
  background: var(--accent-soft); color: var(--accent-2);
  font-size: 10px; font-weight: 660; padding: 3px 9px; border-radius: 20px;
}
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.gray { background: rgba(255,255,255,.07); color: var(--muted); }

/* ---- Sheet / Modal ---- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,.0);
  display: flex; align-items: flex-end;
  pointer-events: none;
  transition: background .28s ease;
}
.sheet-backdrop.is-open {
  background: rgba(8,8,12,.82);
  pointer-events: auto;
}
.sheet {
  width: 100%; max-height: 74vh;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -12px 48px rgba(0,0,0,.5);
  padding: 20px 14px calc(16px + env(safe-area-inset-bottom));
  transform: translateY(100%);
  transition: transform .26s cubic-bezier(.22,.8,.24,1);
  display: flex; flex-direction: column; gap: 12px;
  overflow-y: auto;
  scrollbar-width: none;
}
.sheet::-webkit-scrollbar { display: none; }
.sheet-backdrop.is-open .sheet { transform: translateY(0); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet-title { font-size: 17px; font-weight: 720; color: #fff; margin: 0; }
.close-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-3); border: 0;
  display: grid; place-items: center; color: var(--muted); cursor: pointer;
  transition: background .16s;
}
.close-btn:active { background: #353145; }

/* ---- Form Fields ---- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; color: var(--muted-2); margin-bottom: 5px; }
.field input {
  width: 100%; background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 14px;
  color: #fff; font-size: 15px; outline: none;
  transition: border-color .16s;
}
.field input:focus { border-color: var(--accent); }

/* ---- Method Grid ---- */
.method-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px;
}
.method {
  background: var(--surface-3); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 10px;
  text-align: left; cursor: pointer; color: #fff;
  transition: border-color .16s, background .16s;
}
.method.active { border-color: var(--accent); background: rgba(123,94,240,.08); }
.method-title { font-size: 12px; font-weight: 620; margin: 0 0 2px; display: block; }
.method-sub { font-size: 10px; color: var(--muted-2); display: block; }

/* ---- Primary Button ---- */
.primary-btn {
  width: 100%; background: var(--accent); border: 0;
  border-radius: var(--radius-md); padding: 14px;
  color: #fff; font-size: 15px; font-weight: 680; cursor: pointer;
  transition: background .18s, transform .14s;
}
.primary-btn:active { background: #6948d4; transform: scale(.98); }

.secondary-btn {
  width: 100%; background: var(--surface-3); border: 0;
  border-radius: var(--radius-md); padding: 14px;
  color: var(--text-2); font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .16s;
}
.secondary-btn:active { background: #2d2838; }

/* ---- Summary Box ---- */
.summary-box {
  background: var(--surface-2); border: 1px solid var(--line-soft);
  border-radius: var(--radius-md); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.summary-line { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.summary-line span { color: var(--muted-2); }
.summary-line strong { color: #fff; font-weight: 650; }

/* ---- Sheet Note ---- */
.sheet-note { font-size: 11px; color: var(--muted-2); line-height: 1.5; margin: 0; }

/* ---- Settings ---- */
.setting-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; cursor: pointer; border-bottom: 1px solid var(--line-soft);
}
.setting-row:last-child { border-bottom: 0; }
.setting-title { font-size: 13px; color: #e8e4f6; display: block; }
.setting-sub { font-size: 11px; color: var(--muted-2); display: block; margin-top: 2px; }

/* ---- Switch ---- */
.switch {
  position: relative; width: 44px; height: 26px; flex: 0 0 auto;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0;
  background: var(--surface-3); border-radius: 30px;
  transition: background .2s;
}
.switch span::after {
  content: "";
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform .2s;
}
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---- Toast ---- */
.toast {
  position: fixed; z-index: 80;
  left: 50%; transform: translateX(-50%) translateY(10px);
  bottom: calc(var(--nav-height) + 14px);
  display: flex; align-items: center; gap: 7px;
  background: #1e1d28; border: 1px solid var(--line);
  border-radius: 30px; padding: 10px 18px;
  color: #fff; font-size: 12px; font-weight: 550;
  box-shadow: 0 8px 28px rgba(0,0,0,.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity .22s ease, transform .22s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: rgba(251,113,133,.25); }

/* ---- Owned Card Tabs ---- */
.owned-card-list {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px;
}
.owned-card-tab {
  display: flex; align-items: center; gap: 11px;
  width: 100%; background: var(--surface-2); border: 1.5px solid var(--line);
  border-radius: var(--radius-md); padding: 12px 14px;
  color: var(--text); cursor: pointer; text-align: left;
  transition: border-color .16s, background .16s, transform .14s;
}
.owned-card-tab.selected { border-color: var(--accent); background: rgba(123,94,240,.08); }
.owned-card-tab.frozen { opacity: .55; }
.owned-card-tab:active { transform: scale(.99); }
.owned-card-mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-3); display: grid; place-items: center;
  font-size: 9px; font-weight: 700; color: var(--muted); flex: 0 0 auto;
}
.owned-card-name { font-size: 13px; color: #e8e4f6; display: block; }
.owned-card-number { font-size: 10px; color: var(--muted-2); display: block; margin-top: 1px; }
.owned-card-status { margin-left: auto; font-size: 10px; color: var(--success); font-weight: 550; }

/* ---- Cards Page ---- */
.cards-page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 18px; gap: 12px; }
.cards-page-head .order-header { font-size: 20px; }
.cards-page-head .order-sub { margin-top: 4px; }
.cards-page-actions { margin-top: 8px; }

.order-sub { font-size: 12px; color: var(--muted-2); margin: 6px 0 18px; line-height: 1.5; }

/* ---- Card Catalog ---- */
.card-catalog { display: flex; flex-direction: column; gap: 10px; }

/* ---- QR Box ---- */
.qr-box {
  width: 120px; height: 120px;
  background: #fff; border-radius: var(--radius-sm);
  margin: 0 auto;
}

/* ---- Framer Motion Helpers ---- */
.rollout-content {
  overflow: hidden;
}
