/* =============================================
   Financial Intelligence Engine — Stylesheet
   Clean, modern dark theme with glassmorphism
   ============================================= */

/* ─── CSS Variables ──────────────────────── */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #1e293b;
    --bg-card-hover: #283548;
    --bg-input: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-light: rgba(59, 130, 246, 0.15);
    --success: #22c55e;
    --success-light: rgba(34, 197, 94, 0.15);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.15);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.15);
    --border: #334155;
    --border-light: #475569;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.2s ease;
}

/* ─── Reset & Base ───────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-hover); }

/* ─── Typography ─────────────────────────── */
h1 { font-size: 1.875rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 600; }
h3 { font-size: 1.25rem; font-weight: 600; }
h4 { font-size: 1.1rem; font-weight: 500; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-accent { color: var(--accent); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* ─── Layout ─────────────────────────────── */
.app-container {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    max-width: 1400px;
}

.page-header {
    margin-bottom: 2rem;
}
.page-header h1 { margin-bottom: 0.25rem; }
.page-header p { color: var(--text-secondary); }

/* ─── Navbar / Sidebar ───────────────────── */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 260px;
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 1.5rem 1.5rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.sidebar-brand h2 {
    font-size: 1.1rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-brand .brand-icon { font-size: 1.4rem; }

.sidebar-nav { flex: 1; padding: 0 0.75rem; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: var(--transition);
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
}
.nav-item:hover { background: var(--accent-light); color: var(--text-primary); }
.nav-item.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.nav-item .nav-icon { font-size: 1.2rem; width: 24px; text-align: center; }

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
}
.sidebar-footer .user-info { font-size: 0.85rem; color: var(--text-secondary); }
.sidebar-footer .user-name { color: var(--text-primary); font-weight: 500; }

/* ─── Cards ──────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}
.card:hover { border-color: var(--border-light); }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-secondary); }

/* ─── KPI Cards ──────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.kpi-label {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}
.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}
.kpi-change {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* ─── Charts & Grids ────────────────────── */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}
.chart-card canvas { max-height: 300px; }

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

/* ─── Tables ─────────────────────────────── */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
thead { background: var(--bg-secondary); }
th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}
td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}
tr:hover td { background: rgba(255,255,255,0.02); }
tr:last-child td { border-bottom: none; }

/* ─── Badges ─────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-accent { background: var(--accent-light); color: var(--accent); }
.badge-neutral { background: rgba(148,163,184,0.15); color: var(--text-secondary); }

/* ─── Forms ──────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}
.form-input,
.form-select {
    width: 100%;
    padding: 0.65rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}
.form-input:focus,
.form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-input::placeholder { color: var(--text-muted); }

/* .form-control — alias used by budget/goals modals */
.form-control {
    width: 100%;
    padding: 0.65rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: auto; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

textarea.form-input {
    resize: vertical;
    min-height: 80px;
}

/* ─── Buttons ────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
    background: rgba(255,255,255,0.05);
    border-color: var(--border-light);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
.btn-danger:hover:not(:disabled) { opacity: 0.9; }

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }
.btn-block { width: 100%; }

/* ─── Auth Pages ─────────────────────────── */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}
.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.auth-card h1 {
    text-align: center;
    margin-bottom: 0.5rem;
}
.auth-card .auth-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}
.auth-card .auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ─── Upload Area ────────────────────────── */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}
.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-light);
}
.upload-icon { font-size: 3rem; margin-bottom: 1rem; color: var(--text-muted); }
.upload-text { font-size: 1rem; color: var(--text-secondary); margin-bottom: 0.5rem; }
.upload-hint { font-size: 0.8rem; color: var(--text-muted); }

/* ─── Progress Bar ───────────────────────── */
.progress-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 999px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.5s ease;
    background: var(--accent);
}
.progress-fill.over { background: var(--danger); }
.progress-fill.warning { background: var(--warning); }

