:root {
    --purple-50: #faf5ff;
    --purple-100: #f3e8ff;
    --purple-200: #e9d5ff;
    --purple-300: #d8b4fe;
    --purple-400: #c084fc;
    --purple-500: #a855f7;
    --purple-600: #9333ea;
    --purple-700: #7e22ce;
    --purple-800: #6b21a8;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --green-500: #22c55e;
    --green-600: #16a34a;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--purple-600); text-decoration: none; }
a:hover { color: var(--purple-700); }

/* Layout */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.page { min-height: 100vh; display: flex; flex-direction: column; }
.content { flex: 1; padding: 32px 0; }

/* Header */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header .logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--purple-700);
    letter-spacing: -0.02em;
}
.header nav { display: flex; gap: 8px; align-items: center; }
.header nav a {
    padding: 6px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    transition: all .15s;
}
.header nav a:hover, .header nav a.active {
    background: var(--purple-50);
    color: var(--purple-700);
}

/* Cards */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 24px;
    margin-bottom: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}
.card-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary {
    background: var(--purple-600);
    color: white;
}
.btn-primary:hover { background: var(--purple-700); color: white; }
.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-700); }
.btn-danger { background: var(--red-500); color: white; }
.btn-danger:hover { background: var(--red-600); color: white; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-ghost {
    background: none;
    color: var(--gray-500);
    padding: 4px 8px;
}
.btn-ghost:hover { color: var(--purple-600); background: var(--purple-50); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color .15s;
    background: white;
    color: var(--gray-800);
}
.form-input:focus {
    outline: none;
    border-color: var(--purple-500);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, .15);
}

/* Login page */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--purple-50) 0%, var(--gray-50) 100%);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
}
.login-card h1 {
    text-align: center;
    font-size: 22px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
}
.login-card .subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 28px;
}
.login-card .btn { width: 100%; justify-content: center; padding: 12px; }

/* Error/success messages */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}
.alert-success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Table */
.table-wrapper { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
thead th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--gray-500);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}
thead th a { color: var(--gray-500); }
thead th a:hover { color: var(--purple-600); }
tbody td {
    padding: 12px;
    border-bottom: 1px solid var(--gray-100);
    vertical-align: middle;
}
tbody tr:hover { background: var(--gray-50); }
.file-name {
    font-weight: 500;
    color: var(--gray-900);
    word-break: break-all;
    max-width: 300px;
}
.file-meta {
    font-size: 12px;
    color: var(--gray-400);
}
.actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }

/* Upload area */
.upload-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .2s;
    background: var(--gray-50);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--purple-400);
    background: var(--purple-50);
}
.upload-zone .icon { font-size: 40px; color: var(--purple-400); margin-bottom: 8px; }
.upload-zone p { color: var(--gray-500); font-size: 14px; }
.upload-zone .browse { color: var(--purple-600); font-weight: 500; text-decoration: underline; }

/* Upload progress */
.upload-list { margin-top: 16px; }
.upload-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}
.upload-item .name { flex: 1; color: var(--gray-700); word-break: break-all; }
.upload-item .status { font-size: 12px; color: var(--gray-400); white-space: nowrap; }
.upload-item .status.done { color: var(--green-600); }
.upload-item .status.error { color: var(--red-500); }
.progress-bar {
    width: 120px;
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
    flex-shrink: 0;
}
.progress-bar .fill {
    height: 100%;
    background: var(--purple-500);
    border-radius: 3px;
    transition: width .2s;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card .label { font-size: 13px; color: var(--gray-500); margin-bottom: 4px; }
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--gray-900); }

/* Disk bar */
.disk-bar {
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
    margin-top: 8px;
}
.disk-bar .fill {
    height: 100%;
    background: var(--purple-500);
    border-radius: 4px;
    transition: width .3s;
}

/* Search bar */
.search-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
.search-bar .form-input { max-width: 280px; }
.search-bar select {
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    color: var(--gray-700);
}

/* Download page */
.download-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, var(--purple-50) 0%, var(--gray-50) 100%);
}
.download-card {
    width: 100%;
    max-width: 480px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px 32px;
    text-align: center;
}
.download-card .file-icon {
    width: 64px;
    height: 64px;
    background: var(--purple-100);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    font-size: 28px;
    color: var(--purple-600);
}
.download-card h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 16px;
    word-break: break-all;
}
.download-card .meta {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 28px;
    font-size: 14px;
    color: var(--gray-500);
}
.download-card .meta span { display: flex; align-items: center; gap: 4px; }
.download-card .btn { width: 100%; justify-content: center; padding: 14px; font-size: 16px; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 24px;
    width: 100%;
    max-width: 420px;
}
.modal h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.modal p { font-size: 14px; color: var(--gray-600); margin-bottom: 20px; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Link display */
.link-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 6px 10px;
    margin-top: 4px;
}
.link-box input {
    flex: 1;
    border: none;
    background: none;
    font-size: 13px;
    color: var(--gray-600);
    outline: none;
    min-width: 0;
}
.link-box .btn-ghost { flex-shrink: 0; }

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn .3s ease;
    max-width: 360px;
}
.toast-success { background: #166534; color: white; }
.toast-error { background: #991b1b; color: white; }

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

/* Badge */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 12px;
    font-weight: 500;
}
.badge-purple { background: var(--purple-100); color: var(--purple-700); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* Folder tag */
.folder-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--purple-50);
    color: var(--purple-600);
    border-radius: 100px;
    font-size: 12px;
}

/* Log table */
.log-table { font-size: 13px; }
.log-table td { padding: 8px 12px; }
.log-action { font-weight: 500; }

/* Error page */
.error-page {
    text-align: center;
    padding: 80px 20px;
}
.error-page h1 { font-size: 48px; color: var(--purple-600); font-weight: 700; }
.error-page p { color: var(--gray-500); margin-top: 8px; }

/* Responsive */
@media (max-width: 768px) {
    .header .container { flex-wrap: wrap; gap: 8px; }
    .card { padding: 16px; }
    .table-wrapper { margin: 0 -16px; padding: 0 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar .form-input { max-width: none; }
    .upload-zone { padding: 24px 16px; }
    .download-card { padding: 28px 20px; }
    .actions { flex-direction: column; align-items: flex-start; }
    .file-name { max-width: 160px; }
}

@media (max-width: 480px) {
    .login-card { padding: 28px 20px; }
    .download-card .meta { flex-direction: column; gap: 8px; }
}
