:root {
    --bg-primary: #f4f7fb;
    --bg-secondary: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --border: #e2e8f0;
    --border-hover: #93c5fd;
    --success: #10b981;
    --success-light: #ecfdf5;
    --error: #ef4444;
    --error-light: #fef2f2;
    --warning: #f59e0b;
    --sidebar-width: 260px;
    --header-height: 64px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Typography */
h1, h2, h3, h4 {
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.01em;
}

p, span {
    color: var(--text-secondary);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 50;
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h1 {
    font-size: 1.25rem;
    color: var(--accent);
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: transparent;
    border: none;
    text-align: left;
    width: 100%;
    font-size: 0.95rem;
}

.nav-item:hover {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.nav-item.active {
    background-color: var(--accent-light);
    color: var(--accent);
    font-weight: 600;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 40;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

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

.badge {
    background-color: var(--accent-light);
    color: var(--accent);
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.admin {
    background-color: var(--error-light);
    color: var(--error);
}

.user-stats {
    display: flex;
    gap: 1.25rem;
    border-right: 1px solid var(--border);
    padding-right: 1.5rem;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Content Container */
.content-container {
    padding: 2rem;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.tab-content {
    display: none;
    animation: fadeIn 0.25s ease-in-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards & Containers */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 2rem;
    box-shadow: 0 2px 8px -2px rgba(0,0,0,0.05);
    margin-bottom: 2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 1.35rem;
}

.card-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Drop Zone Styles - Full Width & Modern */
.drop-zone-container {
    width: 100%;
    margin-bottom: 1.5rem;
}

.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 180px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    padding: 2.25rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: #f8fafc;
    position: relative;
    user-select: none;
}

.drop-zone:hover {
    border-color: var(--accent);
    background-color: var(--accent-light);
    transform: translateY(-1px);
}

.drop-zone.dragover {
    border-color: var(--accent);
    background-color: #dbeafe;
    border-style: solid;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
}

.drop-zone input[type="file"] {
    display: none;
}

.drop-zone-icon {
    width: 52px;
    height: 52px;
    margin-bottom: 0.85rem;
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e0e7ff;
    border-radius: 14px;
    transition: transform 0.2s ease;
}

.drop-zone:hover .drop-zone-icon {
    transform: scale(1.06);
}

.drop-zone-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.35rem;
}

.drop-zone-title b {
    color: var(--accent);
}

.drop-zone-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.format-tags {
    display: inline-flex;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.format-tag {
    background: #e2e8f0;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

/* Selected File Banner */
.selected-file-banner {
    display: none;
    align-items: center;
    justify-content: space-between;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 0.85rem 1.25rem;
    margin-top: 1rem;
    animation: fadeIn 0.2s ease-out;
}

.selected-file-banner.show {
    display: flex;
}

.file-info-group {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    overflow: hidden;
}

.file-icon-badge {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.file-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.92rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 450px;
}

.file-size {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.file-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.btn-remove {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: transparent;
    border: none;
    color: var(--error);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: var(--error-light);
}

/* Submit Action Bar */
.submit-action-bar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
}

.submit-action-bar .btn-submit {
    min-width: 200px;
}

/* Divider */
.divider-text {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2.25rem 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.06em;
}

.divider-text::before, .divider-text::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider-text span {
    padding: 0 1.25rem;
    background-color: var(--bg-secondary);
}

/* Direct Path Section */
.direct-path-card {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
}

.direct-path-card .input-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.direct-path-card .input-group input {
    flex: 1;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--border);
    border-radius: 999px;
    overflow: hidden;
    display: none;
    margin-top: 1rem;
}

.progress-bar.show {
    display: block;
}

.progress-fill {
    height: 100%;
    background-color: var(--accent);
    width: 0%;
    transition: width 0.3s ease;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control, input[type="text"], input[type="password"], input[type="number"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.2s;
    outline: none;
}

.form-control:focus, input[type="text"]:focus, input[type="password"]:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.radio-group {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    height: 42px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 0;
}

.radio-group input[type="radio"] {
    accent-color: var(--accent);
    width: 17px;
    height: 17px;
    cursor: pointer;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    gap: 0.5rem;
    text-decoration: none;
    user-select: none;
}

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

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-secondary {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--bg-primary);
    border-color: #cbd5e1;
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #059669;
}

.btn-error {
    background-color: var(--error-light);
    color: var(--error);
}

.btn-error:hover:not(:disabled) {
    background-color: var(--error);
    color: white;
}

.btn-small {
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    border-radius: 6px;
}

/* Checksums Section */
.cs-item {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem;
}

.cs-item-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
}

.cs-item textarea {
    width: 100%;
    height: 70px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem;
    font-size: 0.82rem;
    font-family: monospace;
    resize: vertical;
    background: white;
}

/* Preview Area */
.preview-container {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.preview-container img {
    max-height: 180px;
    max-width: 240px;
    object-fit: contain;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: white;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
}

.table tbody tr:hover {
    background-color: var(--bg-primary);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: var(--bg-secondary);
    width: 100%;
    max-width: 500px;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
    animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-modal {
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover {
    color: var(--text-primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    font-weight: 500;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--error);
}

/* Status Indicator */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-radius: 6px;
    background: #f1f5f9;
    font-weight: 500;
    font-size: 0.9rem;
}

#dbStatusIndicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #94a3b8;
    transition: background 0.3s ease;
}

#dbStatusIndicator.connected {
    background-color: var(--success) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* Utility */
.mt-2 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }

@media (max-width: 768px) {
    .sidebar {
        display: none !important;
    }
    .main-content {
        margin-left: 0;
    }
    .grid-2 {
        grid-template-columns: 1fr;
    }
    .file-name {
        max-width: 200px;
    }
}