/* ─── Chat Interface ─────────────────────── */
.chat-container {
    display: flex;
    gap: 1.5rem;
    height: calc(100vh - 200px);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    line-height: 1.6;
}
.message.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: 4px;
}
.message.assistant {
    align-self: flex-start;
    background: var(--bg-input);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}
.message.assistant pre {
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 4px;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.8rem;
}

.chat-input-area {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}
.chat-input {
    flex: 1;
    padding: 0.65rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}
.chat-input:focus { border-color: var(--accent); }

.chat-sidebar {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ─── Loading States ─────────────────────── */
.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
    background: linear-gradient(90deg, var(--bg-input) 25%, var(--border) 50%, var(--bg-input) 75%);
    background-size: 200% 100%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}
@keyframes skeleton-pulse { 0%{background-position:200%} 100%{background-position:-200%} }

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.75rem 1rem;
}
.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* ─── Alerts ─────────────────────────────── */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.alert-danger { background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.alert-warning { background: var(--warning-light); color: var(--warning); border: 1px solid rgba(245,158,11,0.3); }
.alert-info { background: var(--accent-light); color: var(--accent); border: 1px solid rgba(59,130,246,0.3); }

/* ─── Budget Specific ────────────────────── */
.budget-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}
.budget-info { flex: 1; }
.budget-category { font-weight: 600; margin-bottom: 0.25rem; }
.budget-amounts { font-size: 0.85rem; color: var(--text-secondary); }
.budget-bar { flex: 2; }
.budget-actions { display: flex; gap: 0.5rem; }

/* ─── Goals Specific ─────────────────────── */
.goal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.goal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}
.goal-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-top: 1rem;
    font-size: 0.85rem;
}
.goal-stat-label { color: var(--text-muted); font-size: 0.75rem; }
.goal-stat-value { font-weight: 600; }

/* ─── Empty States ───────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-title { font-size: 1.1rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.5rem; }

/* ─── Responsive ─────────────────────────── */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; padding: 1rem; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .chat-container { flex-direction: column; height: auto; }
    .chat-sidebar { width: 100%; }
    .goal-stats { grid-template-columns: 1fr 1fr; }
}

/* ─── Utilities ──────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-2 { padding: 1rem; }
.hidden { display: none !important; }
.w-full { width: 100%; }

/* ─── Gamification Hub ────────────────────── */

/* Level & XP Hero Card */
.hub-hero {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
}
.hub-hero::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 180px; height: 180px;
    background: radial-gradient(circle, rgba(59,130,246,0.15), transparent);
    border-radius: 50%;
}
.hub-avatar {
    font-size: 3.5rem;
    background: var(--bg-input);
    width: 80px; height: 80px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    border: 3px solid var(--accent);
    flex-shrink: 0;
    cursor: pointer;
    transition: var(--transition);
}
.hub-avatar:hover { transform: scale(1.08); border-color: var(--success); }
.hub-info { flex: 1; }
.hub-level-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 0.15rem;
}
.hub-xp-text { font-size: 0.85rem; color: var(--text-secondary); margin-top: 0.3rem; }

/* XP Bar */
.xp-bar-container {
    width: 100%;
    height: 14px;
    background: var(--bg-input);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 0.5rem;
    position: relative;
}
.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #818cf8);
    border-radius: 10px;
    transition: width 0.8s cubic-bezier(.4,0,.2,1);
    position: relative;
}
.xp-bar-fill::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    animation: xpShimmer 2s infinite;
}
@keyframes xpShimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Stats row */
.hub-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.hub-stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    text-align: center;
}
.hub-stat-icon { font-size: 1.8rem; margin-bottom: 0.25rem; }
.hub-stat-value { font-size: 1.5rem; font-weight: 700; }
.hub-stat-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Streak flame */
.streak-flame { color: #ff6b35; }
.streak-flame.hot { animation: flamePulse 1.2s ease-in-out infinite; }
@keyframes flamePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Challenge Cards */
.challenge-list { display: flex; flex-direction: column; gap: 0.75rem; }
.challenge-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    transition: var(--transition);
}
.challenge-card:hover { border-color: var(--accent); background: var(--bg-card-hover); }
.challenge-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.challenge-type-badge {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-weight: 600;
}
.challenge-type-badge.weekly { background: var(--accent-light); color: var(--accent); }
.challenge-type-badge.monthly { background: rgba(139, 92, 246, 0.15); color: #a78bfa; }
.challenge-xp { font-size: 0.8rem; color: var(--warning); font-weight: 600; }
.challenge-title { font-weight: 600; margin-bottom: 0.25rem; }
.challenge-desc { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 0.6rem; }
.challenge-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-input);
    border-radius: 6px;
    overflow: hidden;
}
.challenge-progress-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.6s ease;
}
.challenge-progress-fill.good { background: var(--success); }
.challenge-progress-fill.warn { background: var(--warning); }
.challenge-progress-fill.danger { background: var(--danger); }
.challenge-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 0.35rem; font-size: 0.75rem; color: var(--text-muted); }

