:root {
    --bw-primary: #1d4ed8;
    --bw-primary-light: #eff6ff;
    --bw-dark: #0f172a;
    --bw-muted: #64748b;
    --bw-border: #e2e8f0;
    --bw-bg: #f8fafc;
    --bw-purple: #7c3aed;
}

* { font-family: 'Montserrat', sans-serif; }

body { background: var(--bw-bg); color: var(--bw-dark); }

.text-purple { color: var(--bw-purple) !important; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: #ffffff;
    border-right: 1px solid var(--bw-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 1030;
    transition: transform .2s ease;
}
.sidebar-brand {
    padding: 22px 20px;
    font-weight: 800;
    font-size: 1.05rem;
    display: flex; align-items: center; gap: 10px;
    color: var(--bw-primary);
    border-bottom: 1px solid var(--bw-border);
}
.sidebar-brand i { font-size: 1.4rem; }
.sidebar-nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px; margin-bottom: 2px;
    border-radius: 8px;
    color: #334155; text-decoration: none;
    font-size: .92rem; font-weight: 500;
}
.sidebar-nav a i { font-size: 1.05rem; width: 20px; text-align: center; color: var(--bw-muted); }
.sidebar-nav a:hover { background: var(--bw-primary-light); color: var(--bw-primary); }
.sidebar-nav a.active { background: var(--bw-primary); color: #fff; }
.sidebar-nav a.active i { color: #fff; }
.sidebar-divider {
    font-size: .68rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--bw-muted); font-weight: 700;
    padding: 16px 14px 6px;
}
.sidebar-storage { padding: 16px 20px; border-top: 1px solid var(--bw-border); }

.app-main { margin-left: 250px; flex: 1; display: flex; flex-direction: column; min-height: 100vh; width: calc(100% - 250px); }
.topbar { background: #fff; border-bottom: 1px solid var(--bw-border); padding: 14px 24px; position: sticky; top: 0; z-index: 1020; }
.app-content { padding: 24px; flex: 1; }

.avatar-circle {
    width: 34px; height: 34px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: .85rem;
}

@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .app-main { margin-left: 0; width: 100%; }
}

/* ---------- Cards / stats ---------- */
.stat-card {
    background: #fff; border: 1px solid var(--bw-border); border-radius: 14px;
    padding: 20px; display: flex; align-items: center; gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: #fff;
}
.stat-value { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: .8rem; color: var(--bw-muted); font-weight: 500; }

.card { border: 1px solid var(--bw-border); border-radius: 14px; }
.card-header { background: #fff; border-bottom: 1px solid var(--bw-border); font-weight: 700; border-radius: 14px 14px 0 0 !important; }

/* ---------- File / folder grid ---------- */
.breadcrumb-bar { background: #fff; border: 1px solid var(--bw-border); border-radius: 10px; padding: 10px 16px; }

.fm-toolbar { background: #fff; border: 1px solid var(--bw-border); border-radius: 12px; padding: 12px 16px; }

.fm-table thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bw-muted); font-weight: 700; border-bottom: 1px solid var(--bw-border); }
.fm-table td { vertical-align: middle; padding: 12px 10px; }
.fm-row { cursor: pointer; }
.fm-row:hover { background: var(--bw-primary-light); }
.fm-row.selected { background: #dbeafe; }
.fm-icon { font-size: 1.4rem; margin-right: 10px; }
.fm-name { font-weight: 600; font-size: .9rem; }
.fm-meta { font-size: .78rem; color: var(--bw-muted); }

.badge-perm-view { background: #e0f2fe; color: #0369a1; }
.badge-perm-edit { background: #dcfce7; color: #15803d; }
.badge-perm-download { background: #fef9c3; color: #854d0e; }
.badge-perm-owner { background: #ede9fe; color: #6d28d9; }

.upload-dropzone {
    border: 2px dashed var(--bw-border); border-radius: 14px; padding: 40px 20px; text-align: center;
    background: #fff; transition: all .15s ease; cursor: pointer;
}
.upload-dropzone.dragover { border-color: var(--bw-primary); background: var(--bw-primary-light); }

.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--bw-border); }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--bw-primary-light); color: var(--bw-primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #1d4ed8, #1e3a8a); padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand i { font-size: 2.4rem; color: var(--bw-primary); }

.preview-frame { width: 100%; min-height: 60vh; border: none; border-radius: 8px; }
.form-check-permission label { font-weight: 500; }
