:root {
    color-scheme: dark;
    --bg: #05070a;
    --panel: #0d1117;
    --panel-2: #161b22;
    --muted: #8b949e;
    --text: #c9d1d9;
    --text-bright: #f0f6fc;
    --line: rgba(48, 54, 61, 0.7);
    --blue: #58a6ff;
    --blue-glow: rgba(88, 166, 255, 0.15);
    --green: #3fb950;
    --red: #f85149;
    --purple: #bc8cff;
    --radius: 14px;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
    --glass: rgba(13, 17, 23, 0.7);
    --owner-gold: #ffd700;
}

* { 
    box-sizing: border-box; 
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: var(--bg);
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(88, 166, 255, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 100% 100%, rgba(188, 140, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(88, 166, 255, 0.02) 0%, transparent 80%);
    color: var(--text);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }

/* Layout */
.app-shell {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    position: sticky;
    top: 0;
    width: 260px;
    height: 100vh;
    padding: 1.5rem;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text-bright);
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--blue), var(--purple));
    color: #0d1117;
    font-weight: 900;
    box-shadow: 0 0 20px var(--blue-glow);
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: var(--panel-2);
    color: var(--text-bright);
}

.nav-item.active {
    box-shadow: inset 0 0 0 1px var(--line);
}

.logout-form { margin-top: auto; }

.ghost-btn {
    width: 100%;
    padding: 0.75rem;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--muted);
    font-weight: 600;
    cursor: pointer;
}

.ghost-btn:hover {
    background: var(--panel-2);
    color: var(--red);
    border-color: var(--red);
}

/* Content */
.content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.topbar h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-bright);
}

.eyebrow {
    color: var(--blue);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

/* Search Box */
.search-box {
    display: flex;
    gap: 0.5rem;
    background: var(--panel);
    padding: 0.4rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    flex: 1;
    max-width: 600px;
}

.search-box input {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    flex: 1;
    color: var(--text);
}

.search-box select {
    background: var(--panel-2);
    border: none;
    border-radius: 8px;
    padding: 0 0.5rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.search-box button {
    background: var(--blue);
    color: #0d1117;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1.25rem;
    font-weight: 700;
    cursor: pointer;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
}

.stat {
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 1.5rem;
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.stat::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: radial-gradient(circle at top right, var(--blue-glow), transparent 70%);
}

.stat span {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

.stat strong {
    font-size: 2rem;
    color: var(--text-bright);
}

.meter {
    height: 6px;
    background: var(--panel-2);
    border-radius: 3px;
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--blue), var(--purple));
    border-radius: 3px;
}

/* Upload Area */
.upload-band {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    border: 2px dashed var(--line);
    transition: all 0.3s ease;
}

.upload-band:hover {
    border-color: var(--blue);
    background: var(--blue-glow);
}

.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    cursor: pointer;
}

.drop-icon {
    font-size: 3rem;
    color: var(--blue);
}

.progress {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 600px;
    background: var(--panel);
    border: 1px solid var(--blue);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 0 0 1px var(--blue-glow);
    z-index: 9999;
    display: none;
    flex-direction: column;
    gap: 1rem;
    backdrop-filter: blur(12px);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translate(-50%, 100%); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

.progress.active { display: flex; }

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

#progressName {
    font-weight: 700;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#progressMeta {
    font-size: 0.8rem;
    color: var(--muted);
}

.progress .meter {
    height: 10px;
    background: var(--panel-2);
    border-radius: 5px;
    width: 100%;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--blue);
}

#progressTime {
    color: var(--muted);
}

/* File List */
.section-block {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.section-header h2 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-bright);
}

.file-table {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    align-items: center;
    padding: 1rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    gap: 1.5rem;
}

.file-row:hover {
    border-color: var(--blue);
    background: var(--panel-2);
    transform: translateX(4px);
}

.file-row.head {
    background: transparent;
    border: none;
    padding: 0.5rem 1rem;
    color: var(--muted);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.file-row.head:hover { transform: none; }

.file-name {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-weight: 600;
    color: var(--text-bright);
}

.file-icon {
    width: 40px;
    height: 40px;
    background: var(--panel-2);
    border-radius: 8px;
    display: grid;
    place-items: center;
    font-size: 0.7rem;
    color: var(--blue);
    border: 1px solid var(--line);
}

.file-name img {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
}

.actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    padding: 0.5rem 1rem;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.icon-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
}

.danger-btn {
    padding: 0.5rem 1rem;
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.2);
    border-radius: 8px;
    color: var(--red);
    font-weight: 600;
    cursor: pointer;
}

.danger-btn:hover {
    background: var(--red);
    color: white;
}

/* Auth Pages */
.auth-page {
    width: 100%;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.auth-panel {
    width: 100%;
    max-width: 400px;
    background: var(--panel);
    padding: 2.5rem;
    border-radius: 20px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
}

.form-group input {
    background: var(--panel-2);
    border: 1px solid var(--line);
    padding: 0.8rem 1rem;
    border-radius: 10px;
    color: var(--text);
}

.form-group input:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px var(--blue-glow);
}

.primary-btn {
    background: var(--blue);
    color: #0d1117;
    padding: 1rem;
    border-radius: 12px;
    border: none;
    font-weight: 800;
    cursor: pointer;
    font-size: 1rem;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--blue-glow);
}

/* Toast */
.toast-stack {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    z-index: 1000;
}

.toast {
    padding: 1rem 1.5rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    color: var(--text-bright);
    animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 4px solid var(--green); }
.toast.danger { border-left: 4px solid var(--red); }
.toast.warning { border-left: 4px solid var(--purple); }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { width: 80px; padding: 1.5rem 0.5rem; align-items: center; }
    .logo span, .nav-item span { display: none; }
    .nav-item { justify-content: center; padding: 1rem; }
}

@media (max-width: 768px) {
    .app-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        height: auto;
        flex-direction: row;
        padding: 1rem;
        position: fixed;
        bottom: 0;
        top: auto;
        border-right: none;
        border-top: 1px solid var(--line);
    }
    .logo { display: none; }
    .nav-item { flex: 1; }
    .content { padding: 1.5rem; padding-bottom: 80px; }
    .topbar { flex-direction: column; align-items: flex-start; gap: 1rem; }
    .search-box { max-width: 100%; }
    .file-row { grid-template-columns: 1fr; gap: 0.75rem; }
    .file-row.head { display: none; }
}
/* Badges */
.owner-badge {
    margin-left: 0.5rem;
    filter: drop-shadow(0 0 8px var(--owner-gold));
    cursor: help;
}

.mini-badge {
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 800;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.mini-badge.owner {
    background: rgba(255, 215, 0, 0.1);
    color: var(--owner-gold);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.mini-badge.admin {
    background: var(--blue-glow);
    color: var(--blue);
    border: 1px solid var(--line);
}

/* Footer */
.app-footer {
    margin-top: auto;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 2rem;
    z-index: 50;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-left p {
    margin: 0.5rem 0 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.owner-link {
    color: var(--text-bright);
    font-weight: 700;
    border-bottom: 1px solid var(--line);
}

.owner-link:hover {
    color: var(--blue);
    border-color: var(--blue);
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.github-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.25rem;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.github-btn:hover {
    background: var(--text-bright);
    color: var(--bg);
    transform: translateY(-2px);
}

.version {
    font-size: 0.75rem;
    color: var(--muted);
    font-family: monospace;
}

.logo-text.small {
    font-weight: 800;
    font-size: 1rem;
    background: linear-gradient(135deg, var(--blue), var(--purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
