*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Segoe UI',-apple-system,sans-serif;background:#0f172a;color:#e2e8f0;min-height:100vh}
a{color:#10b981;text-decoration:none}a:hover{text-decoration:underline}
.sidebar{position:fixed;left:0;top:0;bottom:0;width:220px;background:#1e293b;border-right:1px solid #334155;padding:20px 0;display:flex;flex-direction:column}
.sidebar-brand{padding:0 20px 20px;font-size:1.1rem;font-weight:700;color:#10b981;border-bottom:1px solid #334155}
.nav-link{display:block;padding:12px 20px;color:#94a3b8;font-size:0.9rem;font-weight:500;transition:all 0.2s}
.nav-link:hover{background:#334155;color:#fff;text-decoration:none}
.nav-link.logout{margin-top:auto;color:#ef4444}
main{padding:32px}main.with-sidebar{margin-left:220px}
.auth-container{display:flex;align-items:center;justify-content:center;min-height:100vh}
.auth-card{background:#1e293b;border:1px solid #334155;border-radius:16px;padding:40px;width:100%;max-width:400px;text-align:center}
.auth-card h1{font-size:1.5rem;color:#10b981;margin-bottom:4px}
.subtitle{color:#64748b;margin-bottom:24px;font-size:0.9rem}
.auth-card input{width:100%;padding:12px 16px;margin-bottom:12px;background:#0f172a;border:1px solid #334155;border-radius:8px;color:#e2e8f0;font-size:0.95rem}
.btn-primary{display:inline-block;background:#10b981;color:#fff;padding:12px 24px;border-radius:8px;font-weight:600;border:none;cursor:pointer;font-size:0.95rem;width:100%}
.btn-primary:hover{background:#059669;text-decoration:none}
.btn-secondary{display:inline-block;background:#1e293b;color:#10b981;border:1px solid #10b981;padding:8px 16px;border-radius:8px;font-weight:500;font-size:0.85rem;cursor:pointer}
.btn-outline{display:inline-block;background:transparent;color:#94a3b8;border:1px solid #334155;padding:8px 16px;border-radius:8px;font-size:0.85rem}
.page-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:24px}
.page-header h1{font-size:1.5rem;font-weight:700}
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:16px;margin-bottom:32px}
.stat-card{background:#1e293b;border:1px solid #334155;border-radius:12px;padding:20px}
.stat-value{font-size:1.5rem;font-weight:700;color:#10b981}
.stat-label{color:#64748b;font-size:0.8rem;margin-top:4px}
.books-list,.chapters-list{display:flex;flex-direction:column;gap:8px}
.book-card,.chapter-card{display:flex;align-items:center;gap:12px;background:#1e293b;border:1px solid #334155;border-radius:10px;padding:16px 20px;transition:all 0.2s}
.book-card:hover,.chapter-card:hover{border-color:#10b981;text-decoration:none}
.book-title,.ch-title{font-weight:600;color:#e2e8f0;flex:1}
.book-meta,.ch-meta{font-size:0.8rem;color:#64748b}
.ch-num{background:#10b981;color:#0f172a;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:0.8rem}
.genre{background:rgba(16,185,129,0.15);color:#10b981;padding:2px 8px;border-radius:4px;font-size:0.75rem}
.status{padding:2px 8px;border-radius:4px;font-size:0.75rem;font-weight:600}
.status-draft{background:rgba(59,130,246,0.15);color:#3b82f6}
.status-outline{background:rgba(148,163,184,0.15);color:#94a3b8}
.status-complete{background:rgba(34,197,94,0.15);color:#22c55e}
.status-writing{background:rgba(245,158,11,0.15);color:#f59e0b}
.report-form,.editor-form,.ai-edit-form{background:#1e293b;border:1px solid #334155;border-radius:12px;padding:28px;max-width:700px;margin-bottom:16px}
.form-group{margin-bottom:16px}
.form-group label{display:block;font-size:0.85rem;font-weight:600;color:#94a3b8;margin-bottom:6px}
.form-group input,.form-group textarea,.form-group select{width:100%;padding:10px 14px;background:#0f172a;border:1px solid #334155;border-radius:8px;color:#e2e8f0;font-size:0.9rem}
.editor{width:100%;min-height:400px;padding:16px;background:#0f172a;border:1px solid #334155;border-radius:8px;color:#e2e8f0;font-size:0.95rem;line-height:1.7;font-family:Georgia,serif;resize:vertical;margin-bottom:12px}
.editor-actions{margin-bottom:16px}
.book-desc{color:#64748b;margin-bottom:20px}
.flash{padding:12px 16px;border-radius:8px;margin-bottom:16px;font-size:0.9rem}
.flash-error{background:rgba(239,68,68,0.15);color:#ef4444;border:1px solid rgba(239,68,68,0.3)}
.flash-success{background:rgba(34,197,94,0.15);color:#22c55e;border:1px solid rgba(34,197,94,0.3)}
.empty{color:#64748b;padding:20px;text-align:center}
.auth-link{margin-top:16px;color:#64748b;font-size:0.85rem}
@media(max-width:768px){.sidebar{display:none}main.with-sidebar{margin-left:0}}

/* ============================================
   NEI-Labs Mobile Responsive Fix
   Applied to all 4 products
   ============================================ */

/* Mobile: phones */
@media (max-width: 480px) {
    .auth-container {
        padding: 16px;
        min-height: 100vh;
    }

    .auth-card {
        padding: 24px 20px;
        max-width: 100%;
        border-radius: 8px;
    }

    .auth-card h1 {
        font-size: 18px;
    }

    .nei-brand-header img {
        width: 160px !important;
        max-width: 80% !important;
    }

    .form-group {
        margin-bottom: 14px;
    }

    .form-control {
        font-size: 16px !important; /* prevents iOS zoom on focus */
        padding: 12px;
    }

    .btn-primary {
        padding: 14px;
        font-size: 15px;
    }

    /* Dashboard */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }

    .main-content {
        margin-left: 0 !important;
        padding: 16px !important;
    }

    .topbar {
        padding: 12px 16px;
    }

    .topbar h2 {
        font-size: 16px;
    }

    /* Tables */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
    }

    /* Cards */
    .card {
        padding: 16px;
    }

    .card-header h3 {
        font-size: 14px;
    }
}

/* Tablet */
@media (max-width: 768px) {
    .auth-card {
        padding: 32px 24px;
    }

    .nei-brand-header img {
        width: 200px !important;
        max-width: 80% !important;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        position: fixed;
        z-index: 1000;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0 !important;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Mobile hamburger menu */
    .mobile-menu-btn {
        display: block !important;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 1001;
        background: var(--bg-card, #1a2236);
        border: 1px solid var(--border, #1e293b);
        color: var(--gold, #c9a227);
        padding: 8px 12px;
        border-radius: 6px;
        font-size: 18px;
        cursor: pointer;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

/* Desktop: hide mobile menu button */
@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none !important;
    }
    .sidebar-overlay {
        display: none !important;
    }
}

/* General mobile improvements */
@media (max-width: 768px) {
    /* Form inputs should be full width */
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
    }

    /* Prevent horizontal overflow */
    body {
        overflow-x: hidden;
    }

    /* Better touch targets */
    .btn, button, a.btn {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Editor area */
    .editor-container {
        flex-direction: column;
    }

    .editor-sidebar {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid var(--border, #1e293b);
    }

    .editor-main {
        width: 100% !important;
    }

    .editor-tabs {
        flex-wrap: wrap;
        gap: 4px;
    }

    .editor-tab {
        font-size: 12px;
        padding: 6px 10px;
    }
}

/* Sidebar sections */
.nav-section {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border, #1e293b);
}
.nav-section:last-child {
    border-bottom: none;
}
.nav-section-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted, #64748b);
    padding: 0 16px;
    margin-bottom: 6px;
}
.sidebar-brand img {
    vertical-align: middle;
}
.sidebar-brand span {
    font-size: 14px;
    font-weight: 700;
    color: var(--gold, #c9a227);
}

/* Import page styles */
.import-container {
    max-width: 800px;
}
.import-step {
    background: var(--bg-card, #1a2236);
    border: 1px solid var(--border, #1e293b);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 20px;
}
.import-step h3 {
    color: var(--gold, #c9a227);
    font-size: 15px;
    margin-bottom: 12px;
}
.chapter-import-item {
    background: var(--bg-secondary, #111827);
    border: 1px solid var(--border, #1e293b);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}
.chapter-import-item h4 {
    font-size: 13px;
    color: var(--text-primary, #f1f5f9);
    margin-bottom: 8px;
}
.quality-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.quality-high { background: rgba(34,197,94,0.15); color: #22c55e; }
.quality-medium { background: rgba(245,158,11,0.15); color: #f59e0b; }
.quality-low { background: rgba(239,68,68,0.15); color: #ef4444; }
