body {
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', Arial, sans-serif;
    background-color: #f4f6f9;
    margin: 0;
    padding: 0;
    color: #333;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
}

/* --- Layout & Containers --- */
.app-header {
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    height: 32px;
    width: auto;
}

.header-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.header-nav {
    display: flex;
    gap: 20px;
}

.header-nav a {
    text-decoration: none;
    color: #666;
    font-weight: 500;
    transition: color 0.2s;
    font-size: 0.95rem;
}

.header-nav a:hover, .header-nav a.active {
    color: #007bff;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* User Dropdown/Info in Header */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.container {
    max-width: 900px;
    margin: 80px auto 40px; /* Top margin for fixed header */
    padding: 20px;
}

/* --- Admin Layout --- */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
    padding-top: 60px; /* For fixed header */
}

.admin-sidebar {
    width: 250px;
    background-color: #343a40;
    color: #fff;
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    transition: width 0.3s;
    z-index: 90;
}

.sidebar-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu li {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-menu a {
    display: block;
    padding: 15px 20px;
    color: #adb5bd;
    text-decoration: none;
    transition: all 0.2s;
}

.sidebar-menu a:hover, .sidebar-menu a.active {
    background-color: #007bff;
    color: white;
}

.admin-content {
    flex: 1;
    margin-left: 250px;
    padding: 30px;
    background-color: #f4f6f9;
    min-height: calc(100vh - 60px);
}

/* --- Cards & Forms --- */
.card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    padding: 25px;
    margin-bottom: 25px;
    border: none;
}

.card-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    margin: 0;
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
    font-size: 0.95rem;
}

input[type="text"], 
input[type="password"], 
input[type="number"],
input[type="datetime-local"],
select, 
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: #80bdff;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

button {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s, transform 0.1s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

button:hover {
    background-color: #0069d9;
}

button:active {
    transform: translateY(1px);
}

button.secondary {
    background-color: #6c757d;
}
button.secondary:hover {
    background-color: #5a6268;
}

button.danger {
    background-color: #dc3545;
}
button.danger:hover {
    background-color: #c82333;
}

button.success {
    background-color: #28a745;
}
button.success:hover {
    background-color: #218838;
}

button:disabled {
    background-color: #e2e6ea;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th {
    text-align: left;
    padding: 12px;
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    color: #495057;
    font-weight: 600;
}

td {
    padding: 12px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

/* --- Tabs Content Logic --- */
.tab-content {
    display: none;
    animation: fadeIn 0.3s;
}

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

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

/* --- Misc Components --- */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 600;
}
.badge-admin { background-color: #dc3545; color: white; }
.badge-user { background-color: #17a2b8; color: white; }
.badge-success { color: #28a745; background-color: rgba(40, 167, 69, 0.1); }
.badge-secondary { color: #6c757d; background-color: rgba(108, 117, 125, 0.1); }

.loading {
    text-align: center;
    color: #666;
    display: none;
    margin: 20px 0;
}

.progress-container {
    width: 100%;
    background-color: #e9ecef;
    border-radius: 4px;
    margin: 15px 0;
    overflow: hidden;
    height: 10px;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background-color: #007bff;
    transition: width 0.3s ease;
}

/* --- Mode Switch --- */
.mode-switch {
    display: flex;
    justify-content: center;
    background-color: #e9ecef;
    padding: 4px;
    border-radius: 8px;
    margin: 0 auto 30px;
    width: fit-content;
}

.mode-btn {
    background: transparent;
    border: none;
    padding: 8px 24px;
    border-radius: 6px;
    color: #6c757d;
    font-weight: 500;
    width: auto;
}

.mode-btn.active {
    background-color: white;
    color: #007bff;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.mode-btn:hover:not(.active) {
    background-color: rgba(255,255,255,0.5);
    color: #495057;
}

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

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.2);
    width: 90%; 
    max-width: 450px;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 24px;
    color: #aaa;
    cursor: pointer;
    transition: color 0.2s;
}

.close:hover {
    color: #333;
}

/* --- History List --- */
#history-list li {
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

#history-list li:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* Active tasks get a highlighted left border */
#history-list li.task-active {
    border-left: 4px solid #007bff;
    background: #f0f7ff;
}

#history-list li.task-pending {
    border-left: 4px solid #ffc107;
    background: #fffdf0;
}

/* 已下载任务：左侧绿色细线 + 浅灰背景 */
#history-list li.task-downloaded {
    border-left: 4px solid #adb5bd;
    background: #f8f9fa;
    opacity: 0.85;
}

/* 已下载小标签 */
.downloaded-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.78em;
    color: #6c757d;
    background: #e9ecef;
    border: 1px solid #ced4da;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
    white-space: nowrap;
}

/* History progress bar: compact version */
.history-progress-wrap .progress-container {
    height: 6px;
    margin: 4px 0 0 0;
}

.history-progress-wrap .progress-bar {
    background: linear-gradient(90deg, #007bff, #66b2ff);
    animation: pulse-width 1.5s ease-in-out infinite alternate;
}

@keyframes pulse-width {
    from { filter: brightness(1); }
    to { filter: brightness(1.2); }
}

/* --- Batch Task Card --- */
.batch-task-card {
    background: white;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .admin-sidebar {
        width: 60px;
        overflow: hidden;
    }
    .admin-sidebar:hover {
        width: 250px;
    }
    .sidebar-menu a span {
        display: none;
    }
    .admin-sidebar:hover .sidebar-menu a span {
        display: inline;
    }
    .admin-content {
        margin-left: 60px;
        padding: 15px;
    }
    .container {
        padding: 15px;
    }
    .app-header {
        padding: 0 15px;
    }
}
