:root {
    --bg: #0f1020;
    --bg-soft: #17182e;
    --card: #1d1e38;
    --card-2: #24264a;
    --text: #ececff;
    --muted: #9a9ac4;
    --accent: #6d5efc;
    --accent-2: #8b7dff;
    --danger: #ff5d73;
    --ok: #38d39f;
    --radius: 16px;
    --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(109, 94, 252, .25), transparent 60%),
        radial-gradient(900px 500px at -10% 10%, rgba(56, 211, 159, .12), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

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

.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* ---------- top bar ---------- */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: .9rem 1.1rem;
    padding-top: calc(.9rem + env(safe-area-inset-top));
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(15, 16, 32, .72);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand { color: var(--text); font-weight: 700; font-size: 1.15rem; display: inline-flex; align-items: center; gap: .4rem; }
.brand:hover { text-decoration: none; }
.logo { font-size: 1.3rem; }
.topnav { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.topnav .who { color: var(--muted); font-size: .9rem; }

/* ---------- layout ---------- */
.wrap {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 1.1rem;
    padding-bottom: 4rem;
}
.hero { padding: 1.2rem .3rem .4rem; }
.hero h1 { margin: 0 0 .3rem; font-size: 1.5rem; }
.hero p { margin: 0; }

.card {
    background: linear-gradient(180deg, var(--card), var(--bg-soft));
    border: 1px solid rgba(255, 255, 255, .06);
    border-radius: var(--radius);
    padding: 1.1rem;
    margin: 1rem 0;
    box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: .8rem; }
.card-head h2 { margin: 0; }
.empty { padding: .4rem 0; }

/* ---------- buttons ---------- */
button, .btn-primary, .btn-ghost, .btn-danger { font: inherit; cursor: pointer; }
.btn-primary {
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: .6rem 1.1rem;
    font-weight: 600;
    box-shadow: 0 6px 18px rgba(109, 94, 252, .4);
    transition: transform .08s ease, filter .15s ease;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary.big { padding: .85rem 1.5rem; font-size: 1.05rem; border-radius: 14px; }
.btn-ghost {
    background: rgba(255, 255, 255, .06);
    color: var(--text);
    border: 1px solid rgba(255, 255, 255, .12);
    border-radius: 10px;
    padding: .45rem .8rem;
    transition: background .15s ease;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .12); text-decoration: none; }
.btn-danger {
    background: rgba(255, 93, 115, .12);
    color: var(--danger);
    border: 1px solid rgba(255, 93, 115, .35);
    border-radius: 10px;
    padding: .45rem .8rem;
}
.btn-danger:hover { background: rgba(255, 93, 115, .2); }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: .8rem; }
.form label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; color: var(--muted); }
.form input, .form select {
    background: var(--card-2);
    border: 1px solid rgba(255, 255, 255, .12);
    color: var(--text);
    border-radius: 10px;
    padding: .65rem .8rem;
    font-size: 1rem;
}
.form input:focus, .form select:focus { outline: 2px solid var(--accent); border-color: transparent; }
.row-form { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: .7rem; align-items: end; }
.row-form button { height: 44px; }
.inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0; }
.inline input { background: var(--card-2); border: 1px solid rgba(255, 255, 255, .12); color: var(--text); border-radius: 8px; padding: .4rem .55rem; width: 120px; }

/* ---------- alerts ---------- */
.alert { border-radius: 12px; padding: .7rem .9rem; margin: .8rem 0; font-size: .92rem; }
.alert.err { background: rgba(255, 93, 115, .12); border: 1px solid rgba(255, 93, 115, .4); color: #ffb3be; }
.alert.ok { background: rgba(56, 211, 159, .12); border: 1px solid rgba(56, 211, 159, .4); color: #9af0d2; }

/* ---------- login ---------- */
.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { margin: .2rem 0 .1rem; }
.login-card .form { margin-top: 1rem; text-align: left; }
.login-logo { font-size: 2.6rem; }

/* ---------- uploader ---------- */
.dropzone {
    border: 2px dashed rgba(255, 255, 255, .16);
    border-radius: 14px;
    padding: 1.6rem 1rem;
    text-align: center;
    transition: border-color .15s ease, background .15s ease;
}
.dropzone.drag { border-color: var(--accent); background: rgba(109, 94, 252, .08); }
.dropzone .small { margin: .7rem 0 0; }

.upload-list { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.up-card { background: var(--card-2); border: 1px solid rgba(255, 255, 255, .08); border-radius: 12px; padding: .75rem .85rem; }
.up-top { display: flex; justify-content: space-between; gap: .8rem; align-items: center; }
.up-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-status { font-size: .82rem; color: var(--muted); white-space: nowrap; }
.up-status.ok { color: var(--ok); }
.up-status.err { color: var(--danger); }
.up-bar { height: 8px; background: rgba(255, 255, 255, .08); border-radius: 99px; overflow: hidden; margin: .55rem 0; }
.up-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--ok)); border-radius: 99px; transition: width .2s ease; }
.up-info { display: flex; align-items: center; gap: .6rem; font-size: .8rem; color: var(--muted); }
.up-info .up-rate { flex: 1; }
.up-toggle { padding: .3rem .6rem; font-size: .8rem; }

/* ---------- file list ---------- */
.file-list, .user-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .55rem; }
.file-row, .user-row {
    display: flex; align-items: center; justify-content: space-between; gap: .8rem;
    background: var(--card-2); border: 1px solid rgba(255, 255, 255, .07);
    border-radius: 12px; padding: .7rem .85rem;
}
.file-meta, .user-main { display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-actions, .user-actions { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.file-actions form, .user-actions form { margin: 0; }
.user-row.inactive { opacity: .55; }

.badge { font-size: .68rem; padding: .12rem .45rem; border-radius: 99px; background: rgba(255, 255, 255, .1); color: var(--muted); vertical-align: middle; margin-left: .35rem; }
.badge-admin { background: rgba(109, 94, 252, .25); color: #cdc6ff; }
.badge-off { background: rgba(255, 93, 115, .18); color: #ffb3be; }
.user-name { font-weight: 600; }

/* ---------- footer ---------- */
.foot { text-align: center; padding: 2rem 1rem calc(1rem + env(safe-area-inset-bottom)); }

/* ---------- responsive ---------- */
@media (max-width: 560px) {
    .row-form { grid-template-columns: 1fr 1fr; }
    .row-form button { grid-column: 1 / -1; }
    .file-row, .user-row { flex-direction: column; align-items: stretch; }
    .file-actions, .user-actions { justify-content: flex-start; }
    .inline input { width: 100%; }
}
