:root {
    --bg: #020617;
    --bg-soft: #020617;
    --surface: rgba(15,23,42,0.85);
    --border: rgba(148,163,184,0.15);
    --accent: #3b82f6;
    --accent-soft: rgba(59,130,246,0.12);
    --accent-strong: #22c55e;
    --danger: #ef4444;
    --text: #e5e7eb;
    --text-soft: #9ca3af;
    --radius-lg: 1.1rem;
    --shadow-strong: 0 32px 120px rgba(15,23,42,0.95);
    --shadow-soft: 0 18px 60px rgba(15,23,42,0.9);
    --sidebar-width: 220px;
    --topbar-height: 72px;
    --transition-fast: 0.18s ease-out;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #1e293b 0, #020617 45%, #000 100%);
    color: var(--text);
}

/* Auth layout */

.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.auth-wrapper {
    width: 100%;
    max-width: 480px;
    padding: 1.5rem;
}

.glass {
    background: radial-gradient(circle at top left, rgba(56,189,248,0.08), rgba(15,23,42,0.96));
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-strong);
    backdrop-filter: blur(18px);
}

.auth-card {
    padding: 2.2rem 2rem 1.8rem;
}

.auth-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.auth-logo-circle {
    width: 3rem;
    height: 3rem;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0, #6ee7b7, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #0f172a;
    font-size: 1.1rem;
    box-shadow: 0 0 0 1px rgba(15,23,42,0.8), 0 18px 50px rgba(34,197,94,0.55);
}

.auth-header h1 {
    margin: 0;
    font-size: 1.4rem;
}

.auth-header p {
    margin: 0.15rem 0 0;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.auth-form {
    margin-top: 1rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.9rem;
    font-size: 0.9rem;
}

.field span {
    color: var(--text-soft);
}

.field input,
.field textarea,
.field select {
    border-radius: 0.75rem;
    border: 1px solid rgba(148,163,184,0.4);
    background: rgba(15,23,42,0.9);
    color: var(--text);
    padding: 0.55rem 0.75rem;
    outline: none;
    font: inherit;
    resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(59,130,246,0.4);
}

.auth-footer-note {
    margin-top: 0.9rem;
    font-size: 0.78rem;
    color: var(--text-soft);
    text-align: center;
}

/* Buttons */

.btn-primary,
.btn-secondary,
.btn-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    font: inherit;
    padding: 0.55rem 1.25rem;
    text-decoration: none;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #22c55e);
    color: #0b1120;
    font-weight: 600;
    box-shadow: 0 16px 40px rgba(59,130,246,0.55);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 60px rgba(59,130,246,0.75);
}

.btn-secondary {
    background: rgba(15,23,42,0.9);
    border: 1px solid rgba(148,163,184,0.5);
    color: var(--text);
    padding-inline: 1rem;
}

.btn-secondary:hover {
    background: rgba(30,64,175,0.6);
}

.btn-link {
    background: transparent;
    color: var(--accent);
    padding: 0;
    box-shadow: none;
    border-radius: 0;
}

.btn-link.danger {
    color: var(--danger);
}

.btn-link:hover {
    text-decoration: underline;
}

.btn-primary.full {
    width: 100%;
}

/* Alerts */

.alert {
    padding: 0.7rem 0.8rem;
    border-radius: 0.8rem;
    font-size: 0.85rem;
    margin-bottom: 0.9rem;
}

.alert-error {
    background: rgba(248,113,113,0.1);
    border: 1px solid rgba(248,113,113,0.7);
    color: #fecaca;
}

.alert-success {
    background: rgba(34,197,94,0.1);
    border: 1px solid rgba(34,197,94,0.7);
    color: #bbf7d0;
}