/* Achievement badges */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.75rem; }
.badge-item {
    display: flex; flex-direction: column; align-items: center;
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
}
.badge-item.unlocked { border-color: var(--warning); }
.badge-item.locked { opacity: 0.4; filter: grayscale(1); }
.badge-icon { font-size: 2rem; margin-bottom: 0.25rem; }
.badge-name { font-size: 0.72rem; font-weight: 600; line-height: 1.2; }
.badge-date { font-size: 0.6rem; color: var(--text-muted); }

/* Activity feed */
.activity-feed { display: flex; flex-direction: column; gap: 0.4rem; }
.activity-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
}
.activity-xp {
    font-weight: 700;
    color: var(--warning);
    min-width: 45px;
    text-align: right;
}
.activity-action { flex: 1; color: var(--text-secondary); }
.activity-time { font-size: 0.7rem; color: var(--text-muted); }

/* Hub layout */
.hub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
@media (max-width: 900px) {
    .hub-grid { grid-template-columns: 1fr; }
    .hub-hero { flex-direction: column; text-align: center; }
    .hub-stats { grid-template-columns: 1fr 1fr; }
}

/* Level up animation */
.level-up-toast {
    position: fixed;
    top: 2rem; right: 2rem;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: var(--shadow-lg);
    z-index: 10000;
    animation: slideInToast 0.5s ease, fadeOutToast 0.5s 3s ease forwards;
}
@keyframes slideInToast { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutToast { to { opacity: 0; transform: translateX(120%); } }

/* ─── Flashcards ──────────────────────────── */

.flashcard-stats-bar {
    display: flex; gap: 1.5rem; flex-wrap: wrap;
    margin-bottom: 2rem;
}
.flashcard-stat {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    flex: 1; min-width: 140px;
    text-align: center;
}
.flashcard-stat .stat-value {
    font-size: 1.8rem; font-weight: 800;
    background: linear-gradient(135deg, var(--accent), #818cf8);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.flashcard-stat .stat-label {
    font-size: .78rem; color: var(--text-secondary); margin-top: .25rem;
}

/* Deck grid */
.deck-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}
.deck-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all .25s ease;
    position: relative;
    overflow: hidden;
}
.deck-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(59,130,246,.15);
}
.deck-card .deck-icon {
    font-size: 2.2rem; margin-bottom: .75rem;
}
.deck-card .deck-title {
    font-weight: 700; font-size: 1.05rem; color: var(--text-primary);
}
.deck-card .deck-desc {
    font-size: .8rem; color: var(--text-secondary); margin: .4rem 0 .75rem;
    line-height: 1.4;
}
.deck-card .deck-meta {
    display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
    font-size: .72rem; color: var(--text-secondary);
}
.deck-card .deck-meta .badge {
    background: rgba(59,130,246,.15);
    color: var(--accent);
    padding: .15rem .5rem;
    border-radius: 999px;
    font-size: .7rem; font-weight: 600;
}
.deck-card .deck-meta .badge.due {
    background: rgba(245,158,11,.15);
    color: var(--warning);
}
.deck-card .deck-progress-bar {
    height: 4px;
    background: rgba(255,255,255,.08);
    border-radius: 2px;
    margin-top: .75rem;
    overflow: hidden;
}
.deck-card .deck-progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #818cf8);
    border-radius: 2px;
    transition: width .5s ease;
}

