/* ===== Nexus — Project Command Center ===== */

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

:root {
    --bg-0: #07070a;
    --bg-1: #0c0c11;
    --bg-2: #131319;
    --bg-3: #1a1a23;
    --bg-4: #22222e;
    --border: rgba(255,255,255,0.06);
    --border-hover: rgba(255,255,255,0.12);
    --text-0: #f4f4f5;
    --text-1: #a1a1aa;
    --text-2: #71717a;
    --text-3: #52525b;
    --accent: #818cf8;
    --accent-hover: #6366f1;
    --accent-dim: rgba(129,140,248,0.10);
    --accent-glow: rgba(129,140,248,0.25);
    --success: #4ade80;
    --success-dim: rgba(74,222,128,0.10);
    --warning: #fbbf24;
    --warning-dim: rgba(251,191,36,0.10);
    --danger: #f87171;
    --danger-dim: rgba(248,113,113,0.10);
    --info: #38bdf8;
    --info-dim: rgba(56,189,248,0.10);
    --sidebar-w: 240px;
    --topbar-h: 64px;
    --radius: 10px;
    --radius-sm: 6px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    --transition: 0.2s ease;
}

html { background: var(--bg-0); color: var(--text-0); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
::selection { background: var(--accent-dim); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }

/* --- Layout --- */
#app { display: flex; min-height: 100vh; }

#sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100;
    transition: transform 0.3s ease;
}

#main {
    flex: 1;
    margin-left: var(--sidebar-w);
    display: flex; flex-direction: column;
    min-height: 100vh;
}

#topbar {
    position: sticky; top: 0; z-index: 50;
    height: var(--topbar-h);
    background: rgba(7,7,10,0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 24px; gap: 16px;
}

#content {
    flex: 1;
    padding: 24px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* --- Sidebar --- */
.sidebar-header { padding: 20px 20px 24px; }

.logo {
    display: flex; align-items: center; gap: 10px;
}

.logo-icon {
    width: 28px; height: 28px;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.logo-text {
    font-size: 18px; font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-0), var(--accent));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1; padding: 0 12px;
    display: flex; flex-direction: column; gap: 2px;
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 13px; font-weight: 500;
    transition: all var(--transition);
    text-decoration: none;
}

.nav-item svg {
    width: 18px; height: 18px;
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity var(--transition);
}

.nav-item:hover {
    color: var(--text-0);
    background: var(--bg-3);
}

.nav-item:hover svg { opacity: 1; }

.nav-item.active {
    color: var(--text-0);
    background: var(--accent-dim);
}

.nav-item.active svg { opacity: 1; color: var(--accent); }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.scan-info {
    display: flex; align-items: center; gap: 8px;
    font-size: 11px; color: var(--text-3);
}

.pulse-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74,222,128,0.4); }
    50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(74,222,128,0); }
}

/* --- Topbar --- */
.search-box {
    flex: 1; max-width: 480px;
    position: relative;
    display: flex; align-items: center;
}

.search-icon {
    position: absolute; left: 12px;
    width: 16px; height: 16px;
    color: var(--text-3);
    pointer-events: none;
}

#search {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px 8px 36px;
    color: var(--text-0);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    transition: all var(--transition);
}

#search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

#search::placeholder { color: var(--text-3); }

