/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #07080c;
    --bg-secondary: #0e1017;
    --bg-card: #12141c;
    --bg-card-hover: #181b26;
    --bg-surface: #1a1d2a;
    --border: #1f2335;
    --border-light: #2a2e42;
    --text-primary: #e8eaf0;
    --text-secondary: #8b90a5;
    --text-muted: #5c6078;
    --accent-primary: #6366f1;
    --accent-primary-light: #818cf8;
    --accent-secondary: #8b5cf6;
    --accent-success: #10b981;
    --accent-warning: #f59e0b;
    --accent-danger: #ef4444;
    --accent-info: #3b82f6;
    --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
    --gradient-success: linear-gradient(135deg, #10b981, #34d399);
    --gradient-danger: linear-gradient(135deg, #ef4444, #f87171);
    --gradient-warm: linear-gradient(135deg, #f59e0b, #fbbf24);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 40px rgba(99,102,241,0.15);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    min-height: 100vh;
}
.screen.active {
    display: block;
}

/* ===== NAVBAR ===== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    position: relative;
    z-index: 10;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-icon {
    font-size: 1.5rem;
}
.nav-title {
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
}
.nav-badge {
    background: var(--bg-surface);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 500;
    border: 1px solid var(--border);
}
.navbar-dash {
    background: rgba(7,8,12,0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-actions {
    display: flex;
    gap: 12px;
}

/* ===== HERO BACKGROUND ===== */
.hero-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}
.hero-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.4;
    animation: float 12s ease-in-out infinite;
}
.hero-orb-1 {
    width: 500px;
    height: 500px;
    background: #6366f1;
    top: -150px;
    left: -100px;
    animation-delay: 0s;
}
.hero-orb-2 {
    width: 400px;
    height: 400px;
    background: #8b5cf6;
    bottom: -100px;
    right: -100px;
    animation-delay: -4s;
}
.hero-orb-3 {
    width: 300px;
    height: 300px;
    background: #a78bfa;
    top: 40%;
    left: 50%;
    animation-delay: -8s;
}
@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.05); }
    66% { transform: translate(-20px, 20px) scale(0.95); }
}

/* ===== HERO CONTENT ===== */
.hero-content {
    position: relative;
    z-index: 5;
    max-width: 720px;
    margin: 0 auto;
    padding: 60px 24px 80px;
    text-align: center;
}
.hero-heading {
    font-size: clamp(2rem, 5vw, 3.2rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.03em;
    margin-bottom: 20px;
}
.gradient-text {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 48px;
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-xl);
    padding: 60px 40px;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(18, 20, 28, 0.5);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}
.upload-zone::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity 0.4s;
    border-radius: var(--radius-xl);
}
.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}
.upload-zone:hover::before,
.upload-zone.drag-over::before {
    opacity: 0.05;
}
.upload-icon {
    color: var(--accent-primary-light);
    margin-bottom: 16px;
    transition: var(--transition);
}
.upload-zone:hover .upload-icon {
    transform: translateY(-4px);
}
.upload-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
}
.upload-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== UPLOAD INFO CARDS ===== */
.upload-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 40px;
}
.info-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    text-align: left;
    padding: 16px;
    border-radius: var(--radius-md);
    background: rgba(18, 20, 28, 0.4);
    border: 1px solid var(--border);
    transition: var(--transition);
}
.info-card:hover {
    border-color: var(--border-light);
    background: rgba(18, 20, 28, 0.6);
}
.info-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}
.info-card strong {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 2px;
}
.info-card p {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* ===== DEMO BUTTON ===== */
.btn-demo {
    margin-top: 32px;
    background: transparent;
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
    padding: 12px 28px;
    border-radius: 100px;
    font-size: 0.9rem;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-demo:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary-light);
    background: rgba(99,102,241,0.08);
}

/* ===== BUTTONS ===== */
.btn-primary {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
}
.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(99,102,241,0.4);
}
.btn-sm {
    padding: 8px 18px;
    font-size: 0.8rem;
}
.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    padding: 8px 18px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}
.btn-outline:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary-light);
}
.btn-export {
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent-success);
    border: 1px solid rgba(16, 185, 129, 0.2);
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.btn-export:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
}