/* Review mode */
.review-container {
    max-width: 600px;
    margin: 0 auto;
}
.review-header {
    text-align: center;
    margin-bottom: 1.5rem;
}
.review-header h2 {
    font-size: 1.4rem; font-weight: 700;
}
.review-progress {
    display: flex; align-items: center; gap: .75rem;
    justify-content: center;
    margin-top: .5rem; font-size: .85rem; color: var(--text-secondary);
}
.review-progress-bar {
    width: 200px; height: 6px;
    background: rgba(255,255,255,.08);
    border-radius: 3px; overflow: hidden;
}
.review-progress-bar .fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--accent));
    transition: width .4s ease;
}

/* Flip card */
.flip-card-wrapper {
    perspective: 1000px;
    width: 100%;
    min-height: 320px;
    margin-bottom: 1.5rem;
    cursor: pointer;
}
.flip-card {
    width: 100%;
    min-height: 320px;
    position: relative;
    transition: transform 0.6s cubic-bezier(.4,.2,.2,1);
    transform-style: preserve-3d;
}
.flip-card.flipped {
    transform: rotateY(180deg);
}
.flip-card-front,
.flip-card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: var(--radius);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}
.flip-card-front {
    background: linear-gradient(135deg, var(--bg-secondary), rgba(59,130,246,.08));
    border: 1px solid rgba(59,130,246,.2);
}
.flip-card-back {
    background: linear-gradient(135deg, rgba(34,197,94,.08), var(--bg-secondary));
    border: 1px solid rgba(34,197,94,.2);
    transform: rotateY(180deg);
}
.flip-card-front .card-label {
    font-size: .75rem; color: var(--accent); font-weight: 600;
    letter-spacing: .5px; text-transform: uppercase;
    margin-bottom: 1rem;
}
.flip-card-back .card-label {
    font-size: .75rem; color: var(--success); font-weight: 600;
    letter-spacing: .5px; text-transform: uppercase;
    margin-bottom: 1rem;
}
.flip-card-front .card-text {
    font-size: 1.15rem; font-weight: 600; color: var(--text-primary);
    line-height: 1.5;
}
.flip-card-back .card-text {
    font-size: .95rem; color: var(--text-primary);
    line-height: 1.6;
}
.flip-card-front .card-hint {
    margin-top: 1rem;
    font-size: .8rem; color: var(--text-secondary);
    font-style: italic;
    opacity: 0; transition: opacity .3s;
}
.flip-card-front .card-hint.visible {
    opacity: 1;
}
.tap-hint {
    font-size: .75rem; color: var(--text-secondary);
    text-align: center; margin-top: -.75rem; margin-bottom: 1rem;
}

/* Quality rating buttons */
.quality-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .75rem;
}
.quality-btn {
    padding: .75rem .5rem;
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    text-align: center;
    transition: all .2s ease;
    font-size: .8rem;
}
.quality-btn:hover {
    transform: translateY(-2px);
}
.quality-btn .q-label { font-weight: 700; font-size: .9rem; display: block; }
.quality-btn .q-desc { font-size: .68rem; color: var(--text-secondary); }
.quality-btn.q-again { border-color: rgba(239,68,68,.3); }
.quality-btn.q-again:hover { background: rgba(239,68,68,.15); border-color: var(--danger); }
.quality-btn.q-hard { border-color: rgba(245,158,11,.3); }
.quality-btn.q-hard:hover { background: rgba(245,158,11,.15); border-color: var(--warning); }
.quality-btn.q-good { border-color: rgba(59,130,246,.3); }
.quality-btn.q-good:hover { background: rgba(59,130,246,.15); border-color: var(--accent); }
.quality-btn.q-easy { border-color: rgba(34,197,94,.3); }
.quality-btn.q-easy:hover { background: rgba(34,197,94,.15); border-color: var(--success); }

