:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-card: #334155;
    --bg-input: #1e293b;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #22c55e;
    --warning: #eab308;
    --danger: #ef4444;
    --border: #475569;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 220px;
    background: var(--bg-secondary);
    padding: 1rem;
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    bottom: 0;
    overflow-y: auto;
}
.sidebar h1 { font-size: 1.5rem; margin-bottom: 2rem; color: var(--accent); }
.sidebar nav a {
    display: block;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius);
    color: var(--text-secondary);
    transition: background 0.15s;
}
.sidebar nav a:hover, .sidebar nav a.active {
    background: var(--bg-card);
    color: var(--text-primary);
}
.main-content {
    margin-left: 220px;
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.card h3 { margin-bottom: 0.5rem; }

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.stat-card .value { font-size: 2rem; font-weight: bold; color: var(--accent); }
.stat-card .label { font-size: 0.85rem; color: var(--text-secondary); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--border); }
th { color: var(--text-secondary); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; }
tr:hover { background: var(--bg-card); }

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s;
}
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border: 1px solid var(--border); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.8rem; }

/* Forms */
input, select {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    font-size: 0.95rem;
    width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
.search-bar { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; }
.search-bar input { flex: 1; }
.search-bar select { width: auto; min-width: 120px; }

/* Form groups */
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.25rem; }
.form-group input[type="number"] { width: 150px; }
.form-group select { width: auto; min-width: 150px; }
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.checkbox-label input[type="checkbox"] { width: auto; }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-wanted { background: var(--warning); color: #000; }
.badge-available { background: var(--accent); color: white; }
.badge-downloaded { background: var(--success); color: white; }
.badge-owned { background: #6366f1; color: white; }
.badge-pending { background: var(--text-muted); color: white; }
.badge-failed { background: var(--danger); color: white; }
.badge-completed { background: var(--success); color: white; }

/* Task table fixed column widths */
table.tasks-table { table-layout: fixed; }
table.tasks-table th:nth-child(1) { width: 100px; }
table.tasks-table th:nth-child(2) { width: 100px; }
table.tasks-table th:nth-child(3) { width: 40%; }
table.tasks-table td { overflow: hidden; text-overflow: ellipsis; }

/* Page header */
.page-header { margin-bottom: 1.5rem; }
.page-header h2 { font-size: 1.5rem; }
.page-header p { color: var(--text-secondary); }

/* Utility */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 0.85rem; }
.loading { color: var(--text-muted); font-style: italic; }
.error { color: var(--danger); }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
