:root {
    --primary-color: #667eea;
    --primary-dark: #5a6fd6;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --info-color: #17a2b8;
    --secondary-color: #6c757d;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-color: #eee;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background: var(--bg-color); color: var(--text-primary); line-height: 1.5; }

.login-container { display: flex; justify-content: center; align-items: center; min-height: 100vh; background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%); }
.login-box { background: var(--card-bg); padding: 40px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 400px; }
.login-box h1 { text-align: center; margin-bottom: 30px; color: var(--text-primary); }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; color: var(--text-secondary); }
.form-group input { width: 100%; padding: 12px 16px; border: 1px solid var(--border-color); border-radius: var(--radius-md); font-size: 14px; transition: border-color 0.3s; }
.form-group input:focus { outline: none; border-color: var(--primary-color); }

.btn { padding: 12px 24px; border: none; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.3s; }
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success-color); color: #fff; }
.btn-success:hover { background: #218838; }
.btn-danger { background: var(--danger-color); color: #fff; }
.btn-danger:hover { background: #c82333; }
.btn-info { background: var(--info-color); color: #fff; }
.btn-info:hover { background: #138496; }
.btn-secondary { background: var(--secondary-color); color: #fff; }
.btn-secondary:hover { background: #5a6268; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--primary-color); color: var(--primary-color); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: #2d3436; color: #fff; padding: 20px; flex-shrink: 0; }
.sidebar h2 { font-size: 18px; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 1px solid #444; }
.sidebar ul { list-style: none; }
.sidebar li { margin-bottom: 5px; }
.sidebar a { display: block; padding: 10px 14px; color: #b2bec3; text-decoration: none; border-radius: var(--radius-sm); transition: all 0.3s; font-size: 14px; }
.sidebar a:hover, .sidebar a.active { background: var(--primary-color); color: #fff; }
.main-content { flex: 1; padding: 20px; overflow-y: auto; }

.header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--border-color); }
.header h1 { font-size: 24px; color: var(--text-primary); }
.user-info { display: flex; align-items: center; gap: 15px; }
.user-info span { font-size: 14px; color: var(--text-secondary); }

.card { background: var(--card-bg); border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 20px; margin-bottom: 20px; }
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 15px; color: var(--text-primary); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius-md); padding: 20px; text-align: center; box-shadow: var(--shadow-sm); }
.stat-value { font-size: 32px; font-weight: 700; color: var(--primary-color); margin-bottom: 5px; }
.stat-label { font-size: 14px; color: var(--text-secondary); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 15px; text-align: left; border-bottom: 1px solid var(--border-color); }
.table th { background: #f8f9fa; font-weight: 600; color: var(--text-secondary); }
.table tr:hover { background: #f8f9fa; }
.table input[type="checkbox"] { cursor: pointer; }

.pagination { display: flex; justify-content: center; align-items: center; gap: 5px; margin-top: 20px; }
.pagination button { padding: 6px 14px; border: 1px solid var(--border-color); background: var(--card-bg); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; }
.pagination button:hover:not(:disabled) { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination span { padding: 6px 14px; color: var(--text-secondary); }

.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000; }
.modal.active { display: flex; }
.modal-content { background: var(--card-bg); padding: 30px; border-radius: var(--radius-lg); width: 500px; max-width: 90%; max-height: 90vh; overflow-y: auto; }
.modal-content h3 { margin-bottom: 20px; color: var(--text-primary); }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.progress-bar { height: 8px; background: #eee; border-radius: var(--radius-sm); overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: var(--primary-color); width: 0%; transition: width 0.3s; }

.search-bar { display: flex; gap: 10px; margin-bottom: 10px; }
.search-bar select, .search-bar input { padding: 10px 15px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 14px; }
.search-bar input { flex: 1; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 15px; padding: 12px 15px; background: #f8f9fa; border-radius: var(--radius-md); }
.filter-bar input { flex: 1; padding: 8px 12px; border: 1px solid var(--border-color); border-radius: var(--radius-sm); font-size: 13px; background: var(--card-bg); }
.filter-bar input::placeholder { color: var(--text-muted); }

.breadcrumb { display: flex; gap: 10px; margin-bottom: 15px; font-size: 14px; color: var(--text-secondary); }
.breadcrumb a { color: var(--primary-color); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }

.actions-bar { display: flex; gap: 10px; margin-bottom: 15px; flex-wrap: wrap; }

.alert { padding: 12px 15px; border-radius: var(--radius-sm); margin-bottom: 15px; font-size: 14px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

.file-icon { font-size: 24px; margin-right: 8px; }
.file-image { max-width: 40px; max-height: 40px; border-radius: var(--radius-sm); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state i { font-size: 48px; margin-bottom: 15px; }
.empty-state p { font-size: 16px; }

.category-tabs { display: flex; gap: 8px; margin-bottom: 15px; }
.category-tab { padding: 8px 16px; border: 1px solid var(--border-color); background: var(--card-bg); border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; transition: all 0.3s; }
.category-tab:hover { border-color: var(--primary-color); color: var(--primary-color); }
.category-tab.active { background: var(--primary-color); color: #fff; border-color: var(--primary-color); }

.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; }
.file-card { background: var(--card-bg); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform 0.3s, box-shadow 0.3s; position: relative; }
.file-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.12); }
.file-card .card-image { width: 100%; height: 120px; object-fit: contain; background: #f8f9fa; }
.file-card .card-info { padding: 10px; }
.file-card .card-name { font-size: 13px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card .card-size { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.file-card .card-actions { display: flex; gap: 4px; margin-top: 8px; }
.file-card .card-actions button { padding: 4px 8px; font-size: 11px; }

.video-badge { position: absolute; bottom: 10px; right: 10px; background: rgba(0,0,0,0.6); color: #fff; padding: 4px 8px; border-radius: var(--radius-sm); font-size: 11px; }
.card-image-wrapper { position: relative; height: 120px; }

.files-table-container { overflow-x: auto; }

.card-checkbox { position: absolute; top: 8px; left: 8px; z-index: 10; }
.card-checkbox input { width: 18px; height: 18px; cursor: pointer; }
.file-card.selected { border: 2px solid var(--primary-color); background: #f0f4ff; }
.file-card.dragging { background: #e8efff; }
.selection-rect { position: fixed; border: 2px dashed var(--primary-color); background: rgba(102,126,234,0.2); pointer-events: none; z-index: 1000; display: none; }

.sync-panel { margin-bottom: 15px; padding: 20px; background: linear-gradient(135deg, var(--primary-color) 0%, #764ba2 100%); border-radius: var(--radius-lg); color: #fff; }
.sync-panel h3 { margin: 0 0 15px 0; font-size: 16px; font-weight: 600; }
.sync-panel .btn-secondary { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.3); color: #fff; }
.sync-panel .btn-secondary:hover { background: rgba(255,255,255,0.3); }

.sync-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.sync-stat { text-align: center; padding: 15px 10px; background: rgba(255,255,255,0.1); backdrop-filter: blur(10px); border-radius: var(--radius-md); border: 1px solid rgba(255,255,255,0.1); }
.sync-stat .label { font-size: 12px; opacity: 0.85; margin-bottom: 5px; }
.sync-stat .value { font-size: 22px; font-weight: 700; margin-bottom: 3px; }
.sync-stat .sub { font-size: 11px; opacity: 0.7; }
.sync-stat.cloud { background: rgba(102,126,234,0.3); }
.sync-stat.db { background: rgba(40,167,69,0.3); }
.sync-stat.diff { background: rgba(255,193,7,0.2); }
.sync-stat.ok .value { color: var(--success-color); }
.sync-stat.warning .value { color: #ffc107; }
.sync-stat.error .value { color: var(--danger-color); }

.status-badge { padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.status-active { background: rgba(40,167,69,0.1); color: var(--success-color); }
.status-inactive { background: rgba(220,53,69,0.1); color: var(--danger-color); }

.toast { position: fixed; bottom: 20px; right: 20px; padding: 12px 24px; border-radius: var(--radius-md); color: #fff; font-size: 14px; opacity: 0; transform: translateY(20px); transition: all 0.3s; z-index: 2000; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast-success { background: var(--success-color); }
.toast-error { background: var(--danger-color); }

@media (max-width: 768px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; padding: 15px; }
    .sidebar ul { display: flex; flex-wrap: wrap; gap: 5px; }
    .sidebar li { margin-bottom: 0; }
    .sidebar a { padding: 8px 12px; font-size: 13px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .sync-stats { grid-template-columns: repeat(2, 1fr); }
    .sync-stat .value { font-size: 18px; }
    .modal-content { width: 95%; }
    .files-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .sync-stats { grid-template-columns: 1fr; }
    .actions-bar { flex-direction: column; }
    .btn { width: 100%; }
    .search-bar { flex-direction: column; }
    .search-bar select, .search-bar input { width: 100%; }
}