/* Review complete */
.review-complete {
    text-align: center;
    padding: 3rem 1rem;
}
.review-complete .complete-icon {
    font-size: 4rem; margin-bottom: 1rem;
}
.review-complete h2 {
    font-size: 1.5rem; font-weight: 700; margin-bottom: .5rem;
}
.review-complete p {
    color: var(--text-secondary); margin-bottom: 1.5rem;
}
.review-complete .xp-earned {
    font-size: 1.2rem; font-weight: 700;
    color: var(--accent);
    margin-bottom: 1.5rem;
}

/* Back button in review mode */
.back-to-decks {
    display: inline-flex; align-items: center; gap: .5rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: .85rem;
    margin-bottom: 1.5rem;
    transition: color .2s;
}
.back-to-decks:hover { color: var(--accent); }

@media (max-width: 600px) {
    .deck-grid { grid-template-columns: 1fr; }
    .quality-buttons { grid-template-columns: repeat(2, 1fr); }
    .flashcard-stats-bar { gap: .75rem; }
    .flashcard-stat { min-width: 100px; padding: .75rem 1rem; }
    .flip-card-wrapper { min-height: 280px; }
    .flip-card { min-height: 280px; }
}


/* ─── Planning Suite ──────────────────────── */

/* Tab bar */
.suite-tabs {
    display: flex;
    gap: .5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid rgba(255,255,255,.06);
    padding-bottom: .5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.suite-tabs::-webkit-scrollbar { display: none; }
.suite-tab {
    display: flex; align-items: center; gap: .5rem;
    padding: .65rem 1.25rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: .9rem; font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: all .2s;
    white-space: nowrap;
    flex-shrink: 0;
}
.suite-tab:hover { color: var(--text-primary); background: rgba(255,255,255,.04); }
.suite-tab.active {
    color: var(--accent);
    background: rgba(59,130,246,.08);
    border-bottom: 2px solid var(--accent);
    margin-bottom: -2px;
}
.tab-icon { font-size: 1.15rem; }

/* Panels */
.suite-panel { display: none; }
.suite-panel.active { display: block; animation: fadeInPanel .3s ease; }
@keyframes fadeInPanel { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.panel-intro { margin-bottom: 1.5rem; }
.panel-intro h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: .25rem; }
.panel-intro p { color: var(--text-secondary); font-size: .88rem; }

/* Form grids */
.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.form-section {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.form-section h3 {
    font-size: .95rem; font-weight: 700;
    margin-bottom: 1rem;
    color: var(--text-primary);
}
.form-group { margin-bottom: .85rem; }
.form-group label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .78rem; font-weight: 500; color: var(--text-secondary);
    margin-bottom: .35rem;
}
.form-group input[type="number"],
.form-group input[type="text"],
.form-group select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .55rem .75rem;
    color: var(--text-primary);
    font-size: .88rem;
    font-family: 'JetBrains Mono', monospace;
    transition: border-color .2s;
}
.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.form-group .form-control {
    width: 100%;
}

/* Input with icon */
.input-icon {
    position: relative;
}
.input-icon span {
    position: absolute;
    left: .75rem; top: 50%; transform: translateY(-50%);
    color: var(--text-muted); font-size: .8rem; font-weight: 600;
    pointer-events: none;
}
.input-icon input {
    padding-left: 2rem !important;
}

/* Multi-column form rows */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; }

/* Slider */
.range-slider {
    width: 100%;
    -webkit-appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-input);
    outline: none;
    margin-top: .25rem;
}
.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-primary);
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.range-slider::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: 2px solid var(--bg-primary);
}
.slider-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-secondary);
}

/* Button helpers */
.btn-lg {
    padding: .8rem 2rem !important;
    font-size: .95rem !important;
    font-weight: 700 !important;
    margin-top: .5rem;
}