/* ===== LOADING ===== */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    gap: 24px;
}
.loading-spinner {
    width: 56px;
    height: 56px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.loading-text {
    font-size: 1.2rem;
    font-weight: 600;
}
.loading-subtext {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== SETTINGS BAR ===== */
.settings-bar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 12px 32px;
}
.settings-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
}
.setting-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.setting-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}
.setting-group input {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font);
    width: 70px;
    text-align: center;
    transition: var(--transition);
}
.setting-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.setting-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-family: var(--font);
    min-width: 160px;
    cursor: pointer;
    transition: var(--transition);
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b90a5' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}
.setting-select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.setting-select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

/* ===== KPI CARDS ===== */
.kpi-section {
    padding: 28px 32px 0;
    max-width: 1400px;
    margin: 0 auto;
}
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 16px;
}
.kpi-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: var(--transition);
}
.kpi-card:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.kpi-icon {
    font-size: 1.6rem;
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.kpi-spend { background: rgba(99,102,241,0.12); }
.kpi-sales { background: rgba(16,185,129,0.12); }
.kpi-acos { background: rgba(245,158,11,0.12); }
.kpi-terms { background: rgba(59,130,246,0.12); }
.kpi-wasted { background: rgba(239,68,68,0.12); }
.kpi-roas { background: rgba(139,92,246,0.12); }

.kpi-data {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ===== CHARTS ===== */
.charts-section {
    padding: 28px 32px;
    max-width: 1400px;
    margin: 0 auto;
}
.charts-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 16px;
}
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
}
.chart-title {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text-secondary);
}

/* ===== TABS ===== */
.recommendations-section {
    padding: 0 32px 60px;
    max-width: 1400px;
    margin: 0 auto;
}
.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 14px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tab:hover {
    color: var(--text-secondary);
}
.tab.active {
    color: var(--accent-primary-light);
    border-bottom-color: var(--accent-primary);
}
.tab-count {
    background: var(--bg-surface);
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
}
.tab.active .tab-count {
    background: rgba(99,102,241,0.2);
    color: var(--accent-primary-light);
}

/* ===== TAB CONTENT ===== */
.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}
.tab-content.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
.rec-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 0 16px;
}
.rec-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 4px;
}
.rec-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ===== TABLES ===== */
.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
thead {
    background: var(--bg-surface);
    position: sticky;
    top: 0;
}
th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    white-space: nowrap;
}
tr:last-child td {
    border-bottom: none;
}
tr:hover td {
    background: rgba(99,102,241,0.03);
}
.cell-term {
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}
.cell-campaign {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
}
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
}
.badge-danger {
    background: rgba(239,68,68,0.12);
    color: #f87171;
}
.badge-success {
    background: rgba(16,185,129,0.12);
    color: #34d399;
}
.badge-warning {
    background: rgba(245,158,11,0.12);
    color: #fbbf24;
}
.badge-info {
    background: rgba(59,130,246,0.12);
    color: #60a5fa;
}

.action-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(99,102,241,0.1);
    color: var(--accent-primary-light);
    border: 1px solid rgba(99,102,241,0.15);
}

.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}
.empty-state span {
    font-size: 2rem;
    display: block;
    margin-bottom: 12px;
}

/* ===== ASIN LINKS ===== */
.asin-link {
    color: var(--accent-primary-light);
    text-decoration: none;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    margin: -2px -6px;
    border-radius: 4px;
}
.asin-link:hover {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.12);
    text-decoration: none;
}
.asin-link svg {
    opacity: 0.5;
    transition: var(--transition);
}
.asin-link:hover svg {
    opacity: 1;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
}
@media (max-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .upload-info {
        grid-template-columns: 1fr;
    }
    .hero-heading {
        font-size: 1.8rem;
    }
    .navbar, .settings-bar, .kpi-section, .charts-section, .recommendations-section {
        padding-left: 16px;
        padding-right: 16px;
    }
    .rec-header {
        flex-direction: column;
    }
}
@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }
}
