/* Dashboard layout — sidebar + main content */
:root {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-tertiary: #1a1a1a;
    --bg-hover: #222;
    --text-primary: #e5e5e5;
    --text-secondary: #999;
    --text-muted: #666;
    --accent: #FF6B35;
    --accent-hover: #ff8555;
    --border: #2a2a2a;
    --user-bubble: #FF6B35;
    --user-text: #fff;
    --assistant-bubble: #1e1e1e;
    --assistant-text: #e5e5e5;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 12px;
    --radius-sm: 8px;
    --sidebar-width: 260px;
}

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

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

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-primary);
}

.sidebar-brand .brand-emoji { font-size: 28px; }
.sidebar-brand h2 { font-size: 20px; font-weight: 700; }

.sidebar-nav {
    flex: 1;
    min-height: 0; /* allow this flex child to shrink below content so overflow can scroll */
    overflow-y: auto; /* scroll the nav when Crew sub-agents push it past the viewport */
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
}

.sidebar-nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav a.active { background: var(--accent); color: #fff; }
.sidebar-nav a .nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user img {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Main content area */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Mobile nav */
.mobile-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    z-index: 100;
    padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
}

.mobile-nav-inner {
    display: flex;
    justify-content: space-around;
}

.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
}

.mobile-nav a.active { color: var(--accent); }
.mobile-nav a .nav-icon { font-size: 20px; }

/* Mobile hamburger */
.mobile-header {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    z-index: 99;
    align-items: center;
    gap: 12px;
}

.mobile-header .brand-emoji { font-size: 24px; }
.mobile-header h2 { font-size: 18px; font-weight: 700; flex: 1; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-tertiary); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--bg-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn.loading { opacity: 0.6; pointer-events: none; }

/* Page header */
.page-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
}

.page-header h1 { font-size: 24px; font-weight: 700; }
.page-header p { color: var(--text-secondary); font-size: 14px; margin-top: 4px; }

/* Cards */
.card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 14px; }

/* Loading spinner */
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Responsive */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; padding-bottom: 70px; }
    .mobile-nav { display: block; }
    .mobile-header { display: flex; }
    .page-header { padding: 16px; padding-top: 68px; }
}

/* ============================================================
   Home dashboard (home.html / home.js)
   ============================================================ */
.home-wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 28px 60px; }

/* Hero */
.home-hero {
    display: flex; align-items: center; justify-content: space-between; gap: 20px;
    background: linear-gradient(135deg, rgba(255,107,53,0.14), rgba(255,107,53,0.02));
    border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px 24px; margin-bottom: 26px;
}
.home-hero-text h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.4px; }
.home-hero-sub { color: var(--text-secondary); font-size: 14px; margin-top: 6px; max-width: 640px; line-height: 1.5; }
.home-hero-cta {
    flex-shrink: 0; display: inline-flex; align-items: center; gap: 8px;
    background: var(--accent); color: #fff; text-decoration: none;
    padding: 11px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
    transition: background 0.15s, transform 0.05s;
}
.home-hero-cta:hover { background: var(--accent-hover); }
.home-hero-cta:active { transform: translateY(1px); }

/* Section titles */
.home-section-title {
    font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-secondary); margin: 26px 2px 14px; display: flex; align-items: center; gap: 8px;
}
.home-section-title i { color: var(--accent); font-size: 13px; }

/* Stat grid */
.home-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.home-stat {
    background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 16px 14px; text-decoration: none; color: var(--text-primary);
    display: flex; flex-direction: column; gap: 2px; transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.home-stat:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--bg-tertiary); }
