/* ============================================================
   APK Store - Complete Design System
   Inspired by Material Design 3, Google Play Store, Nothing OS
   ============================================================ */

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

/* --- Design Tokens (Dark Theme - Default) --- */
:root, .theme-dark, [data-theme="dark"] {
    --bg-primary: #0B1220;
    --bg-secondary: #111827;
    --bg-card: #1F2937;
    --bg-card-hover: #273548;
    --bg-input: #1a2744;
    --bg-surface: #111827;

    --text-primary: #FFFFFF;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;

    --primary: #4F8CFF;
    --primary-hover: #3B7BEE;
    --primary-light: rgba(79, 140, 255, 0.15);
    --primary-glow: rgba(79, 140, 255, 0.3);

    --accent: #00D4FF;
    --accent-light: rgba(0, 212, 255, 0.15);

    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;

    --border: rgba(148, 163, 184, 0.1);
    --border-hover: rgba(148, 163, 184, 0.2);

    --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 20px rgba(79, 140, 255, 0.15);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', monospace;

    --sidebar-width: 250px;
    --header-height: 64px;
}

/* --- Light Theme --- */
.theme-light, [data-theme="light"] {
    --bg-primary: #F8FAFC;
    --bg-secondary: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F1F5F9;
    --bg-input: #F1F5F9;
    --bg-surface: #FFFFFF;

    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --text-muted: #94A3B8;

    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    --primary-light: rgba(37, 99, 235, 0.1);
    --primary-glow: rgba(37, 99, 235, 0.2);

    --accent: #06B6D4;
    --accent-light: rgba(6, 182, 212, 0.1);

    --border: rgba(100, 116, 139, 0.15);
    --border-hover: rgba(100, 116, 139, 0.25);

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
    --shadow-glow: 0 0 20px rgba(37, 99, 235, 0.1);
}

/* --- Base Styles --- */
html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}
a:hover { color: var(--primary-hover); }

img { max-width: 100%; height: auto; }
svg { vertical-align: middle; }