.search-kbd {
    position: absolute; right: 10px;
    padding: 2px 6px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 10px;
    color: var(--text-3);
    pointer-events: none;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.btn-icon {
    display: flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover { color: var(--text-0); border-color: var(--border-hover); background: var(--bg-3); }
.btn-icon svg { width: 16px; height: 16px; }
.btn-icon.spinning svg { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

.mobile-only { display: none; }

/* --- Views Common --- */
.view { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.view-header { margin-bottom: 24px; }
.view-header h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.view-header .subtitle { color: var(--text-2); font-size: 13px; margin-top: 4px; }

.section { margin-bottom: 32px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title {
    font-size: 14px; font-weight: 600;
    color: var(--text-1);
    display: flex; align-items: center; gap: 8px;
}
.link { font-size: 12px; color: var(--text-2); transition: color var(--transition); }
.link:hover { color: var(--accent); }

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

.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--stat-color, var(--accent));
    opacity: 0.7;
}

.stat-value {
    font-size: 28px; font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.stat-label {
    font-size: 12px; color: var(--text-2);
    margin-top: 2px;
}

/* --- Cards Grid --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 12px;
}

.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}

.card:hover {
    border-color: var(--border-hover);
    background: var(--bg-3);
    transform: translateY(-1px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.card-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    margin-bottom: 10px;
}

.card-title {
    font-size: 15px; font-weight: 600;
    display: flex; align-items: center; gap: 8px;
}

.card-desc {
    font-size: 12px; color: var(--text-2);
    line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 12px;
    min-height: 36px;
}

.card-meta {
    display: flex; align-items: center; gap: 12px;
    flex-wrap: wrap;
}

.card-meta-item {
    display: flex; align-items: center; gap: 4px;
    font-size: 11px; color: var(--text-2);
}

.card-meta-item svg { width: 12px; height: 12px; }

.card-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.card-links {
    display: flex; gap: 6px;
}

.card-link {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    transition: all var(--transition);
}

.card-link:hover { color: var(--accent); background: var(--accent-dim); }
.card-link svg { width: 14px; height: 14px; }

/* --- Status --- */
.status {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px; font-weight: 500;
    letter-spacing: 0.01em;
}

.status-active { color: var(--success); background: var(--success-dim); }
.status-recent { color: var(--info); background: var(--info-dim); }
.status-idle { color: var(--warning); background: var(--warning-dim); }
.status-archived { color: var(--text-3); background: rgba(82,82,91,0.15); }
.status-local { color: var(--text-2); background: rgba(113,113,122,0.1); }
.status-unknown { color: var(--text-3); background: rgba(82,82,91,0.1); }

.dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-active { background: var(--success); }
.dot-recent { background: var(--info); }
.dot-idle { background: var(--warning); }
.dot-archived { background: var(--text-3); }
.dot-local { background: var(--text-2); }
.dot-warning { background: var(--warning); }
.dot-dirty { background: var(--danger); }
.dot-clean { background: var(--success); }

/* --- Tech Badges --- */
.badges { display: flex; flex-wrap: wrap; gap: 4px; }

.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: var(--bg-4);
    color: var(--text-1);
    border: 1px solid var(--border);
}

/* --- Attention Items --- */
.attention-list { display: flex; flex-direction: column; gap: 6px; }

.attention-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-left: 3px solid var(--warning);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.attention-item:hover { background: var(--bg-3); }
.attention-item .name { font-weight: 600; font-size: 13px; }
.attention-item .detail { font-size: 12px; color: var(--text-2); }

/* --- Activity Timeline --- */
.timeline { display: flex; flex-direction: column; }

.timeline-date {
    padding: 8px 0 6px;
    font-size: 11px; font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-item {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.timeline-item:last-child { border-bottom: none; }
.timeline-item:hover { background: var(--bg-2); margin: 0 -8px; padding: 10px 8px; border-radius: var(--radius-sm); }

.timeline-avatar {
    width: 32px; height: 32px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    flex-shrink: 0;
    color: var(--text-0);
}

.timeline-body { flex: 1; min-width: 0; }

.timeline-project {
    font-size: 11px; font-weight: 600;
    color: var(--accent);
    margin-bottom: 2px;
}

.timeline-message {
    font-size: 13px; color: var(--text-0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.timeline-time {
    font-size: 11px; color: var(--text-3);
    font-family: var(--mono);
    flex-shrink: 0;
    margin-top: 2px;
}

.timeline-hash {
    font-size: 11px; color: var(--text-3);
    font-family: var(--mono);
}

/* --- Projects Table View --- */
.table-wrap {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px; font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-3);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.table th:hover { color: var(--text-1); }
.table th.sorted { color: var(--accent); }
.table th .sort-arrow { margin-left: 4px; font-size: 10px; }

.table td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tr { transition: background var(--transition); cursor: pointer; }
.table tbody tr:hover { background: var(--bg-3); }
.table tbody tr:last-child td { border-bottom: none; }

.table .name-cell { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.table .path-cell { font-family: var(--mono); font-size: 11px; color: var(--text-2); max-width: 250px; overflow: hidden; text-overflow: ellipsis; }

/* --- View Controls --- */
.view-controls {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 16px;
}

.filter-group {
    display: flex; gap: 4px;
}

.filter-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: transparent;
    color: var(--text-2);
    font-size: 12px; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.filter-btn:hover { color: var(--text-0); border-color: var(--border-hover); }
.filter-btn.active { color: var(--accent); background: var(--accent-dim); border-color: rgba(129,140,248,0.2); }

.view-toggles {
    display: flex; gap: 4px;
}

.view-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 32px; height: 32px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    transition: all var(--transition);
}

.view-toggle:hover { color: var(--text-1); border-color: var(--border-hover); }
.view-toggle.active { color: var(--accent); background: var(--accent-dim); border-color: rgba(129,140,248,0.2); }
.view-toggle svg { width: 16px; height: 16px; }

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-3);
    color: var(--text-0);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
}

.btn:hover { background: var(--bg-4); border-color: var(--border-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn svg { width: 14px; height: 14px; }

/* --- Detail View --- */
.detail-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 16px; margin-bottom: 24px;
}

.detail-title { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.detail-path { font-family: var(--mono); font-size: 12px; color: var(--text-2); margin-top: 4px; }
.detail-desc { color: var(--text-1); font-size: 14px; margin-top: 8px; line-height: 1.6; }

.detail-actions { display: flex; gap: 8px; flex-shrink: 0; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.detail-section {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.detail-section h3 {
    font-size: 12px; font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
}

.info-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-2); }
.info-value { color: var(--text-0); font-weight: 500; font-family: var(--mono); font-size: 12px; }

/* --- Modal --- */
.modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}

.modal.hidden { display: none; }

.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}

.modal-panel {
    position: relative;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 100%; max-width: 640px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 24px;
    animation: modalIn 0.2s ease;
}

@keyframes modalIn { from { opacity: 0; transform: scale(0.96); } }

.modal-close {
    position: absolute; top: 16px; right: 16px;
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: var(--radius-sm);
    background: var(--bg-3);
    color: var(--text-2);
    cursor: pointer;
    transition: all var(--transition);
}

.modal-close:hover { color: var(--text-0); background: var(--bg-4); }
.modal-close svg { width: 16px; height: 16px; }

/* --- Loading --- */
.loading {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 400px;
    color: var(--text-2);
    gap: 16px;
}

.spinner {
    width: 32px; height: 32px;
    border: 2px solid var(--bg-4);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* --- Empty State --- */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 300px;
    color: var(--text-2);
    text-align: center;
}

.empty-state h2 { font-size: 18px; color: var(--text-1); margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

/* --- Git status colors --- */
.git-clean { color: var(--success); }
.git-dirty { color: var(--danger); }
.git-ahead { color: var(--warning); }

/* --- Commit list --- */
.commit-list { display: flex; flex-direction: column; }

.commit-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.commit-item:last-child { border-bottom: none; }

.project-links { display: flex; gap: 8px; flex-wrap: wrap; }
.project-link-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 8px;
    background: var(--bg-3); color: var(--text-1);
    text-decoration: none; font-size: 13px; font-weight: 500;
    border: 1px solid var(--border); transition: all 0.15s;
}
.project-link-btn:hover { background: var(--accent); color: var(--bg-0); border-color: var(--accent); }
.project-link-btn svg { width: 14px; height: 14px; }

.commit-hash {
    font-family: var(--mono); font-size: 11px;
    color: var(--accent); flex-shrink: 0;
    padding: 2px 6px;
    background: var(--accent-dim);
    border-radius: 4px;
}

.commit-msg { color: var(--text-0); flex: 1; }
.commit-date { font-size: 11px; color: var(--text-3); flex-shrink: 0; }

/* --- Back link --- */
.back-link {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-2); font-size: 13px;
    margin-bottom: 16px;
    transition: color var(--transition);
}

.back-link:hover { color: var(--accent); }
.back-link svg { width: 16px; height: 16px; }

/* --- Count badge --- */
.count-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--bg-4);
    font-size: 10px; font-weight: 700;
    color: var(--text-2);
}

/* --- Tabs --- */
.tabs {
    display: flex; gap: 2px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.tab {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 16px;
    border: none;
    background: transparent;
    color: var(--text-2);
    font-size: 13px; font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font);
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.tab:hover { color: var(--text-0); background: var(--bg-2); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab svg { width: 14px; height: 14px; }

.tab-content { animation: fadeIn 0.15s ease; }

/* --- Type Badge --- */
.type-badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px; font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid var(--border);
}

/* --- Client Badge --- */
.client-badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px; font-weight: 500;
    color: var(--text-1);
    background: var(--bg-3);
    border: 1px solid var(--border);
}

/* --- Online Badge --- */
.online-badge {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11px; font-weight: 500;
    text-decoration: none;
}

.online-badge.online { color: var(--success); }
.online-badge.offline { color: var(--text-3); }
.dot-offline { background: var(--text-3); }

/* --- Detail Meta Row --- */
.detail-meta-row {
    display: flex; align-items: center; gap: 8px;
    margin-top: 6px;
}

/* --- Card Meta Info --- */
.card-meta-info {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 8px;
}

/* --- Card Indicators --- */
.card-indicators {
    display: flex; align-items: center; gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.indicator {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px; font-weight: 500;
    background: var(--bg-3);
    border: 1px solid var(--border);
    color: var(--text-2);
    white-space: nowrap;
}

.indicator svg { width: 10px; height: 10px; }

.indicator-ok { color: var(--success); border-color: rgba(74,222,128,0.15); background: var(--success-dim); }
.indicator-warn { color: var(--warning); border-color: rgba(251,191,36,0.15); background: var(--warning-dim); }
.indicator-off { color: var(--text-3); }
.indicator-hosting { color: var(--info); border-color: rgba(56,189,248,0.15); background: var(--info-dim); }
.indicator-client { color: var(--accent); border-color: rgba(129,140,248,0.15); background: var(--accent-dim); }

.card-commit {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Markdown Body --- */
.doc-content {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 32px;
}

/* --- Metadocs Layout --- */
.metadocs-layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    gap: 16px;
}

.metadocs-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.metadoc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text-1);
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius);
    text-align: left;
    white-space: nowrap;
}