/* Debt rows */
.debt-row {
    display: grid;
    grid-template-columns: 2fr 1.2fr 0.8fr 0.8fr 1.2fr auto;
    gap: .5rem;
    align-items: center;
    margin-bottom: .5rem;
}
.debt-row input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .5rem .65rem;
    color: var(--text-primary);
    font-size: .82rem;
    font-family: 'JetBrains Mono', monospace;
}
.debt-row input:focus { outline: none; border-color: var(--accent); }
.debt-row input.auto-calc {
    background: rgba(59,130,246,.08);
    border-color: rgba(59,130,246,.3);
    color: var(--accent);
}
.btn-icon-delete {
    background: none;
    border: 1px solid rgba(239,68,68,.3);
    color: var(--danger);
    border-radius: var(--radius-sm);
    width: 32px; height: 32px;
    cursor: pointer;
    font-size: .85rem;
    transition: all .2s;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon-delete:hover { background: rgba(239,68,68,.15); }

/* Strategy comparison */
.strategy-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1.5rem;
}
.strategy-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    position: relative;
}
.strategy-card.recommended {
    border-color: var(--accent);
    box-shadow: 0 0 20px rgba(59,130,246,.12);
}
.strategy-badge {
    font-weight: 700; font-size: 1rem;
    margin-bottom: .75rem;
}
.strategy-stat { margin-bottom: .75rem; }
.strategy-stat .stat-big { font-size: 2rem; font-weight: 800; color: var(--text-primary); display: block; font-family: 'JetBrains Mono', monospace; }
.strategy-stat .stat-sub { font-size: .78rem; color: var(--text-secondary); }
.strategy-detail {
    display: flex; justify-content: space-between;
    font-size: .82rem; padding: .35rem 0;
    border-top: 1px solid rgba(255,255,255,.04);
    color: var(--text-secondary);
}
.strategy-rec {
    margin-top: .75rem;
    font-weight: 700; font-size: .82rem;
    color: var(--accent);
}

/* Recommendation card */
.recommendation-card {
    display: flex; align-items: center; gap: 1rem;
    background: rgba(59,130,246,.06);
    border: 1px solid rgba(59,130,246,.15);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-top: 1rem;
}
.rec-icon { font-size: 1.5rem; flex-shrink: 0; }
.rec-text { font-size: .88rem; color: var(--text-primary); line-height: 1.5; }

/* Readiness hero */
.readiness-hero {
    display: flex; align-items: center; gap: 2rem;
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-top: 1.5rem;
}
.readiness-ring-wrap {
    position: relative;
    width: 120px; height: 120px;
    flex-shrink: 0;
}
.readiness-ring { width: 100%; height: 100%; }
.readiness-score-text {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem; font-weight: 800;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}
.readiness-info { flex: 1; }
.readiness-label { font-size: 1.25rem; font-weight: 700; }
.readiness-sub { font-size: .85rem; color: var(--text-secondary); margin-top: .25rem; }

/* FIRE bars */
.fire-bars {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1rem;
}
.fire-bar-item { margin-bottom: .85rem; }
.fire-bar-item:last-child { margin-bottom: 0; }
.fire-bar-label {
    display: flex; justify-content: space-between; align-items: center;
    font-size: .82rem; color: var(--text-secondary);
    margin-bottom: .35rem;
}
.fire-bar-label span { font-family: 'JetBrains Mono', monospace; font-size: .78rem; font-weight: 600; }
.fire-bar-track {
    height: 10px;
    background: rgba(255,255,255,.06);
    border-radius: 5px;
    overflow: hidden;
}
.fire-bar-fill {
    height: 100%;
    border-radius: 5px;
    transition: width 1s ease;
}

/* Tips card */
.tips-card {
    background: var(--bg-secondary);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-top: 1rem;
}
.tips-card h3 { font-size: .95rem; margin-bottom: .75rem; }
.tips-card ul { list-style: none; padding: 0; }
.tips-card li {
    padding: .5rem 0;
    border-bottom: 1px solid rgba(255,255,255,.04);
    font-size: .85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}
.tips-card li:last-child { border-bottom: none; }
.tips-card li::before {
    content: '→ ';
    color: var(--accent);
    font-weight: 700;
}

