:root {
    --bg: #f4f7fb;
    --panel: rgba(255, 255, 255, 0.92);
    --panel-strong: #ffffff;
    --text: #111827;
    --muted: #64748b;
    --line: #e2e8f0;
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --primary-soft: #e8efff;
    --danger: #dc2626;
    --danger-dark: #b91c1c;
    --warning: #b45309;
    --success: #047857;
    --shadow: 0 22px 55px rgba(15, 23, 42, 0.12);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 30%),
        radial-gradient(circle at top right, rgba(99, 102, 241, 0.14), transparent 26%),
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}

button,
input,
select {
    font: inherit;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 40px;
}

.hero {
    position: relative;
    overflow: hidden;
    padding: 28px;
    color: #fff;
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%);
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.hero::after {
    content: "";
    position: absolute;
    right: -85px;
    bottom: -100px;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    filter: blur(7px);
}

.hero-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}

.hero h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -0.035em;
}

.hero p {
    max-width: 720px;
    margin: 10px 0 0;
    color: rgba(255, 255, 255, 0.84);
    font-size: 15px;
    line-height: 1.6;
}

.hero-stats {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-top: 22px;
}

.stat {
    padding: 16px;
    background: rgba(255, 255, 255, 0.11);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 18px;
    backdrop-filter: blur(8px);
}

.stat .label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.8;
}

.stat .value {
    margin-top: 8px;
    font-size: 26px;
    font-weight: 800;
}

.top-actions,
.actions,
.file-actions,
.inline-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.top-actions form,
.file-actions form,
.inline-actions form {
    margin: 0;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 14px;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    backdrop-filter: blur(8px);
    transition: 0.2s ease;
}

.nav-link:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.19);
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 12px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
}

.grid {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 22px;
    margin-top: 22px;
    align-items: start;
}

.users-layout {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 22px;
    margin-top: 22px;
    align-items: start;
}

.card {
    padding: 22px;
    background: var(--panel);
    border: 1px solid rgba(255, 255, 255, 0.85);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
}

.card h2,
.card h3 {
    margin: 0 0 8px;
}

.card h2 {
    font-size: 20px;
}

.card h3 {
    font-size: 17px;
}

.sub,
.muted {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.flash {
    margin-top: 18px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: 16px;
    font-size: 14px;
}

.flash.success {
    color: #065f46;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.flash.error {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.flash.warning {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

label {
    display: block;
    margin: 14px 0 8px;
    font-size: 13px;
    font-weight: 700;
}

input[type="text"],
input[type="password"],
input[type="file"],
select {
    width: 100%;
    padding: 13px 14px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    outline: none;
    transition: 0.2s ease;
}

input:focus,
select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

input:disabled,
select:disabled {
    cursor: not-allowed;
    background: #f1f5f9;
    color: #94a3b8;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.checkbox-row input {
    width: 18px;
    height: 18px;
}

.checkbox-row label {
    margin: 0;
}

.actions {
    margin-top: 18px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 11px 15px;
    border: 0;
    border-radius: 14px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 750;
    transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    color: #fff;
    background: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-ghost {
    color: #1e3a8a;
    background: var(--primary-soft);
}

.btn-ghost:hover {
    background: #dbe7ff;
}

.btn-soft {
    color: #111827;
    background: #f1f5f9;
}

.btn-soft:hover {
    background: #e2e8f0;
}

.btn-danger {
    color: var(--danger);
    background: #fee2e2;
}

.btn-danger:hover {
    color: #fff;
    background: var(--danger-dark);
}

.btn-warning {
    color: #92400e;
    background: #fef3c7;
}

.btn-warning:hover {
    background: #fde68a;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

.toolbar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.toolbar > * {
    flex: 1 1 220px;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.file-card,
.user-card {
    background: var(--panel-strong);
    border: 1px solid #edf2f7;
    border-radius: 20px;
}

.file-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
}

.badge {
    display: grid;
    place-items: center;
    flex: 0 0 58px;
    width: 58px;
    height: 58px;
    color: #1d4ed8;
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    border-radius: 16px;
    font-size: 13px;
    font-weight: 850;
    letter-spacing: 0.06em;
}

.file-main {
    flex: 1;
    min-width: 0;
}

.file-name {
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.35;
    word-break: break-word;
}

.meta-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.pill,
.status-pill,
.role-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 650;
}

.pill {
    color: #475569;
    background: #f8fafc;
}

.status-pill.active {
    color: #065f46;
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.status-pill.inactive {
    color: #991b1b;
    background: #fef2f2;
    border-color: #fecaca;
}

.role-pill.admin {
    color: #1e3a8a;
    background: #e0e7ff;
    border-color: #c7d2fe;
}

.role-pill.user {
    color: #475569;
    background: #f8fafc;
}

.empty,
.hint {
    color: var(--muted);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid #e2e8f0;
    border-radius: 18px;
}

.empty {
    padding: 28px;
    text-align: center;
    border-style: dashed;
    border-width: 2px;
}

.hint {
    margin-top: 14px;
    padding: 14px;
    font-size: 13px;
    line-height: 1.55;
}

.login-box {
    max-width: 520px;
    margin: 22px auto 0;
}

.users-list {
    display: grid;
    gap: 14px;
}

.user-card {
    padding: 18px;
}

.user-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    align-items: flex-start;
    margin-bottom: 14px;
}

.user-title {
    font-size: 17px;
    font-weight: 850;
    word-break: break-word;
}

.user-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.user-form-grid .full {
    grid-column: 1 / -1;
}

.divider {
    height: 1px;
    margin: 16px 0;
    background: var(--line);
}

.security-note {
    margin-top: 18px;
    padding: 15px;
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.6;
}

@media (max-width: 1024px) {
    .grid,
    .users-layout {
        grid-template-columns: 1fr;
    }

    .files-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 680px) {
    .shell {
        width: min(100% - 18px, 1000px);
        margin: 10px auto 24px;
    }

    .hero,
    .card {
        padding: 18px;
        border-radius: 22px;
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .top-actions {
        width: 100%;
    }

    .nav-link,
    .top-actions .btn,
    .top-actions form {
        flex: 1 1 auto;
    }

    .top-actions form .btn {
        width: 100%;
    }

    .file-card {
        flex-direction: column;
    }

    .badge {
        width: 52px;
        height: 52px;
        flex-basis: 52px;
    }

    .user-form-grid {
        grid-template-columns: 1fr;
    }

    .user-form-grid .full {
        grid-column: auto;
    }

    .file-actions .btn,
    .file-actions form,
    .file-actions form .btn,
    .inline-actions .btn,
    .inline-actions form,
    .inline-actions form .btn {
        width: 100%;
    }
}