.home-stat.accent { border-left: 3px solid var(--accent); }
.home-stat.muted { opacity: 0.82; }
.home-stat-ic { font-size: 16px; color: var(--accent); margin-bottom: 6px; }
.home-stat.muted .home-stat-ic { color: var(--text-secondary); }
.home-stat-v { font-size: 28px; font-weight: 800; line-height: 1.1; letter-spacing: -0.5px; }
.home-stat-l { font-size: 13px; font-weight: 600; }
.home-stat-s { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.home-stat-skeleton {
    height: 108px; border-radius: var(--radius); border: 1px solid var(--border);
    background: linear-gradient(90deg, var(--bg-secondary), var(--bg-tertiary), var(--bg-secondary));
    background-size: 200% 100%; animation: home-shimmer 1.3s infinite;
}
@keyframes home-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* Two-column row */
.home-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.home-card { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; }
.home-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.home-card-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
.home-card-head h3 i { color: var(--accent); font-size: 14px; }

/* Setup checklist */
.home-setup-progress { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.home-progress { height: 6px; background: var(--bg-tertiary); border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.home-progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.5s ease; }
.home-steps { display: flex; flex-direction: column; gap: 2px; }
.home-step { display: flex; align-items: center; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.home-step:last-child { border-bottom: none; }
.home-step-ring { width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 10px; color: #fff; }
.home-step.done .home-step-ring { background: var(--success); border-color: var(--success); }
.home-step-label { flex: 1; font-size: 13.5px; color: var(--text-primary); }
.home-step.done .home-step-label { color: var(--text-muted); text-decoration: line-through; }
.home-step-cta { flex-shrink: 0; background: transparent; border: 1px solid var(--accent); color: var(--accent); border-radius: 999px; padding: 4px 13px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.home-step-cta:hover { background: var(--accent); color: #fff; }

/* Recent wins */
.home-results { display: flex; flex-direction: column; gap: 2px; }
.home-result { display: flex; align-items: flex-start; gap: 11px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.home-result:last-child { border-bottom: none; }
.home-result-ic { font-size: 16px; flex-shrink: 0; line-height: 1.4; }
.home-result-t { font-size: 13.5px; font-weight: 500; }
.home-result-m { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.home-results-empty { text-align: center; color: var(--text-muted); font-size: 13px; line-height: 1.6; padding: 26px 10px; }
.home-results-empty-ic { font-size: 32px; margin-bottom: 8px; }

/* Learn / tour card */
.home-learn { display: flex; align-items: center; gap: 18px; margin-top: 16px; background: linear-gradient(120deg, rgba(255,107,53,0.10), var(--bg-secondary)); }
.home-learn-icon { width: 48px; height: 48px; flex-shrink: 0; border-radius: 12px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.home-learn-text { flex: 1; min-width: 0; }
.home-learn-text h3 { font-size: 15px; font-weight: 700; }
.home-learn-text p { font-size: 13px; color: var(--text-secondary); margin-top: 4px; line-height: 1.45; }
.home-learn-actions { display: flex; gap: 9px; flex-shrink: 0; }
.home-btn { text-decoration: none; padding: 9px 15px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; white-space: nowrap; }
.home-btn-primary { background: var(--accent); color: #fff; }
.home-btn-primary:hover { background: var(--accent-hover); }
.home-btn-ghost { border: 1px solid var(--border); color: var(--text-secondary); }
.home-btn-ghost:hover { border-color: var(--accent); color: var(--text-primary); }

/* Use-case gallery */
.home-usecases { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.home-uc {
    text-align: left; cursor: pointer; background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 3px;
    color: var(--text-primary); font-family: inherit; transition: border-color 0.15s, transform 0.1s, background 0.15s;
}
.home-uc:hover { border-color: var(--accent); transform: translateY(-2px); background: var(--bg-tertiary); }
.home-uc-ic { font-size: 22px; margin-bottom: 5px; }
.home-uc-l1 { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.home-uc-l2 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--accent); margin-top: 3px; }

@media (max-width: 860px) {
    .home-wrap { padding: 18px 16px 60px; }
    .home-hero { flex-direction: column; align-items: flex-start; gap: 14px; }
    .home-hero-cta { width: 100%; justify-content: center; }
    .home-cols { grid-template-columns: 1fr; }
    .home-learn { flex-direction: column; align-items: flex-start; }
    .home-learn-actions { width: 100%; }
    .home-btn { flex: 1; text-align: center; }
}