/* Scenario KPIs */
.scenario-kpis { margin-top: 1.5rem; }

/* ─── Global Mobile Improvements ──────────── */

/* Mobile hamburger menu */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: .75rem; left: .75rem;
    z-index: 200;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 44px; height: 44px;
    font-size: 1.3rem;
    color: var(--text-primary);
    cursor: pointer;
    align-items: center; justify-content: center;
    box-shadow: var(--shadow);
}

@media (max-width: 768px) {
    .mobile-menu-toggle { display: flex; }
    .sidebar {
        display: none;
        position: fixed;
        z-index: 150;
        width: 260px;
    }
    .sidebar.open {
        display: flex;
    }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 140;
    }
    .sidebar-overlay.open { display: block; }

    .main-content {
        margin-left: 0 !important;
        padding: 1rem .75rem !important;
        padding-top: 3.5rem !important;
    }
    .page-header h1 { font-size: 1.35rem; }
    .page-header p { font-size: .82rem; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: .6rem; }
    .kpi-card { padding: .85rem 1rem; }
    .kpi-value { font-size: 1.35rem; }
    .kpi-label { font-size: .7rem; }
    .chart-grid { grid-template-columns: 1fr; }

    /* Planning Suite mobile */
    .form-grid-2col { grid-template-columns: 1fr; gap: 1rem; }
    .form-section { padding: 1rem; }
    .strategy-compare { grid-template-columns: 1fr; }
    .readiness-hero { flex-direction: column; text-align: center; padding: 1.25rem; gap: 1rem; }
    .suite-tab { padding: .5rem .85rem; font-size: .82rem; }
    .tab-icon { font-size: 1rem; }
    .btn-full-mobile { width: 100%; text-align: center; }
    .debt-row { grid-template-columns: 1fr 1fr; gap: .4rem; }
    .debt-row input { font-size: .78rem; padding: .45rem .55rem; }
    .debt-header { display: none !important; }
    .form-row-2 { grid-template-columns: 1fr 1fr; }
    .form-row-3 { grid-template-columns: 1fr; }

    /* Flashcard mobile */
    .flashcard-stats-bar { flex-wrap: wrap; gap: .5rem; }
    .flashcard-stat { flex: 1 1 calc(50% - .5rem); min-width: 0; }

    /* Hub mobile */
    .hub-hero { flex-direction: column; text-align: center; padding: 1.25rem; }
    .challenge-grid { grid-template-columns: 1fr; }
    .badge-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .form-row-2 { grid-template-columns: 1fr; }
    .debt-row { grid-template-columns: 1fr; }
    .debt-header { display: none !important; }
    .suite-tabs { gap: .25rem; }
    .suite-tab { padding: .45rem .65rem; font-size: .78rem; }
    .quality-buttons { grid-template-columns: repeat(2, 1fr); }
    .strategy-stat .stat-big { font-size: 1.5rem; }
}

/* ─── Mobile Bottom Tab Bar (Global) ────────── */
.bottom-tabs-global {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 200;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 0.25rem 0 env(safe-area-inset-bottom, 0.15rem);
}
.btab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.4rem 0;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.62rem;
    font-weight: 500;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.btab-icon { font-size: 1.2rem; line-height: 1; }
.btab-label { font-size: 0.6rem; }
.btab:hover, .btab.active { color: var(--accent); }
.btab.active .btab-icon { filter: drop-shadow(0 0 6px rgba(59,130,246,0.5)); }

.global-more-menu {
    display: none;
    position: fixed;
    bottom: 56px; left: 0; right: 0;
    z-index: 300;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 0.75rem;
    max-height: 55vh;
    overflow-y: auto;
}
.gmore-link {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.6rem 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-size: 0.82rem;
    text-decoration: none;
    transition: all 0.15s;
    cursor: pointer;
}
.gmore-link:hover {
    border-color: var(--accent);
    color: var(--text-primary);
    background: rgba(59,130,246,0.08);
}

@media (max-width: 768px) {
    .bottom-tabs-global {
        display: flex;
    }
}