::selection { background: var(--primary-light); color: var(--primary); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
.small { font-size: 0.875rem; }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-center { text-align: center; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }

/* --- Container --- */
.container {
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}
.btn svg { flex-shrink: 0; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    box-shadow: var(--shadow-glow);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}
.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-error {
    background: var(--error);
    color: #fff;
    border-color: var(--error);
}
.btn-error:hover { opacity: 0.9; color: #fff; }

.btn-sm { padding: 6px 12px; font-size: 0.8125rem; }
.btn-lg { padding: 14px 28px; font-size: 1rem; }
.btn:disabled { opacity: 0.7; cursor: not-allowed; }
.w-full { width: 100%; }
.d-inline { display: inline; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Form Elements --- */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    outline: none;
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-color { height: 42px; padding: 4px; cursor: pointer; }
select.form-input { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-checkbox { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.form-checkbox input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.form-checkbox label { cursor: pointer; font-size: 0.875rem; color: var(--text-secondary); }
.form-checkboxes { display: flex; gap: 24px; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.form-section { margin-bottom: 32px; }
.form-section-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form-actions { display: flex; gap: 12px; align-items: center; padding-top: 20px; border-top: 1px solid var(--border); }

.filter-group { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-group .form-input { width: auto; min-width: 160px; }

/* --- Alerts --- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.alert-success { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.alert-error { background: rgba(239, 68, 68, 0.1); color: var(--error); border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.alert ul { margin-left: 16px; }
.alert button { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2rem; padding: 0 4px; }
.alert-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2rem; }

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-title { font-size: 1rem; font-weight: 600; }
.card-link { font-size: 0.875rem; color: var(--primary); }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.card-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
}
.p-3 { padding: 16px; }
.p-0 { padding: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mx-auto { margin-left: auto; margin-right: auto; }
.py-4 { padding-top: 24px; padding-bottom: 24px; }
.py-5 { padding-top: 48px; padding-bottom: 48px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.ml-auto { margin-left: auto; }

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-full);
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-error { background: rgba(239, 68, 68, 0.1); color: var(--error); }

/* --- Code --- */
code, .code-sm {
    font-family: var(--mono);
    font-size: 0.8125rem;
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--accent);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}
.empty-state svg { margin-bottom: 16px; }
.empty-state h3 { color: var(--text-primary); margin-bottom: 8px; }

/* ============================================================
   PAGE CENTER (used for maintenance, etc.)
   ============================================================ */
.page-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

/* ============================================================
   STORE LAYOUT
   ============================================================ */
.store-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- Store Header --- */
.store-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.store-header-inner {
    display: flex;
    align-items: center;
    height: var(--header-height);
    gap: 20px;
}
.store-back {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius-full);
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 1cm;
    transition: all 0.2s;
}
.store-back:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}
.store-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}
.store-logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-primary);
}
.store-search { flex: 1; max-width: 480px; }
.search-form {
    position: relative;
    width: 100%;
}
.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.search-input {
    width: 100%;
    padding: 10px 14px 10px 42px;
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    outline: none;
    transition: all 0.2s;
}
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.search-input::placeholder { color: var(--text-muted); }
.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 4px;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: none;
    overflow: hidden;
}
.search-suggestions.active { display: block; }
.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
    color: var(--text-primary);
}
.suggestion-item:hover { background: var(--bg-card-hover); }
.suggestion-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    flex-shrink: 0;
}
.suggestion-icon-placeholder {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}
.suggestion-info { flex: 1; min-width: 0; }
.suggestion-name { font-size: 0.875rem; font-weight: 500; display: block; }
.suggestion-meta { font-size: 0.75rem; color: var(--text-secondary); }
.suggestion-view {
    font-size: 0.75rem;
    color: var(--primary);
    flex-shrink: 0;
}
.no-suggestions {
    padding: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* --- Store Nav --- */
.store-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.store-nav-link {
    padding: 8px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    text-decoration: none;
}
.store-nav-link:hover, .store-nav-link.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* --- Theme Toggle --- */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s;
    flex-shrink: 0;
}
.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--primary);
}
.theme-dark .sun-icon { display: block; }
.theme-dark .moon-icon { display: none; }
.theme-light .sun-icon { display: none; }
.theme-light .moon-icon { display: block; }

/* --- Mobile Menu --- */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}
.mobile-menu-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
}
.mobile-menu-overlay.open { display: block; }
.mobile-menu {
    display: none;
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    background: var(--bg-card);
    z-index: 300;
    transition: right 0.3s ease;
    padding: 20px;
    border-left: 1px solid var(--border);
}
.mobile-menu.open { right: 0; }
.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.mobile-menu-title { font-size: 1.125rem; font-weight: 600; }
.mobile-menu-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}
.mobile-menu-nav { display: flex; flex-direction: column; gap: 4px; }
.mobile-menu-nav a {
    padding: 12px 16px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: background 0.2s;
}
.mobile-menu-nav a:hover { background: var(--bg-card-hover); }

/* --- Store Main --- */
.store-main {
    flex: 1;
    padding: 24px 0 48px;
}

/* --- Store Footer --- */
.store-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 48px 0 24px;
    margin-top: auto;
}
.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 32px;
}
.footer-brand h3 { margin-bottom: 8px; }
.footer-brand p { font-size: 0.875rem; }
.footer-links h4 { font-size: 0.875rem; font-weight: 600; margin-bottom: 12px; color: var(--text-secondary); }
.footer-links a {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    padding: 4px 0;
    text-decoration: none;
}
.footer-links a:hover { color: var(--primary); }
.footer-bottom {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.8125rem;
    color: var(--text-muted);
}
.footer-credit {
    margin-top: 6px;
    font-size: 0.8125rem;
    color: var(--text-muted);
    opacity: 0.8;
}
.footer-credit strong {
    color: var(--primary);
}

/* ============================================================
   HERO SECTION
   ============================================================ */
