:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #273449;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #334155;
    --danger: #ef4444;
    --success: #22c55e;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 12px;
}
.brand { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.navbar nav { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.navbar .user { color: var(--muted); font-size: .9rem; }
.btn-logout { color: var(--danger); }

.container {
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 28px 24px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.page-head h1 { margin: 0; font-size: 1.5rem; }

.search { display: flex; gap: 8px; }
.search input {
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

.files-area {
    flex: 1;
    min-height: calc(100vh - 260px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
}
.grid .file-card {
    width: 260px;
    max-width: 100%;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 18px;
}

.file-card { display: flex; flex-direction: column; }
.file-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.file-head h3 { margin: 0 0 6px; font-size: 1.05rem; }
.desc { color: var(--muted); font-size: .9rem; margin: 4px 0 12px; }
.meta {
    list-style: none;
    display: flex;
    gap: 12px;
    padding: 0;
    margin: auto 0 14px;
    color: var(--muted);
    font-size: .82rem;
    flex-wrap: wrap;
}
.badge {
    background: var(--surface-2);
    color: var(--primary);
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
}

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: .95rem;
    cursor: pointer;
    text-align: center;
    transition: background .15s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn-dl { width: 100%; }

.auth-card { max-width: 420px; margin: 40px auto; }
.auth-card h1 { margin-top: 0; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
.auth-card input,
.auth-card textarea,
.auth-card select {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: .95rem;
}

.alert { padding: 10px 14px; border-radius: 8px; font-size: .9rem; }
.alert.error { background: rgba(239,68,68,.15); color: #fca5a5; }
.alert.success { background: rgba(34,197,94,.15); color: #86efac; }

.muted { color: var(--muted); }
.empty { text-align: center; padding: 40px 0; }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--primary); }
.stat-label { color: var(--muted); font-size: .85rem; }

.card h2 { margin-top: 0; font-size: 1.2rem; }

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
.table th,
.table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface-2); }

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    align-items: end;
}
.form-grid label { display: flex; flex-direction: column; gap: 6px; font-size: .9rem; color: var(--muted); }
.form-grid input,
.form-grid select {
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font-size: .95rem;
}
.form-actions { display: flex; }

.row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.inline { display: inline; margin: 0; }
.link-btn {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: .85rem;
    padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--danger); }
.delete-form { margin-top: 10px; text-align: center; }

.card-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 14px;
}
.btn-download {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    border-radius: 10px;
    font-weight: 600;
    font-size: .95rem;
    color: #fff;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 4px 14px rgba(37, 99, 235, .35);
    transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.btn-download svg { transition: transform .2s ease; }
.btn-download:hover {
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(37, 99, 235, .5);
    filter: brightness(1.05);
}
.btn-download:hover svg { transform: translateY(2px); }
.btn-download:active { transform: translateY(0); box-shadow: 0 3px 10px rgba(37, 99, 235, .4); }

.btn-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    padding: 0;
    border-radius: 10px;
    color: var(--danger);
    background: rgba(239, 68, 68, .12);
    border: 1px solid rgba(239, 68, 68, .3);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, transform .15s ease;
}
.btn-delete:hover { background: var(--danger); color: #fff; transform: translateY(-2px); }
.btn-delete:active { transform: translateY(0); }

.cat-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}
.cat-tabs a {
    padding: 8px 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--muted);
    font-size: .88rem;
}
.cat-tabs a:hover { text-decoration: none; border-color: var(--primary); color: var(--text); }
.cat-tabs a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.cat-badge {
    display: inline-block;
    align-self: flex-start;
    background: var(--surface-2);
    color: var(--primary);
    font-size: .72rem;
    padding: 3px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    margin: 4px 0 8px;
}

.footer { text-align: center; padding: 24px; color: var(--muted); border-top: 1px solid var(--border); }
