/* ============================================================
   MYTHIC VOYAGER PORTAL - Styles v2.0
   Dark RPG Theme
   ============================================================ */

:root {
  --bg: #030712;
  --bg-card: #0f172a;
  --bg-card2: #1e293b;
  --bg-card3: #0d1424;
  --border: #1e293b;
  --border-hover: #334155;
  --purple-900: #1e1b4b;
  --purple-700: #4338ca;
  --purple-500: #8b5cf6;
  --purple-400: #a78bfa;
  --gold: #f59e0b;
  --gold-light: #fcd34d;
  --emerald: #10b981;
  --red: #ef4444;
  --blue: #0ea5e9;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #475569;
  --sidebar-w: 220px;
  --bottom-nav-h: 60px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; cursor: pointer; }

/* ===== LAYOUT ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar-nav {
  width: var(--sidebar-w);
  background: var(--bg-card3);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  gap: 2px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  margin-bottom: 20px;
}

.logo-icon { font-size: 1.8rem; }
.logo-title {
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--purple-400);
  letter-spacing: 0.1em;
  line-height: 1;
}
.logo-sub {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  line-height: 1.5;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.sidebar-item:hover {
  background: var(--bg-card2);
  color: var(--text);
}

.sidebar-item.active {
  background: rgba(124, 58, 237, 0.15);
  color: var(--purple-400);
  border: 1px solid rgba(124, 58, 237, 0.2);
}

.sidebar-item i {
  width: 16px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding-bottom: 20px;
}

/* Bottom nav (mobile) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--bg-card3);
  border-top: 1px solid var(--border);
  z-index: 100;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.6rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.15s ease;
  user-select: none;
}

.nav-item i { font-size: 1.1rem; }
.nav-item:hover, .nav-item.active { color: var(--purple-400); }
.nav-item.active { background: rgba(124, 58, 237, 0.1); }

/* ===== PAGE BODY ===== */
.page { height: 100%; }