.hero-section {
    text-align: center;
    padding: 60px 0 48px;
}
.hero-title {
    font-size: clamp(1.75rem, 5vw, 3rem);
    font-weight: 800;
    line-height: 1.15;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.hero-subtitle {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.hero-search {
    max-width: 560px;
    margin: 0 auto;
}
.hero-search form {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    padding: 4px;
    transition: all 0.2s;
}
.hero-search form:focus-within {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}
.hero-search-icon {
    margin-left: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.hero-search-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 1rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
}
.hero-search-input::placeholder { color: var(--text-muted); }
.hero-search-btn {
    padding: 12px 28px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-full);
    font-size: 0.9375rem;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.hero-search-btn:hover { background: var(--primary-hover); }

/* ============================================================
   SECTIONS
   ============================================================ */
.section { margin-bottom: 48px; }
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}
.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
}
.section-title-sm {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}
.section-link {
    font-size: 0.875rem;
    color: var(--primary);
    text-decoration: none;
}
.section-link:hover { text-decoration: underline; }

/* ============================================================
   APP GRID & CARDS
   ============================================================ */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.app-card {
    display: flex;
    gap: 14px;
    padding: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
}
.app-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
    transform: translateY(-2px);
}
.app-card-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    flex-shrink: 0;
}
.app-card-icon img { width: 100%; height: 100%; object-fit: cover; }
.app-icon-placeholder {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff;
    border-radius: var(--radius-lg);
}
.app-icon-placeholder-sm {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    color: #fff;
    border-radius: var(--radius-sm);
    background: var(--primary);
}
.app-icon-placeholder-xs {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    border-radius: var(--radius-sm);
}
.app-card-body { flex: 1; min-width: 0; }
.app-card-title {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-card-desc {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.app-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.75rem;
}
.app-card-category { font-weight: 500; }
.app-card-downloads { color: var(--text-muted); }

/* ============================================================
   CATEGORY GRID
   ============================================================ */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.category-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    border-left: 3px solid var(--cat-color);
}
.category-card:hover {
    border-color: var(--cat-color);
    background: var(--bg-card-hover);
    transform: translateY(-1px);
}
.category-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border-radius: var(--radius-md);
    color: var(--cat-color);
    flex-shrink: 0;
}
.category-card-body h3 { font-size: 0.9375rem; font-weight: 600; }
.category-card-body span { font-size: 0.8125rem; color: var(--text-secondary); }

/* --- App detail page uses ps-* classes (Google Play design) --- */
.sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 16px;
}
.sidebar-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.details-list { list-style: none; }
.details-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.details-list li:last-child { border-bottom: none; }
.detail-label { font-size: 0.8125rem; color: var(--text-muted); }
.detail-value { font-size: 0.875rem; font-weight: 500; }

/* ============================================================
   AUTH PAGES
   ============================================================ */
.installed-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
}
/* ============================================================
   MODAL & TOAST SYSTEM
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}
.modal-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 32px;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
    transform: scale(0.92) translateY(12px);
    transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
    position: relative;
}
.modal-overlay.open .modal-box {
    transform: scale(1) translateY(0);
}
.modal-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 18px;
}
.modal-icon-danger { background: rgba(239,68,68,0.12); color: var(--error); }
.modal-icon-success { background: rgba(16,185,129,0.12); color: var(--success); }
.modal-icon-info { background: var(--primary-light); color: var(--primary); }
.modal-title {
    font-size: 1.125rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text-primary);
}
.modal-message {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}
.modal-actions .btn { min-width: 90px; }

/* Progress bar inside modal */
.modal-progress {
    margin: 16px 0 20px;
}
.modal-progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-surface);
    border-radius: 3px;
    overflow: hidden;
}
.modal-progress-fill {
    height: 100%;
    width: 0%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
}
.modal-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}
.modal-progress-percent {
    font-weight: 600;
    color: var(--text-primary);
}
.modal-progress-filename {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}
.modal-progress-cancel {
    display: block;
    margin: 4px auto 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    cursor: pointer;
    padding: 6px 14px;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}