/* App layout */

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.4rem;
    z-index: 20;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.logo-circle {
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 0.9rem;
    background: conic-gradient(from 210deg, #22c55e, #22d3ee, #3b82f6, #22c55e);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #020617;
    box-shadow: 0 18px 40px rgba(34,197,94,0.5);
}

.app-meta {
    display: flex;
    flex-direction: column;
}

.app-title {
    font-weight: 600;
    letter-spacing: 0.03em;
}

.app-subtitle {
    font-size: 0.78rem;
    color: var(--text-soft);
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-meta {
    display: flex; flex-direction: column; align-items:flex-end;
}

.user-name {
    font-size: 0.9rem;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-soft);
}

.main-layout {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    gap: 1.5rem;
    padding: calc(var(--topbar-height) + 1rem) 1.5rem 1.5rem;
}

.sidebar {
    height: calc(100vh - var(--topbar-height) - 2rem);
    position: sticky;
    top: calc(var(--topbar-height) + 1rem);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
    box-shadow: var(--shadow-soft);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.nav-link {
    padding: 0.45rem 0.65rem;
    border-radius: 0.7rem;
    color: var(--text-soft);
    text-decoration: none;
    font-size: 0.9rem;
    transition: background var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.nav-link:hover {
    background: rgba(15,23,42,0.9);
    color: var(--text);
}

.nav-link.active {
    background: var(--accent-soft);
    color: #bfdbfe;
    transform: translateX(2px);
}

.sidebar-footer {
    font-size: 0.75rem;
    color: var(--text-soft);
}

.sidebar-footer code {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    background: rgba(15,23,42,0.9);
    border: 1px solid rgba(148,163,184,0.4);
}

/* Content */

.content {
    min-height: calc(100vh - var(--topbar-height) - 2rem);
}

.grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr);
    gap: 1.35rem;
}

.card {
    padding: 1.4rem 1.5rem 1.3rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}

.card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
}

.muted {
    margin: 0 0 1rem;
    color: var(--text-soft);
    font-size: 0.88rem;
}

/* Upload */

.upload-form {
    margin-top: 0.4rem;
}

.upload-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 0.6rem;
}

.upload-meta {
    font-size: 0.8rem;
    color: var(--text-soft);
}

.progress-wrapper {
    margin-top: 0.9rem;
}

.progress-bar-bg {
    width: 100%;
    height: 0.6rem;
    border-radius: 999px;
    background: rgba(15,23,42,0.9);
    overflow: hidden;
    border: 1px solid rgba(148,163,184,0.4);
}

.progress-bar-fg {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    transition: width 0.12s linear;
}

.progress-info {
    margin-top: 0.3rem;
    display: flex;
    justify-content: space-between;
    font-size: 0.78rem;
    color: var(--text-soft);
}

/* Tables */

.table-wrapper {
    margin-top: 0.6rem;
    border-radius: 1rem;
    border: 1px solid rgba(30,64,175,0.6);
    overflow: hidden;
    background: radial-gradient(circle at top left, rgba(37,99,235,0.1), rgba(15,23,42,0.95));
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.table thead {
    background: linear-gradient(to right, rgba(37,99,235,0.25), rgba(30,64,175,0.2));
}

.table th,
.table td {
    padding: 0.6rem 0.7rem;
    text-align: left;
    border-bottom: 1px solid rgba(30,64,175,0.45);
}

.table tbody tr:nth-child(even) {
    background: rgba(15,23,42,0.8);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.file-name {
    font-weight: 500;
}

.file-desc {
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: var(--text-soft);
}

/* Generic */

.form {
    margin-top: 0.5rem;
}

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

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Responsive */

@media (max-width: 960px) {
    .main-layout {
        grid-template-columns: minmax(0, 1fr);
        padding-inline: 1rem;
    }
    .sidebar {
        display: none;
    }
    .grid {
        grid-template-columns: minmax(0, 1fr);
    }
    .topbar {
        padding-inline: 1rem;
    }
}

@media (max-width: 640px) {
    .auth-card {
        padding: 1.5rem 1.3rem 1.4rem;
    }
    .main-layout {
        padding-inline: 0.8rem;
    }
    .card {
        padding-inline: 1.1rem;
    }
}
