:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #22263a;
    --accent: #4f8ef7;
    --accent2: #6c63ff;
    --success: #2ecc71;
    --danger: #e74c3c;
    --text: #e8eaf0;
    --muted: #7a7f9a;
    --border: #2e3250;
    --radius: 10px;
}

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

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* LOGIN */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-box h1 { font-size: 2rem; margin-bottom: .3rem; }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: .9rem; }

.login-box form { display: flex; flex-direction: column; gap: .8rem; }

/* HEADER */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .8rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

header h1 { font-size: 1.3rem; }

nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
nav a { color: var(--accent); text-decoration: none; font-size: .9rem; }
nav a:hover { text-decoration: underline; }

.user-info .badge {
    padding: .25rem .7rem;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
}
.badge.admin { background: #4f1f8e; color: #d4b3ff; }
.badge.user  { background: #1a3a6e; color: #90c0ff; }
.badge.readonly { background: #2a3a2a; color: #90d090; }

/* MAIN */
main {
    max-width: 1100px;
    margin: 2rem auto;
    padding: 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

h2 { font-size: 1.1rem; margin-bottom: 1rem; color: var(--text); }

/* ALERTS */
.alert {
    padding: .8rem 1.2rem;
    border-radius: var(--radius);
    font-size: .9rem;
}
.alert.success { background: #1a3a2a; border: 1px solid #2ecc71; color: #2ecc71; }
.alert.error   { background: #3a1a1a; border: 1px solid #e74c3c; color: #e74c3c; }

/* INPUTS */
input[type="text"],
input[type="password"],
input[type="file"],
select {
    width: 100%;
    padding: .65rem .9rem;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .95rem;
    outline: none;
    transition: border-color .2s;
}
input:focus, select:focus { border-color: var(--accent); }
input[type="file"] { cursor: pointer; }

/* BUTTONS */
button, .btn-dl, .btn-logout {
    padding: .6rem 1.2rem;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 600;
    transition: opacity .2s;
    text-decoration: none;
    display: inline-block;
}
button[type="submit"], #upload-btn {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #fff;
    width: 100%;
    padding: .75rem;
    margin-top: .3rem;
}
button:hover, .btn-dl:hover, .btn-logout:hover { opacity: .85; }

.btn-dl {
    background: var(--surface2);
    color: var(--accent);
    border: 1px solid var(--border);
    font-size: .82rem;
    padding: .35rem .7rem;
}
.btn-del {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: .35rem .6rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: .82rem;
}
.btn-del:hover { background: var(--danger); color: #fff; }
.btn-logout {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: .85rem;
    padding: .4rem .9rem;
}

/* DROP ZONE */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    color: var(--muted);
    cursor: pointer;
    transition: border-color .2s, background .2s;
    margin-bottom: .8rem;
}
.drop-zone.dragover { border-color: var(--accent); background: rgba(79,142,247,.07); }
.drop-zone input[type="file"] { display: none; }
.link { color: var(--accent); cursor: pointer; text-decoration: underline; }

#file-preview {
    background: var(--surface2);
    border-radius: 6px;
    padding: .6rem 1rem;
    font-size: .88rem;
    margin-bottom: .5rem;
    color: var(--text);
}

/* PROGRESS */
#progress-bar {
    height: 6px;
    background: var(--surface2);
    border-radius: 3px;
    margin-top: .5rem;
    overflow: hidden;
}
#progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent), var(--accent2));
    transition: width .3s;
}

/* TABLE */
.search-bar { margin-bottom: 1rem; }
.search-bar input { max-width: 320px; width: 100%; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th {
    text-align: left;
    padding: .6rem .8rem;
    color: var(--muted);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .15s; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: .65rem .8rem; vertical-align: middle; }

.mime {
    background: var(--surface2);
    padding: .15rem .5rem;
    border-radius: 4px;
    font-size: .78rem;
    color: var(--muted);
}
.actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.empty { color: var(--muted); text-align: center; padding: 2rem; }

/* LAYOUT SIDEBAR */
.layout {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
}

.sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: .9rem;
}

.btn-icon {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.folder-form {
    padding: .8rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.folder-form input { font-size: .85rem; padding: .4rem .6rem; }
.folder-form button { width: auto; margin-top: 0; padding: .4rem .8rem; font-size: .85rem; }

.folder-list { display: flex; flex-direction: column; }

.folder-item-wrap {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.folder-item-wrap:last-child { border-bottom: none; }

.folder-item {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .65rem 1rem;
    color: var(--text);
    text-decoration: none;
    font-size: .88rem;
    transition: background .15s;
    border-bottom: 1px solid var(--border);
}
.folder-item:last-child { border-bottom: none; }
.folder-item:hover { background: var(--surface2); }
.folder-item.active { background: var(--surface2); color: var(--accent); font-weight: 600; }

.folder-count {
    background: var(--surface2);
    color: var(--muted);
    font-size: .75rem;
    padding: .1rem .45rem;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}
.folder-item.active .folder-count { background: rgba(79,142,247,.2); color: var(--accent); }

.btn-folder-del {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: .4rem .6rem;
    font-size: .85rem;
    flex-shrink: 0;
}
.btn-folder-del:hover { color: var(--danger); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1.5rem; }

/* BREADCRUMB */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .88rem;
    color: var(--muted);
    padding: .5rem 0;
}
.breadcrumb a { color: var(--accent); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.folder-desc { color: var(--muted); font-style: italic; }

.folder-select { margin-bottom: .5rem; }

.count-badge {
    font-size: .78rem;
    font-weight: 400;
    color: var(--muted);
    margin-left: .5rem;
}

/* ADMIN */
.inline-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.inline-form input, .inline-form select { width: auto; flex: 1; min-width: 120px; }
.inline-form button { width: auto; margin-top: 0; }

.pwd-form {
    display: flex;
    gap: .4rem;
    margin-top: .4rem;
    flex-wrap: wrap;
}
.pwd-form input { flex: 1; min-width: 150px; }
.pwd-form button { width: auto; margin-top: 0; padding: .4rem .8rem; }

.hidden { display: none !important; }

/* RESPONSIVE */
@media (max-width: 700px) {
    .header-inner { flex-direction: column; align-items: flex-start; }
    .layout { flex-direction: column; }
    .sidebar { width: 100%; }
    table { font-size: .8rem; }
    thead { display: none; }
    tbody tr { display: block; margin-bottom: 1rem; border: 1px solid var(--border); border-radius: var(--radius); }
    tbody td { display: flex; justify-content: space-between; padding: .5rem .8rem; }
    tbody td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; }
}