.modal-progress-cancel:hover {
    background: var(--bg-surface);
    color: var(--text-primary);
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    max-width: 380px;
    width: 100%;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    transform: translateX(120%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.16,1,0.3,1), opacity 0.35s ease;
    font-size: 0.875rem;
    color: var(--text-primary);
}
.toast.show {
    transform: translateX(0);
    opacity: 1;
}
.toast-icon { flex-shrink: 0; width: 20px; height: 20px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--error); }
.toast-info .toast-icon { color: var(--primary); }
.toast-body { flex: 1; }
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
}
.toast-close:hover { color: var(--text-secondary); background: var(--bg-card-hover); }
@media (max-width: 480px) {
    .toast-container { top: auto; bottom: 20px; right: 10px; left: 10px; max-width: none; }
    .toast { transform: translateY(120%); }
    .toast.show { transform: translateY(0); }
    .modal-box { padding: 24px 20px; margin: 10px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
}

.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--header-height) - 80px);
    padding: 40px 20px;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
}
.auth-header { text-align: center; margin-bottom: 32px; }
.auth-logo { display: inline-block; margin-bottom: 16px; }
.auth-header h1 { font-size: 1.5rem; margin-bottom: 4px; }
.auth-form .form-group { margin-bottom: 20px; }
.auth-form .btn { margin-top: 8px; }
.auth-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.auth-footer a { font-weight: 500; }

/* ============================================================
   SEARCH PAGE
   ============================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: 0.875rem; color: var(--text-secondary); margin-top: 4px; }
.page-header-right { flex-shrink: 0; }

.search-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
}
.filter-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}
.filter-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}
.filter-list { display: flex; flex-direction: column; gap: 2px; }
.filter-item {
    display: block;
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.15s;
}
.filter-item:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.filter-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}
.popular-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.popular-tag {
    padding: 4px 10px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    background: var(--bg-input);
    border-radius: var(--radius-full);
    text-decoration: none;
    transition: all 0.2s;
}
.popular-tag:hover { background: var(--primary-light); color: var(--primary); }

.sort-select {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}
.sort-select select {
    padding: 8px 32px 8px 12px;
    font-size: 0.875rem;
    font-family: var(--font);
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 32px;
}
.pagination-btn {
    padding: 8px 16px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.2s;
}
.pagination-btn:hover { border-color: var(--primary); color: var(--primary); }
.pagination-pages { display: flex; gap: 4px; }
.pagination-page {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.2s;
}
.pagination-page:hover { border-color: var(--border); color: var(--text-primary); }
.pagination-page.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   ADMIN LAYOUT
   ============================================================ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}
.sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.sidebar-logo-text { font-size: 1.125rem; font-weight: 700; color: var(--text-primary); }

.sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all 0.15s;
    margin-bottom: 2px;
}
.sidebar-link:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}
.sidebar-link.active {
    color: var(--primary);
    background: var(--primary-light);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border);
}

/* --- Admin Topbar --- */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}
.admin-topbar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 50;
}
.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}
.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.admin-profile {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
.admin-name { font-size: 0.875rem; font-weight: 500; }
.admin-role { font-size: 0.75rem; color: var(--text-muted); }

/* --- Admin Content --- */
.admin-content {
    padding: 24px;
}

/* --- Admin Tabs --- */
.admin-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
}
.tab-btn {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font);
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
    background: var(--primary);
    color: #fff;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* --- Dashboard --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.stat-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}
.stat-body { flex: 1; }
.stat-value { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.8125rem; color: var(--text-muted); }

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}
.dashboard-grid .card:first-child { grid-column: 1 / -1; }
.dashboard-grid .card:nth-child(2) { grid-column: 1 / 2; }
.dashboard-grid .card:nth-child(3) { grid-column: 2 / 3; }
.dashboard-grid .card:nth-child(4) { grid-column: 1 / 2; }
.dashboard-grid .card:nth-child(5) { grid-column: 2 / 3; }
.dashboard-grid .card:nth-child(6) { grid-column: 1 / 2; }
.dashboard-grid .card:nth-child(7) { grid-column: 2 / 3; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.table th, .table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-input);
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-card-hover); }

