:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: rgba(59,130,246,0.14);
  --secondary: #22d3ee;
  --money: #a3e635;
  --gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 55%, #3b82f6 100%);
  --gradient-soft: linear-gradient(135deg, #2563eb, #3b82f6);
  --gradient-card: linear-gradient(140deg, #131a2c 0%, #0d1424 45%, #1a2540 100%);
  --success: #34d399;
  --success-light: rgba(52,211,153,0.14);
  --danger: #f87171;
  --danger-light: rgba(248,113,113,0.14);
  --warning: #fbbf24;
  --warning-light: rgba(251,191,36,0.14);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-tertiary: #5b6679;
  --border: rgba(255,255,255,0.08);
  --border-soft: rgba(255,255,255,0.05);
  --bg: #0a0e18;
  --bg-elevated: #11172a;
  --card: #141b30;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 8px 24px rgba(37,99,235,0.25);
  --shadow-lg: 0 16px 40px rgba(0,0,0,0.45);
  --topbar-h: 50px;
  --bottomnav-h: 60px;
  --radius: 16px;
  --radius-sm: 11px;
  --topbar-bg: rgba(10,14,24,0.78);
  --navbar-bg: rgba(10,14,24,0.85);
}

html[data-theme="light"] {
  --primary-light: rgba(37,99,235,0.1);
  --success-light: rgba(22,163,74,0.1);
  --danger-light: rgba(220,38,38,0.1);
  --warning-light: rgba(217,119,6,0.12);
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --border: rgba(15,23,42,0.09);
  --border-soft: rgba(15,23,42,0.06);
  --bg: #f4f6fa;
  --bg-elevated: #ffffff;
  --card: #ffffff;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05), 0 1px 1px rgba(15,23,42,0.04);
  --shadow-md: 0 8px 22px rgba(37,99,235,0.16);
  --shadow-lg: 0 16px 36px rgba(15,23,42,0.16);
  --topbar-bg: rgba(244,246,250,0.85);
  --navbar-bg: rgba(255,255,255,0.9);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overscroll-behavior-y: contain;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; }
svg { display: block; flex-shrink: 0; }

/* ===== APP SHELL ===== */
.app {
  max-width: 460px;
  margin: 0 auto;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgba(59,130,246,0.12), transparent 45%),
    radial-gradient(circle at 100% 30%, rgba(34,211,238,0.07), transparent 40%),
    var(--bg);
  position: relative;
  padding-bottom: calc(var(--bottomnav-h) + 14px);
}

/* ===== TOP BAR ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--topbar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.topbar h1 { font-size: 15.5px; font-weight: 700; color: var(--text); letter-spacing: -0.2px; }
.topbar .balance-pill {
  background: var(--gradient-soft);
  color: white;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 13px;
  border-radius: 20px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(37,99,235,0.35);
}
.topbar-back { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated); border: 1px solid var(--border); cursor: pointer; color: var(--text);
}
.icon-btn:active { background: var(--border); }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  max-width: 460px;
  margin: 0 auto;
  background: var(--navbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-soft);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 9px 0 8px;
  color: var(--text-tertiary);
  font-size: 10.5px;
  font-weight: 600;
  position: relative;
}
.nav-tab .tab-icon {
  width: 32px; height: 26px;
  display: flex; align-items: center; justify-content: center; border-radius: 9px;
  transition: background 0.18s, color 0.18s;
}
.nav-tab.active { color: var(--text); }
.nav-tab.active .tab-icon { background: var(--gradient-soft); color: white; box-shadow: 0 4px 12px rgba(37,99,235,0.4); }
.nav-tab .badge-dot {
  position: absolute; top: 3px; right: 27%;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--danger); border: 2px solid var(--bg);
}

/* ===== MAIN CONTENT ===== */
.content { padding: 14px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 9px; }
.section-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 9px; }
.link-sm { font-size: 11.5px; font-weight: 700; color: var(--secondary); display: inline-flex; align-items: center; gap: 3px; }

