:root {
    --bg:         #0f1117;
    --surface:    #1a1d27;
    --surface2:   #21263a;
    --border:     #2a2f45;
    --accent:     #4f7ef8;
    --accent-h:   #3a65d4;
    --text:       #e4e6f0;
    --text-muted: #8892aa;
    --danger:     #e05252;
    --warn:       #d4a017;
    --success:    #3db87a;
    --radius:     8px;
    --sidebar-w:  240px;
    --topbar-h:   56px;
    --font:       -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.btn:hover { background: var(--border); text-decoration: none; }
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface2); color: var(--text); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #c44; }
.btn-full { width: 100%; justify-content: center; }

/* ── Auth page ── */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 50% 0%, #1a2040 0%, var(--bg) 70%);
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 36px;
    text-align: center;
}

.auth-logo {
    color: var(--accent);
    margin-bottom: 16px;
}

.auth-card h1 {
    font-size: 24px;
    font-weight: 600;
    letter-spacing: -0.3px;
    margin-bottom: 4px;
}

.auth-sub {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 28px;
}

.field {
    text-align: left;
    margin-bottom: 16px;
}
.field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}
.field input {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 18px;
    text-align: left;
}
.alert-error { background: rgba(224,82,82,.15); border: 1px solid rgba(224,82,82,.4); color: #f09090; }
.alert-warn  { background: rgba(212,160,23,.15); border: 1px solid rgba(212,160,23,.4); color: #e0bb5a; }
.alert-success { background: rgba(61,184,122,.15); border: 1px solid rgba(61,184,122,.4); color: #5dd39e; }

/* ── App layout ── */
.app-page { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-icon { color: var(--accent); }
.topbar-brand { font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--text-muted); font-size: 13px; }

.layout {
    display: flex;
    margin-top: var(--topbar-h);
    min-height: calc(100vh - var(--topbar-h));
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    flex-shrink: 0;
    position: sticky;
    top: var(--topbar-h);
    height: calc(100vh - var(--topbar-h));
    overflow-y: auto;
}
.sidebar-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.8px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 0 20px 12px;
}
.sidebar-empty { color: var(--text-muted); font-size: 13px; padding: 0 20px; }

.cat-list { list-style: none; }
.cat-list li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--text-muted);
    font-size: 13px;
    transition: background 0.1s, color 0.1s;
}
.cat-list li a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.cat-list li.active a { background: rgba(79,126,248,.12); color: var(--accent); }
.cat-list li a svg { flex-shrink: 0; }

/* ── Content area ── */
.content {
    flex: 1;
    padding: 32px 36px;
    max-width: 960px;
}

.content-header {
    margin-bottom: 24px;
}
.content-header h2 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.cat-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 16px; }

.search-form {
    display: flex;
    gap: 8px;
    align-items: center;
}
.search-form input {
    padding: 7px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    outline: none;
    width: 280px;
}
.search-form input:focus { border-color: var(--accent); }

.welcome { padding-top: 60px; }
.welcome h2 { font-size: 24px; margin-bottom: 8px; }
.welcome p { color: var(--text-muted); }

.empty-state { color: var(--text-muted); padding: 40px 0; }

/* ── File table ── */
.file-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.file-table th {
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
}
.file-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(42,47,69,.5);
    vertical-align: middle;
}
.file-table tr:last-child td { border-bottom: none; }
.file-table tr:hover td { background: rgba(255,255,255,.02); }

.file-name {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    color: var(--text);
    max-width: 480px;
}
.file-name svg { flex-shrink: 0; margin-top: 2px; color: var(--text-muted); }
.file-name span { word-break: break-word; }
.file-desc { display: block; color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.file-size { color: var(--text-muted); white-space: nowrap; }
.file-date { color: var(--text-muted); white-space: nowrap; }
.file-action { text-align: right; }

/* ── Admin page base ── */
.admin-layout { display: flex; margin-top: var(--topbar-h); min-height: calc(100vh - var(--topbar-h)); }

.admin-sidebar {
    width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 20px 0;
}
.admin-sidebar ul { list-style: none; }
.admin-sidebar ul li a {
    display: block;
    padding: 9px 20px;
    color: var(--text-muted);
    font-size: 13px;
}
.admin-sidebar ul li a:hover { background: var(--surface2); color: var(--text); text-decoration: none; }
.admin-sidebar ul li.active a { color: var(--accent); background: rgba(79,126,248,.1); }
.admin-sidebar-title {
    font-size: 11px; font-weight: 600; letter-spacing: 0.8px;
    text-transform: uppercase; color: var(--text-muted);
    padding: 0 20px 12px;
}

.admin-content { flex: 1; padding: 32px 36px; max-width: 900px; }
.admin-content h2 { font-size: 20px; font-weight: 600; margin-bottom: 20px; }

/* ── Forms (admin) ── */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px; font-weight: 500;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-group input[type=text],
.form-group input[type=email],
.form-group input[type=password],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group select option { background: var(--surface2); }
.form-row { display: flex; gap: 16px; }
.form-row .form-group { flex: 1; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ── Data table (admin) ── */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 16px; }
.data-table th {
    text-align: left;
    font-size: 11px; font-weight: 600; letter-spacing: 0.6px;
    text-transform: uppercase; color: var(--text-muted);
    padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid rgba(42,47,69,.5); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(255,255,255,.02); }
.data-table .actions { display: flex; gap: 8px; justify-content: flex-end; }

.badge {
    display: inline-block;
    padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600;
}
.badge-admin  { background: rgba(79,126,248,.2); color: #8ab4ff; }
.badge-user   { background: rgba(255,255,255,.06); color: var(--text-muted); }
.badge-active { background: rgba(61,184,122,.15); color: #5dd39e; }
.badge-off    { background: rgba(224,82,82,.15); color: #f09090; }

/* ── Checkbox list (permissions) ── */
.check-list { display: flex; flex-direction: column; gap: 10px; }
.check-list label {
    display: flex; align-items: center; gap: 10px;
    font-size: 14px; color: var(--text);
    cursor: pointer; text-transform: none; letter-spacing: 0;
}
.check-list input[type=checkbox] { width: 16px; height: 16px; cursor: pointer; accent-color: var(--accent); }

/* ── Audit log ── */
.audit-table { font-size: 12px; }
.audit-table td { padding: 8px 12px; font-family: monospace; }

/* ── Upload drop zone ── */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 16px;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(79,126,248,.05);
    color: var(--text);
}
.drop-zone input[type=file] { display: none; }

/* ── Progress bar ── */
.progress-wrap { margin-top: 12px; }
.progress-bar-outer {
    background: var(--surface2);
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
}
.progress-bar-inner {
    height: 100%;
    background: var(--accent);
    width: 0%;
    transition: width 0.2s;
}
.progress-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