.table-app { display: flex; align-items: center; gap: 12px; }
.table-app-icon { width: 40px; height: 40px; border-radius: var(--radius-md); object-fit: cover; }
.table-app-name { display: block; font-weight: 500; color: var(--text-primary); text-decoration: none; }
.table-app-name:hover { color: var(--primary); }
.table-app-date { font-size: 0.75rem; color: var(--text-muted); }

.table-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* --- Top Apps List --- */
.top-apps-list { padding: 8px; }
.top-app-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-md);
    transition: background 0.15s;
}
.top-app-item:hover { background: var(--bg-card-hover); }
.top-app-rank {
    width: 24px;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--text-muted);
    text-align: center;
}
.top-app-icon { flex-shrink: 0; }
.top-app-icon img { width: 36px; height: 36px; border-radius: var(--radius-sm); object-fit: cover; }
.top-app-name { flex: 1; font-size: 0.875rem; font-weight: 500; }
.top-app-downloads { font-size: 0.8125rem; color: var(--text-muted); white-space: nowrap; }
.top-app-info { flex: 1; }
.top-app-info .top-app-downloads { display: block; }

/* --- Activity List --- */
.activity-list { padding: 8px; }
.activity-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: var(--radius-md);
    transition: background 0.15s;
}
.activity-item:hover { background: var(--bg-card-hover); }
.activity-icon {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}
.activity-body { flex: 1; min-width: 0; }
.activity-title { display: block; font-size: 0.875rem; font-weight: 500; }
.activity-meta { font-size: 0.75rem; color: var(--text-muted); }

/* --- Upload Form --- */
.file-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}
.file-dropzone:hover, .file-dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary);
}
.file-dropzone p { font-size: 0.9375rem; margin: 8px 0 4px; }
.file-dropzone .small { font-size: 0.8125rem; }
.file-dropzone .file-input { display: none; }
.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
}
.file-previews {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.screenshot-preview {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 9/16;
    background: var(--bg-input);
}
.screenshot-preview img { width: 100%; height: 100%; object-fit: cover; }
.screenshot-preview span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 8px;
    background: rgba(0,0,0,0.7);
    font-size: 0.6875rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Screenshots Grid (Admin) --- */
.screenshots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}
.screenshot-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 9/16;
    background: var(--bg-input);
}
.screenshot-item img { width: 100%; height: 100%; object-fit: cover; }
.screenshot-delete {
    position: absolute;
    top: 4px;
    right: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}
.screenshot-item:hover .screenshot-delete { opacity: 1; }

/* --- Storage Stats (Settings) --- */
.storage-stats { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.storage-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
}
.storage-stat.total { background: var(--primary-light); }
.storage-label { flex: 1; font-size: 0.875rem; font-weight: 500; }
.storage-value { font-size: 0.8125rem; color: var(--text-secondary); }
.storage-size { font-size: 0.875rem; font-weight: 600; color: var(--primary); white-space: nowrap; }
.storage-bar {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}
.storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width 0.3s;
}

/* --- Info Grid (Settings) --- */
.info-grid { display: flex; flex-direction: column; gap: 12px; }
.info-grid > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.info-label { font-size: 0.8125rem; color: var(--text-muted); }
.info-value { font-size: 0.875rem; font-weight: 500; }

/* --- Metrics List (Analytics) --- */
.metrics-list { display: flex; flex-direction: column; gap: 8px; }
.metric-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}
.metric-item:last-child { border-bottom: none; }
.metric-label { font-size: 0.875rem; color: var(--text-secondary); }
.metric-value { font-size: 1rem; font-weight: 600; }

/* --- Period Selector --- */
.period-selector {
    display: flex;
    gap: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 3px;
}
.period-btn {
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: all 0.2s;
}
.period-btn:hover { color: var(--text-primary); }
.period-btn.active { background: var(--primary); color: #fff; }

/* --- Filters Form --- */
.filters-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }

/* --- User Avatar --- */
.user-avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* --- Color Dot --- */
.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.open { display: flex; }
.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    cursor: pointer;
}
.modal-content {
    position: relative;
    width: 100%;
    max-width: 500px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}
