*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary: #206bc4;
    --primary-light: #e8f1fb;
    --sidebar-w: 240px;
    --navbar-h: 60px;
    --body-bg: #f6f8fa;
    --card-bg: #fff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-soft: #94a3b8;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--body-bg);
    color: var(--text);
    min-height: 100vh;
}

/* ===== Splash / Login ===== */
.splash-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}

.splash-card {
    background: #fff;
    border-radius: 16px;
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 60px rgba(0,0,0,.3);
}

.splash-logo { text-align: center; margin-bottom: 32px; }

.splash-logo h1 {
    font-size: 28px; font-weight: 700; color: #0f172a; letter-spacing: -0.5px;
}
.splash-logo span {
    display: block; font-size: 14px; color: var(--text-muted); font-weight: 400; margin-top: 4px;
}

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 600; color: #475569;
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px;
}
.form-control {
    width: 100%; padding: 12px 16px; border: 2px solid var(--border);
    border-radius: 10px; font-size: 15px; outline: none; background: #f8fafc;
    transition: all .2s;
}
.form-control:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(32,107,196,.1); }

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border: none; border-radius: 10px;
    font-size: 15px; font-weight: 600; cursor: pointer; transition: all .2s; gap: 8px;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:hover { background: #1a5aa8; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(32,107,196,.3); }
.btn-sm { padding: 8px 16px; font-size: 13px; border-radius: 8px; }
.btn-outline { background: transparent; border: 1.5px solid #cbd5e1; color: #475569; }
.btn-outline:hover { background: #f1f5f9; border-color: #94a3b8; }

.btn-danger-outline {
    background: #fef2f2; border: 1.5px solid #fecaca; color: #dc2626;
}
.btn-danger-outline:hover { background: #fee2e2; border-color: #fca5a5; }

.btn-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1.5px solid #cbd5e1;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.btn-icon:hover {
    background: #f1f5f9;
    border-color: var(--primary);
    color: var(--primary);
}

.alert { padding: 12px 16px; border-radius: 10px; font-size: 14px; margin-bottom: 20px; }
.alert-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* ===== Dashboard Layout ===== */
.dashboard { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w);
    background: #0f172a; color: #fff;
    display: flex; flex-direction: column;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 20px 24px; border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 18px; font-weight: 700; letter-spacing: -0.3px;
}
.sidebar-brand span { display: block; font-size: 11px; color: var(--text-soft); font-weight: 400; margin-top: 2px; }

.sidebar-nav { padding: 12px 0; flex: 1; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 24px; font-size: 14px; color: #94a3b8;
    cursor: pointer; transition: all .15s; border-left: 3px solid transparent;
    text-decoration: none; user-select: none;
}
.nav-item:hover { color: #e2e8f0; background: rgba(255,255,255,.04); }
.nav-item.active {
    color: #fff; background: rgba(32,107,196,.15);
    border-left-color: var(--primary); font-weight: 600;
}

.nav-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    padding: 16px 24px; border-top: 1px solid rgba(255,255,255,.08);
    font-size: 12px; color: var(--text-soft);
}

/* Main content area */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Top navbar (inside main) */
.topbar {
    height: var(--navbar-h); min-height: var(--navbar-h);
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 0 28px; display: flex; align-items: center; justify-content: space-between;
}
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }

/* Content panel */
.content { flex: 1; overflow-y: auto; padding: 28px; }

/* ===== Tab: TBD stub ===== */
.tbd-card {
    background: #fff; border-radius: 14px; border: 1px solid var(--border);
    padding: 48px; text-align: center; max-width: 600px; margin: 40px auto 0;
}
.tbd-card .tbd-icon { font-size: 48px; margin-bottom: 20px; opacity: .5; }
.tbd-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; color: var(--text); }
.tbd-card p { font-size: 14px; color: var(--text-muted); line-height: 1.6; margin-bottom: 12px; }
.tbd-badge {
    display: inline-block; padding: 4px 12px; border-radius: 20px;
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
    background: var(--primary-light); color: var(--primary);
}

/* ===== Tab: Products (file browser) ===== */
.file-browser { }
.file-browser-header {
    display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
}
.file-browser-header h2 { font-size: 20px; font-weight: 700; }
.search-input {
    padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13px; width: 240px; outline: none; background: #f8fafc;
    transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(32,107,196,.12); }
.search-input::placeholder { color: #94a3b8; }

.search-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.12);
    max-height: 360px;
    overflow-y: auto;
    z-index: 600;
    padding: 6px;
}
.search-dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.search-dd-item:hover { background: var(--primary-light); color: var(--primary); }
.search-dd-item b { color: var(--primary); }

.breadcrumbs {
    display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted);
    margin-bottom: 20px; flex-wrap: wrap; position: relative;
}
.breadcrumbs a { color: var(--primary); text-decoration: none; cursor: pointer; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { color: #cbd5e1; }

.breadcrumb-dropdown {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0,0,0,.12);
    min-width: 200px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 500;
    padding: 6px;
}
.breadcrumb-dd-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.breadcrumb-dd-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.file-table {
    width: 100%; border-collapse: collapse; background: #fff;
    border-radius: 12px; overflow: hidden; border: 1px solid var(--border);
}
.file-table th {
    text-align: left; padding: 12px 20px; font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted);
    background: #f8fafc; border-bottom: 1px solid var(--border);
}
.file-table td { padding: 10px 20px; font-size: 14px; border-bottom: 1px solid #f1f5f9; }
.file-table tr:last-child td { border-bottom: none; }
.file-table tr:hover td { background: #f8fafc; }

.file-row { cursor: pointer; }
.file-name { font-weight: 500; display: flex; align-items: center; gap: 10px; }
.file-icon { width: 18px; height: 18px; opacity: .6; flex-shrink: 0; }
.file-type { font-size: 12px; color: var(--text-soft); }
.file-size { font-size: 12px; color: var(--text-soft); text-align: right; }

/* ===== File viewer modal ===== */
.modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.7); backdrop-filter: blur(4px);
    z-index: 200; align-items: center; justify-content: center; padding: 40px;
}
.modal-overlay.active { display: flex; }

