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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: #09090f;
    color: #e2e8f0;
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    font-size: 14px;
}

/* ── Layout shell ─────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 220px;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    background: #06060e;
    border-right: 1px solid rgba(255,255,255,0.06);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.25s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
}
.page-wrapper {
    margin-left: 220px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Sidebar internals ────────────────────────────────── */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}
.sidebar-brand-icon {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar-brand-icon svg,
.sidebar-brand-icon i { width: 15px; height: 15px; color: #fff; display: block; }
.sidebar-brand-name { font-size: 0.8125rem; font-weight: 600; color: #f1f5f9; letter-spacing: -0.01em; line-height: 1.3; }
.sidebar-brand-tag  { font-size: 0.65rem; color: #334155; margin-top: 1px; }

.sidebar-nav {
    flex: 1;
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    overflow-y: auto;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    border-radius: 6px;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    line-height: 1;
}
.nav-item svg,
.nav-item i { width: 15px; height: 15px; flex-shrink: 0; display: block; }
.nav-item:hover  { background: rgba(255,255,255,0.05); color: #94a3b8; }
.nav-item.active { background: rgba(139,92,246,0.12);  color: #a78bfa; }

.sidebar-bottom {
    padding: 6px 8px 10px;
    border-top: 1px solid rgba(255,255,255,0.05);
    flex-shrink: 0;
}
.sidebar-logout {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 8px 10px;
    border-radius: 6px;
    background: none;
    border: none;
    color: #475569;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    line-height: 1;
}
.sidebar-logout svg,
.sidebar-logout i { width: 15px; height: 15px; flex-shrink: 0; display: block; }
.sidebar-logout:hover { background: rgba(239,68,68,0.08); color: #f87171; }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
    height: 52px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: #09090f;
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
}
.topbar-heading { font-size: 0.9rem; font-weight: 600; color: #f1f5f9; }
.topbar-sub     { font-size: 0.75rem; color: #475569; margin-top: 1px; }
.topbar-sub:empty { display: none; }
.topbar-right   { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ── Page content ─────────────────────────────────────── */
.page-content {
    padding: 28px 24px;
    flex: 1;
}
.content-area {
    max-width: 960px;
    margin: 0 auto;
}

/* ── Section spacing ──────────────────────────────────── */
.section { margin-bottom: 20px; }

/* ── Cards ────────────────────────────────────────────── */
.card {
    background: #0f0f1a;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 20px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.card-title {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 0.8375rem;
    font-weight: 600;
    color: #94a3b8;
    letter-spacing: 0.01em;
}
.card-title svg { width: 14px; height: 14px; }

/* ── Stats grid ───────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}
.stat-card {
    background: #0f0f1a;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    padding: 16px 18px;
}
.stat-label { font-size: 0.72rem; font-weight: 500; color: #475569; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 10px; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.stat-sub   { font-size: 0.72rem; color: #475569; margin-top: 5px; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 7px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: opacity 0.12s, background 0.12s, box-shadow 0.12s;
    white-space: nowrap;
    line-height: 1;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary  { background: #7c3aed; color: #fff; box-shadow: 0 1px 3px rgba(124,58,237,0.4); }
.btn-primary:hover:not(:disabled) { background: #6d28d9; }
.btn-ghost    { background: rgba(255,255,255,0.06); color: #94a3b8; border: 1px solid rgba(255,255,255,0.08); }
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.09); color: #cbd5e1; }
.btn-success  { background: rgba(34,197,94,0.1); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,0.16); }
.btn-danger   { background: rgba(239,68,68,0.1); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.16); }
.btn-sm { padding: 5px 11px; font-size: 0.775rem; border-radius: 6px; }
.btn-sm svg { width: 13px; height: 13px; }

/* ── Badges ───────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}
.badge svg { width: 10px; height: 10px; }
.badge-purple { background: rgba(139,92,246,0.12); color: #a78bfa; }
.badge-green  { background: rgba(34,197,94,0.1);   color: #4ade80; }
.badge-red    { background: rgba(239,68,68,0.1);   color: #f87171; }
.badge-yellow { background: rgba(234,179,8,0.1);   color: #fbbf24; }
.badge-blue   { background: rgba(99,102,241,0.1);  color: #818cf8; }
.badge-slate  { background: rgba(100,116,139,0.12); color: #94a3b8; }

/* ── Alert banners ────────────────────────────────────── */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 8px;
    font-size: 0.8125rem;
    margin-bottom: 20px;
}
.alert svg { width: 15px; height: 15px; flex-shrink: 0; }
.alert-green  { background: rgba(34,197,94,0.07);  border: 1px solid rgba(34,197,94,0.18);  color: #86efac; }
.alert-yellow { background: rgba(234,179,8,0.07);  border: 1px solid rgba(234,179,8,0.18);  color: #fde68a; }
.alert-blue   { background: rgba(99,102,241,0.07); border: 1px solid rgba(99,102,241,0.18); color: #c7d2fe; }
.alert-red    { background: rgba(239,68,68,0.07);  border: 1px solid rgba(239,68,68,0.18);  color: #fecaca; }

/* ── Form ─────────────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.775rem; font-weight: 500; color: #94a3b8; margin-bottom: 5px; }
.form-hint  { font-size: 0.72rem; color: #475569; margin-top: 4px; }
.form-hint a { color: #8b5cf6; text-decoration: none; }
.form-hint a:hover { text-decoration: underline; }

.input {
    width: 100%;
    padding: 8px 11px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 7px;
    color: #e2e8f0;
    font-size: 0.8375rem;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.input:focus {
    border-color: rgba(139,92,246,0.5);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.08);
}
.input::placeholder { color: #334155; }
select.input option  { background: #0f0f1a; }

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8375rem;
    color: #94a3b8;
    cursor: pointer;
    margin-bottom: 10px;
    user-select: none;
}
.checkbox-row input[type=checkbox] { width: 14px; height: 14px; accent-color: #7c3aed; cursor: pointer; flex-shrink: 0; }

/* ── Table ────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
.table th { text-align: left; padding: 8px 12px; color: #475569; font-weight: 500; border-bottom: 1px solid rgba(255,255,255,0.06); }
.table th.center, .table td.center { text-align: center; }
.table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.04); color: #cbd5e1; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Activity list ────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; }
.activity-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.activity-row:last-child { border-bottom: none; }
.activity-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.activity-title { font-size: 0.8375rem; font-weight: 500; color: #e2e8f0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-meta  { display: flex; align-items: center; gap: 8px; margin-top: 2px; flex-wrap: wrap; }
.activity-meta-item { font-size: 0.72rem; color: #475569; display: flex; align-items: center; gap: 3px; }
.activity-meta-item svg { width: 11px; height: 11px; }

/* ── Progress ─────────────────────────────────────────── */
.progress { height: 5px; background: rgba(255,255,255,0.06); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width 0.4s ease, background 0.4s ease; }

/* ── Divider ──────────────────────────────────────────── */
.divider { height: 1px; background: rgba(255,255,255,0.06); margin: 20px 0; }

/* ── Toast ────────────────────────────────────────────── */
#toast-container {
    position: fixed; bottom: 20px; right: 20px;
    z-index: 9999;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.8125rem; font-weight: 500;
    min-width: 240px; max-width: 340px;
    pointer-events: all;
    animation: toastIn 0.2s ease;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.toast svg { width: 15px; height: 15px; flex-shrink: 0; }
@keyframes toastIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
.toast-success { background: #14532d; border: 1px solid #166534; color: #bbf7d0; }
.toast-error   { background: #450a0a; border: 1px solid #7f1d1d; color: #fecaca; }
.toast-info    { background: #1e1b4b; border: 1px solid #312e81; color: #c7d2fe; }
.toast-warning { background: #431407; border: 1px solid #7c2d12; color: #fed7aa; }

/* ── Loading overlay ──────────────────────────────────── */
#loadingOverlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(6px);
    z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
#loadingOverlay.hidden { display: none; }
.loading-box {
    background: #0f0f1a;
    border: 1px solid rgba(139,92,246,0.25);
    border-radius: 14px;
    padding: 36px 40px;
    text-align: center;
    max-width: 280px; width: 90%;
}
.loading-box h3 { font-size: 0.9375rem; font-weight: 600; color: #f1f5f9; margin: 14px 0 6px; }
.loading-box p  { font-size: 0.775rem; color: #475569; }

/* ── Spinner ──────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,0.08);
    border-top-color: #7c3aed;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
    flex-shrink: 0;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Page loader ──────────────────────────────────────── */
#page-loader {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 2px;
    background: linear-gradient(90deg, #7c3aed, #6366f1);
    transform: scaleX(0); transform-origin: left;
    transition: transform 0.3s ease;
    z-index: 9999;
}
#page-loader.loading { transform: scaleX(1); }

/* ── Page transition handled by JS ───────────────────── */
body { opacity: 1; }

/* ── Hamburger ────────────────────────────────────────── */
.hamburger {
    display: none;
    align-items: center; justify-content: center;
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 6px;
    cursor: pointer; color: #64748b; flex-shrink: 0;
}
.hamburger svg { width: 16px; height: 16px; }

/* ── Sidebar overlay ──────────────────────────────────── */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.6); z-index: 99;
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(139,92,246,0.2); border-radius: 99px; }


/* ── Settings 2-col layout ────────────────────────────── */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 20px;
    align-items: start;
}
.settings-col { display: flex; flex-direction: column; }

/* ── Password input wrapper ───────────────────────────── */
.input-secret {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.09);
    border-radius: 7px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.input-secret:focus-within {
    border-color: rgba(139,92,246,0.5);
    box-shadow: 0 0 0 3px rgba(139,92,246,0.08);
}
.input-secret .input {
    background: transparent;
    border: none;
    box-shadow: none;
    flex: 1;
    min-width: 0;
}
.input-secret .input:focus { border: none; box-shadow: none; }
.input-secret .toggle-pw {
    background: none; border: none; cursor: pointer;
    color: #475569; padding: 0 10px; flex-shrink: 0;
    display: flex; align-items: center;
    transition: color 0.12s;
}
.input-secret .toggle-pw:hover { color: #94a3b8; }

/* ── Confirm Modal ────────────────────────────────────── */
#confirm-modal {
    display: none;
    position: fixed; inset: 0; z-index: 300;
    align-items: center; justify-content: center;
}
#confirm-modal.open { display: flex; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(4px);
}
.modal-box {
    position: relative;
    background: #0f0f1a;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 28px 28px 24px;
    width: 90%; max-width: 340px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0,0,0,0.6);
}
.modal-icon { margin-bottom: 12px; }
.modal-title { font-size: 0.9375rem; font-weight: 600; color: #f1f5f9; margin-bottom: 8px; }
.modal-msg   { font-size: 0.8125rem; color: #64748b; margin-bottom: 20px; line-height: 1.5; }
.modal-actions { display: flex; gap: 8px; justify-content: center; }
.modal-actions .btn { min-width: 90px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 12px 0 40px rgba(0,0,0,0.6); }
    .sidebar-overlay.open { display: block; }
    .page-wrapper { margin-left: 0; }
    .hamburger { display: flex; }
    .page-content { padding: 16px; }
    .settings-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    #toast-container { bottom: 12px; right: 12px; left: 12px; }
    .toast { min-width: unset; max-width: 100%; }
}

/* ── Two-col grid (responsive) ────────────────────────── */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.research-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
@media (max-width: 640px) {
    .two-col-grid,
    .research-grid { grid-template-columns: 1fr; }
}