.modal-header h3 { font-size: 1.125rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.modal-body { padding: 20px 24px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 0 24px 20px;
}

/* ============================================================
   DOWNLOAD BUTTON
   ============================================================ */
.download-btn {
    font-size: 1rem;
    padding: 16px 32px;
    border-radius: var(--radius-full);
    min-width: 200px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
    .search-layout {
        grid-template-columns: 1fr;
    }
    .search-filters {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .dashboard-grid .card:nth-child(2),
    .dashboard-grid .card:nth-child(3),
    .dashboard-grid .card:nth-child(4),
    .dashboard-grid .card:nth-child(5),
    .dashboard-grid .card:nth-child(6),
    .dashboard-grid .card:nth-child(7) {
        grid-column: 1 / -1;
    }
}

/* ============================================================
   MOBILE FIRST: 768px and below
   Play Store style compact layout
   ============================================================ */
@media (max-width: 768px) {
    /* --- Container --- */
    .container {
        padding: 0 16px;
    }

    /* --- Header: compact one-row with full-width search below --- */
    .store-header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 0;
        gap: 0;
    }
    /* ===== FORCE FIX MOBILE BACK BUTTON ===== */

    /* TARGET REAL BUTTON */
    .store-back,
    .store-header .store-header-inner .store-back{

        all: unset !important;

        width: 32px !important;
        height: 32px !important;

        min-width: 32px !important;
        min-height: 32px !important;

        max-width: 32px !important;
        max-height: 32px !important;

        background: transparent !important;

        display: flex !important;
        align-items: center !important;
        justify-content: center !important;

        padding: 0 !important;
        margin-right: 8px !important;

        border: none !important;
        box-shadow: none !important;
        border-radius: 0 !important;

        flex: 0 0 32px !important;

        overflow: hidden !important;

        line-height: 1 !important;

        cursor: pointer !important;
        z-index: 100 !important;
    }

    /* ICON */
    .store-back svg{

        width: 18px !important;
        height: 18px !important;

        font-size: 18px !important;

        color: #fff !important;

        line-height: 1 !important;
    }
    .store-logo { order: 2; }
    .store-logo svg { width: 32px; height: 32px; }
    .store-logo-text { font-size: 18px; }
    .store-nav { display: none; order: 5; }
    .theme-toggle {
        order: 2;
        width: 40px;
        height: 40px;
        margin-left: auto;
    }
    .mobile-menu-btn {
        order: 3;
        display: flex;
        width: 40px;
        height: 40px;
        align-items: center;
        justify-content: center;
    }
    .mobile-menu { display: flex; flex-direction: column; }

    /* Search bar: full width below header row */
    .store-search {
        order: 4;
        display: block;
        flex: 0 0 100%;
        max-width: 100%;
        padding: 8px 0 4px;
    }
    .store-search .search-form {
        width: 100%;
        max-width: 100%;
    }
    .store-search .search-input {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* --- Hero Section --- */
    .hero-section { padding: 24px 0 20px; }
    .hero-title { font-size: 1.5rem; }
    .hero-subtitle { font-size: 1rem; margin-bottom: 20px; }
    .hero-search form { padding: 4px; }
    .hero-search-input { padding: 10px 12px; font-size: 0.875rem; }
    .hero-search-btn { padding: 10px 18px; font-size: 0.875rem; }

    /* --- Categories: 2-column grid, compact --- */
    .category-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .category-card {
        height: 100px;
        padding: 14px;
        border-radius: 16px;
        border-left: none;
        flex-direction: column;
        align-items: flex-start;
        justify-content: center;
        gap: 8px;
    }
    .category-card-icon { width: 36px; height: 36px; }
    .category-card-body h3 { font-size: 0.875rem; }
    .category-card-body span { font-size: 0.75rem; }

    /* --- App Grid: single column, Play Store style cards --- */
    .app-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .app-card {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 12px;
        height: 110px;
        border-radius: var(--radius-lg);
    }
    .app-card-icon { width: 64px; height: 64px; border-radius: 14px; }
    .app-card-body { flex: 1; min-width: 0; }
    .app-card-title { font-size: 0.9375rem; margin-bottom: 2px; }
    .app-card-desc { display: none; }
    .app-card-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .app-card-category {
        font-size: 0.75rem;
    }
    .app-card-downloads {
        font-size: 0.75rem;
    }

    /* --- Sections --- */
    .section { margin-bottom: 32px; }
    .section-header { margin-bottom: 16px; }
    .section-title { font-size: 1.25rem; }
    .section-link { font-size: 0.8125rem; }

    /* --- Footer --- */
    .footer-grid { grid-template-columns: 1fr; gap: 24px; }
    .store-footer { padding: 32px 0 20px; }

    /* --- Search page --- */
    .search-layout { grid-template-columns: 1fr; }
    .search-filters {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    .page-header { flex-direction: column; }

    /* --- Admin --- */
    .admin-sidebar {
        transform: translateX(-100%);
    }
    .admin-sidebar.open {
        transform: translateX(0);
    }
    .admin-main {
        margin-left: 0;
    }
    .sidebar-toggle { display: flex; }
    .admin-content { padding: 16px; }
    .admin-tabs { overflow-x: auto; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .dashboard-grid .card:nth-child(2),
    .dashboard-grid .card:nth-child(3),
    .dashboard-grid .card:nth-child(4),
    .dashboard-grid .card:nth-child(5),
    .dashboard-grid .card:nth-child(6),
    .dashboard-grid .card:nth-child(7) {
        grid-column: 1 / -1;
    }
    .table-actions { flex-direction: column; }
    .filter-group { flex-direction: column; }
    .filter-group .form-input { width: 100%; }
    .form-grid { grid-template-columns: 1fr; }
    .form-checkboxes { flex-direction: column; }
    .period-selector { width: 100%; }
    .period-selector .period-btn { flex: 1; text-align: center; }
}

/* ============================================================
   SMALL MOBILE: 480px and below
   ============================================================ */
@media (max-width: 480px) {
    .app-grid { grid-template-columns: 1fr; }
    .app-card { height: 100px; gap: 10px; padding: 10px; }
    .app-card-icon { width: 56px; height: 56px; }
    .app-card-title { font-size: 0.875rem; }

    .category-grid { gap: 10px; }
    .category-card { height: 90px; padding: 12px; }
    .category-card-icon { width: 32px; height: 32px; }
    .category-card-body h3 { font-size: 0.8125rem; }
    .category-card-body span { font-size: 0.6875rem; }

    .stats-grid { grid-template-columns: 1fr; }

    .store-logo-text { font-size: 16px; }
    .store-logo svg { width: 28px; height: 28px; }

    .hero-section { padding: 20px 0 16px; }
    .hero-title { font-size: 1.25rem; }

    .section-title { font-size: 1.125rem; }

    .search-filters { grid-template-columns: 1fr; }

    /* Toast on mobile */
    .toast-container { top: auto; bottom: 20px; right: 10px; left: 10px; max-width: none; }
    .toast { transform: translateY(120%); }
    .toast.show { transform: translateY(0); }
    .modal-box { padding: 24px 20px; margin: 10px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .btn { width: 100%; }
}

/* ============================================================
   VERY SMALL: 360px and below
   ============================================================ */
@media (max-width: 360px) {
    .store-logo-text { font-size: 14px; }
    .store-logo svg { width: 24px; height: 24px; }
    .theme-toggle { width: 36px; height: 36px; }
    .mobile-menu-btn { width: 36px; height: 36px; }
    .container { padding: 0 12px; }

    .app-card { height: 90px; gap: 8px; padding: 8px; }
    .app-card-icon { width: 48px; height: 48px; }
    .app-card-title { font-size: 0.8125rem; }
    .app-card-meta { gap: 1px; }
    .app-card-category,
    .app-card-downloads { font-size: 0.6875rem; }

    .category-card { height: 80px; padding: 10px; gap: 6px; }
    .category-card-icon { width: 28px; height: 28px; }
    .category-card-body h3 { font-size: 0.75rem; }
    .category-card-body span { font-size: 0.625rem; }

    .hero-title { font-size: 1.125rem; }
    .hero-search-btn { padding: 8px 14px; font-size: 0.8125rem; }

}