.page-body {
  max-width: 680px;
  margin: 0 auto;
  padding: 20px 16px 40px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-title {
  font-size: 1.3rem;
  font-weight: 900;
  color: white;
  letter-spacing: -0.02em;
}

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

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

/* ===== SECTION CARD ===== */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

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

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.danger-title { color: #f87171 !important; }

.section-sub {
  font-size: 0.7rem;
  color: var(--text-dim);
}

/* ===== CHARACTER CARD ===== */
.character-card {
  background: linear-gradient(135deg, #1e1b4b 0%, #0f172a 60%, #1a0a3a 100%);
  border: 1px solid rgba(124, 58, 237, 0.4);
  border-radius: 16px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.character-card::before {
  content: '';
  position: absolute;
  top: -40%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(124,58,237,0.15) 0%, transparent 70%);
  pointer-events: none;
}

.character-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.character-class {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--purple-400);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-bottom: 4px;
}

.character-title {
  font-size: 1.4rem;
  font-weight: 900;
  color: white;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.character-meta {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 4px;
}

.character-right {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.level-badge {
  background: linear-gradient(135deg, var(--gold), #d97706);
  color: #000;
  font-size: 0.75rem;
  font-weight: 900;
  padding: 4px 12px;
  border-radius: 9999px;
  letter-spacing: 0.05em;
  display: inline-block;
}

.avail-xp {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ===== XP BAR ===== */
.xp-bar-track {
  background: #1e293b;
  border-radius: 9999px;
  height: 10px;
  overflow: hidden;
  position: relative;
}

.xp-bar-fill {
  background: linear-gradient(90deg, #7c3aed, #a78bfa, #f59e0b);
  height: 100%;
  border-radius: 9999px;
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.xp-bar-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.18), transparent);
  animation: shimmer 2.5s infinite;
}

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

.xp-bar-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.68rem;
  color: var(--text-dim);
}

/* ===== STATS GRID ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 10px;
  text-align: center;
  transition: border-color 0.15s;
}

.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover { border-color: var(--border-hover); }

.stat-value {
  font-size: 1.5rem;
  font-weight: 900;
  color: white;
  line-height: 1;
}

.stat-denom {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-muted);
}

.stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 600;
}

.stat-badge.perfect {
  font-size: 0.6rem;
  font-weight: 700;
  color: #34d399;
  margin-top: 2px;
}

/* ===== LOADING / ERROR ===== */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  gap: 12px;
}

.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--purple-400);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.loading-text {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 20px;
  color: #f87171;
  gap: 8px;
  font-size: 0.9rem;
}

.error-state i { font-size: 2rem; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 50px 20px;
  text-align: center;
}

.empty-icon { font-size: 2.5rem; margin-bottom: 10px; }

.empty-text {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* ===== HABIT CARDS (Today Page) ===== */
.today-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.today-counter {
  text-align: right;
  flex-shrink: 0;
  margin-left: 12px;
}

.today-count {
  font-size: 1.6rem;
  font-weight: 900;
  color: white;
  line-height: 1;
}

.today-pct {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.today-counter.perfect .today-count { color: #34d399; }

.perfect-banner {
  text-align: center;
  font-weight: 900;
  font-size: 0.9rem;
  color: #34d399;
  padding: 6px 0;
  animation: glow-pulse 2s ease-in-out infinite;
}

@keyframes glow-pulse {
  0%, 100% { text-shadow: 0 0 8px rgba(52, 211, 153, 0.4); }
  50% { text-shadow: 0 0 20px rgba(52, 211, 153, 0.8); }
}

.today-xp-line {
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  align-items: center;
}

.habit-stack { display: flex; flex-direction: column; gap: 8px; }

.habit-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  transition: border-color 0.2s;
}

.habit-card.done {
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(124, 58, 237, 0.05);
}

.habit-card.missed-card {
  border-color: rgba(239, 68, 68, 0.25);
  background: rgba(239, 68, 68, 0.03);
}

.habit-toggle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2.5px solid #334155;
  background: var(--bg-card3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s ease;
  flex-shrink: 0;
  color: #475569;
}

.habit-toggle:hover { border-color: var(--purple-500); transform: scale(1.05); }
.habit-toggle:active { transform: scale(0.95); }
.habit-toggle.complete { background: #7c3aed; border-color: #a78bfa; color: white; }
.habit-toggle.missed { background: rgba(239, 68, 68, 0.15); border-color: #ef4444; color: #f87171; }

.habit-info { flex: 1; min-width: 0; }

.habit-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.habit-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}

.habit-subtitle {
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 2px;
  margin-bottom: 4px;
  line-height: 1.35;
  font-style: italic;
}

.habit-dots {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  align-items: center;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.dot.done { background: var(--purple-400); }
.dot.miss { background: #ef444466; border: 1px solid #ef444499; }
.dot.empty { background: var(--border); }

.habit-xp {
  flex-shrink: 0;
  text-align: right;
  min-width: 36px;
}

.xp-earn { font-size: 0.75rem; font-weight: 700; color: #34d399; }
.xp-loss { font-size: 0.75rem; font-weight: 700; color: #f87171; }
.xp-pend { font-size: 0.75rem; font-weight: 600; color: #475569; }

.today-tip {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  padding: 4px;
}

/* ===== HABIT MANAGEMENT ===== */
.habits-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.summary-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: white;
}

.summary-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 3px;
  font-weight: 600;
}

.habit-manage-list { display: flex; flex-direction: column; gap: 8px; }

.habit-manage-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.habit-manage-card:hover { border-color: var(--border-hover); }

.habit-manage-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.habit-manage-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: #e2e8f0;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.habit-manage-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 2px;
}

/* ===== STREAK BADGE ===== */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.streak-badge.high {
  background: rgba(167, 139, 250, 0.1);
  border-color: rgba(167, 139, 250, 0.35);
  color: #c4b5fd;
}

.streak-badge.max {
  background: rgba(245, 158, 11, 0.15);
  border-color: #f59e0b;
  color: #fcd34d;
  animation: glow-gold 2s ease-in-out infinite alternate;
}

@keyframes glow-gold {
  from { box-shadow: 0 0 4px rgba(245, 158, 11, 0.3); }
  to { box-shadow: 0 0 12px rgba(245, 158, 11, 0.6); }
}

/* ===== STREAK ROWS ===== */
.streak-list { display: flex; flex-direction: column; gap: 8px; }

.streak-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.streak-rank {
  font-size: 0.68rem;
  color: var(--text-dim);
  width: 20px;
  flex-shrink: 0;
}

.streak-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  color: #e2e8f0;
}

.streak-leaderboard { display: flex; flex-direction: column; gap: 10px; }
.streak-lb-row { display: flex; align-items: center; gap: 10px; }
.streak-lb-rank { font-size: 0.7rem; color: var(--text-dim); width: 24px; }
.streak-lb-name { flex: 1; font-size: 0.85rem; color: #e2e8f0; }

/* ===== HABIT ROW (Dashboard) ===== */
.habit-list { display: flex; flex-direction: column; gap: 8px; }
.habit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card2);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.danger-row {
  border-color: rgba(239, 68, 68, 0.2);
  background: rgba(239, 68, 68, 0.04);
}

.habit-row.clickable { cursor: pointer; }
.habit-row.clickable:hover { border-color: #ef4444; }
.habit-row-info { flex: 1; }
.habit-row-name { font-size: 0.82rem; font-weight: 600; color: #e2e8f0; }
.habit-row-meta { font-size: 0.68rem; margin-top: 2px; }

/* ===== XP LIST ===== */
.xp-list { display: flex; flex-direction: column; }
.xp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.xp-row:last-child { border-bottom: none; }
.xp-row-name {
  font-size: 0.77rem;
  color: #94a3b8;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 8px;
}
.xp-row-amount {
  font-size: 0.77rem;
  font-weight: 700;
  flex-shrink: 0;
}
.xp-row-amount.earn { color: #34d399; }
.xp-row-amount.spend { color: #f87171; }

/* ===== TODO CHIPS ===== */
.todo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.todo-chip {
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: #94a3b8;
  padding: 4px 10px;
  border-radius: 9999px;
}

.todo-chip.muted { color: var(--text-dim); }

.perfect-day-card {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.04);
}

/* ===== QUEST CARDS ===== */
.quest-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tab-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim);
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.tab-btn:hover { background: var(--bg-card2); color: var(--text); }
.tab-btn.active { background: rgba(124, 58, 237, 0.15); color: var(--purple-400); }

.tab-content { display: flex; flex-direction: column; gap: 8px; }
.tab-content.hidden { display: none; }

.quest-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  transition: border-color 0.15s;
}

.quest-card:hover { border-color: rgba(59, 130, 246, 0.4); }
.quest-card.completed { opacity: 0.55; cursor: default; }
.quest-card.completed:hover { border-color: var(--border); }

.quest-info { flex: 1; min-width: 0; }
.quest-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}
.quest-name.done-text { text-decoration: line-through; color: #64748b; }
.quest-notes {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.quest-xp { flex-shrink: 0; text-align: right; }
.xp-reward {
  font-size: 1rem;
  font-weight: 800;
  color: #fcd34d;
}
.xp-earned {
  font-size: 0.88rem;
  font-weight: 700;
  color: #34d399;
}
.quest-status.active {
  font-size: 0.65rem;
  color: #60a5fa;
  font-weight: 600;
  margin-top: 2px;
}

/* ===== COLLECTION CARDS ===== */
.collection-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  cursor: pointer;
  transition: border-color 0.15s;
}

.collection-card:hover { border-color: rgba(124, 58, 237, 0.4); }

.collection-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.collection-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}

.collection-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.collection-next-milestone {
  font-size: 0.7rem;
  color: var(--purple-400);
  margin-top: 6px;
}

/* ===== CAREER ===== */
.career-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.career-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.career-source {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.career-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e2e8f0;
}

.career-stats { text-align: right; }

/* ===== PROGRESS BAR ===== */
.progress-track {
  background: var(--bg-card2);
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
  height: 6px;
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.8s ease;
}

/* ===== PROGRAMS ===== */
.program-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
}

.program-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.program-name {
  font-size: 1rem;
  font-weight: 700;
  color: white;
}

.program-dates {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.program-stats { text-align: right; }
.program-xp { font-size: 0.9rem; font-weight: 700; }
.program-days-stat { font-size: 0.68rem; color: var(--text-dim); }

.program-habits {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.program-habit-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prog-habit-name {
  font-size: 0.72rem;
  color: #94a3b8;
  width: 100px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.program-compliance-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.program-habit-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-card2);
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  color: #e2e8f0;
  transition: background 0.15s;
}

.program-habit-check:hover { background: #334155; }

/* ===== REWARDS ===== */
.xp-balance-card {
  background: linear-gradient(135deg, #1a1200, #0f172a);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.balance-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.balance-value {
  font-size: 2.5rem;
  font-weight: 900;
  line-height: 1;
}

.balance-breakdown {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.reward-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s;
}

.reward-card.affordable {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.03);
}

.reward-card.locked { opacity: 0.75; }

.reward-top { flex: 1; }
.reward-name { font-size: 0.88rem; font-weight: 600; color: #e2e8f0; }
.reward-desc { font-size: 0.7rem; color: var(--text-dim); margin-top: 3px; }
.reward-price { font-size: 0.7rem; color: var(--text-dim); margin-top: 3px; }

.reward-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reward-xp-cost {
  font-size: 1.1rem;
  font-weight: 900;
  color: #fcd34d;
}

.reward-locked-msg {
  font-size: 0.65rem;
  color: var(--text-dim);
}

.reward-purchased {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reward-date { font-size: 0.68rem; color: var(--text-dim); }

/* ===== LEDGER ===== */
.ledger-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.ledger-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.ledger-stat-val {
  font-size: 1.3rem;
  font-weight: 900;
}

.ledger-stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 600;
}

.ledger-entries { display: flex; flex-direction: column; gap: 4px; }

.ledger-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  background: var(--bg-card2);
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.1s;
}

.ledger-entry:hover { border-color: var(--border-hover); }
.ledger-entry-info { flex: 1; min-width: 0; }
.ledger-entry-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #cbd5e1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-entry-meta {
  font-size: 0.65rem;
  color: var(--text-dim);
  margin-top: 2px;
}
.ledger-type {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 600;
  background: var(--bg-card);
}
.ledger-type.habit { color: #a78bfa; }
.ledger-type.quest, .ledger-type.quest_complete { color: #60a5fa; }
.ledger-type.reward_spend { color: #f87171; }
.ledger-type.collection, .ledger-type.collection_milestone { color: #34d399; }
.ledger-type.career { color: #fb923c; }
.ledger-type.program { color: #38bdf8; }
.ledger-type.manual { color: #94a3b8; }

.ledger-entry-amount {
  font-size: 0.82rem;
  font-weight: 700;
  flex-shrink: 0;
}
.ledger-entry-amount.earn { color: #34d399; }
.ledger-entry-amount.spend { color: #f87171; }

/* ===== ANALYTICS ===== */
.analytics-source-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}

@media (min-width: 480px) {
  .analytics-source-wrap {
    flex-direction: row;
    align-items: flex-start;
  }
}

.source-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.source-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.source-label {
  flex: 1;
  font-size: 0.78rem;
  color: #94a3b8;
  text-transform: capitalize;
}

.source-xp {
  font-size: 0.78rem;
  font-weight: 700;
  color: #34d399;
}

.compliance-list { display: flex; flex-direction: column; gap: 12px; }

.compliance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.compliance-info { flex: 1; }
.compliance-name { font-size: 0.85rem; font-weight: 600; color: #e2e8f0; }
.compliance-meta { font-size: 0.68rem; color: var(--text-dim); margin-top: 2px; }

.compliance-pct {
  font-size: 1rem;
  font-weight: 900;
  margin-left: 12px;
}

.compliance-pct.good { color: #34d399; }
.compliance-pct.ok { color: #fbbf24; }
.compliance-pct.low { color: #f87171; }

/* ===== SETTINGS ===== */
.xp-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.xp-breakdown-item {
  text-align: center;
  padding: 10px;
  background: var(--bg-card2);
  border-radius: 10px;
}

.xp-breakdown-val {
  font-size: 1.1rem;
  font-weight: 800;
}

.xp-breakdown-label {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.titles-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 280px;
  overflow-y: auto;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--bg-card2);
  border-radius: 8px;
  font-size: 0.75rem;
}

.title-row.achieved { border-left: 3px solid var(--purple-400); }
.title-level { color: var(--text-dim); width: 36px; flex-shrink: 0; }
.title-name { flex: 1; color: #cbd5e1; font-weight: 500; }
.title-xp { color: var(--purple-400); font-weight: 700; }
.title-check { color: #34d399; font-size: 0.8rem; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  padding: 0;
}

.modal-overlay.open { opacity: 1; }

@media (min-width: 640px) {
  .modal-overlay { align-items: center; padding: 20px; }
  .modal-overlay.wide .modal-sheet { max-width: 560px; }
}

.modal-sheet {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 20px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s ease;
}

.modal-overlay.open .modal-sheet { transform: translateY(0); }

@media (min-width: 640px) {
  .modal-sheet {
    border-radius: 20px;
    max-width: 480px;
    transform: scale(0.96);
  }
  .modal-overlay.open .modal-sheet { transform: scale(1); }
  .modal-overlay.wide .modal-sheet { max-width: 560px; }
}

.modal-content { display: flex; flex-direction: column; gap: 16px; }

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

.modal-header h3 {
  font-size: 1.05rem;
  font-weight: 800;
  color: white;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.15s;
}

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

/* ===== FORMS ===== */
.form-stack { display: flex; flex-direction: column; gap: 14px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }

.form-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  color: var(--text);
  width: 100%;
  transition: border-color 0.15s;
  outline: none;
}

.form-input:focus { border-color: var(--purple-500); }

textarea.form-input { resize: vertical; }

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 16px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); }

.btn-primary {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: white;
}
.btn-success:hover:not(:disabled) { background: linear-gradient(135deg, #10b981, #059669); }

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.25);
}
.btn-danger:hover:not(:disabled) { background: rgba(239, 68, 68, 0.25); }

.btn-ghost {
  background: var(--bg-card2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: #334155; color: var(--text); }

.btn-gold {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: white;
}
.btn-gold:hover:not(:disabled) { background: linear-gradient(135deg, #f59e0b, #d97706); }

.btn-sm {
  padding: 7px 12px;
  font-size: 0.78rem;
  border-radius: 8px;
}

.btn-xs {
  padding: 4px 8px;
  font-size: 0.7rem;
  border-radius: 6px;
}

.w-full { width: 100%; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-2 { margin-top: 8px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.flex-1 { flex: 1; }
.hidden { display: none !important; }
.space-y-2 > * + * { margin-top: 8px; }
.space-y-3 > * + * { margin-top: 12px; }

/* ===== CHART ===== */
.chart-wrap {
  position: relative;
  height: 160px;
  width: 100%;
}

/* ===== COLLECTION ITEMS ===== */
.milestone-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}

.milestone-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 9999px;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.milestone-chip.achieved {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

.collection-items-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 420px;
  overflow-y: auto;
  margin-top: 8px;
  padding-right: 2px;
}

.group-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--border);
}

.collection-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--bg-card2);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  border: 1px solid transparent;
}

.collection-item:hover { background: #334155; }
.collection-item.completed { opacity: 0.7; }
.collection-item.set-bonus { border-color: rgba(234, 179, 8, 0.2); background: rgba(234, 179, 8, 0.04); }

.item-rank {
  font-size: 0.65rem;
  color: var(--text-dim);
  width: 28px;
  flex-shrink: 0;
}

.item-name {
  flex: 1;
  font-size: 0.8rem;
  color: #cbd5e1;
}

.item-xp {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-dim);
}

.item-xp.earned { color: #34d399; }

.item-check {
  font-size: 1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.set-bonus-badge {
  font-size: 0.6rem;
  font-weight: 700;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border-radius: 4px;
  padding: 2px 5px;
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 600;
  z-index: 9999;
  opacity: 0;
  transition: all 0.25s ease;
  max-width: 320px;
  text-align: center;
  white-space: pre-wrap;
  word-break: break-word;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.success { border-color: rgba(16, 185, 129, 0.5); color: #34d399; }
.toast.error { border-color: rgba(239, 68, 68, 0.5); color: #f87171; }
.toast.gold { border-color: rgba(245, 158, 11, 0.5); color: #fcd34d; }

/* ===== XP POP ===== */
.xp-pop {
  position: fixed;
  font-size: 0.85rem;
  font-weight: 900;
  color: #a78bfa;
  pointer-events: none;
  z-index: 9999;
  text-shadow: 0 0 10px rgba(167, 139, 250, 0.5);
  animation: float-up 1.6s ease-out forwards;
  transform: translateX(-50%);
}

@keyframes float-up {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-60px); }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 9999px; }

/* ===== MOBILE ===== */
@media (max-width: 767px) {
  .sidebar-nav { display: none; }
  .bottom-nav { display: flex; }
  .main-content { margin-left: 0; padding-bottom: var(--bottom-nav-h); }

  .toast { bottom: calc(var(--bottom-nav-h) + 12px); }
  .xp-pop { }

  .rewards-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid { gap: 8px; }
  .stat-value { font-size: 1.2rem; }
  .character-title { font-size: 1.2rem; }
}

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

/* ===== UTILITIES ===== */
.text-emerald-400 { color: #34d399 !important; }
.text-red-400 { color: #f87171 !important; }
.text-yellow-400 { color: #fbbf24 !important; }
.text-blue-400 { color: #60a5fa !important; }
.text-purple-400 { color: #c084fc !important; }
.text-gray-400 { color: #9ca3af !important; }
.text-gray-500 { color: #6b7280 !important; }
.text-white { color: #fff !important; }
.font-bold { font-weight: 700 !important; }
.font-black { font-weight: 900 !important; }
.text-xs { font-size: 0.75rem !important; }
.text-sm { font-size: 0.875rem !important; }
.text-base { font-size: 1rem !important; }
.text-lg { font-size: 1.125rem !important; }
.text-xl { font-size: 1.25rem !important; }
.text-2xl { font-size: 1.5rem !important; }
.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.uppercase { text-transform: uppercase !important; }
.capitalize { text-transform: capitalize !important; }
.tracking-wider { letter-spacing: 0.05em !important; }
.tracking-widest { letter-spacing: 0.1em !important; }
.line-through { text-decoration: line-through !important; }
.opacity-70 { opacity: 0.7 !important; }
.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-6 { padding-top: 24px; padding-bottom: 24px; }
.px-1 { padding-left: 4px; padding-right: 4px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.p-4 { padding: 16px; }
.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.mr-1 { margin-right: 4px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.flex-wrap { flex-wrap: wrap; }
.min-w-0 { min-width: 0; }
.flex-shrink-0 { flex-shrink: 0; }
.overflow-hidden { overflow: hidden; }
.overflow-y-auto { overflow-y: auto; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rounded { border-radius: 4px; }
.rounded-lg { border-radius: 8px; }
.rounded-full { border-radius: 9999px; }
.border-b { border-bottom: 1px solid var(--border); }
.last\:border-0:last-child { border-bottom: none !important; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: 1fr 1fr; }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.max-h-60 { max-height: 15rem; }
.max-h-64 { max-height: 16rem; }
.max-h-96 { max-height: 24rem; }
.space-y-1 > * + * { margin-top: 4px; }
.space-y-1\.5 > * + * { margin-top: 6px; }

/* ===== ADDITIONAL RESPONSIVE / UTILITY ===== */
.space-y-4 > * + * { margin-top: 16px; }
.space-y-6 > * + * { margin-top: 24px; }
.mt-1 { margin-top: 4px; }
.mb-1 { margin-bottom: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.pr-1 { padding-right: 4px; }
.mr-2 { margin-right: 8px; }
.text-4xl { font-size: 2.25rem !important; }
.accent-purple-500 { accent-color: #8b5cf6; }

/* Sticky sidebar scroll */
@media (min-width: 768px) {
  .sidebar-nav::-webkit-scrollbar { display: none; }
}

/* Better focus styles */
button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--purple-500);
  outline-offset: 2px;
}

/* Improved chart containers */
.chart-wrap canvas { display: block; }

/* Loading screen (initial page load) */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  z-index: 9999;
  gap: 16px;
  transition: opacity 0.4s ease;
}

#loading-screen.fade-out { opacity: 0; pointer-events: none; }

.loading-logo {
  font-size: 3rem;
  animation: pulse-logo 1.5s ease-in-out infinite;
}

@keyframes pulse-logo {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.loading-title {
  font-size: 1rem;
  font-weight: 900;
  color: var(--purple-400);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.loading-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* Program habit check - larger touch target */
.program-habit-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

/* Better reward card on small screens */
@media (max-width: 480px) {
  .rewards-grid { grid-template-columns: 1fr; }
  .xp-balance-card { flex-direction: column; gap: 12px; }
  .balance-breakdown { text-align: left; }
  .balance-value { font-size: 2rem; }
}

/* Analytics specific */
.analytics-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

@media (min-width: 480px) {
  .analytics-kpi-grid { grid-template-columns: repeat(4, 1fr); }
}

.analytics-kpi {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
}

.analytics-kpi-val {
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
}

.analytics-kpi-label {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Subtle separator */
.sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Link-style button */
.btn-link {
  background: none;
  border: none;
  color: var(--purple-400);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Danger zone / at-risk highlighting */
.text-orange-400 { color: #fb923c !important; }
.text-orange-300 { color: #fdba74 !important; }

/* Better mobile nav icon sizing */
@media (max-width: 380px) {
  .nav-item { padding: 6px 8px; }
  .nav-item i { font-size: 1rem; }
  .nav-item span { font-size: 0.55rem; }
}

/* Quest summary identical to habit summary */
.quest-summary .summary-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

/* Flex utilities */
.flex-end { justify-content: flex-end; }
.items-end { align-items: flex-end; }

/* Programs detail modal */
.prog-day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 3px;
}

.prog-day-dot {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  cursor: default;
}

.prog-day-dot.perfect { background: rgba(124,58,237,0.25); color: #a78bfa; }
.prog-day-dot.partial { background: rgba(245,158,11,0.15); color: #fcd34d; }
.prog-day-dot.miss { background: rgba(239,68,68,0.1); color: #f87171; }

/* Modal wide override */
@media (min-width: 640px) {
  .modal-overlay.wide .modal-sheet { max-width: 600px; }
}

/* Textarea placeholder */
textarea::placeholder, input::placeholder { color: var(--text-dim); }

/* Milestone label wrap fix */
.collection-next-milestone {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ============================================================
   STYLES v2.1 ADDITIONS
   ============================================================ */

/* Streak right-aligned in dashboard */
.streak-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.streak-label-best {
  font-size: 0.6rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* XP row with date */
.xp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(30,41,59,0.6);
}
.xp-row:last-child { border-bottom: none; }
.xp-row-name {
  flex: 1;
  font-size: 0.8rem;
  color: #cbd5e1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.xp-row-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-shrink: 0;
}
.xp-row-amount {
  font-size: 0.85rem;
  font-weight: 800;
  flex-shrink: 0;
}
.xp-row-amount.earn { color: var(--emerald); }
.xp-row-amount.spend { color: var(--red); }

/* History banner in Today page */
.history-banner {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #fcd34d;
}

/* Ledger filter bar */
.ledger-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.ledger-filter-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ledger-filter-btn:hover { border-color: var(--purple-400); color: var(--purple-400); }
.ledger-filter-btn.active {
  background: rgba(124, 58, 237, 0.15);
  border-color: var(--purple-400);
  color: var(--purple-400);
}

/* Ledger type badge inline */
.ledger-type {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(30,41,59,0.8);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

/* Streak lb right */
.streak-lb-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

/* Analytics source wrap flex */
.analytics-source-wrap {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
@media (min-width: 500px) {
  .analytics-source-wrap {
    flex-direction: row;
    align-items: flex-start;
  }
}
.source-legend {
  flex: 1;
  width: 100%;
}

/* Compliance list */
.compliance-list { display: flex; flex-direction: column; gap: 14px; }
.compliance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.compliance-info { flex: 1; }
.compliance-name { font-size: 0.85rem; font-weight: 600; color: #e2e8f0; }
.compliance-meta { font-size: 0.72rem; color: var(--text-dim); margin-top: 1px; }
.compliance-pct {
  font-size: 1.1rem;
  font-weight: 900;
  margin-left: 12px;
}
.compliance-pct.good { color: var(--emerald); }
.compliance-pct.ok { color: var(--gold); }
.compliance-pct.low { color: var(--red); }

/* Program habit row with percent */
.program-habit-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.prog-habit-name {
  font-size: 0.72rem;
  color: var(--text-muted);
  min-width: 100px;
  max-width: 120px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

/* Today XP line enhanced */
.today-xp-line {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0 2px;
}

/* Quest notes clamp */
.quest-notes {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 3px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Reward purchased card */
.reward-purchased {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-card2);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.reward-date { font-size: 0.7rem; color: var(--text-dim); margin-top: 1px; }

/* Better mobile Today page */
@media (max-width: 480px) {
  .today-header { gap: 8px; }
  .habit-card { padding: 10px 12px; gap: 10px; }
  .habit-toggle { width: 36px; height: 36px; font-size: 0.95rem; }
  .habit-dots .dot { width: 9px; height: 9px; }
}

/* Source row in analytics */
.source-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.78rem;
}
.source-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.source-label {
  flex: 1;
  color: var(--text);
  text-transform: capitalize;
  font-weight: 500;
}
.source-xp {
  font-weight: 700;
  color: var(--emerald);
}

/* Ledger summary 4-col */
.ledger-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
@media (min-width: 480px) {
  .ledger-summary { grid-template-columns: repeat(4, 1fr); }
}

/* ============================================================
   FORGE TOTALS PAGE
   ============================================================ */

/* Goal card grid — side by side on mobile */
.ft-goal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 480px) {
  .ft-goal-grid { grid-template-columns: 1fr; }
}

.ft-goal-card {
  background: var(--bg-card);
  border-radius: 14px;
  padding: 16px;
  border: 1px solid var(--border);
}
.ft-goal-weight { border-top: 3px solid #f97316; }
.ft-goal-cardio { border-top: 3px solid #22d3ee; }

.ft-goal-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}
.ft-goal-icon {
  font-size: 1.25rem;
  margin-top: 2px;
}
.ft-goal-weight .ft-goal-icon { color: #f97316; }
.ft-goal-cardio .ft-goal-icon { color: #22d3ee; }

.ft-goal-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.ft-goal-target {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.ft-goal-pct {
  margin-left: auto;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--text);
  white-space: nowrap;
}

/* Progress bar */
.ft-progress-bar-track {
  height: 10px;
  background: var(--bg-card2);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 12px;
}
.ft-progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
}
.ft-fill-weight { background: linear-gradient(90deg, #ea580c, #f97316, #fb923c); }
.ft-fill-cardio { background: linear-gradient(90deg, #0891b2, #22d3ee, #67e8f9); }

/* Goal stats row */
.ft-goal-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 8px;
}
.ft-goal-stat-val {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.1;
}
.ft-goal-stat-lbl {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ft-weight-color { color: #f97316; }
.ft-cardio-color { color: #22d3ee; }

.ft-pace-line {
  font-size: 0.72rem;
  margin-top: 4px;
}
.ft-pace-ahead { color: #34d399; font-weight: 600; }
.ft-pace-behind { color: #f87171; font-weight: 600; }

/* Quick Add Card */
.ft-add-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.ft-add-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.ft-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 400px) {
  .ft-form-grid { grid-template-columns: 1fr; }
}
.ft-form-notes { grid-column: 1 / -1; }

.ft-form-group { display: flex; flex-direction: column; gap: 4px; }
.ft-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ft-optional { font-weight: 400; font-style: italic; text-transform: none; }

.ft-input {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  font-size: 0.9rem;
  width: 100%;
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s;
}
.ft-input:focus { border-color: #f97316; }
.ft-input::placeholder { color: var(--text-muted); }
.ft-input[type="date"]::-webkit-calendar-picker-indicator { filter: invert(0.6); }

.ft-btn-add {
  width: 100%;
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.03em;
  transition: opacity 0.15s, transform 0.1s;
}
.ft-btn-add:active { opacity: 0.85; transform: scale(0.98); }

/* Section cards */
.ft-section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}
.ft-section-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

/* Monthly table */
.ft-monthly-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.ft-monthly-table th {
  text-align: left;
  padding: 5px 6px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.72rem;
  border-bottom: 1px solid var(--border);
}
.ft-monthly-table td { padding: 7px 6px; }
.ft-monthly-table tr + tr { border-top: 1px solid var(--border-subtle, #1e293b); }
.ft-mo-name { font-weight: 600; color: var(--text); }
.ft-mo-val  { color: var(--text); text-align: right; }
.ft-mo-cnt  { color: var(--text-muted); text-align: right; }
.ft-empty-cell { text-align: center; color: var(--text-muted); padding: 16px; }
.ft-monthly-total td {
  font-weight: 700;
  color: var(--text);
  border-top: 2px solid var(--border);
  padding-top: 8px;
}

/* Entry cards */
.ft-entry-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle, #1e293b);
}
.ft-entry-card:last-child { border-bottom: none; }
.ft-entry-card.ft-editing {
  flex-direction: column;
  align-items: stretch;
  background: var(--bg-card2);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 6px;
  border-bottom: none;
}

.ft-entry-date {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 80px;
  white-space: nowrap;
}
.ft-entry-stats {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.ft-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 0.78rem;
  font-weight: 600;
}
.ft-weight-chip { background: rgba(249,115,22,0.15); color: #fb923c; }
.ft-cardio-chip { background: rgba(34,211,238,0.12); color: #22d3ee; }
.ft-entry-notes {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
  width: 100%;
}
.ft-entry-btns {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.ft-icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  padding: 5px 7px;
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.15s;
}
.ft-icon-btn:hover { color: var(--text); border-color: var(--text-muted); }
.ft-delete-btn:hover { color: #f87171; border-color: #f87171; }

/* Edit form inside entry card */
.ft-edit-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.ft-input-notes { grid-column: 1 / -1; }
.ft-entry-actions {
  display: flex;
  gap: 8px;
}
.ft-btn-save {
  flex: 1;
  background: #059669;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px;
  font-size: 0.83rem;
  font-weight: 700;
  cursor: pointer;
}
.ft-btn-cancel {
  flex: 1;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px;
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
}

.ft-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 24px 0;
}