.metadoc-item:hover { background: var(--bg-2); color: var(--text-0); }
.metadoc-item.active { background: var(--accent); color: #fff; }
.metadoc-item svg { width: 14px; height: 14px; flex-shrink: 0; }

@media (max-width: 768px) {
    .metadocs-layout { grid-template-columns: 1fr; }
    .metadocs-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
}

.markdown-body {
    color: var(--text-0);
    line-height: 1.7;
    font-size: 14px;
}

.markdown-body h1 { font-size: 24px; font-weight: 700; margin: 24px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.markdown-body h2 { font-size: 20px; font-weight: 600; margin: 20px 0 10px; }
.markdown-body h3 { font-size: 16px; font-weight: 600; margin: 16px 0 8px; }
.markdown-body h4 { font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.markdown-body p { margin: 0 0 12px; }
.markdown-body ul, .markdown-body ol { margin: 0 0 12px; padding-left: 24px; }
.markdown-body li { margin: 4px 0; }
.markdown-body a { color: var(--accent); }
.markdown-body a:hover { text-decoration: underline; }
.markdown-body code { font-family: var(--mono); font-size: 12px; background: var(--bg-4); padding: 2px 6px; border-radius: 4px; color: var(--accent); }
.markdown-body pre { background: var(--bg-0); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 16px; overflow-x: auto; margin: 12px 0; }
.markdown-body pre code { background: none; padding: 0; color: var(--text-0); }
.markdown-body blockquote { border-left: 3px solid var(--accent); padding-left: 16px; margin: 12px 0; color: var(--text-1); }
.markdown-body table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.markdown-body th, .markdown-body td { padding: 8px 12px; border: 1px solid var(--border); text-align: left; font-size: 13px; }
.markdown-body th { background: var(--bg-3); font-weight: 600; color: var(--text-1); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.markdown-body img { max-width: 100%; border-radius: var(--radius-sm); }
.markdown-body strong { color: var(--text-0); font-weight: 600; }

/* --- Todo Styles --- */
.todo-group { margin-bottom: 20px; }

.todo-group-header {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 0;
    font-size: 12px; font-weight: 600;
    color: var(--text-1);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.todo-list { display: flex; flex-direction: column; }

.todo-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    border-radius: 0;
}

.todo-item:first-child { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.todo-item:last-child { border-bottom: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm); }
.todo-item:only-child { border-radius: var(--radius-sm); }

.todo-item:hover { background: var(--bg-2); }

.todo-item.todo-done { opacity: 0.5; }
.todo-item.todo-done .todo-title { text-decoration: line-through; }

.todo-check {
    width: 16px; height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

.todo-content {
    flex: 1; min-width: 0;
    display: flex; align-items: center; gap: 8px;
}

.todo-title {
    font-size: 13px; font-weight: 500;
    color: var(--text-0);
}

.todo-project {
    font-size: 10px; font-weight: 500;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--accent-dim);
    color: var(--accent);
    white-space: nowrap;
}

.todo-date {
    font-size: 11px;
    color: var(--text-2);
    font-family: var(--mono);
    white-space: nowrap;
}

.todo-overdue { color: var(--danger); font-weight: 600; }

.todo-list-done .todo-item { opacity: 0.4; }
.todo-list-done .todo-item:hover { opacity: 0.7; }

.done-section {
    margin-top: 24px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}

.done-toggle {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    padding: 6px 0;
    user-select: none;
    list-style: none;
}

.done-toggle::-webkit-details-marker { display: none; }
.done-toggle svg { width: 14px; height: 14px; }
.done-toggle:hover { color: var(--text-0); }

/* --- Inline Form --- */
.inline-form {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
}

.inline-form form {
    display: flex; align-items: center; gap: 8px;
    flex-wrap: wrap;
}

.inline-input {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    color: var(--text-0);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
    flex: 1;
    min-width: 180px;
}

.inline-input:focus { border-color: var(--accent); }

.inline-select {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    color: var(--text-0);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
}

.inline-select:focus { border-color: var(--accent); }

/* --- Form Groups (Modals) --- */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 12px; font-weight: 500;
    color: var(--text-1);
    margin-bottom: 4px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    color: var(--text-0);
    font-size: 13px;
    font-family: var(--font);
    outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group textarea { resize: vertical; min-height: 60px; }

.form-actions {
    display: flex; gap: 8px; justify-content: flex-end;
    margin-top: 16px;
}

/* --- Calendar Styles --- */
.calendar-nav {
    display: flex; align-items: center; justify-content: center; gap: 20px;
    margin-bottom: 20px;
}

.calendar-month {
    font-size: 18px; font-weight: 600;
    min-width: 200px;
    text-align: center;
}

.calendar-grid {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.calendar-header {
    display: grid; grid-template-columns: repeat(7, 1fr);
    background: var(--bg-3);
    border-bottom: 1px solid var(--border);
}

.cal-day-name {
    padding: 10px;
    text-align: center;
    font-size: 11px; font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-body {
    display: grid; grid-template-columns: repeat(7, 1fr);
}

.cal-day {
    min-height: 90px;
    padding: 6px 8px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
    cursor: pointer;
}

.cal-day:nth-child(7n) { border-right: none; }
.cal-day:hover { background: var(--bg-3); }

.cal-day.cal-empty {
    background: var(--bg-1);
    cursor: default;
}

.cal-day-num {
    display: inline-flex; align-items: center; justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    font-size: 12px; font-weight: 500;
    color: var(--text-1);
    margin-bottom: 4px;
}

.cal-today .cal-day-num {
    background: var(--accent);
    color: white;
    font-weight: 700;
}

.cal-event {
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px; font-weight: 500;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: opacity var(--transition);
}

.cal-event:hover { opacity: 0.8; }

/* --- Color Picker --- */
.color-picker {
    display: flex; gap: 6px; flex-wrap: wrap;
}

.color-option {
    cursor: pointer;
}

.color-option input { display: none; }

.color-option span {
    display: block;
    width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid transparent;
    transition: all var(--transition);
}

.color-option input:checked + span {
    border-color: var(--text-0);
    box-shadow: 0 0 0 2px var(--bg-0);
}

/* --- Dashboard Layout --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    align-items: start;
}

.dashboard-side {
    display: flex; flex-direction: column; gap: 20px;
}

.mini-list {
    display: flex; flex-direction: column;
}

.mini-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.mini-item:last-child { border-bottom: none; }

.mini-text {
    flex: 1; min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-0);
}

.mini-meta {
    font-size: 11px;
    color: var(--text-2);
    font-family: var(--mono);
    white-space: nowrap;
}

/* --- Buttons Extra --- */
.btn-small { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: rgba(248,113,113,0.2); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-full { width: 100%; }

.hidden { display: none !important; }

/* --- Settings --- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 16px;
}

.settings-section {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}

.settings-section h3 {
    font-size: 14px; font-weight: 600;
    margin-bottom: 14px;
}

.settings-desc {
    font-size: 12px; color: var(--text-2);
    margin-bottom: 12px;
}

/* --- Shared Tag --- */
.shared-tag {
    font-size: 9px; font-weight: 600;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--accent-dim);
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

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

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-error {
    background: var(--danger-dim);
    color: var(--danger);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-bottom: 12px;
}

.login-links {
    display: flex; gap: 12px; justify-content: center;
    margin-top: 16px;
}

.link-btn {
    font-size: 12px; color: var(--text-2);
    background: none; border: none;
    cursor: pointer; font-family: var(--font);
}

.link-btn:hover { color: var(--accent); }

/* --- Invite --- */
.invite-result {
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 12px;
}

.invite-url-input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 8px;
    color: var(--text-0);
    font-family: var(--mono);
    font-size: 11px;
}

.invite-list { display: flex; flex-direction: column; gap: 6px; }

.invite-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-3);
    border-radius: var(--radius-sm);
    font-size: 12px;
}

.invite-code { font-family: var(--mono); color: var(--accent); }
.invite-status { font-weight: 500; }
.invite-date { color: var(--text-2); }

.members-list { display: flex; flex-direction: column; gap: 4px; }

.member-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.member-item:last-child { border-bottom: none; }
.member-name { font-weight: 500; }
.member-role { font-size: 11px; color: var(--text-2); }

/* --- Google Calendar --- */
.gcal-section h3 svg { width: 16px; height: 16px; display: inline; vertical-align: -2px; }

.gcal-connected, .gcal-disconnected {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px;
}

.gcal-connected .btn, .gcal-disconnected .btn { margin-left: auto; }

.gcal-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 1px 6px;
    border-radius: 3px;
    background: rgba(66,133,244,0.1);
    color: #4285f4;
    font-size: 11px; font-weight: 500;
}

.gcal-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4285f4;
    margin-right: 2px;
    flex-shrink: 0;
}

.cal-event-google {
    opacity: 0.85;
    font-style: italic;
}

.gcal-legend {
    display: flex; align-items: center; gap: 6px;
    margin-top: 12px;
    font-size: 11px; color: var(--text-2);
}

.form-msg {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-top: 8px;
}

.form-msg.success { background: var(--success-dim); color: var(--success); }
.form-msg.error { background: var(--danger-dim); color: var(--danger); }
.form-hint { font-size: 11px; color: var(--text-2); margin-top: 4px; display: block; }
.form-hint a { color: var(--accent); }
.form-hint code { font-family: var(--mono); font-size: 10px; background: var(--bg-3); padding: 1px 4px; border-radius: 3px; }

/* --- No Sidebar (Login) --- */
.no-sidebar #sidebar { display: none; }
.no-sidebar #main { margin-left: 0; }

/* --- Toggle Switch --- */
.toggle-row {
    display: flex; align-items: center; gap: 0.8rem; cursor: pointer;
    font-weight: 500; color: var(--text-0);
}
.toggle-row input { display: none; }
.toggle-switch {
    position: relative; width: 40px; height: 22px; background: var(--bg-4);
    border-radius: 11px; transition: background 0.2s; flex-shrink: 0;
}
.toggle-switch::after {
    content: ''; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; background: var(--text-2);
    border-radius: 50%; transition: all 0.2s;
}
.toggle-row input:checked + .toggle-switch { background: var(--accent); }
.toggle-row input:checked + .toggle-switch::after { left: 21px; background: #fff; }

/* --- Bug Reporter --- */
.br-fab {
    position: fixed; bottom: 2rem; right: 1.5rem;
    width: 52px; height: 52px; border-radius: 50%;
    background: var(--bg-3); border: 2px solid var(--danger);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10001;
    box-shadow: 0 2px 12px rgba(248,113,113,0.3); transition: all 0.2s;
}
.br-fab:hover { transform: scale(1.1); box-shadow: 0 4px 20px rgba(248,113,113,0.5); border-color: #fca5a5; }
.br-fab svg { width: 26px; height: 26px; stroke: var(--danger); }
.br-fab:hover svg { stroke: #fca5a5; }

body.br-selecting { cursor: crosshair !important; }
body.br-selecting * { cursor: crosshair !important; }
body.br-selecting .br-fab { cursor: pointer !important; }

.br-overlay {
    position: fixed; pointer-events: none;
    border: 2px solid var(--danger); background: rgba(248,113,113,0.12);
    border-radius: 4px; z-index: 99999;
    transition: top 0.08s, left 0.08s, width 0.08s, height 0.08s; display: none;
}

.br-modal-wrap {
    position: fixed; inset: 0; z-index: 10002;
    display: flex; align-items: flex-start; justify-content: center;
    background: rgba(0,0,0,0.5);
}
.br-modal {
    background: var(--bg-3); border: 1px solid var(--border);
    border-radius: 12px; max-width: 460px; width: 90vw; margin-top: 10vh;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.br-modal-header {
    padding: 1rem 1.2rem; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.br-modal-header h2 { margin: 0; font-size: 1.1rem; }
.br-modal-close {
    background: none; border: none; color: var(--text-2);
    font-size: 1.5rem; cursor: pointer; padding: 0 4px; line-height: 1;
}
.br-modal-close:hover { color: var(--text-0); }
.br-modal-body { padding: 1.2rem; }

.br-field { margin-bottom: 1rem; }
.br-label {
    display: block; font-size: 0.8rem; color: var(--text-2);
    margin-bottom: 0.3rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.br-info code {
    background: rgba(255,255,255,0.06); padding: 0.25rem 0.5rem;
    border-radius: 4px; font-size: 0.85rem; color: var(--accent); display: inline-block;
}
.br-path small { color: var(--text-2); font-size: 0.75rem; margin-top: 0.2rem; display: block; }

.br-type-toggle { display: flex; gap: 0.5rem; }
.br-type-option { cursor: pointer; }
.br-type-option input { display: none; }
.br-type-chip {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.45rem 1rem; border-radius: 20px; font-size: 0.85rem; font-weight: 500;
    border: 1.5px solid var(--border); color: var(--text-2);
    background: transparent; transition: all 0.2s;
}
.br-type-option input:checked + .br-type-bug {
    border-color: var(--danger); color: var(--danger); background: var(--danger-dim);
}
.br-type-option input:checked + .br-type-feature {
    border-color: var(--accent); color: var(--accent); background: var(--accent-dim);
}

.br-textarea {
    width: 100%; background: rgba(255,255,255,0.04);
    border: 1px solid var(--border); border-radius: 8px;
    color: var(--text-0); padding: 0.7rem; font-size: 0.9rem;
    font-family: inherit; resize: vertical; min-height: 80px;
}
.br-textarea:focus { outline: none; border-color: var(--accent); }

.br-submit {
    width: 100%; padding: 0.7rem; border: none; border-radius: 8px;
    background: var(--accent); color: #fff; font-size: 0.9rem;
    font-weight: 600; cursor: pointer; transition: background 0.2s;
}
.br-submit:hover { background: var(--accent-hover); }

.br-toast {
    position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%);
    padding: 0.6rem 1.2rem; border-radius: 8px; font-size: 0.85rem;
    color: #fff; z-index: 10010; animation: br-fade-in 0.2s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}
.br-toast.success { background: var(--success); color: #000; }
.br-toast.error { background: var(--danger); }
.br-toast.info { background: var(--info); color: #000; }
@keyframes br-fade-in { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* --- Responsive --- */
@media (max-width: 900px) {
    .card-grid { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .settings-grid { grid-template-columns: 1fr; }
    .calendar-body .cal-day { min-height: 60px; }
    .cal-event { font-size: 9px; }
}

@media (max-width: 768px) {
    .mobile-only { display: flex; }
    .search-kbd { display: none; }

    #sidebar {
        transform: translateX(-100%);
    }

    #sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 40px rgba(0,0,0,0.5);
    }

    #main { margin-left: 0; }
    #content { padding: 16px; }

    .view-header h1 { font-size: 20px; }
    .stat-value { font-size: 22px; }

    .inline-form form { flex-direction: column; }
    .inline-input { min-width: unset; width: 100%; }
    .inline-form .btn { width: 100%; justify-content: center; }

    .cal-day { min-height: 50px; padding: 4px; }
    .cal-day-num { width: 20px; height: 20px; font-size: 11px; }
    .cal-event { display: none; }
    .cal-day.has-events::after {
        content: '';
        display: block;
        width: 4px; height: 4px;
        border-radius: 50%;
        background: var(--accent);
        margin: 2px auto 0;
    }
}
