        :root {
            --primary: #ee4d2d;
            --primary-dark: #d73211;
            --tiktok: #000000;
            --tiktok-accent: #25F4EE;
            --bg: #0f1117;
            --bg-card: #1a1d27;
            --bg-card-hover: #222636;
            --text: #e8e8e8;
            --text-muted: #8b8fa3;
            --border: #2a2e3d;
            --success: #00c853;
            --warning: #ffab00;
            --danger: #ff1744;
            --info: #448aff;
            --gradient-shopee: linear-gradient(135deg, #ee4d2d, #ff6b35);
            --gradient-tiktok: linear-gradient(135deg, #25F4EE, #FE2C55);
            --gradient-success: linear-gradient(135deg, #00c853, #69f0ae);
            --gradient-gold: linear-gradient(135deg, #ffd700, #ffab00);
        }

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

        body {
            font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
            background: var(--bg);
            color: var(--text);
            /* Layout bug 13 Okt: header is ~85px (shop selector, stats), but the layout
               assumed 61px -> sidebar items below the fold were unreachable. Now the
               page is exactly one screen; header takes what it needs, sidebar and
               content each scroll on their own. */
            height: 100vh;
            height: 100dvh;
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }

        /* Scrollbar */
        ::-webkit-scrollbar { width: 6px; }
        ::-webkit-scrollbar-track { background: var(--bg); }
        ::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
        ::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

        /* Header */
        .header {
            background: var(--bg-card);
            border-bottom: 1px solid var(--border);
            padding: 12px 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            position: relative;
            flex-shrink: 0;
            z-index: 100;
        }

        .logo {
            display: flex;
            align-items: center;
            gap: 10px;
            font-size: 20px;
            font-weight: 700;
        }

        .logo-icon {
            width: 36px;
            height: 36px;
            background: var(--gradient-shopee);
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 18px;
        }

        .header-stats {
            display: flex;
            gap: 24px;
        }

        .header-stat {
            text-align: center;
        }

        .header-stat-value {
            font-size: 18px;
            font-weight: 700;
            color: var(--primary);
        }

        .header-stat-label {
            font-size: 11px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        /* Layout */
        .app-layout {
            display: flex;
            flex: 1;
            min-height: 0;
        }

        /* Sidebar */
        .sidebar {
            width: 220px;
            background: var(--bg-card);
            border-right: 1px solid var(--border);
            padding: 16px 0;
            flex-shrink: 0;
            overflow-y: auto;
        }

        .nav-section {
            padding: 0 12px;
            margin-bottom: 20px;
        }

        .nav-section-title {
            font-size: 10px;
            text-transform: uppercase;
            letter-spacing: 1px;
            color: var(--text-muted);
            padding: 0 12px;
            margin-bottom: 8px;
        }

        .nav-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 12px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.2s;
            color: var(--text-muted);
            font-size: 13px;
            font-weight: 500;
        }

        .nav-item:hover { background: var(--bg-card-hover); color: var(--text); }
        .nav-item.active { background: rgba(238, 77, 45, 0.15); color: var(--primary); }
        .nav-item-icon { font-size: 18px; width: 24px; text-align: center; }

        /* Main Content */
        .main-content {
            flex: 1;
            padding: 24px;
            overflow-y: auto;
            min-width: 0;
        }

        .page { display: none; }
        .page.active { display: block; }

        .page-title {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 4px;
        }

        .page-subtitle {
            color: var(--text-muted);
            font-size: 14px;
            margin-bottom: 24px;
        }

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

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

        .card-title {
            font-size: 16px;
            font-weight: 600;
        }

        /* Metrics Grid */
        .metrics-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 16px;
            margin-bottom: 24px;
        }

        .metric-card {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 12px;
            padding: 20px;
            position: relative;
            overflow: hidden;
        }

        .metric-card::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            height: 3px;
        }

        .metric-card.shopee::before { background: var(--gradient-shopee); }
        .metric-card.success::before { background: var(--gradient-success); }
        .metric-card.gold::before { background: var(--gradient-gold); }
        .metric-card.info::before { background: linear-gradient(135deg, #448aff, #82b1ff); }

        .metric-icon {
            width: 40px;
            height: 40px;
            border-radius: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            margin-bottom: 12px;
        }

        .metric-value {
            font-size: 28px;
            font-weight: 700;
            margin-bottom: 4px;
        }

        .metric-label {
            font-size: 13px;
            color: var(--text-muted);
        }

        .metric-change {
            font-size: 12px;
            margin-top: 8px;
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .metric-change.up { color: var(--success); }
        .metric-change.down { color: var(--danger); }

        /* Grid layouts */
        .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
        .grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
        .grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
        @media (max-width: 900px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
        @media (max-width: 560px) { .grid-4 { grid-template-columns: 1fr; } }

        /* Form elements */
        .form-group {
            margin-bottom: 16px;
        }

        .form-label {
            display: block;
            font-size: 13px;
            font-weight: 600;
            margin-bottom: 6px;
            color: var(--text-muted);
        }

        .form-input, .form-select, .form-textarea {
            width: 100%;
            padding: 10px 14px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            color: var(--text);
            font-size: 14px;
            transition: border-color 0.2s;
            font-family: inherit;
        }

        .form-input:focus, .form-select:focus, .form-textarea:focus {
            outline: none;
            border-color: var(--primary);
        }

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

        /* Buttons */
        .btn {
            padding: 10px 20px;
            border-radius: 8px;
            font-size: 13px;
            font-weight: 600;
            cursor: pointer;
            border: none;
            transition: all 0.2s;
            display: inline-flex;
            align-items: center;
            gap: 6px;
        }

        .btn-primary {
            background: var(--gradient-shopee);
            color: white;
        }
        .btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

        .btn-secondary {
            background: var(--bg);
            color: var(--text);
            border: 1px solid var(--border);
        }
        .btn-secondary:hover { border-color: var(--text-muted); }

        .btn-success {
            background: var(--gradient-success);
            color: #000;
        }

        .btn-sm { padding: 6px 12px; font-size: 12px; }

        /* Tags */
        .tag {
            display: inline-flex;
            align-items: center;
            padding: 4px 10px;
            border-radius: 20px;
            font-size: 11px;
            font-weight: 600;
            gap: 4px;
        }

        .tag-shopee { background: rgba(238,77,45,0.15); color: var(--primary); }
        .tag-tiktok { background: rgba(37,244,238,0.15); color: var(--tiktok-accent); }
        .tag-success { background: rgba(0,200,83,0.15); color: var(--success); }
        .tag-warning { background: rgba(255,171,0,0.15); color: var(--warning); }
        .tag-danger { background: rgba(255,23,68,0.15); color: var(--danger); }

        /* Score Circle */
        .score-circle {
            width: 80px;
            height: 80px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            font-weight: 700;
            position: relative;
        }

        .score-circle::before {
            content: '';
            position: absolute;
            inset: 3px;
            border-radius: 50%;
            background: var(--bg-card);
        }

        .score-circle span { position: relative; z-index: 1; }
        .score-excellent { background: conic-gradient(var(--success) calc(var(--score) * 3.6deg), var(--border) 0); }
        .score-good { background: conic-gradient(var(--info) calc(var(--score) * 3.6deg), var(--border) 0); }
        .score-average { background: conic-gradient(var(--warning) calc(var(--score) * 3.6deg), var(--border) 0); }
        .score-poor { background: conic-gradient(var(--danger) calc(var(--score) * 3.6deg), var(--border) 0); }

        /* Table */
        .table-container { overflow-x: auto; }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th {
            text-align: left;
            padding: 12px 16px;
            font-size: 11px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
            color: var(--text-muted);
            border-bottom: 1px solid var(--border);
            font-weight: 600;
        }

        td {
            padding: 12px 16px;
            font-size: 13px;
            border-bottom: 1px solid rgba(42,46,61,0.5);
        }

        tr:hover td { background: var(--bg-card-hover); }

        /* Keyword tags */
        .keyword-list {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;
        }

        .keyword-tag {
            padding: 4px 10px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 6px;
            font-size: 12px;
            cursor: pointer;
            transition: all 0.2s;
        }

        .keyword-tag:hover { border-color: var(--primary); color: var(--primary); }
        .keyword-tag.hot { border-color: var(--danger); color: var(--danger); background: rgba(255,23,68,0.1); }
        .keyword-tag.trending { border-color: var(--warning); color: var(--warning); background: rgba(255,171,0,0.1); }

        /* Progress bar */
        .progress-bar {
            height: 6px;
            background: var(--border);
            border-radius: 3px;
            overflow: hidden;
        }

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

        .progress-fill.excellent { background: var(--success); }
        .progress-fill.good { background: var(--info); }
        .progress-fill.average { background: var(--warning); }
        .progress-fill.poor { background: var(--danger); }

        /* Checklist */
        .checklist-item {
            display: flex;
            align-items: center;
            gap: 10px;
            padding: 10px 0;
            border-bottom: 1px solid rgba(42,46,61,0.3);
            font-size: 13px;
        }

        .checklist-icon { font-size: 16px; }
        .checklist-icon.pass { color: var(--success); }
        .checklist-icon.fail { color: var(--danger); }
        .checklist-icon.warn { color: var(--warning); }

        /* Title optimizer */
        .title-preview {
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 16px;
            margin-top: 12px;
        }

        .title-preview-label {
            font-size: 11px;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            margin-bottom: 8px;
        }

        .title-preview-text {
            font-size: 15px;
            font-weight: 500;
            line-height: 1.5;
        }

        .title-char-count {
            font-size: 12px;
            color: var(--text-muted);
            margin-top: 8px;
        }

        .title-char-count.over { color: var(--danger); }

        /* Suggestion cards */
        .suggestion-card {
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            padding: 14px;
            margin-bottom: 8px;
            display: flex;
            align-items: flex-start;
            gap: 12px;
        }

        .suggestion-priority {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin-top: 6px;
            flex-shrink: 0;
        }

        .suggestion-priority.high { background: var(--danger); }
        .suggestion-priority.medium { background: var(--warning); }
        .suggestion-priority.low { background: var(--info); }

        .suggestion-text { font-size: 13px; line-height: 1.5; }
        .suggestion-impact { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

        /* Shopee photo optimizer */
        .photo-framework-grid {
            display: grid;
            grid-template-columns: repeat(4, minmax(0, 1fr));
            gap: 12px;
        }
        .photo-framework-step {
            min-height: 128px;
            padding: 14px;
            border: 1px solid var(--border);
            border-top: 3px solid var(--info);
            border-radius: 8px;
            background: var(--bg);
        }
        .photo-framework-step:nth-child(2) { border-top-color: var(--success); }
        .photo-framework-step:nth-child(3) { border-top-color: var(--warning); }
        .photo-framework-step:nth-child(4) { border-top-color: var(--primary); }
        .photo-step-number {
            display: inline-flex;
            width: 24px;
            height: 24px;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: rgba(68,138,255,0.15);
            color: var(--info);
            font-size: 12px;
            font-weight: 700;
            margin-bottom: 9px;
        }
        .photo-step-title { font-size: 14px; font-weight: 700; margin-bottom: 5px; }
        .photo-step-copy { font-size: 12px; color: var(--text-muted); line-height: 1.5; }
        .photo-checklist-item {
            display: grid;
            grid-template-columns: 22px 36px minmax(0, 1fr);
            gap: 9px;
            align-items: start;
            padding: 11px 0;
            border-bottom: 1px solid rgba(42,46,61,0.45);
        }
        .photo-checklist-item input {
            width: 17px;
            height: 17px;
            margin-top: 2px;
            accent-color: var(--success);
        }
        .photo-checklist-item label { cursor: pointer; }
        .photo-checklist-item.checked label { color: var(--text-muted); }
        .photo-checklist-title { font-size: 13px; font-weight: 600; }
        .photo-checklist-copy { font-size: 11px; color: var(--text-muted); line-height: 1.45; margin-top: 3px; }
        .photo-slide-list { display: grid; gap: 8px; }
        .photo-slide-row {
            display: grid;
            grid-template-columns: 34px minmax(0, 1fr) auto;
            align-items: start;
            gap: 10px;
            padding: 11px;
            border: 1px solid var(--border);
            border-radius: 8px;
            background: var(--bg);
        }
        .photo-slide-index {
            display: flex;
            width: 30px;
            height: 30px;
            align-items: center;
            justify-content: center;
            border-radius: 6px;
            background: rgba(238,77,45,0.14);
            color: var(--primary);
            font-size: 12px;
            font-weight: 700;
        }
        .photo-gallery {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
            gap: 12px;
        }
        .photo-gallery-item {
            min-height: 176px;
            border: 1px solid var(--border);
            border-radius: 8px;
            overflow: hidden;
            background: var(--bg);
        }
        .photo-gallery-item img {
            display: block;
            width: 100%;
            aspect-ratio: 1;
            object-fit: cover;
            background: #fff;
        }
        .photo-gallery-placeholder {
            display: flex;
            aspect-ratio: 1;
            align-items: center;
            justify-content: center;
            padding: 16px;
            color: var(--text-muted);
            text-align: center;
            font-size: 12px;
            border-bottom: 1px dashed var(--border);
        }
        .photo-gallery-meta { padding: 10px; font-size: 11px; color: var(--text-muted); }

        /* Chart container */
        .chart-container {
            position: relative;
            height: 300px;
        }

        /* Animations */
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }

        .animate-in { animation: fadeIn 0.3s ease; }

        /* Responsive — 15 Okt: on phones the sidebar used to be display:none with NO replacement
           (no way to change page), and the whole header block (shop picker, Keluar) was hidden. */
        .mobile-menu-btn { display: none; }
        .nav-backdrop { display: none; }
        @media (max-width: 768px) {
            .mobile-menu-btn {
                display: inline-flex; align-items: center; justify-content: center;
                width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border);
                background: var(--bg-card-hover); color: var(--text); font-size: 20px; cursor: pointer; flex-shrink: 0;
            }
            .header { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
            .logo { font-size: 16px; gap: 6px; }
            .logo-icon { width: 30px; height: 30px; font-size: 15px; }
            .logo .tag { display: none; }
            .header-stats { display: flex; gap: 6px; flex: 1; justify-content: flex-end; min-width: 0; }
            .header-stat, #wsStatus, #mpAccountTag, #connOpenai, #headerShopeeProfileWrap > span:first-child,
            #headerShopeeProfileWrap > button[onclick*="import"] { display: none !important; }
            .conn-badges { margin-left: 0 !important; gap: 6px !important; min-width: 0; }
            #headerShopeeProfileWrap { padding: 3px !important; min-width: 0; }
            #headerShopeeProfileSelect { min-width: 0 !important; max-width: 150px !important; }
            .sidebar {
                display: block; position: fixed; top: 0; left: 0; bottom: 0; width: 270px; max-width: 85vw;
                z-index: 300; transform: translateX(-100%); transition: transform 0.2s ease;
                box-shadow: 4px 0 24px rgba(0,0,0,0.4);
            }
            body.nav-open .sidebar { transform: none; }
            body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.55); z-index: 250; }
            .nav-item { padding: 12px; font-size: 14px; }          /* finger-sized */
            .main-content { padding: 12px; }
            .page-header { flex-wrap: wrap; gap: 10px; }
            .page-title { font-size: 20px; }
            .grid-2, .grid-3 { grid-template-columns: 1fr; }
            .metrics-grid { grid-template-columns: 1fr 1fr; }
            .photo-framework-grid { grid-template-columns: 1fr 1fr; }
            .card { padding: 14px; }
            .btn { min-height: 36px; }
            input.form-input, select.form-select { font-size: 16px !important; }   /* iOS: no zoom on focus */
            .mp-range { width: 100%; }
            .mp-range .form-select, .mp-range .form-input { flex: 1 1 140px; }
        }

        @media (max-width: 480px) {
            .photo-framework-grid { grid-template-columns: 1fr; }
        }

        /* Modal */
        .modal-overlay {
            display: none;
            position: fixed;
            inset: 0;
            background: rgba(0,0,0,0.7);
            z-index: 200;
            align-items: center;
            justify-content: center;
        }
        .modal-overlay.active { display: flex; }
        .modal {
            background: var(--bg-card);
            border: 1px solid var(--border);
            border-radius: 16px;
            padding: 28px;
            width: 90%;
            max-width: 600px;
            max-height: 80vh;
            overflow-y: auto;
        }
        .modal-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

        /* Platform toggle */
        .platform-toggle {
            display: flex;
            background: var(--bg);
            border-radius: 8px;
            padding: 3px;
            gap: 3px;
        }
        .platform-toggle-btn {
            flex: 1;
            padding: 8px 16px;
            border: none;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            background: transparent;
            color: var(--text-muted);
            transition: all 0.2s;
        }
        .platform-toggle-btn.active {
            background: var(--primary);
            color: white;
        }
        .platform-toggle-btn.tiktok-active {
            background: #000;
            color: var(--tiktok-accent);
        }

        /* Niche selector */
        .niche-grid {
            display: grid;
            grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
            gap: 8px;
        }
        .niche-option {
            padding: 12px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            text-align: center;
            cursor: pointer;
            transition: all 0.2s;
            font-size: 13px;
        }
        .niche-option:hover { border-color: var(--primary); }
        .niche-option.selected { border-color: var(--primary); background: rgba(238,77,45,0.1); }
        .niche-option-icon { font-size: 24px; margin-bottom: 6px; }

        /* Generated title list */
        .gen-title {
            padding: 12px;
            background: var(--bg);
            border: 1px solid var(--border);
            border-radius: 8px;
            margin-bottom: 8px;
            cursor: pointer;
            transition: all 0.2s;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        .gen-title:hover { border-color: var(--primary); }
        .gen-title-text { font-size: 13px; flex: 1; }
        .gen-title-score { font-size: 12px; font-weight: 700; padding: 4px 8px; border-radius: 4px; }

        /* Tooltip */
        .tooltip-container { position: relative; display: inline-flex; }
        .tooltip-text {
            display: none;
            position: absolute;
            bottom: calc(100% + 8px);
            left: 50%;
            transform: translateX(-50%);
            background: #333;
            color: white;
            padding: 6px 10px;
            border-radius: 6px;
            font-size: 11px;
            white-space: nowrap;
            z-index: 50;
        }
        .tooltip-container:hover .tooltip-text { display: block; }

        /* Tab system */
        .tabs {
            display: flex;
            gap: 2px;
            background: var(--bg);
            padding: 3px;
            border-radius: 8px;
            margin-bottom: 16px;
        }
        .tab-btn {
            flex: 1;
            padding: 8px 16px;
            border: none;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            background: transparent;
            color: var(--text-muted);
            transition: all 0.2s;
        }
        .tab-btn.active { background: var(--bg-card); color: var(--text); }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: var(--text-muted);
        }
        .empty-state-icon { font-size: 48px; margin-bottom: 16px; }
        .empty-state-title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
    
/* Active ads period (Today / 7 / 30 / 3 bulan) must be obvious */
.ads-period-btn.active { background: var(--primary, #ee4d2d) !important; border-color: var(--primary, #ee4d2d) !important; color: #fff !important; font-weight: 700; box-shadow: 0 0 0 2px rgba(238,77,45,.25); }
        /* 14 Okt: legacy/secondary tools collapsed under "Alat lain" */
        .nav-more { margin-top: 2px; }
        .nav-more-summary { list-style: none; cursor: pointer; font-size: 12px; color: var(--text-muted); padding: 8px 12px; border-radius: 8px; }
        .nav-more-summary::-webkit-details-marker { display: none; }
        .nav-more-summary::before { content: '▸ '; }
        .nav-more[open] > .nav-more-summary::before { content: '▾ '; }
        .nav-more-summary:hover { color: var(--text); }
        .nav-more .nav-item { padding-left: 24px; font-size: 13px; }
