@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-main: #0b0f1a;
    --bg-card: #141a2a;
    --bg-elev: #1b2336;
    --bg-subtle: rgba(255, 255, 255, 0.02);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(99, 102, 241, 0.45);

    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-faint: #64748b;

    --primary: #6366f1;
    --primary-grad: linear-gradient(90deg, #6366f1 0%, #818cf8 100%);
    --success: #10b981;
    --success-grad: linear-gradient(90deg, #10b981 0%, #34d399 100%);
    --warning: #f59e0b;
    --danger: #ef4444;
    --purple: #a855f7;
    --cyan: #06b6d4;

    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

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

body {
    background: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    padding: 1.5rem;
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
}

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.3); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.5); }

/* Accent text helpers */
.accent-success { color: var(--success) !important; }
.accent-warning { color: var(--warning) !important; }
.accent-purple  { color: var(--purple) !important; }
.accent-cyan    { color: var(--cyan) !important; }
.muted          { color: var(--text-faint) !important; }

/* ---- Header ---- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
}
.brand { display: flex; align-items: center; gap: 0.85rem; }
.brand-icon {
    width: 42px; height: 42px;
    background: var(--primary-grad);
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.brand-info h1 { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.02em; }
.brand-info p { font-size: 0.8rem; color: var(--text-muted); }

.header-actions { display: flex; align-items: center; gap: 0.75rem; }
.last-updated {
    font-size: 0.8rem; color: var(--text-muted);
    background: var(--bg-subtle); border: 1px solid var(--border-color);
    padding: 0.5rem 0.85rem; border-radius: 9px;
}
.last-updated span { font-weight: 600; color: var(--text-main); }

.btn {
    display: inline-flex; align-items: center; gap: 0.5rem;
    background: var(--primary); color: #fff; border: none;
    padding: 0.55rem 1rem; border-radius: 9px;
    cursor: pointer; font-family: var(--font-sans);
    font-weight: 600; font-size: 0.85rem;
    transition: filter 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { filter: brightness(0.95); }
.btn-secondary {
    background: var(--bg-elev); color: var(--text-main);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover { background: var(--bg-elev); border-color: var(--border-hover); filter: none; }
.icon-btn { padding: 0.55rem 0.65rem; }

/* ---- Filter bar ---- */
.filter-bar {
    display: flex; align-items: flex-end; flex-wrap: wrap; gap: 0.85rem;
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 1rem 1.25rem; margin-bottom: 1.25rem;
}
.search-box { position: relative; flex: 1 1 280px; min-width: 220px; }
.search-box input {
    width: 100%;
    background: var(--bg-elev); border: 1px solid var(--border-color);
    border-radius: 9px; padding: 0.6rem 0.85rem 0.6rem 2.3rem;
    color: var(--text-main); font-family: var(--font-sans); font-size: 0.85rem;
    transition: border-color 0.15s ease;
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-box::before {
    content: "🔍"; position: absolute; left: 0.75rem; top: 50%;
    transform: translateY(-50%); font-size: 0.85rem; opacity: 0.7;
}
.filter-field { display: flex; flex-direction: column; gap: 0.3rem; }
.filter-field label {
    font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-faint); padding-left: 0.15rem;
}
.filter-field select {
    background: var(--bg-elev); border: 1px solid var(--border-color);
    border-radius: 9px; padding: 0.55rem 0.85rem; min-width: 160px;
    color: var(--text-main); font-family: var(--font-sans); font-size: 0.85rem;
    cursor: pointer; transition: border-color 0.15s ease;
}
.filter-field select:focus { outline: none; border-color: var(--primary); }

/* Compact selector used inside a section header (e.g. language comparison) */
.filter-field.inline { flex-direction: row; align-items: center; gap: 0.5rem; }
.filter-field.inline label { padding: 0; }
.filter-field.inline select { padding: 0.4rem 0.6rem; min-width: 130px; font-size: 0.8rem; }

/* ---- KPI cards ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem; margin-bottom: 1.25rem;
}
.stat-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 1.1rem 1.25rem;
    display: flex; flex-direction: column; gap: 0.15rem;
}
.stat-card p {
    font-size: 0.72rem; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em;
}
.stat-card h3 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.stat-sub { font-size: 0.74rem; color: var(--text-faint); font-weight: 500; }

/* ---- Section card ---- */
.section-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem;
}
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.section-title {
    font-size: 1.05rem; font-weight: 700;
    display: flex; align-items: center; gap: 0.5rem;
}
.section-meta { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.dashboard-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 980px) { .dashboard-row { grid-template-columns: 1fr; } }

