/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:         #f1f5f9;
    --surface:    #ffffff;
    --border:     #e2e8f0;
    --text:       #0f172a;
    --text-muted: #64748b;
    --primary:    #2563eb;
    --primary-h:  #1d4ed8;
    --danger:     #ef4444;
    --danger-h:   #dc2626;
    --success:    #10b981;
    --warning:    #f59e0b;
    --radius:     10px;
    --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow-lg:  0 10px 25px rgba(0,0,0,.12);
    --font:       -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body { height: 100%; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ---- Login Page ---- */
.page-login {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
}

.login-wrap { width: 100%; max-width: 400px; padding: 24px; }

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
    justify-content: center;
}

.login-brand svg {
    width: 36px;
    height: 36px;
    color: var(--primary);
    stroke: var(--primary);
}

.login-brand span {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.5px;
}

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 20px;
}
.alert-error   { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

/* ---- Form Elements ---- */
.form-group { margin-bottom: 18px; }

label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="email"] {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font);
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .15s, opacity .15s, box-shadow .15s;
    white-space: nowrap;
    line-height: 1;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-h); color: #fff; text-decoration: none; }

.btn-block { width: 100%; justify-content: center; padding: 11px 18px; font-size: 15px; }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.btn-sm { padding: 6px 12px; font-size: 13px; }

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

.btn-icon { padding: 6px 8px; }

.btn-copy {
    background: var(--bg);
    color: var(--text-muted);
    border: 1.5px solid var(--border);
    font-size: 12px;
}
.btn-copy:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-copy.copied { background: var(--success); color: #fff; border-color: var(--success); }

/* ---- Top Nav ---- */
.topnav {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.topnav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.3px;
    color: var(--text);
}

.topnav-brand svg {
    width: 22px;
    height: 22px;
    stroke: var(--primary);
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---- Main Content ---- */
.main-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 28px;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 18px;
}

.section-header {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 18px;
}
.file-count {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 99px;
    border: 1px solid var(--border);
}

/* ---- Drop Zone ---- */
.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    background: var(--bg);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: #eff6ff;
}

.drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.drop-zone-inner svg {
    width: 48px;
    height: 48px;
    stroke: var(--text-muted);
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.drop-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.drop-subtext {
    font-size: 13px;
    color: var(--text-muted);
}

.link-text {
    color: var(--primary);
    font-weight: 600;
}

/* ---- Upload Queue ---- */
.upload-queue { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }

.upload-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
}

.upload-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.upload-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70%;
}

.upload-item-status {
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
}
.upload-item-status.done   { color: var(--success); font-weight: 600; }
.upload-item-status.error  { color: var(--danger);  font-weight: 600; }

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 99px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 99px;
    transition: width .3s ease;
    width: 0%;
}
.progress-fill.done  { background: var(--success); }
.progress-fill.error { background: var(--danger); }

/* ---- File Table ---- */
.table-wrap { overflow-x: auto; }

.file-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.file-table th {
    text-align: left;
    padding: 8px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

.file-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

.file-table tbody tr:hover td { background: #f8fafc; }

.col-name {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 300px;
}

.file-icon { font-size: 18px; flex-shrink: 0; }

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.col-size, .col-date, .col-dl {
    color: var(--text-muted);
    white-space: nowrap;
}

.col-link { white-space: nowrap; }

.col-del { text-align: right; }

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state svg {
    width: 48px;
    height: 48px;
    stroke: var(--border);
    margin-bottom: 12px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.empty-state p { font-size: 14px; }

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: 14px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}
.modal-close:hover { background: var(--bg); }

.modal-body { padding: 20px 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #1e293b;
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    z-index: 300;
    max-width: 320px;
}
.toast.show {
    opacity: 1;
    transform: translateY(0);
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .topnav { padding: 0 16px; }
    .main-content { padding: 20px 16px 48px; }
    .card { padding: 20px 16px; }
    .login-card { padding: 28px 20px; }
    .col-date, .col-dl { display: none; }
}