.modal-dialog {
    background: #fff; border-radius: 18px; width: 100%; max-width: 900px;
    max-height: 85vh; display: flex; flex-direction: column;
    box-shadow: 0 30px 80px rgba(0,0,0,.25);
}

.modal-dialog.wide { max-width: 1100px; }

.modal-header {
    padding: 20px 28px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; flex-shrink: 0;
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
    width: 36px; height: 36px; border-radius: 50%; border: none;
    background: #f1f5f9; cursor: pointer; font-size: 20px;
    display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.modal-close:hover { background: #e2e8f0; }

.modal-body { padding: 24px 28px; overflow-y: auto; }

/* Gallery in modal */
.gallery-grid-modal {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px;
}
.gallery-grid-modal img {
    width: 100%; height: 200px; object-fit: cover; border-radius: 10px; cursor: pointer;
    transition: transform .2s;
}
.gallery-grid-modal img:hover { transform: scale(1.03); }

/* ===== Gallery grid (file browser) ===== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.gallery-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    position: relative;
}

.gallery-thumb {
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    background: #f1f5f9;
    cursor: pointer;
}
.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-label {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.gallery-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px 8px 12px;
    gap: 4px;
}

/* Selection mode */
.gallery-check {
    display: none;
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,.8);
    background: rgba(0,0,0,.3);
    color: #fff;
    font-size: 14px;
    align-items: center;
    justify-content: center;
    z-index: 2;
    cursor: pointer;
    opacity: 0;
    transition: opacity .15s;
}
.gallery-grid.selecting .gallery-check {
    display: flex;
    opacity: .7;
}
.gallery-grid.selecting .gallery-card:hover .gallery-check {
    opacity: 1;
}
.gallery-card.selected .gallery-check {
    display: flex !important;
    opacity: 1 !important;
    background: var(--primary);
    border-color: var(--primary);
}
.gallery-card.selected {
    outline: 3px solid var(--primary);
    outline-offset: -3px;
    border-radius: 14px;
}

.select-bar {
    position: sticky;
    bottom: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 -2px 16px rgba(0,0,0,.06);
    padding: 12px 20px;
    margin: 20px auto 0;
    display: inline-flex;
    align-items: center;
    gap: 20px;
    z-index: 10;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.btn-link {
    background: #f1f5f9;
    border: 1px solid var(--border);
    cursor: pointer;
    font-size: 13px;
    padding: 3px 8px;
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    color: var(--text-muted);
}
.btn-link:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

.file-action {
    width: 80px;
    text-align: center;
    padding: 4px !important;
    white-space: nowrap;
}
.file-action .btn-link {
    display: inline-flex;
}

/* Code / text viewer */
.code-block {
    background: #1e293b; color: #e2e8f0; border-radius: 10px;
    padding: 20px; font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;
    font-size: 13px; line-height: 1.6; overflow-x: auto; white-space: pre-wrap;
    max-height: 60vh; overflow-y: auto;
}

.md-content { font-size: 14px; line-height: 1.8; }
.md-content h1, .md-content h2, .md-content h3 { margin: 16px 0 8px; }
.md-content h2 { font-size: 18px; }
.md-content h3 { font-size: 15px; }
.md-content p { margin-bottom: 10px; }
.md-content ul, .md-content ol { padding-left: 24px; margin-bottom: 10px; }
.md-content li { margin-bottom: 4px; }
.md-content code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-size: 13px; }

/* Loading & Empty */
.loading { text-align: center; padding: 60px 20px; color: var(--text-soft); }
.spinner {
    width: 36px; height: 36px; border: 3px solid var(--border);
    border-top-color: var(--primary); border-radius: 50%;
    animation: spin .8s linear infinite; margin: 0 auto 16px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 80px 20px; color: var(--text-soft); }
.empty-state svg { width: 64px; height: 64px; opacity: .2; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--text-muted); margin-bottom: 6px; }

/* Toast */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: #0f172a; color: #fff; padding: 12px 20px;
    border-radius: 10px; font-size: 14px; z-index: 300;
    animation: slideUp .3s ease;
}
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* Lightbox */
.lightbox-overlay {
    display: none; position: fixed; inset: 0; background: rgba(0,0,0,.92);
    z-index: 400; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox-overlay.active { display: flex; }
.lightbox-overlay img { max-width: 90vw; max-height: 90vh; object-fit: contain; border-radius: 8px; cursor: default; }

.lightbox-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,.1); color: #fff; border: none;
    font-size: 48px; width: 56px; height: 56px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s; z-index: 401; line-height: 1;
}
.lightbox-nav:hover { background: rgba(255,255,255,.25); }
.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }

.lightbox-counter {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    color: rgba(255,255,255,.6); font-size: 14px; z-index: 401;
}

.lightbox-close {
    position: absolute; top: 16px; right: 24px;
    background: rgba(255,255,255,.1); color: #fff; border: none;
    font-size: 32px; width: 44px; height: 44px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: background .15s; z-index: 401; line-height: 1;
}
.lightbox-close:hover { background: rgba(255,255,255,.25); }

/* ===== Welcome card on dashboard ===== */
.welcome-card {
    background: #fff; border-radius: 14px; border: 1px solid var(--border);
    padding: 32px; margin-bottom: 24px;
}
.welcome-card h2 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.welcome-card p { font-size: 14px; color: var(--text-muted); line-height: 1.6; }
