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

:root {
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #0f172a;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --blue: #3b82f6;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 10;
}

.sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 0.5rem 1.25rem 1.5rem;
    color: var(--primary);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.15s;
}

.nav-item:hover { color: var(--text); background: rgba(99, 102, 241, 0.08); }
.nav-item.active { color: var(--primary); background: rgba(99, 102, 241, 0.12); border-right: 2px solid var(--primary); }
.nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-spacer { flex: 1; }

/* Content */
.content {
    flex: 1;
    margin-left: 220px;
    padding: 2rem;
    max-width: 1200px;
}

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 600; }

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

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

.card-header h2 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.25rem; }

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }
.stat-blue .stat-value { color: var(--blue); }
.stat-green .stat-value { color: var(--success); }
.stat-red .stat-value { color: var(--danger); }

/* Table */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.table th {
    text-align: left;
    padding: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: rgba(99, 102, 241, 0.06); }

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-platform { background: #1e3a5f; color: #93c5fd; }
.badge-green { background: #064e3b; color: #6ee7b7; }
.badge-blue { background: #1e3a5f; color: #93c5fd; }
.badge-red { background: #7f1d1d; color: #fca5a5; }
.badge-yellow { background: #78350f; color: #fcd34d; }
.badge-gray { background: #374151; color: #d1d5db; }

/* Progress */
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    display: inline-block;
    width: 80px;
    vertical-align: middle;
}

.progress-bar-lg { width: 100%; height: 8px; border-radius: 4px; }

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--primary-hover));
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-text { font-size: 0.8rem; color: var(--text-muted); margin-left: 0.5rem; }

.progress-section { margin-bottom: 1.25rem; }
.progress-details {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Status */
.status-overview { }
.status-badge-large {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.status-badge-large.badge-green { background: #064e3b; color: #6ee7b7; }
.status-badge-large.badge-blue { background: #1e3a5f; color: #93c5fd; }
.status-badge-large.badge-red { background: #7f1d1d; color: #fca5a5; }
.status-badge-large.badge-yellow { background: #78350f; color: #fcd34d; }
.status-badge-large.badge-gray { background: #374151; color: #d1d5db; }

.status-details { margin-top: 1rem; }

/* Detail items */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.detail-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.detail-item:last-child { border-bottom: none; }
.detail-label { color: var(--text-muted); font-size: 0.875rem; }
.detail-value { font-size: 0.875rem; text-align: right; max-width: 60%; word-break: break-all; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-group label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.form-input:focus { outline: none; border-color: var(--primary); }
select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; }

.form-row {
    display: flex;
    gap: 1rem;
}

.form-row .form-group { flex: 1; }

/* Filters */
.filters-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.filter-search { flex: 1; min-width: 200px; }
.filter-search .form-input { margin-bottom: 0; }

.filter-group {
    display: flex;
    gap: 0.5rem;
}

.filter-select { width: 160px; }

.total-badge {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--border);
    padding: 0.15rem 0.6rem;
    border-radius: 9999px;
    margin-left: 0.5rem;
    vertical-align: middle;
}

.color-input-wrap {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.color-input-wrap input[type="color"] {
    width: 40px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    background: none;
    padding: 2px;
}

.checkbox-group { display: flex; flex-direction: column; gap: 0.75rem; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Track link */
.track-link-box {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.track-link-box .form-input { font-size: 0.8rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-card);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}

.btn:hover { background: #334155; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }
.btn-copy { background: #1e293b; border-color: #475569; color: #94a3b8; min-width: 60px; }
.btn-copy:hover { background: #334155; color: #e2e8f0; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: #047857; border-color: #047857; color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #b45309; border-color: #b45309; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-danger { background: #b91c1c; border-color: #b91c1c; color: white; }
.btn-danger:hover { background: #dc2626; }

.actions-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.alert-success { background: #064e3b; color: #6ee7b7; border: 1px solid #065f46; }
.alert-danger { background: #7f1d1d; color: #fca5a5; border: 1px solid #991b1b; }
.alert-warning { background: #78350f; color: #fcd34d; border: 1px solid #92400e; }

/* Misc */
.mono { font-family: 'Cascadia Code', 'Fira Code', Consolas, monospace; }
.help-text { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.5rem; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state p { margin-bottom: 1rem; }

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding-top: 1rem;
}

.page-info { font-size: 0.85rem; color: var(--text-muted); }

/* Login */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
}

.login-card h1 { font-size: 1.5rem; font-weight: 700; color: var(--primary); margin-bottom: 0.25rem; }
.login-sub { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.9rem; }

/* HTMX */
.htmx-indicator { opacity: 0; transition: opacity 0.2s; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

.btn-refresh-admin { display: inline-flex; align-items: center; gap: 6px; }
.btn-refresh-admin.htmx-request .refresh-icon { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .content { margin-left: 0; padding: 1rem; }
    .form-row { flex-direction: column; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