/* ---- Data tables ---- */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint);
    padding: 0.6rem 0.85rem; border-bottom: 1px solid var(--border-color);
    white-space: nowrap; user-select: none;
}
.data-table td {
    padding: 0.7rem 0.85rem; font-size: 0.85rem;
    border-bottom: 1px solid var(--border-color); vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table.compact td, .data-table.compact th { padding: 0.55rem 0.75rem; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th.num { text-align: right; }

#projects-table tbody tr { cursor: pointer; transition: background 0.12s ease; }
#projects-table tbody tr:hover { background: var(--bg-subtle); }

.cell-title { min-width: 200px; }
.t-name { font-weight: 600; color: var(--text-main); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-id { font-size: 0.72rem; color: var(--text-faint); }

.table-empty { text-align: center; color: var(--text-muted); padding: 2.5rem 1rem !important; }
.table-empty.error { color: var(--danger); }

/* Sortable headers */
th.sortable { cursor: pointer; transition: color 0.12s ease; }
th.sortable:hover { color: var(--text-muted); }
th.sortable::after { content: "↕"; opacity: 0.3; margin-left: 0.35rem; font-size: 0.7rem; }
th.sort-asc::after { content: "↑"; opacity: 1; color: var(--primary); }
th.sort-desc::after { content: "↓"; opacity: 1; color: var(--primary); }

/* Inline progress bars */
.progress-col { min-width: 130px; }
.bar-row { display: flex; align-items: center; gap: 0.6rem; }
.bar-track { flex: 1; height: 7px; background: var(--bg-elev); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease; }
.bar-primary { background: var(--primary-grad); }
.bar-success { background: var(--success-grad); }
.bar-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); width: 34px; text-align: right; }
.bar-label.wide { width: 52px; }

/* Badges */
.badge {
    font-size: 0.68rem; font-weight: 600; padding: 0.22rem 0.6rem;
    border-radius: 99px; white-space: nowrap;
}
.badge-active { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; }
.badge-completed { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; }
.badge-empty { background: rgba(148, 163, 184, 0.12); color: #94a3b8; }

/* Rank badges */
.rank-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px; border-radius: 50%; font-size: 0.75rem; font-weight: 700;
}
.rank-1 { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.rank-2 { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
.rank-3 { background: rgba(180, 83, 9, 0.25); color: #fb923c; }
.rank-other { background: var(--bg-elev); color: var(--text-muted); }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(5, 8, 15, 0.78);
    backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center; z-index: 1000;
    opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 18px; width: 92%; max-width: 640px; max-height: 86vh;
    overflow-y: auto; transform: translateY(10px); transition: transform 0.2s ease;
}
.modal-overlay.active .modal-card { transform: translateY(0); }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 1.75rem; border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; background: var(--bg-card); z-index: 1;
}
.modal-title h2 { font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; }
.modal-close {
    background: var(--bg-elev); border: 1px solid var(--border-color);
    color: var(--text-muted); width: 30px; height: 30px; border-radius: 50%;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    transition: all 0.15s ease;
}
.modal-close:hover { color: var(--text-main); border-color: var(--border-hover); }
.modal-body { padding: 1.5rem 1.75rem; }
.modal-desc { font-size: 0.88rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.modal-section-title {
    font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-faint); margin-bottom: 0.6rem;
}
.modal-progress-box {
    background: var(--bg-subtle); border: 1px solid var(--border-color);
    border-radius: 11px; padding: 1rem; margin-bottom: 1.5rem;
}
.progress-header {
    display: flex; justify-content: space-between; font-size: 0.8rem;
    color: var(--text-muted); font-weight: 500; margin-bottom: 0.5rem;
}
.progress-pct { color: var(--text-main); font-weight: 700; }
.progress-bar-container { background: var(--bg-elev); border-radius: 99px; height: 8px; width: 100%; overflow: hidden; margin-bottom: 1.5rem; }
.progress-bar-fill { height: 100%; border-radius: 99px; background: var(--primary-grad); transition: width 0.5s ease; }

.modal-grid-stats {
    display: grid; grid-template-columns: repeat(3, 1fr);
    gap: 0.85rem; margin-bottom: 1.5rem;
}
@media (max-width: 540px) { .modal-grid-stats { grid-template-columns: repeat(2, 1fr); } }
.m-stat-box {
    background: var(--bg-subtle); border: 1px solid var(--border-color);
    border-radius: 11px; padding: 0.85rem; text-align: center;
}
.m-stat-box p { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.25rem; }
.m-stat-box h4 { font-size: 1.2rem; font-weight: 700; }

.modal-meta-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem; }
.modal-meta-item {
    background: var(--bg-subtle); border: 1px solid var(--border-color);
    padding: 0.6rem 0.85rem; border-radius: 9px; font-size: 0.82rem; color: var(--text-muted);
}
.modal-meta-item span { color: var(--text-main); font-weight: 600; }

.annotator-pill-list { display: flex; flex-direction: column; gap: 0.6rem; }
.annotator-pill {
    display: flex; justify-content: space-between; align-items: center;
    background: var(--bg-subtle); border: 1px solid var(--border-color);
    padding: 0.65rem 0.85rem; border-radius: 10px;
}
.annotator-pill-info { display: flex; align-items: center; gap: 0.6rem; }
.pill-avatar { font-size: 1.1rem; }
.pill-name { font-weight: 600; font-size: 0.85rem; }
.pill-email { font-size: 0.72rem; color: var(--text-faint); }
.annotator-pill-count {
    font-weight: 700; color: var(--primary);
    background: rgba(99, 102, 241, 0.12); padding: 0.2rem 0.6rem;
    border-radius: 8px; font-size: 0.8rem;
}

/* ==========================================================================
   Light theme
   ========================================================================== */
body.light-theme {
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --bg-elev: #f1f5f9;
    --bg-subtle: rgba(0, 0, 0, 0.02);
    --border-color: rgba(15, 23, 42, 0.1);
    --border-hover: rgba(99, 102, 241, 0.5);

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-faint: #94a3b8;

    --primary: #4f46e5;
    --success: #059669;
    --warning: #d97706;
    --purple: #7c3aed;
    --cyan: #0891b2;

    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
body.light-theme .badge-active { background: rgba(79, 70, 229, 0.1); color: #4f46e5; }
body.light-theme .badge-completed { background: rgba(5, 150, 105, 0.12); color: #047857; }
body.light-theme .rank-other { background: #e2e8f0; }