/* ===== CARDS (glass) ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 14px;
}
.card-flat { background: var(--bg-elevated); border-radius: var(--radius-sm); padding: 12px; border: 1px solid var(--border-soft); }

/* ===== VIRTUAL CARD (balance widget) ===== */
.virtual-card {
  position: relative;
  background: var(--gradient-card);
  border-radius: 20px;
  padding: 20px 18px;
  color: white;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: var(--shadow-lg);
}
.virtual-card::before {
  content: '';
  position: absolute; inset: -40% -10% auto auto; width: 70%; height: 140%;
  background: radial-gradient(circle, rgba(59,130,246,0.35), transparent 65%);
  pointer-events: none;
}
.virtual-card::after {
  content: '';
  position: absolute; left: -20%; bottom: -50%; width: 60%; height: 100%;
  background: radial-gradient(circle, rgba(34,211,238,0.18), transparent 65%);
  pointer-events: none;
}
.vc-top { display: flex; justify-content: space-between; align-items: flex-start; position: relative; z-index: 1; }
.vc-brand { font-size: 13px; font-weight: 800; letter-spacing: 0.3px; opacity: 0.95; }
.vc-chip { width: 30px; height: 22px; border-radius: 5px; background: linear-gradient(135deg, #fde68a, #f59e0b); position: relative; z-index: 1; }
.vc-chip::before, .vc-chip::after { content: ''; position: absolute; left: 5px; right: 5px; height: 1px; background: rgba(0,0,0,0.25); }
.vc-chip::before { top: 7px; } .vc-chip::after { top: 14px; }
.vc-label { font-size: 10.5px; opacity: 0.7; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 14px; position: relative; z-index: 1; }
.vc-amount { font-size: 27px; font-weight: 800; margin: 4px 0 16px; letter-spacing: -0.3px; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.vc-row { display: flex; gap: 8px; position: relative; z-index: 1; }
.vc-stat { flex: 1; }
.vc-stat .stat-label { font-size: 9.5px; opacity: 0.65; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.vc-stat .stat-val { font-size: 13px; font-weight: 700; margin-top: 3px; }
.vc-dots { letter-spacing: 3px; font-size: 13px; opacity: 0.55; font-weight: 700; }

/* ===== STAT GRID ===== */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-bottom: 14px; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 11px 13px; }
.stat-box .label { font-size: 10px; color: var(--text-secondary); font-weight: 600; }
.stat-box .value { font-size: 16px; font-weight: 800; margin-top: 3px; color: var(--text); }
.stat-box.success .value { color: var(--success); }
.stat-box.warn .value { color: var(--warning); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 700; border: none; cursor: pointer;
  transition: opacity 0.15s, transform 0.1s; -webkit-appearance: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary { background: var(--gradient-soft); color: white; box-shadow: 0 3px 10px rgba(37,99,235,0.3); }
.btn-success { background: var(--success); color: #052e1f; }
.btn-danger { background: var(--danger); color: #2c0a0a; }
.btn-outline { background: transparent; color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost { background: var(--bg-elevated); color: var(--text); }
.btn-full { width: 100%; }
.btn-sm { min-height: 29px; padding: 0 11px; font-size: 11px; }
.btn .spinner-sm { width: 13px; height: 13px; border: 2px solid rgba(255,255,255,0.4); border-top-color: white; border-radius: 50%; animation: spin 0.7s linear infinite; }

/* ===== FORMS ===== */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--text-secondary); margin-bottom: 5px; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 44px; padding: 0 13px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); font-size: 14px; outline: none; background: var(--bg-elevated); color: var(--text);
  transition: border-color 0.15s;
}
.field select { color-scheme: dark; }
html[data-theme="light"] .field select { color-scheme: light; }
.field textarea { min-height: 72px; padding: 10px 13px; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--text-tertiary); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); }
.field input.invalid, .field select.invalid { border-color: var(--danger); }
.field .error-text { font-size: 11px; color: var(--danger); margin-top: 4px; font-weight: 600; }
.field .hint-text { font-size: 11px; color: var(--text-tertiary); margin-top: 4px; }
.field-row { display: flex; gap: 8px; }
.field-row .field { flex: 1; }

/* ===== ALERTS / TOASTS ===== */
.alert { padding: 11px 13px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 12.5px; font-weight: 600; display: flex; align-items: flex-start; gap: 8px; }
.alert-success { background: var(--success-light); color: var(--success); }
.alert-danger { background: var(--danger-light); color: var(--danger); }
.alert-info { background: var(--primary-light); color: var(--primary); }
.alert-warning { background: var(--warning-light); color: var(--warning); }

.toast {
  position: fixed; bottom: calc(var(--bottomnav-h) + 14px); left: 50%;
  transform: translateX(-50%) translateY(20px); max-width: 400px; width: calc(100% - 28px);
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); padding: 11px 15px; border-radius: var(--radius-sm);
  font-size: 12.5px; font-weight: 600; z-index: 500; opacity: 0; transition: all 0.25s; pointer-events: none;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.toast-danger { background: var(--danger); color: #2c0a0a; border-color: transparent; }
.toast.toast-success { background: var(--success); color: #052e1f; border-color: transparent; }

/* ===== BADGES ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 10.5px; font-weight: 700; }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-secondary { background: var(--bg-elevated); color: var(--text-secondary); border: 1px solid var(--border); }

/* ===== TABS (segmented control) ===== */
.segmented { display: flex; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 3px; margin-bottom: 13px; }
.segmented button {
  flex: 1; border: none; background: transparent; padding: 8px 0; border-radius: 8px;
  font-size: 12.5px; font-weight: 700; color: var(--text-secondary); cursor: pointer; position: relative;
  transition: background 0.15s, color 0.15s;
}
.segmented button.active { background: var(--gradient-soft); color: white; box-shadow: 0 2px 8px rgba(37,99,235,0.35); }
.segmented button .count {
  display: inline-flex; min-width: 17px; height: 17px; padding: 0 5px; align-items: center; justify-content: center;
  background: var(--text-tertiary); color: var(--bg); border-radius: 10px; font-size: 9.5px; margin-left: 4px;
}
.segmented button.active .count { background: rgba(255,255,255,0.3); color: white; }

/* ===== LIST ITEMS ===== */
.list-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--border-soft);
}
.list-item:last-child { border-bottom: none; }
.list-item .avatar {
  width: 38px; height: 38px; border-radius: 11px; background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.list-item .avatar.success { background: var(--success-light); color: var(--success); }
.platform-glyph { display: flex; align-items: center; justify-content: center; border-radius: 11px; flex-shrink: 0; }
.list-item .info { flex: 1; min-width: 0; }
.list-item .info .title { font-size: 12.5px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .info .sub { font-size: 10.5px; color: var(--text-secondary); margin-top: 2px; }
.list-item .trail { text-align: right; flex-shrink: 0; }
.list-item .trail .amount { font-size: 12.5px; font-weight: 800; font-variant-numeric: tabular-nums; }
.list-item .trail .amount.positive { color: var(--success); }
.list-item .trail .amount.negative { color: var(--danger); }

/* ===== TASK CARDS ===== */
.task-card { background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-sm); border-radius: var(--radius); overflow: hidden; margin-bottom: 10px; }
.task-thumb {
  width: 100%; height: 112px; background: var(--gradient-card);
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.task-thumb img { width: 100%; height: 100%; object-fit: cover; }
.task-thumb .thumb-icon { opacity: 0.5; }
.task-thumb .platform-badge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,0.45); backdrop-filter: blur(4px); color: white; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.task-thumb .done-badge { position: absolute; top: 8px; right: 8px; background: var(--success); color: #052e1f; padding: 3px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; display: flex; align-items: center; gap: 4px; }
.task-body { padding: 12px; }
.task-body h3 { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; color: var(--text); }
.task-body p { font-size: 11.5px; color: var(--text-secondary); line-height: 1.45; margin-bottom: 10px; }
.task-meta { display: flex; justify-content: space-between; align-items: center; }
.task-reward { font-size: 15px; font-weight: 800; color: var(--money); }
.task-duration { font-size: 10.5px; color: var(--text-secondary); margin-top: 1px; display: flex; align-items: center; gap: 3px; }

/* ===== VIDEO/TIMER ===== */
.video-frame { position: relative; width: 100%; border-radius: var(--radius); overflow: hidden; background: #000; }
.video-frame iframe { width: 100%; height: 200px; border: none; display: block; }
.timer-bar { background: var(--bg-elevated); border: 1px solid var(--border-soft); border-radius: 10px; height: 8px; margin-top: 12px; overflow: hidden; }
.timer-fill { height: 100%; background: var(--gradient-soft); border-radius: 10px; transition: width 1s linear; }
.timer-info { display: flex; justify-content: space-between; margin-top: 7px; font-size: 11.5px; color: var(--text-secondary); font-weight: 600; }

/* ===== MODAL / SHEET ===== */
.sheet-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.65); z-index: 1000;
  align-items: flex-end; justify-content: center;
}
.sheet-overlay.open { display: flex; }
.sheet {
  background: var(--bg-elevated); border: 1px solid var(--border); border-bottom: none; border-radius: 20px 20px 0 0; width: 100%; max-width: 460px;
  max-height: 88vh; overflow-y: auto; padding: 16px 14px calc(16px + env(safe-area-inset-bottom, 0));
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0.5; } to { transform: translateY(0); opacity: 1; } }
.sheet-handle { width: 32px; height: 4px; background: var(--border); border-radius: 4px; margin: 0 auto 14px; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.sheet-header h2 { font-size: 16px; font-weight: 700; color: var(--text); }

/* ===== EMPTY / LOADING STATES ===== */
.empty-state { text-align: center; padding: 36px 18px; color: var(--text-secondary); }
.empty-state .icon-wrap { width: 52px; height: 52px; border-radius: 50%; background: var(--bg-elevated); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; margin: 0 auto 12px; color: var(--text-tertiary); }
.empty-state p { font-size: 12.5px; line-height: 1.55; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 28px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--bg-elevated) 25%, var(--border) 37%, var(--bg-elevated) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ===== CELEBRATION (confetti + success burst) ===== */
.confetti-piece {
  position: fixed; top: -10px; z-index: 2000; border-radius: 2px; pointer-events: none;
  animation: confettiFall linear forwards;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(540deg); opacity: 0; }
}
.success-burst {
  width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 14px;
  background: var(--success-light); display: flex; align-items: center; justify-content: center; color: var(--success);
  animation: burstPop 0.45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes burstPop { 0% { transform: scale(0.3); opacity: 0; } 60% { transform: scale(1.08); } 100% { transform: scale(1); opacity: 1; } }

/* ===== OFFLINE BANNER ===== */
.offline-banner {
  display: none; position: sticky; top: 0; z-index: 60; background: var(--warning); color: #2c1f02;
  text-align: center; padding: 6px; font-size: 11px; font-weight: 700;
}
.offline-banner.show { display: block; }

/* ===== MISC ===== */
.mt-2 { margin-top: 7px; } .mt-3 { margin-top: 10px; } .mt-4 { margin-top: 14px; } .mt-6 { margin-top: 20px; }
.mb-3 { margin-bottom: 10px; } .mb-4 { margin-bottom: 14px; }
.flex { display: flex; } .gap-2 { gap: 7px; } .gap-3 { gap: 10px; }
.items-center { align-items: center; } .justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.w-full { width: 100%; }

/* ===== AUTH SCREEN ===== */
.auth-screen { min-height: 100vh; display: flex; flex-direction: column; max-width: 460px; margin: 0 auto; background: var(--bg); }
.auth-hero {
  background:
    radial-gradient(circle at 20% 10%, rgba(59,130,246,0.35), transparent 50%),
    radial-gradient(circle at 90% 60%, rgba(34,211,238,0.18), transparent 45%),
    var(--gradient-card);
  padding: 44px 22px 34px; color: white; position: relative; overflow: hidden;
}
.auth-hero .logo { font-size: 24px; font-weight: 800; letter-spacing: -0.3px; display: flex; align-items: center; gap: 8px; }
.auth-hero .tagline { font-size: 12.5px; opacity: 0.75; margin-top: 4px; }
.auth-body { flex: 1; padding: 22px; }
.auth-body h2 { font-size: 17.5px; font-weight: 700; margin-bottom: 16px; color: var(--text); }
.auth-switch { text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--text-secondary); }
.auth-switch a { color: var(--secondary); font-weight: 700; }

@media (min-width: 461px) {
  .app, .bottom-nav, .auth-screen { box-shadow: 0 0 0 1px var(--border); }
}
